mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
(Windows) Hiding of console windows during game launches can now be configured via the %HIDEWINDOW% variable.
This commit is contained in:
parent
82f81f89a6
commit
c958a94ca6
|
@ -766,6 +766,10 @@ void FileData::launchGame(Window* window)
|
|||
const std::string romRaw = Utils::FileSystem::getPreferredPath(getPath());
|
||||
const std::string esPath = Utils::FileSystem::getExePath();
|
||||
|
||||
#if defined(_WIN64)
|
||||
bool hideWindow = false;
|
||||
#endif
|
||||
|
||||
std::string coreEntry;
|
||||
std::string coreName;
|
||||
size_t coreEntryPos = 0;
|
||||
|
@ -773,6 +777,20 @@ void FileData::launchGame(Window* window)
|
|||
bool foundCoreFile = false;
|
||||
std::vector<std::string> emulatorCorePaths;
|
||||
|
||||
#if defined(_WIN64)
|
||||
// If the %HIDEWINDOW% variable is defined, we pass a flag to launchGameWindows() to
|
||||
// hide the window. This is intended primarily for hiding console windows when launching
|
||||
// scripts (used for example by Steam games and source ports).
|
||||
if (command.substr(0, 12) == "%HIDEWINDOW%") {
|
||||
hideWindow = true;
|
||||
command = Utils::String::replace(command, "%HIDEWINDOW%", "");
|
||||
// Trim any leading whitespaces as they could cause the script execution to fail.
|
||||
command.erase(command.begin(), std::find_if(command.begin(), command.end(), [](char c) {
|
||||
return !std::isspace(static_cast<unsigned char>(c));
|
||||
}));
|
||||
}
|
||||
#endif
|
||||
|
||||
// If there's a quotation mark before the %CORE_ variable, then remove it.
|
||||
// The closing quotation mark will be removed later below.
|
||||
command = Utils::String::replace(command, "\"%CORE_", "%CORE_");
|
||||
|
@ -1025,7 +1043,7 @@ void FileData::launchGame(Window* window)
|
|||
|
||||
#if defined(_WIN64)
|
||||
returnValue = launchGameWindows(Utils::String::stringToWideString(command),
|
||||
ViewController::get()->runInBackground(mSystem));
|
||||
ViewController::get()->runInBackground(mSystem), hideWindow);
|
||||
#else
|
||||
returnValue = launchGameUnix(command, ViewController::get()->runInBackground(mSystem));
|
||||
#endif
|
||||
|
|
|
@ -136,17 +136,19 @@ int launchGameUnix(const std::string& cmd_utf8, bool runInBackground)
|
|||
#endif
|
||||
}
|
||||
|
||||
int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground)
|
||||
int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool hideWindow)
|
||||
{
|
||||
#if defined(_WIN64)
|
||||
STARTUPINFOW si {};
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
si.cb = sizeof(si);
|
||||
// The console window is hidden by default when compiled with MSVC, but when
|
||||
// using MinGW it has to be set explicitly.
|
||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_HIDE;
|
||||
if (hideWindow) {
|
||||
// Optionally hide the window. This is intended primarily for hiding console windows when
|
||||
// launching scripts (used for example by Steam games and source ports).
|
||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_HIDE;
|
||||
}
|
||||
bool processReturnValue = true;
|
||||
DWORD errorCode = 0;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ int runSystemCommand(const std::string& cmd_utf8);
|
|||
int runSystemCommand(const std::wstring& cmd_utf16);
|
||||
|
||||
int launchGameUnix(const std::string& cmd_utf8, bool runInBackground);
|
||||
int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground);
|
||||
int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool hideWindow);
|
||||
|
||||
unsigned int getTaskbarState();
|
||||
void hideTaskbar();
|
||||
|
|
|
@ -285,7 +285,7 @@
|
|||
<fullname>Desktop applications</fullname>
|
||||
<path>%ROMPATH%\desktop</path>
|
||||
<extension>.bat</extension>
|
||||
<command>cmd.exe /C %ROM%</command>
|
||||
<command>%HIDEWINDOW% cmd.exe /C %ROM%</command>
|
||||
<platform>pc</platform>
|
||||
<theme>desktop</theme>
|
||||
</system>
|
||||
|
@ -447,7 +447,7 @@
|
|||
<fullname>Kodi home theatre software</fullname>
|
||||
<path>%ROMPATH%\kodi</path>
|
||||
<extension>.bat</extension>
|
||||
<command>cmd.exe /C %ROM%</command>
|
||||
<command>%HIDEWINDOW% cmd.exe /C %ROM%</command>
|
||||
<platform>pc</platform>
|
||||
<theme>kodi</theme>
|
||||
</system>
|
||||
|
@ -816,7 +816,7 @@
|
|||
<fullname>Ports</fullname>
|
||||
<path>%ROMPATH%\ports</path>
|
||||
<extension>.bat</extension>
|
||||
<command>cmd.exe /C %ROM%</command>
|
||||
<command>%HIDEWINDOW% cmd.exe /C %ROM%</command>
|
||||
<platform>pc</platform>
|
||||
<theme>ports</theme>
|
||||
</system>
|
||||
|
@ -1014,7 +1014,7 @@
|
|||
<fullname>Valve Steam</fullname>
|
||||
<path>%ROMPATH%\steam</path>
|
||||
<extension>.bat</extension>
|
||||
<command>cmd.exe /C %ROM%</command>
|
||||
<command>%HIDEWINDOW% cmd.exe /C %ROM%</command>
|
||||
<platform>steam</platform>
|
||||
<theme>steam</theme>
|
||||
</system>
|
||||
|
|
Loading…
Reference in a new issue