mirror of
https://github.com/Alia5/GlosSI.git
synced 2024-10-30 15:20:38 +00:00
Rename "standalone mode" -> "global mode"
This commit is contained in:
parent
b86d548fc2
commit
54fb29a79d
@ -51,8 +51,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,1,2,0018002705604
|
||||
PRODUCTVERSION 0,1,2,0018002705604
|
||||
FILEVERSION 0,1,2,0030000050130
|
||||
PRODUCTVERSION 0,1,2,0030000050130
|
||||
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.2.0-18-g27056b4"
|
||||
VALUE "FileVersion", "0.1.2.0-30-geb5f13f"
|
||||
VALUE "InternalName", "GlosSIConfig"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
|
||||
VALUE "OriginalFilename", "GlosSIConfig.exe"
|
||||
VALUE "ProductName", "GlosSI"
|
||||
VALUE "ProductVersion", "0.1.2.0-18-g27056b4"
|
||||
VALUE "ProductVersion", "0.1.2.0-30-geb5f13f"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -398,8 +398,8 @@ QVariantMap UIModel::getDefaultConf() const
|
||||
QJsonValue::fromVariant(QString::fromStdWString(getSteamPath(false).wstring()))},
|
||||
{"steamUserId",
|
||||
QJsonValue::fromVariant(QString::fromStdWString(getSteamUserId(false)))},
|
||||
{"standaloneModeGameId", ""},
|
||||
{"standaloneUseGamepadUI", false},
|
||||
{"globalModeGameId", ""},
|
||||
{"globalModeUseGamepadUI", false},
|
||||
{"controller", QJsonObject{{"maxControllers", 1}, {"emulateDS4", false}, {"allowDesktopConfig", false}}},
|
||||
{"devices",
|
||||
QJsonObject{
|
||||
@ -474,36 +474,36 @@ void UIModel::saveDefaultConf(QVariantMap conf) const
|
||||
file.close();
|
||||
}
|
||||
|
||||
Q_INVOKABLE QVariant UIModel::standaloneShortcutConf() {
|
||||
Q_INVOKABLE QVariant UIModel::globalModeShortcutConf() {
|
||||
for (auto& target : targets_) {
|
||||
const auto map = target.toMap();
|
||||
if (map["name"] == "GlosSI Standalone/Desktop") {
|
||||
if (map["name"] == "GlosSI GlobalMode/Desktop") {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Q_INVOKABLE bool UIModel::standaloneModeShortcutExists() {
|
||||
const auto map = standaloneShortcutConf().toMap();
|
||||
if (map["name"] == "GlosSI Standalone/Desktop") {
|
||||
Q_INVOKABLE bool UIModel::globalModeShortcutExists() {
|
||||
const auto map = globalModeShortcutConf().toMap();
|
||||
if (map["name"] == "GlosSI GlobalMode/Desktop") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_INVOKABLE uint32_t UIModel::standaloneModeShortcutAppId() {
|
||||
if (!standaloneModeShortcutExists()) {
|
||||
Q_INVOKABLE uint32_t UIModel::globalModeShortcutAppId() {
|
||||
if (!globalModeShortcutExists()) {
|
||||
return 0;
|
||||
}
|
||||
return getAppId(standaloneShortcutConf());
|
||||
return getAppId(globalModeShortcutConf());
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString UIModel::standaloneModeShortcutGameId() {
|
||||
if (!standaloneModeShortcutExists()) {
|
||||
Q_INVOKABLE QString UIModel::globalModeShortcutGameId() {
|
||||
if (!globalModeShortcutExists()) {
|
||||
return "";
|
||||
}
|
||||
return getGameId(standaloneShortcutConf());
|
||||
return getGameId(globalModeShortcutConf());
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -64,10 +64,10 @@ class UIModel : public QObject {
|
||||
Q_INVOKABLE QVariantMap getDefaultConf() const;
|
||||
Q_INVOKABLE void saveDefaultConf(QVariantMap conf) const;
|
||||
|
||||
Q_INVOKABLE QVariant standaloneShortcutConf();
|
||||
Q_INVOKABLE bool standaloneModeShortcutExists();
|
||||
Q_INVOKABLE uint32_t standaloneModeShortcutAppId();
|
||||
Q_INVOKABLE QString standaloneModeShortcutGameId();
|
||||
Q_INVOKABLE QVariant globalModeShortcutConf();
|
||||
Q_INVOKABLE bool globalModeShortcutExists();
|
||||
Q_INVOKABLE uint32_t globalModeShortcutAppId();
|
||||
Q_INVOKABLE QString globalModeShortcutGameId();
|
||||
|
||||
#ifdef _WIN32
|
||||
Q_INVOKABLE QVariantList uwpApps();
|
||||
|
@ -140,10 +140,10 @@ Item {
|
||||
Row {
|
||||
Row {
|
||||
CheckBox {
|
||||
id: standaloneUseGamepadUI
|
||||
text: qsTr("Use BPM for standalone-/desktop-mode")
|
||||
checked: config.standaloneUseGamepadUI
|
||||
onCheckedChanged: config.standaloneUseGamepadUI = checked
|
||||
id: globalModeUseGamepadUI
|
||||
text: qsTr("Use BPM for global-/desktop-mode")
|
||||
checked: config.globalModeUseGamepadUI
|
||||
onCheckedChanged: config.globalModeUseGamepadUI = checked
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,44 +153,44 @@ Item {
|
||||
spacing: 16
|
||||
Label {
|
||||
topPadding: 8
|
||||
id: standAloneGameIdLabel
|
||||
text: qsTr("StandaloneGameId")
|
||||
id: GlobalModeGameIdLabel
|
||||
text: qsTr("GlobalMode GameId")
|
||||
}
|
||||
FluentTextInput {
|
||||
width: 128
|
||||
id: standAloneGameId
|
||||
id: GlobalModeGameId
|
||||
enabled: false
|
||||
text: config.standaloneModeGameId
|
||||
onTextChanged: config.standaloneModeGameId = text
|
||||
text: config.globalModeGameId
|
||||
onTextChanged: config.globalModeGameId = text
|
||||
}
|
||||
Button {
|
||||
id: standAloneGameIdButton
|
||||
text: qsTr("Create standalone-/desktop-mode shortcut")
|
||||
id: GlobalModeGameIdButton
|
||||
text: qsTr("Create global-/desktop-mode shortcut")
|
||||
onClicked: {
|
||||
const standaloneConf = uiModel.getDefaultConf();
|
||||
standaloneConf.name = "GlosSI Standalone/Desktop";
|
||||
standaloneConf.launch.launch = false;
|
||||
uiModel.addTarget(standaloneConf);
|
||||
if (uiModel.addToSteam(standaloneConf, "")) {
|
||||
const globalModeConf = uiModel.getDefaultConf();
|
||||
globalModeConf.name = "GlosSI GlobalMode/Desktop";
|
||||
globalModeConf.launch.launch = false;
|
||||
uiModel.addTarget(globalModeConf);
|
||||
if (uiModel.addToSteam(globalModeConf, "")) {
|
||||
steamChangedDialog.open();
|
||||
}
|
||||
const standaloneGID = uiModel.standaloneModeShortcutGameId();
|
||||
standAloneGameId.text = standaloneGID;
|
||||
const globalModeGID = uiModel.globalModeShortcutGameId();
|
||||
GlobalModeGameId.text = globalModeGID;
|
||||
setTimeout(() => {
|
||||
uiModel.saveDefaultConf(config);
|
||||
done();
|
||||
}, 10);
|
||||
}
|
||||
highlighted: true
|
||||
visible: !uiModel.standaloneModeShortcutExists()
|
||||
visible: !uiModel.globalModeShortcutExists()
|
||||
}
|
||||
Button {
|
||||
id: standAloneGameIdConfigButton
|
||||
text: qsTr("Open standalone-/desktop-mode controller config")
|
||||
id: GlobalModeGameIdConfigButton
|
||||
text: qsTr("Open global-/desktop-mode controller config")
|
||||
onClicked: {
|
||||
Qt.openUrlExternally("steam://currentcontrollerconfig/" + uiModel.standaloneModeShortcutAppId() + "/");
|
||||
Qt.openUrlExternally("steam://currentcontrollerconfig/" + uiModel.globalModeShortcutAppId() + "/");
|
||||
}
|
||||
visible: uiModel.standaloneModeShortcutExists()
|
||||
visible: uiModel.globalModeShortcutExists()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,25 +215,25 @@ void SteamTarget::focusWindow(WindowHandle hndl)
|
||||
void SteamTarget::init_FuckingRenameMe()
|
||||
{
|
||||
if (!SteamOverlayDetector::IsSteamInjected()) {
|
||||
if (Settings::common.allowStandAlone) {
|
||||
if (Settings::common.allowGlobalMode) {
|
||||
spdlog::warn("GlosSI not launched via Steam.\nEnabling EXPERIMENTAL global controller and overlay...");
|
||||
if (Settings::common.standaloneModeGameId == L"") {
|
||||
spdlog::error("No game id set for standalone mode. Controller will use desktop-config!");
|
||||
if (Settings::common.globalModeGameId == L"") {
|
||||
spdlog::error("No game id set for global mode. Controller will use desktop-config!");
|
||||
}
|
||||
|
||||
SetEnvironmentVariable(L"SteamAppId", L"0");
|
||||
SetEnvironmentVariable(L"SteamClientLaunch", L"0");
|
||||
SetEnvironmentVariable(L"SteamEnv", L"1");
|
||||
SetEnvironmentVariable(L"SteamPath", steam_path_.wstring().c_str());
|
||||
SetEnvironmentVariable(L"SteamTenfoot", Settings::common.standaloneUseGamepadUI ? L"1" : L"0");
|
||||
SetEnvironmentVariable(L"SteamTenfoot", Settings::common.globalModeUseGamepadUI ? L"1" : L"0");
|
||||
// SetEnvironmentVariable(L"SteamTenfootHybrid", L"1");
|
||||
SetEnvironmentVariable(L"SteamGamepadUI", Settings::common.standaloneUseGamepadUI ? L"1" : L"0");
|
||||
SetEnvironmentVariable(L"SteamGameId", Settings::common.standaloneModeGameId.c_str());
|
||||
SetEnvironmentVariable(L"SteamOverlayGameId", Settings::common.standaloneModeGameId.c_str());
|
||||
SetEnvironmentVariable(L"SteamGamepadUI", Settings::common.globalModeUseGamepadUI ? L"1" : L"0");
|
||||
SetEnvironmentVariable(L"SteamGameId", Settings::common.globalModeGameId.c_str());
|
||||
SetEnvironmentVariable(L"SteamOverlayGameId", Settings::common.globalModeGameId.c_str());
|
||||
SetEnvironmentVariable(L"EnableConfiguratorSupport", L"15");
|
||||
SetEnvironmentVariable(L"SteamStreamingForceWindowedD3D9", L"1");
|
||||
|
||||
if (Settings::common.standaloneUseGamepadUI) {
|
||||
if (Settings::common.globalModeUseGamepadUI) {
|
||||
system("start steam://open/bigpicture");
|
||||
auto steamwindow = FindWindow(L"Steam Big Picture Mode", nullptr);
|
||||
auto timer = sf::Clock{};
|
||||
|
@ -3,7 +3,7 @@
|
||||
!define APP_NAME "GlosSI"
|
||||
!define COMP_NAME "Peter Repukat - Flatspotsoftware"
|
||||
!define WEB_SITE "https://glossi.flatspot.pictures/"
|
||||
!define VERSION "0.1.2.0-18-g27056b4"
|
||||
!define VERSION "0.1.2.0-31-gd2b43ff"
|
||||
!define COPYRIGHT "Peter Repukat - FlatspotSoftware © 2017-2022"
|
||||
!define DESCRIPTION "SteamInput compatibility tool"
|
||||
!define INSTALLER_NAME "GlosSI-Installer.exe"
|
||||
|
@ -31,10 +31,11 @@ limitations under the License.
|
||||
#include "../common/nlohmann_json_wstring.h"
|
||||
#include "../common/util.h"
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
|
||||
namespace Settings {
|
||||
|
||||
inline struct Launch {
|
||||
inline struct Launch
|
||||
{
|
||||
bool launch = false;
|
||||
std::wstring launchPath;
|
||||
std::wstring launchAppArgs;
|
||||
@ -46,12 +47,14 @@ namespace Settings {
|
||||
std::vector<std::wstring> launcherProcesses{};
|
||||
} launch;
|
||||
|
||||
inline struct Devices {
|
||||
inline struct Devices
|
||||
{
|
||||
bool hideDevices = true;
|
||||
bool realDeviceIds = false;
|
||||
} devices;
|
||||
|
||||
inline struct Window {
|
||||
inline struct Window
|
||||
{
|
||||
bool windowMode = false;
|
||||
int maxFps = 0;
|
||||
float scale = 0.f;
|
||||
@ -60,13 +63,15 @@ namespace Settings {
|
||||
bool disableGlosSIOverlay = false;
|
||||
} window;
|
||||
|
||||
inline struct Controller {
|
||||
inline struct Controller
|
||||
{
|
||||
int maxControllers = 1;
|
||||
bool allowDesktopConfig = false;
|
||||
bool emulateDS4 = false;
|
||||
} controller;
|
||||
|
||||
inline struct Common {
|
||||
inline struct Common
|
||||
{
|
||||
bool no_uwp_overlay = false;
|
||||
bool disable_watchdog = false;
|
||||
bool extendedLogging = false;
|
||||
@ -75,30 +80,39 @@ namespace Settings {
|
||||
int version;
|
||||
std::wstring steamPath;
|
||||
std::wstring steamUserId;
|
||||
std::wstring standaloneModeGameId; /* = L"12605636929694728192"; */
|
||||
bool standaloneUseGamepadUI = false;
|
||||
bool allowStandAlone = true;
|
||||
std::wstring globalModeGameId; /* = L"12605636929694728192"; */
|
||||
bool globalModeUseGamepadUI = false;
|
||||
bool allowGlobalMode = true;
|
||||
} common;
|
||||
|
||||
inline const std::map<std::wstring, std::function<void()>> cmd_args = {
|
||||
{L"-disableuwpoverlay", [&]() { common.no_uwp_overlay = true; }},
|
||||
{L"-disablewatchdog", [&]() { common.disable_watchdog = true; }},
|
||||
{L"-ignorelauncher", [&]() { launch.ignoreLauncher = true; }},
|
||||
{L"-window", [&]() { window.windowMode = true; }},
|
||||
{L"-extendedLogging", [&]() { common.extendedLogging = true; }},
|
||||
{L"-standaloneUseGamepadUI", [&]() { common.standaloneUseGamepadUI = true; }},
|
||||
{L"-disallowStandAlone", [&]() { common.allowStandAlone = false; }},
|
||||
{L"-disableuwpoverlay", [&]()
|
||||
{ common.no_uwp_overlay = true; }},
|
||||
{L"-disablewatchdog", [&]()
|
||||
{ common.disable_watchdog = true; }},
|
||||
{L"-ignorelauncher", [&]()
|
||||
{ launch.ignoreLauncher = true; }},
|
||||
{L"-window", [&]()
|
||||
{ window.windowMode = true; }},
|
||||
{L"-extendedLogging", [&]()
|
||||
{ common.extendedLogging = true; }},
|
||||
{L"-globalModeUseGamepadUI", [&]()
|
||||
{ common.globalModeUseGamepadUI = true; }},
|
||||
{L"-disallowGlobalMode", [&]()
|
||||
{ common.allowGlobalMode = false; }},
|
||||
};
|
||||
|
||||
inline std::filesystem::path settings_path_ = "";
|
||||
|
||||
inline bool checkIsUwp(const std::wstring &launch_path)
|
||||
{
|
||||
if (launch_path.find(L"://") != std::wstring::npos) {
|
||||
if (launch_path.find(L"://") != std::wstring::npos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
std::wsmatch m;
|
||||
if (!std::regex_search(launch_path, m, std::wregex(L"^.{1,5}:"))) {
|
||||
if (!std::regex_search(launch_path, m, std::wregex(L"^.{1,5}:")))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -112,10 +126,12 @@ namespace Settings {
|
||||
auto VN = util::win::GetRealOSVersion();
|
||||
isWin10 = VN.dwBuildNumber < 22000;
|
||||
|
||||
if (isWin10) {
|
||||
if (isWin10)
|
||||
{
|
||||
spdlog::info("Running on Windows 10; Winver: {}.{}.{}", VN.dwMajorVersion, VN.dwMinorVersion, VN.dwBuildNumber);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
spdlog::info("Running on Windows 11; Winver: {}.{}.{}", VN.dwMajorVersion, VN.dwMinorVersion, VN.dwBuildNumber);
|
||||
}
|
||||
}
|
||||
@ -123,38 +139,47 @@ namespace Settings {
|
||||
|
||||
inline void Parse(const nlohmann::basic_json<> &json)
|
||||
{
|
||||
constexpr auto safeParseValue = []<typename T>(const auto & object, const auto & key, T & value) {
|
||||
try {
|
||||
if (object.is_null() || object.empty() || object.at(key).empty() || object.at(key).is_null()) {
|
||||
constexpr auto safeParseValue = []<typename T>(const auto &object, const auto &key, T &value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (object.is_null() || object.empty() || object.at(key).empty() || object.at(key).is_null())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if constexpr (std::is_same_v<T, std::wstring>) {
|
||||
if constexpr (std::is_same_v<T, std::wstring>)
|
||||
{
|
||||
value = util::string::to_wstring(object[key].get<std::string>());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
value = object[key];
|
||||
}
|
||||
}
|
||||
catch (const nlohmann::json::exception& e) {
|
||||
catch (const nlohmann::json::exception &e)
|
||||
{
|
||||
e.id == 403
|
||||
? spdlog::trace("Err parsing \"{}\"; {}", key, e.what())
|
||||
: spdlog::warn("Err parsing \"{}\"; {}", key, e.what());
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
spdlog::warn("Err parsing \"{}\"; {}", key, e.what());
|
||||
}
|
||||
};
|
||||
|
||||
int version;
|
||||
safeParseValue(json, "version", version);
|
||||
if (version != 1) { // TODO: versioning stuff
|
||||
if (version != 1)
|
||||
{ // TODO: versioning stuff
|
||||
spdlog::warn("Config version doesn't match application version.");
|
||||
}
|
||||
|
||||
// TODO: make this as much generic as fits in about the same amount of code if one would parse every value separately.
|
||||
try {
|
||||
if (const auto launchconf = json["launch"]; !launchconf.is_null() && !launchconf.empty() && launchconf.is_object()) {
|
||||
try
|
||||
{
|
||||
if (const auto launchconf = json["launch"]; !launchconf.is_null() && !launchconf.empty() && launchconf.is_object())
|
||||
{
|
||||
safeParseValue(launchconf, "launch", launch.launch);
|
||||
safeParseValue(launchconf, "launchPath", launch.launchPath);
|
||||
safeParseValue(launchconf, "launchAppArgs", launch.launchAppArgs);
|
||||
@ -163,24 +188,29 @@ namespace Settings {
|
||||
safeParseValue(launchconf, "killLauncher", launch.killLauncher);
|
||||
safeParseValue(launchconf, "ignoreLauncher", launch.ignoreLauncher);
|
||||
|
||||
if (launchconf.contains("launcherProcesses") && launchconf["launcherProcesses"].is_array()) {
|
||||
if (launchconf.contains("launcherProcesses") && launchconf["launcherProcesses"].is_array())
|
||||
{
|
||||
if (const auto launcherProcs = launchconf["launcherProcesses"];
|
||||
!launcherProcs.is_null() && !launcherProcs.empty() && launcherProcs.is_array()) {
|
||||
!launcherProcs.is_null() && !launcherProcs.empty() && launcherProcs.is_array())
|
||||
{
|
||||
launch.launcherProcesses.clear();
|
||||
launch.launcherProcesses.reserve(launcherProcs.size());
|
||||
for (auto& proc : launcherProcs) {
|
||||
for (auto &proc : launcherProcs)
|
||||
{
|
||||
launch.launcherProcesses.push_back(util::string::to_wstring(proc));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto devconf = json["devices"]; !devconf.is_null() && !devconf.empty() && devconf.is_object()) {
|
||||
if (const auto devconf = json["devices"]; !devconf.is_null() && !devconf.empty() && devconf.is_object())
|
||||
{
|
||||
safeParseValue(devconf, "hideDevices", devices.hideDevices);
|
||||
safeParseValue(devconf, "realDeviceIds", devices.realDeviceIds);
|
||||
}
|
||||
|
||||
if (const auto winconf = json["window"]; !winconf.is_null() && !winconf.empty() && winconf.is_object()) {
|
||||
if (const auto winconf = json["window"]; !winconf.is_null() && !winconf.empty() && winconf.is_object())
|
||||
{
|
||||
safeParseValue(winconf, "windowMode", window.windowMode);
|
||||
safeParseValue(winconf, "maxFps", window.maxFps);
|
||||
safeParseValue(winconf, "scale", window.scale);
|
||||
@ -189,7 +219,8 @@ namespace Settings {
|
||||
safeParseValue(winconf, "disableGlosSIOverlay", window.disableGlosSIOverlay);
|
||||
}
|
||||
|
||||
if (const auto controllerConf = json["controller"]; !controllerConf.is_null() && !controllerConf.empty() && controllerConf.is_object()) {
|
||||
if (const auto controllerConf = json["controller"]; !controllerConf.is_null() && !controllerConf.empty() && controllerConf.is_object())
|
||||
{
|
||||
safeParseValue(controllerConf, "maxControllers", controller.maxControllers);
|
||||
safeParseValue(controllerConf, "allowDesktopConfig", controller.allowDesktopConfig);
|
||||
safeParseValue(controllerConf, "emulateDS4", controller.emulateDS4);
|
||||
@ -202,16 +233,19 @@ namespace Settings {
|
||||
safeParseValue(json, "steamPath", common.steamPath);
|
||||
safeParseValue(json, "steamUserId", common.steamUserId);
|
||||
|
||||
safeParseValue(json, "standaloneModeGameId", common.standaloneModeGameId);
|
||||
safeParseValue(json, "standaloneUseGamepadUI", common.standaloneUseGamepadUI);
|
||||
safeParseValue(json, "globalModeGameId", common.globalModeGameId);
|
||||
safeParseValue(json, "globalModeUseGamepadUI", common.globalModeUseGamepadUI);
|
||||
}
|
||||
catch (const nlohmann::json::exception& e) {
|
||||
catch (const nlohmann::json::exception &e)
|
||||
{
|
||||
spdlog::warn("Err parsing config: {}", e.what());
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
spdlog::warn("Err parsing config: {}", e.what());
|
||||
}
|
||||
if (launch.launch) {
|
||||
if (launch.launch)
|
||||
{
|
||||
launch.isUWP = checkIsUwp(launch.launchPath);
|
||||
}
|
||||
}
|
||||
@ -220,42 +254,52 @@ namespace Settings {
|
||||
{
|
||||
std::wstring configName;
|
||||
std::vector<std::function<void()>> cli_overrides;
|
||||
for (const auto& arg : args) {
|
||||
if (arg.empty()) {
|
||||
for (const auto &arg : args)
|
||||
{
|
||||
if (arg.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (cmd_args.contains(arg))
|
||||
{
|
||||
cli_overrides.push_back(cmd_args.at(arg));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
configName += L" " + std::wstring(arg.begin(), arg.end());
|
||||
}
|
||||
}
|
||||
if (!configName.empty()) {
|
||||
if (configName[0] == L' ') {
|
||||
if (!configName.empty())
|
||||
{
|
||||
if (configName[0] == L' ')
|
||||
{
|
||||
configName.erase(configName.begin());
|
||||
}
|
||||
if (!configName.ends_with(L".json")) {
|
||||
if (!configName.ends_with(L".json"))
|
||||
{
|
||||
configName += L".json";
|
||||
}
|
||||
}
|
||||
auto path = util::path::getDataDirPath();
|
||||
if (!configName.empty()) {
|
||||
if (!configName.empty())
|
||||
{
|
||||
path /= "Targets";
|
||||
path /= configName;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
spdlog::info("No config file specified, using default");
|
||||
path /= "default.json";
|
||||
}
|
||||
|
||||
std::ifstream json_file;
|
||||
json_file.open(path);
|
||||
if (!json_file.is_open()) {
|
||||
if (!json_file.is_open())
|
||||
{
|
||||
spdlog::error(L"Couldn't open settings file {}", path.wstring());
|
||||
spdlog::debug(L"Using sane defaults...");
|
||||
for (const auto& ovr : cli_overrides) {
|
||||
for (const auto &ovr : cli_overrides)
|
||||
{
|
||||
ovr();
|
||||
}
|
||||
return;
|
||||
@ -264,7 +308,8 @@ namespace Settings {
|
||||
const auto &json = nlohmann::json::parse(json_file);
|
||||
Parse(json);
|
||||
|
||||
for (const auto& ovr : cli_overrides) {
|
||||
for (const auto &ovr : cli_overrides)
|
||||
{
|
||||
ovr();
|
||||
}
|
||||
spdlog::debug("Read config file \"{}\"; config: {}", path.string(), json.dump());
|
||||
@ -304,7 +349,8 @@ namespace Settings {
|
||||
|
||||
std::ofstream json_file;
|
||||
json_file.open(settings_path_);
|
||||
if (!json_file.is_open()) {
|
||||
if (!json_file.is_open())
|
||||
{
|
||||
spdlog::error(L"Couldn't open settings file {}", settings_path_.wstring());
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user