Skip to content

Commit

Permalink
Add configurable Launcher options / Launcher ProcessList
Browse files Browse the repository at this point in the history
  • Loading branch information
Alia5 committed Oct 21, 2022
1 parent 63fdab1 commit 5528dfb
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 48 deletions.
8 changes: 4 additions & 4 deletions GlosSIConfig/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,0,2035000100080
PRODUCTVERSION 0,1,0,2035000100080
FILEVERSION 0,1,0,2045006300001
PRODUCTVERSION 0,1,0,2045006300001
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - Config"
VALUE "FileVersion", "0.1.0.2-35-g01efd8d"
VALUE "FileVersion", "0.1.0.2-45-g63fdab1"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.1.0.2-35-g01efd8d"
VALUE "ProductVersion", "0.1.0.2-45-g63fdab1"
END
END
BLOCK "VarFileInfo"
Expand Down
10 changes: 7 additions & 3 deletions GlosSIConfig/UIModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
#include <QFont>
#include <QGuiApplication>
#include <QJsonDocument>
#include <QJsonArray>
#include <QNetworkAccessManager>
#include <QNetworkReply>

Expand All @@ -32,6 +33,8 @@ limitations under the License.
#include <shlobj.h>
#endif

#include "ExeImageProvider.h"
#include "ExeImageProvider.h"
#include "../version.hpp"
#include "steamgrid_api_keys.h"

Expand Down Expand Up @@ -365,15 +368,13 @@ QVariantMap UIModel::getDefaultConf() const
path /= "Roaming";
path /= "GlosSI";
path /= "default.json";

