GlosSITarget: parse and use "ignoreEGS" setting

pull/192/head
Peter Repukat 2 years ago
parent fc03e91c2b
commit 18a960abab

@ -25,7 +25,6 @@ limitations under the License.
#include <propkey.h> #include <propkey.h>
#include <shellapi.h> #include <shellapi.h>
#pragma comment(lib, "Shell32.lib") #pragma comment(lib, "Shell32.lib")
#endif #endif
#include "Settings.h" #include "Settings.h"
@ -76,10 +75,9 @@ void AppLauncher::launchApp(const std::wstring& path, const std::wstring& args)
glossi_util::KillProcess(pid); glossi_util::KillProcess(pid);
} }
}); });
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::End(); ImGui::End();
}); });
#endif #endif
} }
@ -118,21 +116,22 @@ void AppLauncher::update()
}); });
auto filtered_pids = pids_ | std::ranges::views::filter([](DWORD pid) { 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(); return std::ranges::find(EGS_LAUNCHER_PROCNAMES_, glossi_util::GetProcName(pid)) == EGS_LAUNCHER_PROCNAMES_.end();
}); });
if (was_egs_launch_ && !filtered_pids.empty()) { if (was_egs_launch_ && !filtered_pids.empty()) {
egs_has_launched_game_ = true; egs_has_launched_game_ = true;
} }
if (Settings::launch.closeOnExit && Settings::launch.launch) { 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()) { 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..."); spdlog::info("Configured to close on all children exit. Shutting down after game launched via EGS quit...");
shutdown_(); shutdown_();
} }
} else { }
else {
if (pids_.empty()) { if (pids_.empty()) {
spdlog::info("Configured to close on all children exit. Shutting down..."); spdlog::info("Configured to close on all children exit. Shutting down...");
shutdown_(); shutdown_();
} }
} }
} }
@ -159,8 +158,20 @@ std::vector<DWORD> AppLauncher::launchedPids()
pid_mutex_.lock(); pid_mutex_.lock();
std::vector<DWORD> res; std::vector<DWORD> res;
res.reserve(pids_.size()); res.reserve(pids_.size());
std::ranges::copy(pids_.begin(), pids_.end(), if (Settings::common.ignoreEGS) {
std::back_inserter(res)); 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(); pid_mutex_.unlock();
return res; return res;
} }

@ -63,6 +63,7 @@ inline struct Common {
bool no_uwp_overlay = false; bool no_uwp_overlay = false;
bool disable_watchdog = false; bool disable_watchdog = false;
bool extendedLogging = false; bool extendedLogging = false;
bool ignoreEGS = true;
std::wstring name; std::wstring name;
std::wstring icon; std::wstring icon;
int version; int version;
@ -194,6 +195,7 @@ inline void Parse(const nlohmann::basic_json<>& json)
safeWStringParse(json, "name", common.name); safeWStringParse(json, "name", common.name);
safeWStringParse(json, "icon", common.icon); safeWStringParse(json, "icon", common.icon);
safeParseValue(json, "version", common.version); safeParseValue(json, "version", common.version);
safeParseValue(json, "ignoreEGS", common.ignoreEGS);
if (launch.launch) { if (launch.launch) {
launch.isUWP = checkIsUwp(launch.launchPath); launch.isUWP = checkIsUwp(launch.launchPath);
@ -213,6 +215,9 @@ inline void Parse(const std::vector<std::wstring>& args)
else if (arg == L"-disablewatchdog") { else if (arg == L"-disablewatchdog") {
common.disable_watchdog = true; common.disable_watchdog = true;
} }
else if (arg == L"-ignoreegs") {
common.ignoreEGS = true;
}
else { else {
configName += L" " + std::wstring(arg.begin(), arg.end()); configName += L" " + std::wstring(arg.begin(), arg.end());
} }

Loading…
Cancel
Save