From 18a960abab2a67f76baa1621fad9ed4df3c18a51 Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Tue, 11 Oct 2022 22:07:06 +0200 Subject: [PATCH] GlosSITarget: parse and use "ignoreEGS" setting --- GlosSITarget/AppLauncher.cpp | 35 +++++++++++++++++++++++------------ GlosSITarget/Settings.h | 5 +++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/GlosSITarget/AppLauncher.cpp b/GlosSITarget/AppLauncher.cpp index 71e10a2..1e81d6a 100644 --- a/GlosSITarget/AppLauncher.cpp +++ b/GlosSITarget/AppLauncher.cpp @@ -25,7 +25,6 @@ limitations under the License. #include #include - #pragma comment(lib, "Shell32.lib") #endif #include "Settings.h" @@ -76,10 +75,9 @@ void AppLauncher::launchApp(const std::wstring& path, const std::wstring& args) glossi_util::KillProcess(pid); } }); - ImGui::EndChild(); + ImGui::EndChild(); } ImGui::End(); - }); #endif } @@ -118,21 +116,22 @@ void AppLauncher::update() }); auto filtered_pids = pids_ | std::ranges::views::filter([](DWORD pid) { - return std::ranges::find(EGS_LAUNCHER_PROCNAMES_, glossi_util::GetProcName(pid)) == EGS_LAUNCHER_PROCNAMES_.end(); - }); - if (was_egs_launch_ && !filtered_pids.empty()) { + return std::ranges::find(EGS_LAUNCHER_PROCNAMES_, glossi_util::GetProcName(pid)) == EGS_LAUNCHER_PROCNAMES_.end(); + }); + if (was_egs_launch_ && !filtered_pids.empty()) { egs_has_launched_game_ = true; } if (Settings::launch.closeOnExit && Settings::launch.launch) { - if (was_egs_launch_) { + if (was_egs_launch_ && Settings::common.ignoreEGS) { if (egs_has_launched_game_ && filtered_pids.empty()) { spdlog::info("Configured to close on all children exit. Shutting down after game launched via EGS quit..."); - shutdown_(); + shutdown_(); } - } else { + } + else { if (pids_.empty()) { spdlog::info("Configured to close on all children exit. Shutting down..."); - shutdown_(); + shutdown_(); } } } @@ -159,8 +158,20 @@ std::vector AppLauncher::launchedPids() pid_mutex_.lock(); std::vector res; res.reserve(pids_.size()); - std::ranges::copy(pids_.begin(), pids_.end(), - std::back_inserter(res)); + if (Settings::common.ignoreEGS) { + for (const auto& pid : pids_ | std::ranges::views::filter( + [](DWORD pid) { + return std::ranges::find( + EGS_LAUNCHER_PROCNAMES_, + glossi_util::GetProcName(pid)) == EGS_LAUNCHER_PROCNAMES_.end(); + })) { + res.push_back(pid); + } + } + else { + std::ranges::copy(pids_.begin(), pids_.end(), + std::back_inserter(res)); + } pid_mutex_.unlock(); return res; } diff --git a/GlosSITarget/Settings.h b/GlosSITarget/Settings.h index dfe0eb6..9227b1f 100644 --- a/GlosSITarget/Settings.h +++ b/GlosSITarget/Settings.h @@ -63,6 +63,7 @@ inline struct Common { bool no_uwp_overlay = false; bool disable_watchdog = false; bool extendedLogging = false; + bool ignoreEGS = true; std::wstring name; std::wstring icon; int version; @@ -194,6 +195,7 @@ inline void Parse(const nlohmann::basic_json<>& json) safeWStringParse(json, "name", common.name); safeWStringParse(json, "icon", common.icon); safeParseValue(json, "version", common.version); + safeParseValue(json, "ignoreEGS", common.ignoreEGS); if (launch.launch) { launch.isUWP = checkIsUwp(launch.launchPath); @@ -213,6 +215,9 @@ inline void Parse(const std::vector& args) else if (arg == L"-disablewatchdog") { common.disable_watchdog = true; } + else if (arg == L"-ignoreegs") { + common.ignoreEGS = true; + } else { configName += L" " + std::wstring(arg.begin(), arg.end()); }