Made game launching more seamless and prevent minimizing of window when switching applications. Also added menu entry to choose between normal fullscreen mode and borderless fullscren mode

This commit is contained in:
Leon Styhre 2020-05-15 17:51:32 +02:00
parent 24d6a70019
commit ffcf52c710
5 changed files with 62 additions and 21 deletions

View file

@ -281,7 +281,8 @@ void FileData::launchGame(Window* window)
AudioManager::getInstance()->deinit();
VolumeControl::getInstance()->deinit();
window->deinit();
// window->deinit();
std::string command = mEnvData->mLaunchCommand;
@ -305,7 +306,7 @@ void FileData::launchGame(Window* window)
Scripting::fireEvent("game-end");
window->init();
// window->init();
VolumeControl::getInstance()->init();
window->normalizeNextUpdate();

View file

@ -231,6 +231,24 @@ void GuiMenu::openUISettings()
}
});
// fullscreen mode
auto fullscreen_mode = std::make_shared< OptionListComponent<std::string> >(mWindow, "FULLSCREEN MODE", false);
std::vector<std::string> screenmode;
screenmode.push_back("normal");
screenmode.push_back("borderless");
for(auto it = screenmode.cbegin(); it != screenmode.cend(); it++)
fullscreen_mode->add(*it, *it, Settings::getInstance()->getString("FullscreenMode") == *it);
s->addWithLabel("FULLSCREEN MODE (RESTART REQUIRED)", fullscreen_mode);
s->addSaveFunc([fullscreen_mode] {
if (Settings::getInstance()->getString("FullscreenMode") == "normal"
&& fullscreen_mode->getSelected() != "normal")
{
Settings::getInstance()->setString("PowerSaverMode", "default");
PowerSaver::init();
}
Settings::getInstance()->setString("FullscreenMode", fullscreen_mode->getSelected());
});
// screensaver
ComponentListRow screensaver_row;
screensaver_row.elements.clear();

View file

@ -124,9 +124,12 @@ bool parseArgs(int argc, char* argv[])
Settings::getInstance()->setBool("Debug", true);
Settings::getInstance()->setBool("HideConsole", false);
Log::setReportingLevel(LogDebug);
}else if(strcmp(argv[i], "--fullscreen-normal") == 0)
{
Settings::getInstance()->setString("FullscreenMode", "normal");
}else if(strcmp(argv[i], "--fullscreen-borderless") == 0)
{
Settings::getInstance()->setBool("FullscreenBorderless", true);
Settings::getInstance()->setString("FullscreenMode", "borderless");
}else if(strcmp(argv[i], "--windowed") == 0)
{
Settings::getInstance()->setBool("Windowed", true);
@ -170,22 +173,24 @@ bool parseArgs(int argc, char* argv[])
"Written by Alec \"Aloshi\" Lofquist.\n"
"Version " << PROGRAM_VERSION_STRING << ", built " << PROGRAM_BUILT_STRING << "\n\n"
"Command line arguments:\n"
"--resolution [width] [height] try and force a particular resolution\n"
"--gamelist-only skip automatic game search, only read from gamelist.xml\n"
"--ignore-gamelist ignore the gamelist (useful for troubleshooting)\n"
"--draw-framerate display the framerate\n"
"--no-exit don't show the exit option in the menu\n"
"--no-splash don't show the splash screen\n"
"--debug more logging, show console on Windows\n"
"--scrape scrape using command line interface\n"
"--windowed not fullscreen, should be used with --resolution\n"
"--vsync [1/on or 0/off] turn vsync on or off (default is on)\n"
"--resolution [width] [height] Try and force a particular resolution\n"
"--gamelist-only Skip automatic game search, only read from gamelist.xml\n"
"--ignore-gamelist Ignore the gamelist (useful for troubleshooting)\n"
"--draw-framerate Display the framerate\n"
"--no-exit Don't show the exit option in the menu\n"
"--no-splash Don't show the splash screen\n"
"--debug More logging, show console on Windows\n"
"--scrape Scrape using command line interface\n"
"--windowed Not fullscreen, should be used with --resolution\n"
"--fullscreen-normal Run in normal fullscreen mode\n"
"--fullscreen-borderless Run in borderless fullscreen mode (always on top)\n"
"--vsync [1/on or 0/off] Turn vsync on or off (default is on)\n"
"--max-vram [size] Max VRAM to use in Mb before swapping. 0 for unlimited\n"
"--force-kid Force the UI mode to be Kid\n"
"--force-kiosk Force the UI mode to be Kiosk\n"
"--force-disable-filters Force the UI to ignore applied filters in gamelist\n"
"--home [path] Directory to use as home path\n"
"--help, -h summon a sentient, angry tuba\n\n"
"--help, -h Summon a sentient, angry tuba\n\n"
"More information available in README.md.\n";
return false; //exit after printing help
}

View file

@ -25,7 +25,6 @@ std::vector<const char*> settings_dont_save {
{ "SplashScreen" },
{ "SplashScreenProgress" },
{ "VSync" },
{ "FullscreenBorderless" },
{ "Windowed" },
{ "WindowWidth" },
{ "WindowHeight" },
@ -63,7 +62,6 @@ void Settings::setDefaults()
mBoolMap["ShowExit"] = true;
mBoolMap["ShowRestartSystem"] = true;
mBoolMap["ShowShutdownSystem"] = true;
mBoolMap["FullscreenBorderless"] = false;
mBoolMap["Windowed"] = false;
mBoolMap["SplashScreen"] = true;
mBoolMap["SplashScreenProgress"] = true;
@ -94,6 +92,7 @@ void Settings::setDefaults()
mIntMap["MaxVRAM"] = 100;
#endif
mStringMap["FullscreenMode"] = "normal";
mStringMap["TransitionStyle"] = "fade";
mStringMap["ThemeSet"] = "";
mStringMap["ScreenSaverBehavior"] = "dim";

View file

@ -79,9 +79,27 @@ namespace Renderer
screenOffsetY = Settings::getInstance()->getInt("ScreenOffsetY") ? Settings::getInstance()->getInt("ScreenOffsetY") : 0;
screenRotate = Settings::getInstance()->getInt("ScreenRotate") ? Settings::getInstance()->getInt("ScreenRotate") : 0;
// Prevent ES window from minimizing when switching windows
// (when launching games or when manually switching windows using task switcher)
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
setupWindow();
unsigned int windowFlags = (Settings::getInstance()->getBool("Windowed") ? 0 : (Settings::getInstance()->getBool("FullscreenBorderless") ? SDL_WINDOW_BORDERLESS : SDL_WINDOW_FULLSCREEN)) | getWindowFlags();
unsigned int windowFlags;
if (Settings::getInstance()->getBool("Windowed"))
{
windowFlags = getWindowFlags();
}
else if (Settings::getInstance()->getString("FullscreenMode") == "borderless")
{
windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALWAYS_ON_TOP | getWindowFlags();
}
else
{
windowFlags = SDL_WINDOW_FULLSCREEN | getWindowFlags();
}
if((sdlWindow = SDL_CreateWindow("EmulationStation", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowWidth, windowHeight, windowFlags)) == nullptr)
{