From a8235ca9c96455a93e83fd1f319a3ab150d99842 Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Sat, 5 Nov 2022 13:56:25 +0100 Subject: [PATCH 1/4] GlosSITarget: Fix UI Scaling --- GlosSITarget/TargetWindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GlosSITarget/TargetWindow.cpp b/GlosSITarget/TargetWindow.cpp index 9d0d938..5744f9d 100644 --- a/GlosSITarget/TargetWindow.cpp +++ b/GlosSITarget/TargetWindow.cpp @@ -357,6 +357,7 @@ void TargetWindow::createWindow() overlay_ = std::make_shared( window_, [this]() { close(); }, toggle_overlay_state_, Settings::window.windowMode); + spdlog::debug("auto screen scale: {}", dpi/96.f); ImGuiIO& io = ImGui::GetIO(); io.FontGlobalScale = dpi / 96.f; ImGui::SFML::UpdateFontTexture(); @@ -369,7 +370,8 @@ void TargetWindow::createWindow() spdlog::debug("Config file fps limit seems sane..."); setFpsLimit(Settings::window.maxFps); } - if (Settings::window.scale < 0.3f) { // Now that's just getting ridicoulus + if (Settings::window.scale > 0.3f) { // Now that's just getting ridicoulus + spdlog::debug("setting screen scale by config: {}", Settings::window.scale); ImGuiIO& io = ImGui::GetIO(); io.FontGlobalScale = Settings::window.scale; ImGui::SFML::UpdateFontTexture(); From 5176dab9be61c66accc6cbaffd216f4417b7fd63 Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Sat, 5 Nov 2022 14:30:28 +0100 Subject: [PATCH 2/4] GlosSIConfig: Open Steam controller configurator from GlosSI --- GlosSIConfig/Resource.rc | 156 ++++++++++++++++++++++++++++- GlosSIConfig/UIModel.cpp | 18 +++- GlosSIConfig/UIModel.h | 6 +- GlosSIConfig/qml/ShortcutCards.qml | 104 +++++++++++-------- GlosSIConfig/qml/main.qml | 17 ++++ 5 files changed, 245 insertions(+), 56 deletions(-) diff --git a/GlosSIConfig/Resource.rc b/GlosSIConfig/Resource.rc index d4150b5..cfa4115 100644 --- a/GlosSIConfig/Resource.rc +++ b/GlosSIConfig/Resource.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,1,1,002004500680 - PRODUCTVERSION 0,1,1,002004500680 + FILEVERSION 0,1,1,101000823500 + PRODUCTVERSION 0,1,1,101000823500 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "Peter Repukat - FlatspotSoftware" VALUE "FileDescription", "GlosSI - Config" - VALUE "FileVersion", "0.1.1.0-2-g45bd68e" + VALUE "FileVersion", "0.1.1.1-1-ga8235ca" VALUE "InternalName", "GlosSIConfig" VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware" VALUE "OriginalFilename", "GlosSIConfig.exe" VALUE "ProductName", "GlosSI" - VALUE "ProductVersion", "0.1.1.0-2-g45bd68e" + VALUE "ProductVersion", "0.1.1.1-1-ga8235ca" END END BLOCK "VarFileInfo" @@ -1252,6 +1252,154 @@ IDI_ICON1 ICON "..\GlosSI_Icon.ico" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GlosSIConfig/UIModel.cpp b/GlosSIConfig/UIModel.cpp index cddb456..007545a 100644 --- a/GlosSIConfig/UIModel.cpp +++ b/GlosSIConfig/UIModel.cpp @@ -33,7 +33,6 @@ limitations under the License. #include #endif -#include "ExeImageProvider.h" #include "ExeImageProvider.h" #include "../version.hpp" @@ -170,7 +169,7 @@ bool UIModel::isInSteam(QVariant shortcut) const return false; } -uint32_t UIModel::getAppId(QVariant shortcut) const +uint32_t UIModel::getAppId(QVariant shortcut) { if (!isInSteam(shortcut)) { return 0; @@ -179,6 +178,10 @@ uint32_t UIModel::getAppId(QVariant shortcut) const for (auto& steam_shortcut : shortcuts_vdf_) { if (map["name"].toString() == QString::fromStdString(steam_shortcut.appname)) { if (QString::fromStdString(steam_shortcut.exe).toLower().contains("glossitarget.exe")) { + if (steam_shortcut.appid == 0) { + parseShortcutVDF(); + return getAppId(shortcut); + } return steam_shortcut.appid; } } @@ -323,13 +326,18 @@ void UIModel::enableSteamInputXboxSupport() } } -bool UIModel::restartSteam() +bool UIModel::restartSteam(const QString& steamURL) { const auto path = getSteamPath(); if (QProcess::execute("taskkill.exe", {"/im", steam_executable_name_, "/f"}) != 0) { return false; } - QProcess::startDetached(QString::fromStdWString(path) + "/" + steam_executable_name_); + if (steamURL.isEmpty()) { + QProcess::startDetached(QString::fromStdWString(path) + "/" + steam_executable_name_); + } + else { + system((QString::fromLatin1("start ") + steamURL).toStdString().c_str()); + } return true; } @@ -499,7 +507,7 @@ void UIModel::loadSteamGridImages() steamgrid_proc_.write("\n"); } -QString UIModel::getGridImagePath(QVariant shortcut) const +QString UIModel::getGridImagePath(QVariant shortcut) { if (!foundSteam()) { return ""; diff --git a/GlosSIConfig/UIModel.h b/GlosSIConfig/UIModel.h index b3cb982..8bc5871 100644 --- a/GlosSIConfig/UIModel.h +++ b/GlosSIConfig/UIModel.h @@ -49,14 +49,14 @@ class UIModel : public QObject { Q_INVOKABLE bool updateTarget(int index, QVariant shortcut); Q_INVOKABLE void deleteTarget(int index); Q_INVOKABLE bool isInSteam(QVariant shortcut) const; - Q_INVOKABLE uint32_t getAppId(QVariant shortcut) const; + Q_INVOKABLE uint32_t getAppId(QVariant shortcut); Q_INVOKABLE bool addToSteam(QVariant shortcut, const QString& shortcutspath, bool from_cmd = false); bool addToSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false); Q_INVOKABLE bool removeFromSteam(const QString& name, const QString& shortcutspath, bool from_cmd = false); Q_INVOKABLE QVariantMap manualProps(QVariant shortcut); Q_INVOKABLE void enableSteamInputXboxSupport(); - Q_INVOKABLE bool restartSteam(); + Q_INVOKABLE bool restartSteam(const QString& steamURL = ""); Q_INVOKABLE void updateCheck(); @@ -69,7 +69,7 @@ class UIModel : public QObject { Q_INVOKABLE QVariantList egsGamesList() const; Q_INVOKABLE void loadSteamGridImages(); - Q_INVOKABLE QString getGridImagePath(QVariant shortcut) const; + Q_INVOKABLE QString getGridImagePath(QVariant shortcut); [[nodiscard]] bool writeShortcutsVDF(const std::wstring& mode, const std::wstring& name, const std::wstring& shortcutspath, bool is_admin_try = false) const; diff --git a/GlosSIConfig/qml/ShortcutCards.qml b/GlosSIConfig/qml/ShortcutCards.qml index e0f634b..90857c0 100644 --- a/GlosSIConfig/qml/ShortcutCards.qml +++ b/GlosSIConfig/qml/ShortcutCards.qml @@ -34,7 +34,7 @@ GridView { property real margins: 16 cellWidth: 292 + 16 - cellHeight: 190 + 16 + cellHeight: 212 + 16 readonly property real displayedItems: Math.floor((parent.width - margins*2) / cellWidth) width: displayedItems * cellWidth model: uiModel.targetList; @@ -72,7 +72,7 @@ GridView { bgOpacity: 0.3 radius: 8 width: 292 - height: 190 + height: 212 Material.elevation: 4 clip: true property bool isInSteam: uiModel.isInSteam(modelData); @@ -145,57 +145,73 @@ GridView { } } - Button { - id: steambutton - anchors.left: parent.left + Column { + anchors.left: parent.left anchors.bottom: parent.bottom - width: 72 - onClicked: function(){ - if (delegateRoot.isInSteam) { - if (!uiModel.removeFromSteam(modelData.name, "")) { - writeErrorDialog.open(); - return; - } - } else { - if (!uiModel.addToSteam(modelData, "")) { - manualInfo = uiModel.manualProps(modelData); - writeErrorDialog.open(); - return; - } - } - if (steamShortcutsChanged == false) { - steamChangedDialog.open(); + spacing: 4 + + Button { + highlighted: true + visible: delegateRoot.isInSteam + text: qsTr("Steam controller config") + onClicked: function() { + controllerConfigDialog.confirmedExtraParam = uiModel.getAppId(modelData) + controllerConfigDialog.confirmedParam = uiModel.getAppId(modelData) + controllerConfigDialog.open(); } - delegateRoot.isInSteam = uiModel.isInSteam(modelData) - steamShortcutsChanged = true } - highlighted: delegateRoot.isInSteam - Material.accent: Material.color(Material.Red, Material.Shade800) - Row { - anchors.centerIn: parent - spacing: 8 - Label { - anchors.verticalCenter: parent.verticalCenter - text: delegateRoot.isInSteam ? "-" : "+" - font.bold: true - font.pixelSize: 24 + + Button { + id: steambutton + width: 72 + onClicked: function(){ + if (delegateRoot.isInSteam) { + if (!uiModel.removeFromSteam(modelData.name, "")) { + writeErrorDialog.open(); + return; + } + } else { + if (!uiModel.addToSteam(modelData, "")) { + manualInfo = uiModel.manualProps(modelData); + writeErrorDialog.open(); + return; + } + } + if (steamShortcutsChanged == false) { + steamChangedDialog.open(); + } + delegateRoot.isInSteam = uiModel.isInSteam(modelData) + steamShortcutsChanged = true } - Image { - anchors.verticalCenter: parent.verticalCenter - source: "qrc:/svg/steam.svg" - width: 22 - height: 22 - smooth: true - mipmap: true - ColorOverlay { - anchors.fill: parent - source: parent - color: "white" + highlighted: delegateRoot.isInSteam + Material.accent: Material.color(Material.Red, Material.Shade800) + Row { + anchors.centerIn: parent + spacing: 8 + Label { + anchors.verticalCenter: parent.verticalCenter + text: delegateRoot.isInSteam ? "-" : "+" + font.bold: true + font.pixelSize: 24 + } + Image { + anchors.verticalCenter: parent.verticalCenter + source: "qrc:/svg/steam.svg" + width: 22 + height: 22 + smooth: true + mipmap: true + ColorOverlay { + anchors.fill: parent + source: parent + color: "white" + } } } } } + Row { id: buttonrow anchors.right: parent.right diff --git a/GlosSIConfig/qml/main.qml b/GlosSIConfig/qml/main.qml index 479c2bd..1f5fe67 100644 --- a/GlosSIConfig/qml/main.qml +++ b/GlosSIConfig/qml/main.qml @@ -266,6 +266,23 @@ Window { } } + InfoDialog { + id: controllerConfigDialog + titleText: qsTr("Open Steam controller config") + text: qsTr("Steams controller config can only open if a controller is connected") + + "\n" + + qsTr("and the shortcut is visible in Steam (Steam restarted after adding).") + buttonText: qsTr("Open") + extraButton: true + extraButtonText: qsTr("Restart and open") + onConfirmedExtra: function(data) { + uiModel.restartSteam("steam://currentcontrollerconfig/" + data + "/") + } + onConfirmed: function(data) { + Qt.openUrlExternally("steam://currentcontrollerconfig/" + data + "/"); + } + } + Rectangle { id: titleBar visible: uiModel.isWindows From 9e170d24bda5979837ecbde5dc3f58ccfe8fc4de Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Mon, 7 Nov 2022 19:18:59 +0100 Subject: [PATCH 3/4] Fix typo --- GlosSITarget/TargetWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GlosSITarget/TargetWindow.cpp b/GlosSITarget/TargetWindow.cpp index 5744f9d..ee01712 100644 --- a/GlosSITarget/TargetWindow.cpp +++ b/GlosSITarget/TargetWindow.cpp @@ -357,7 +357,7 @@ void TargetWindow::createWindow() overlay_ = std::make_shared( window_, [this]() { close(); }, toggle_overlay_state_, Settings::window.windowMode); - spdlog::debug("auto screen scale: {}", dpi/96.f); + spdlog::debug("auto screen sCale: {}", dpi/96.f); ImGuiIO& io = ImGui::GetIO(); io.FontGlobalScale = dpi / 96.f; ImGui::SFML::UpdateFontTexture(); From 128e7f4a62bd50d2670d3472a993c2f74273aa2e Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Mon, 7 Nov 2022 20:32:31 +0100 Subject: [PATCH 4/4] GlosSITarget: add -window cli switch --- GlosSITarget/Settings.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GlosSITarget/Settings.h b/GlosSITarget/Settings.h index 1acfaf5..05db5b9 100644 --- a/GlosSITarget/Settings.h +++ b/GlosSITarget/Settings.h @@ -228,6 +228,9 @@ inline void Parse(const std::vector& args) else if (arg == L"-ignorelauncher") { launch.ignoreLauncher = true; } + else if (arg == L"-window") { + window.windowMode = true; + } else { configName += L" " + std::wstring(arg.begin(), arg.end()); }