GlosSIConfig: Max Controllers setting

pull/169/head
Peter Repukat 2 years ago
parent be88fc1032
commit f7b4578919

@ -82,6 +82,7 @@ void UIModel::readConfigs()
json["windowMode"] = filejson["window"]["windowMode"];
json["maxFps"] = filejson["window"]["maxFps"];
json["scale"] = filejson["window"]["scale"];
json["maxControllers"] = filejson["controller"]["maxControllers"];
json["name"] = filejson.contains("name") ? filejson["name"] : QString(name).replace(QRegularExpression("\\.json"), "");
@ -177,19 +178,11 @@ bool UIModel::addToSteam(QVariant shortcut, const QString& shortcutspath, bool f
if (maybeIcon.isEmpty()) {
if (launch && !maybeLaunchPath.isEmpty())
vdfshortcut.icon.value =
"\"" + (
is_windows_
? QString(maybeLaunchPath).replace(QRegularExpression("\\/"), "\\").toStdString()
: maybeLaunchPath.toStdString()
) + "\"";
"\"" + (is_windows_ ? QString(maybeLaunchPath).replace(QRegularExpression("\\/"), "\\").toStdString() : maybeLaunchPath.toStdString()) + "\"";
}
else {
vdfshortcut.icon.value =
"\"" + (
is_windows_
? QString(maybeIcon).replace(QRegularExpression("\\/"), "\\").toStdString()
: maybeIcon.toStdString()
) + "\"";
"\"" + (is_windows_ ? QString(maybeIcon).replace(QRegularExpression("\\/"), "\\").toStdString() : maybeIcon.toStdString()) + "\"";
}
// Add installed locally and GlosSI tag
VDFParser::ShortcutTag locallyTag;
@ -249,10 +242,9 @@ QVariantMap UIModel::manualProps(QVariant shortcut)
res.insert("config", name + ".json");
res.insert("launch", ("\"" + appDir.absolutePath() + "/GlosSITarget.exe" + "\""));
res.insert("launchDir", (
launch && !maybeLaunchPath.isEmpty()
? (QString("\"") + QString::fromStdString(std::filesystem::path(maybeLaunchPath.toStdString()).parent_path().string()) + "\"")
: ("\"" + appDir.absolutePath() + "\""))
);
launch && !maybeLaunchPath.isEmpty()
? (QString("\"") + QString::fromStdString(std::filesystem::path(maybeLaunchPath.toStdString()).parent_path().string()) + "\"")
: ("\"" + appDir.absolutePath() + "\"")));
return res;
}
@ -268,12 +260,11 @@ bool UIModel::writeShortcutsVDF(const std::wstring& mode, const std::wstring& na
#ifdef _WIN32
const std::filesystem::path config_path = is_admin_try
? shortcutspath
: std::wstring(getSteamPath()) + user_data_path_.toStdWString() + getSteamUserId() + shortcutsfile_.toStdWString();
: std::wstring(getSteamPath()) + user_data_path_.toStdWString() + getSteamUserId() + shortcutsfile_.toStdWString();
qDebug() << "Steam config Path: " << config_path;
qDebug() << "Trying to write config as admin: " << is_admin_try;
auto write_res = VDFParser::Parser::writeShortcuts(config_path, shortcuts_vdf_);
if (!write_res && !is_admin_try) {
@ -309,7 +300,7 @@ bool UIModel::writeShortcutsVDF(const std::wstring& mode, const std::wstring& na
}
return false;
}
}
}
}
return write_res;
#else
@ -366,6 +357,10 @@ void UIModel::writeTarget(const QJsonObject& json, const QString& name)
windowObject["scale"] = json["scale"];
fileJson["window"] = windowObject;
QJsonObject controllerObject;
controllerObject["maxControllers"] = json["maxControllers"];
fileJson["controller"] = controllerObject;
auto wtf = QString(QJsonDocument(fileJson).toJson(QJsonDocument::Indented)).toStdString();
file.write(wtf.data());
file.close();

@ -42,6 +42,7 @@ Item {
maxFps: null,
scale: null,
icon: null,
maxControllers: 4
})
function resetInfo() {
@ -58,6 +59,7 @@ Item {
maxFps: null,
scale: null,
icon: null,
maxControllers: 4
})
}
@ -70,9 +72,9 @@ Item {
waitForChildren.checked = shortcutInfo.waitForChildProcs || false
hideDevices.checked = shortcutInfo.hideDevices || false
windowMode.checked = shortcutInfo.windowMode || false
maxControllersSpinBox.value = shortcutInfo.maxControllers
}
Column {
anchors.margins: 32
anchors.top: parent.top
@ -261,7 +263,6 @@ Item {
Material.elevation: 32
bgOpacity: 0.97
Column {
spacing: 2
width: parent.width
@ -284,6 +285,25 @@ Item {
width: parent.width
leftPadding: 32
}
Item {
width: 1
height: 4
}
Row {
leftPadding: 16
Label {
text: qsTr("Max. emulated controllers")
topPadding: 16
}
SpinBox {
id: maxControllersSpinBox
width: 128
value: 4
from: 0
to: 4
onValueChanged: shortcutInfo.maxControllers = value
}
}
}
}
RPane {

Loading…
Cancel
Save