QJsonObject defaults = {
{"icon", QJsonValue::Null},
{"name", QJsonValue::Null},
{"version", 1},
{"extendedLogging", false},
{"snapshotNotify", false},
{"ignoreEGS", true},
{"killEGS", false},
{"controller", QJsonObject{{"maxControllers", 1}, {"emulateDS4", false}, {"allowDesktopConfig", false}}},
{"devices",
QJsonObject{
Expand All @@ -387,6 +388,9 @@ QVariantMap UIModel::getDefaultConf() const
{"launchAppArgs", QJsonValue::Null},
{"launchPath", QJsonValue::Null},
{"waitForChildProcs", true},
{"launcherProcesses", QJsonArray{}},
{"ignoreLauncher", true},
{"killLauncher", false},
}},
{"window",
QJsonObject{
Expand Down
101 changes: 99 additions & 2 deletions GlosSIConfig/qml/AdvancedTargetSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CollapsiblePane {
shortcutInfo.launch.waitForChildProcs = checked
}
}
CheckBox {
/*CheckBox {
height: subTitle != "" || (shortcutInfo.launch.launchPath || "").includes("epicgames.launcher") ? 32 : 0
visible: subTitle != "" || (shortcutInfo.launch.launchPath || "").includes("epicgames.launcher")
id: ignoreEGS
Expand All @@ -109,7 +109,7 @@ CollapsiblePane {
onCheckedChanged: function(){
shortcutInfo.killEGS = checked
}
}
}*/
}
Column {
spacing: 2
Expand Down Expand Up @@ -483,7 +483,104 @@ CollapsiblePane {
id: commonPane
Column {
spacing: 4
width: parent.width
Column {
width: parent.width
Row {
width: parent.width
Label {
text: qsTr("Launcher processes")
anchors.verticalCenter: parent.verticalCenter
}
RoundButton {
onClicked: () => {
helpInfoDialog.titleText = qsTr("Launcher processes")
helpInfoDialog.text =
qsTr("Tells GlosSI what processes should be treated as launchers")
+ "\n"
qsTr("Only use executable name, not full path")
+ "\n"
qsTr("One process per line")
+ "\n"
+ qsTr("List must be filled for \"")
+ qsTr("Ignore launcher for close detection")
+ qsTr("\" and \"") + qsTr("Close launcher on game exit.")
+ qsTr("\" to work")

helpInfoDialog.open()
}
width: 48
height: 48
Material.elevation: 0
anchors.verticalCenter: parent.verticalCenter
Image {
anchors.centerIn: parent
source: "qrc:/svg/help_outline_white_24dp.svg"
width: 24
height: 24
}
}
}
RPane {
color: Qt.lighter(Material.background, 1.6)
bgOpacity: 0.3
radius: 8
width: parent.width
height: launcherProcessesTextArea.height + 16
Flickable {
width: parent.width
height: parent.height
clip: true
ScrollBar.vertical: ScrollBar {

}
contentWidth: parent.width
flickableDirection: Flickable.VerticalFlick
TextArea {
id: launcherProcessesTextArea
width: parent.width
TextArea.flickable: parent
text: ((shortcutInfo.launch.launcherProcesses || []).length == 0 && (shortcutInfo.launch.launchPath || "").includes("epicgames.launcher"))
? "EpicGamesLauncher.exe\nEpicWebHelper.exe"
: (shortcutInfo.launch.launcherProcesses || [""]).reduce((acc, curr) => {
return acc + "\n" + curr;
})
onTextChanged: function() {
shortcutInfo.launch.launcherProcesses = text.split("\n")
.map((e) => {
e = e.endsWith(".exe") ? e : e + ".exe"
return e.trim()
})
.filter((e) => {
return e != "" && e != ".exe"
});
}
}

}
}
}
Row {
CheckBox {
id: ignoreLauncherCheckbox
text: qsTr("Ignore launcher for close detection")
checked: shortcutInfo.launch.ignoreLauncher
onCheckedChanged: function(){
shortcutInfo.launch.ignoreLauncher = checked
}
}
CheckBox {
id: killLauncherCheckbox
text: qsTr("Close launcher on game exit.")
enabled: ignoreLauncherCheckbox.checked
checked: shortcutInfo.launch.killLauncher
onCheckedChanged: function(){
shortcutInfo.launch.killLauncher = checked
}
}
}
Row {
anchors.topMargin: 24
Row {
CheckBox {
id: extendedLogging
Expand Down
34 changes: 20 additions & 14 deletions GlosSITarget/AppLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ AppLauncher::AppLauncher(
void AppLauncher::launchApp(const std::wstring& path, const std::wstring& args)
{
#ifdef _WIN32

if (!Settings::launch.launcherProcesses.empty()) {
has_extra_launchers_ = true;
spdlog::debug("Has extra launchers");
}

if (Settings::launch.isUWP) {
spdlog::info("LaunchApp is UWP, launching...");
launched_uwp_path_ = path;
Expand Down Expand Up @@ -87,8 +93,8 @@ void AppLauncher::update()
if (process_check_clock_.getElapsedTime().asMilliseconds() > 250) {
pid_mutex_.lock();
#ifdef _WIN32
if (was_egs_launch_ && pids_.empty()) {
findEgsPid();
if (has_extra_launchers_ && pids_.empty()) {
findLauncherPids();
}
if (!pids_.empty() && pids_[0] > 0) {
if (Settings::launch.waitForChildProcs) {
Expand Down Expand Up @@ -116,14 +122,14 @@ 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();
return std::ranges::find(Settings::launch.launcherProcesses, glossi_util::GetProcName(pid)) == Settings::launch.launcherProcesses.end();
});
if (was_egs_launch_ && !filtered_pids.empty()) {
egs_has_launched_game_ = true;
if (has_extra_launchers_ && !filtered_pids.empty()) {
launcher_has_launched_game_ = true;
}
if (Settings::launch.closeOnExit && Settings::launch.launch) {
if (was_egs_launch_ && (Settings::common.ignoreEGS || Settings::common.killEGS)) {
if (egs_has_launched_game_ && filtered_pids.empty()) {
if (has_extra_launchers_ && (Settings::launch.ignoreLauncher || Settings::launch.killLauncher)) {
if (launcher_has_launched_game_ && filtered_pids.empty()) {
spdlog::info("Configured to close on all children exit. Shutting down after game launched via EGS quit...");
shutdown_();
}
Expand Down Expand Up @@ -158,12 +164,12 @@ std::vector<DWORD> AppLauncher::launchedPids()
pid_mutex_.lock();
std::vector<DWORD> res;
res.reserve(pids_.size());
if (!Settings::common.killEGS && Settings::common.ignoreEGS) {
if (!Settings::launch.killLauncher && Settings::launch.ignoreLauncher) {
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();
Settings::launch.launcherProcesses,
glossi_util::GetProcName(pid)) == Settings::launch.launcherProcesses.end();
})) {
res.push_back(pid);
}
Expand Down Expand Up @@ -255,7 +261,7 @@ void AppLauncher::getProcessHwnds()
#endif

#ifdef _WIN32
bool AppLauncher::findEgsPid()
bool AppLauncher::findLauncherPids()
{
if (const auto pid = glossi_util::PidByName(L"EpicGamesLauncher.exe")) {
spdlog::debug("Found EGS-Launcher running");
Expand Down Expand Up @@ -395,7 +401,7 @@ void AppLauncher::launchURL(const std::wstring& url, const std::wstring& args, c
CoUninitialize();

if (url.find(L"epicgames.launcher") != std::wstring::npos) {
was_egs_launch_ = true;
has_extra_launchers_ = true;
}
if (execute_info.hProcess != nullptr) {
if (const auto pid = GetProcessId(execute_info.hProcess); pid > 0) {
Expand All @@ -407,12 +413,12 @@ void AppLauncher::launchURL(const std::wstring& url, const std::wstring& args, c
}
}

if (was_egs_launch_) {
if (has_extra_launchers_) {
spdlog::debug("Epic Games launch; Couldn't find egs launcher PID");
pid_mutex_.lock();

const auto pid = glossi_util::PidByName(L"EpicGamesLauncher.exe");
if (!findEgsPid()) {
if (!findLauncherPids()) {
spdlog::debug("Did not find EGS-Launcher not running, retrying later...");
}
pid_mutex_.unlock();
Expand Down
12 changes: 3 additions & 9 deletions GlosSITarget/AppLauncher.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,9 @@ class AppLauncher {
void getProcessHwnds();
std::vector<HWND>& process_hwnds_;

static inline const std::array<std::wstring_view, 2> EGS_LAUNCHER_PROCNAMES_{
L"EpicGamesLauncher.exe",
L"EpicWebHelper.exe",
};


bool was_egs_launch_ = false;
bool egs_has_launched_game_ = false;
bool findEgsPid();
bool has_extra_launchers_ = false;
bool launcher_has_launched_game_ = false;
bool findLauncherPids();


std::wstring launched_uwp_path_;
Expand Down
8 changes: 4 additions & 4 deletions GlosSITarget/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,0,2033009290000
PRODUCTVERSION 0,1,0,2033009290000
FILEVERSION 0,1,0,2045006300001
PRODUCTVERSION 0,1,0,2045006300001
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - SteamTarget"
VALUE "FileVersion", "0.1.0.2-33-g929abfe"
VALUE "FileVersion", "0.1.0.2-45-g63fdab1"
VALUE "InternalName", "GlosSITarget"
VALUE "LegalCopyright", "Copyright (C) 2021-2022 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSITarget.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.1.0.2-33-g929abfe"
VALUE "ProductVersion", "0.1.0.2-45-g63fdab1"
END
END
BLOCK "VarFileInfo"
Expand Down
Loading

0 comments on commit 5528dfb

Please sign in to comment.