From 7bb89693f30b9be3aa07973ee2661f68cf56a2fe Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 25 Jan 2021 18:10:11 +0100 Subject: [PATCH] Settings are now saved immediately when using some command line options. --- INSTALL.md | 18 ++++++++++++------ es-app/src/main.cpp | 30 ++++++++++++++++++------------ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 80c69ad12..45a3285c0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1108,14 +1108,13 @@ You can use **--help** or **-h** to view the list of command line options, as sh ### Unix ``` ---display [index] Display/monitor to use (1, 2, 3 or 4) +--display [index, 1-4] Display/monitor to use --resolution [width] [height] Application resolution --windowed Windowed mode, should be combined with --resolution --fullscreen-normal Normal fullscreen mode --fullscreen-borderless Borderless fullscreen mode (always on top) --vsync [1/on or 0/off] Turn VSync on or off (default is on) --max-vram [size] Max VRAM to use (in mebibytes) before swapping ---gpu-statistics Display framerate and VRAM usage overlay --no-splash Don't show the splash screen during startup --gamelist-only Skip automatic game ROM search, only read from gamelist.xml --ignore-gamelist Ignore the gamelist files (useful for troubleshooting) @@ -1134,11 +1133,10 @@ You can use **--help** or **-h** to view the list of command line options, as sh ### macOS and Windows ``` ---display [index] Display/monitor to use (1, 2, 3 or 4) +--display [index, 1-4] Display/monitor to use --resolution [width] [height] Application resolution --vsync [1/on or 0/off] Turn VSync on or off (default is on) --max-vram [size] Max VRAM to use (in mebibytes) before swapping ---gpu-statistics Display framerate and VRAM usage overlay --no-splash Don't show the splash screen during startup --gamelist-only Skip automatic game ROM search, only read from gamelist.xml --ignore-gamelist Ignore the gamelist files (useful for troubleshooting) @@ -1154,9 +1152,17 @@ You can use **--help** or **-h** to view the list of command line options, as sh --help, -h Summon a sentient, angry tuba ``` -As long as ES-DE hasn't frozen, you can always press F4 to close the application. +As you can see above, you can override the home directory path using the `--home` flag. So by running for instance the command `emulationstation --home ~/games/emulation`, ES-DE will use `~/games/emulation/.emulationstation` as its base directory. -As you can see above, you can override the home directory path using the `--home` flag. So by running for instance the command `emulationstation --home ~/games/emulation`, ES will use `~/games/emulation/.emulationstation` as its base directory. +For the following options, the es_settings.cfg file is immediately updated/saved when passing the parameter: +``` +--display +--fullscreen-normal +--fullscreen-borderless +--max-vram +--show-hidden-files +--show-hidden-games +``` ## es_systems.cfg diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 42fb0bcab..60563dca9 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -49,6 +49,7 @@ #include bool forceInputConfig = false; +bool settingsNeedSaving = false; enum returnCode { NO_LOADING_ERROR, @@ -171,9 +172,9 @@ bool parseArgs(int argc, char* argv[]) return false; } int DisplayIndex = atoi(argv[i + 1]); - i++; Settings::getInstance()->setInt("DisplayIndex", DisplayIndex); - Settings::getInstance()->saveFile(); + settingsNeedSaving = true; + i++; } else if (strcmp(argv[i], "--resolution") == 0) { if (i >= argc - 2) { @@ -182,9 +183,9 @@ bool parseArgs(int argc, char* argv[]) } int width = atoi(argv[i + 1]); int height = atoi(argv[i + 2]); - i += 2; Settings::getInstance()->setInt("WindowWidth", width); Settings::getInstance()->setInt("WindowHeight", height); + i += 2; } else if (strcmp(argv[i], "--screensize") == 0) { if (i >= argc - 2) { @@ -193,9 +194,9 @@ bool parseArgs(int argc, char* argv[]) } int width = atoi(argv[i + 1]); int height = atoi(argv[i + 2]); - i += 2; Settings::getInstance()->setInt("ScreenWidth", width); Settings::getInstance()->setInt("ScreenHeight", height); + i += 2; } else if (strcmp(argv[i], "--screenoffset") == 0) { if (i >= argc - 2) { @@ -204,9 +205,9 @@ bool parseArgs(int argc, char* argv[]) } int x = atoi(argv[i + 1]); int y = atoi(argv[i + 2]); - i += 2; Settings::getInstance()->setInt("ScreenOffsetX", x); Settings::getInstance()->setInt("ScreenOffsetY", y); + i += 2; } else if (strcmp(argv[i], "--screenrotate") == 0) { if (i >= argc - 1) { @@ -214,8 +215,8 @@ bool parseArgs(int argc, char* argv[]) return false; } int rotate = atoi(argv[i + 1]); - i++; Settings::getInstance()->setInt("ScreenRotate", rotate); + i++; } // On Unix, enable settings for the fullscreen mode. // On macOS and Windows only windowed mode is supported. @@ -225,9 +226,11 @@ bool parseArgs(int argc, char* argv[]) } else if (strcmp(argv[i], "--fullscreen-normal") == 0) { Settings::getInstance()->setString("FullscreenMode", "normal"); + settingsNeedSaving = true; } else if (strcmp(argv[i], "--fullscreen-borderless") == 0) { Settings::getInstance()->setString("FullscreenMode", "borderless"); + settingsNeedSaving = true; } #endif else if (strcmp(argv[i], "--vsync") == 0) { @@ -243,11 +246,9 @@ bool parseArgs(int argc, char* argv[]) } int maxVRAM = atoi(argv[i + 1]); Settings::getInstance()->setInt("MaxVRAM", maxVRAM); + settingsNeedSaving = true; i++; } - else if (strcmp(argv[i], "--gpu-statistics") == 0) { - Settings::getInstance()->setBool("DisplayGPUStatistics", "true"); - } else if (strcmp(argv[i], "--no-splash") == 0) { Settings::getInstance()->setBool("SplashScreen", false); } @@ -259,9 +260,11 @@ bool parseArgs(int argc, char* argv[]) } else if (strcmp(argv[i], "--show-hidden-files") == 0) { Settings::getInstance()->setBool("ShowHiddenFiles", true); + settingsNeedSaving = true; } else if (strcmp(argv[i], "--show-hidden-games") == 0) { Settings::getInstance()->setBool("ShowHiddenGames", true); + settingsNeedSaving = true; } else if (strcmp(argv[i], "--force-full") == 0) { Settings::getInstance()->setString("UIMode", "full"); @@ -290,7 +293,7 @@ bool parseArgs(int argc, char* argv[]) "Usage: emulationstation [options]\n" "EmulationStation Desktop Edition, Emulator Front-end\n\n" "Options:\n" -" --display [index] Display/monitor to use (1, 2, 3 or 4)\n" +" --display [index, 1-4] Display/monitor to use\n" " --resolution [width] [height] Application resolution\n" #if defined(__unix__) " --windowed Windowed mode, should be combined with --resolution\n" @@ -299,7 +302,6 @@ bool parseArgs(int argc, char* argv[]) #endif " --vsync [1/on or 0/off] Turn VSync on or off (default is on)\n" " --max-vram [size] Max VRAM to use (in mebibytes) before swapping\n" -" --gpu-statistics Display framerate and VRAM usage overlay\n" " --no-splash Don't show the splash screen during startup\n" " --gamelist-only Skip automatic game ROM search, only read from gamelist.xml\n" " --ignore-gamelist Ignore the gamelist files (useful for troubleshooting)\n" @@ -442,6 +444,10 @@ int main(int argc, char* argv[]) LOG(LogInfo) << "Settings file es_settings.cfg does not exist, creating it..."; Settings::getInstance()->saveFile(); } + else if (settingsNeedSaving) { + LOG(LogInfo) << "Saving settings that were modified by the passed command line options..."; + Settings::getInstance()->saveFile(); + } Window window; SystemScreensaver screensaver(&window); @@ -553,7 +559,7 @@ int main(int argc, char* argv[]) ViewController::get()->preload(); if (splashScreen && splashScreenProgress) - window.renderLoadingScreen("Done."); + window.renderLoadingScreen("Done"); // Choose which GUI to open depending on if an input configuration already exists and // whether the flag to force the input configuration was passed from the command line.