2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// Settings.cpp
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
2021-06-16 17:05:24 +00:00
|
|
|
// Functions to read from and write to the configuration file es_settings.xml.
|
2020-06-21 12:25:28 +00:00
|
|
|
// The default values for the application settings are defined here as well.
|
2023-02-18 11:42:19 +00:00
|
|
|
// This class is not thread safe.
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
|
|
|
|
2013-06-17 19:01:03 +00:00
|
|
|
#include "Settings.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
2023-01-08 16:00:36 +00:00
|
|
|
#include "GuiComponent.h"
|
2013-06-17 19:01:03 +00:00
|
|
|
#include "Log.h"
|
2020-09-21 17:17:34 +00:00
|
|
|
#include "Scripting.h"
|
2021-07-07 18:31:46 +00:00
|
|
|
#include "utils/FileSystemUtil.h"
|
|
|
|
#include "utils/StringUtil.h"
|
2020-06-28 16:39:18 +00:00
|
|
|
|
2018-01-09 22:55:09 +00:00
|
|
|
#include <algorithm>
|
2020-09-21 17:17:34 +00:00
|
|
|
#include <pugixml.hpp>
|
2018-01-09 22:55:09 +00:00
|
|
|
#include <vector>
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2021-11-15 21:53:21 +00:00
|
|
|
namespace
|
2021-07-07 18:31:46 +00:00
|
|
|
{
|
2023-01-08 16:00:36 +00:00
|
|
|
// These settings are not saved to es_settings.xml. Most can be set using command-line
|
|
|
|
// arguments but a couple are debug flags or used for other application-internal purposes.
|
2022-01-16 11:09:55 +00:00
|
|
|
std::vector<std::string> settingsSkipSaving {
|
2021-11-15 21:53:21 +00:00
|
|
|
// clang-format off
|
|
|
|
// These options can be set using command-line arguments:
|
2023-02-12 21:14:09 +00:00
|
|
|
"ScreenWidth", // Set via --resolution [width] [height]
|
|
|
|
"ScreenHeight", // set via --resolution [width] [height]
|
|
|
|
"ScreenOffsetX", // Set via --screenoffset [horiz.] [vert.]
|
|
|
|
"ScreenOffsetY", // Set via --screenoffset [horiz.] [vert.]
|
|
|
|
"FullscreenPadding", // Set via --fullscreen-padding [1/on or 0/off]
|
|
|
|
"VSync", // --vsync [1/on or 0/off]
|
2021-11-15 21:53:21 +00:00
|
|
|
"IgnoreGamelist", // --ignore-gamelist
|
|
|
|
"SplashScreen", // --no-splash
|
|
|
|
"ForceFull", // --force-full
|
|
|
|
"ForceKiosk", // --force-kiosk
|
|
|
|
"ForceKid", // --force-kid
|
2023-02-12 21:14:09 +00:00
|
|
|
"Debug", // --debug
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-01-08 16:00:36 +00:00
|
|
|
// These options are only used internally during the application session:
|
2023-02-18 11:42:19 +00:00
|
|
|
"PortableMode",
|
2021-11-15 21:53:21 +00:00
|
|
|
"DebugGrid",
|
|
|
|
"DebugText",
|
|
|
|
"DebugImage",
|
2023-01-08 16:00:36 +00:00
|
|
|
"ScraperFilter",
|
|
|
|
"TransitionsSystemToSystem",
|
|
|
|
"TransitionsSystemToGamelist",
|
|
|
|
"TransitionsGamelistToGamelist",
|
|
|
|
"TransitionsGamelistToSystem",
|
|
|
|
"TransitionsStartupToSystem",
|
|
|
|
"TransitionsStartupToGamelist"
|
2021-11-15 21:53:21 +00:00
|
|
|
// clang-format on
|
|
|
|
};
|
2023-01-06 17:37:41 +00:00
|
|
|
|
|
|
|
template <typename K, typename V>
|
|
|
|
void saveMap(pugi::xml_document& doc, std::map<K, V>& map, const std::string& type)
|
|
|
|
{
|
|
|
|
for (auto it = map.cbegin(); it != map.cend(); ++it) {
|
|
|
|
// Key is on the "don't save" list, so don't save it.
|
|
|
|
if (std::find(settingsSkipSaving.cbegin(), settingsSkipSaving.cend(), it->first) !=
|
|
|
|
settingsSkipSaving.cend()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-07-30 16:17:27 +00:00
|
|
|
pugi::xml_node node {doc.append_child(type.c_str())};
|
2023-01-06 17:37:41 +00:00
|
|
|
node.append_attribute("name").set_value(it->first.c_str());
|
|
|
|
node.append_attribute("value").set_value(it->second.second);
|
|
|
|
}
|
|
|
|
}
|
2021-11-15 21:53:21 +00:00
|
|
|
} // namespace
|
2014-06-05 20:43:19 +00:00
|
|
|
|
2013-10-06 02:56:06 +00:00
|
|
|
Settings::Settings()
|
2013-06-17 19:01:03 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
mWasChanged = false;
|
|
|
|
setDefaults();
|
|
|
|
loadFile();
|
2013-06-17 19:01:03 +00:00
|
|
|
}
|
|
|
|
|
2022-01-04 20:54:55 +00:00
|
|
|
Settings* Settings::getInstance()
|
2021-03-19 17:40:37 +00:00
|
|
|
{
|
2022-01-04 20:54:55 +00:00
|
|
|
static Settings instance;
|
|
|
|
return &instance;
|
2021-03-19 17:40:37 +00:00
|
|
|
}
|
|
|
|
|
2013-06-17 19:01:03 +00:00
|
|
|
void Settings::setDefaults()
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
mBoolMap.clear();
|
|
|
|
mIntMap.clear();
|
2021-03-19 17:40:37 +00:00
|
|
|
mStringMap.clear();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2020-12-14 16:25:41 +00:00
|
|
|
// All settings are in pairs of default values and current values.
|
|
|
|
// As such, in this function we set these pairs identically.
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
//
|
|
|
|
// Settings configured via the in-program settings menu.
|
|
|
|
//
|
|
|
|
|
2020-11-05 17:18:11 +00:00
|
|
|
// Scraper.
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["Scraper"] = {"screenscraper", "screenscraper"};
|
|
|
|
mStringMap["ScraperUsernameScreenScraper"] = {"", ""};
|
|
|
|
mStringMap["ScraperPasswordScreenScraper"] = {"", ""};
|
2021-12-06 19:21:32 +00:00
|
|
|
mBoolMap["ScraperUseAccountScreenScraper"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
|
|
|
|
mBoolMap["ScrapeGameNames"] = {true, true};
|
|
|
|
mBoolMap["ScrapeRatings"] = {true, true};
|
2022-12-15 17:27:45 +00:00
|
|
|
// ScreenScraper controller scraping is currently broken, it's unclear if they will fix it.
|
|
|
|
// mBoolMap["ScrapeControllers"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScrapeMetadata"] = {true, true};
|
|
|
|
mBoolMap["ScrapeVideos"] = {true, true};
|
|
|
|
mBoolMap["ScrapeScreenshots"] = {true, true};
|
2021-10-28 19:00:23 +00:00
|
|
|
mBoolMap["ScrapeTitleScreens"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScrapeCovers"] = {true, true};
|
2021-10-28 19:00:23 +00:00
|
|
|
mBoolMap["ScrapeBackCovers"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScrapeMarquees"] = {true, true};
|
|
|
|
mBoolMap["Scrape3DBoxes"] = {true, true};
|
2021-10-28 19:00:23 +00:00
|
|
|
mBoolMap["ScrapePhysicalMedia"] = {true, true};
|
2022-02-20 16:49:57 +00:00
|
|
|
mBoolMap["ScrapeFanArt"] = {true, true};
|
2023-06-28 18:42:51 +00:00
|
|
|
mBoolMap["ScrapeManuals"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
|
|
|
|
mStringMap["MiximageResolution"] = {"1280x960", "1280x960"};
|
2023-07-01 09:15:43 +00:00
|
|
|
mStringMap["MiximageScreenshotHorizontalFit"] = {"crop", "crop"};
|
|
|
|
mStringMap["MiximageScreenshotVerticalFit"] = {"contain", "contain"};
|
|
|
|
mStringMap["MiximageScreenshotAspectThreshold"] = {"high", "high"};
|
|
|
|
mStringMap["MiximageScreenshotBlankAreasColor"] = {"black", "black"};
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["MiximageScreenshotScaling"] = {"sharp", "sharp"};
|
2021-10-30 17:01:58 +00:00
|
|
|
mStringMap["MiximageBoxSize"] = {"medium", "medium"};
|
|
|
|
mStringMap["MiximagePhysicalMediaSize"] = {"medium", "medium"};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["MiximageGenerate"] = {true, true};
|
|
|
|
mBoolMap["MiximageOverwrite"] = {true, true};
|
|
|
|
mBoolMap["MiximageRemoveLetterboxes"] = {true, true};
|
|
|
|
mBoolMap["MiximageRemovePillarboxes"] = {true, true};
|
2021-10-30 17:01:58 +00:00
|
|
|
mBoolMap["MiximageRotateHorizontalBoxes"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["MiximageIncludeMarquee"] = {true, true};
|
|
|
|
mBoolMap["MiximageIncludeBox"] = {true, true};
|
|
|
|
mBoolMap["MiximageCoverFallback"] = {true, true};
|
2021-10-30 17:01:58 +00:00
|
|
|
mBoolMap["MiximageIncludePhysicalMedia"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
|
|
|
|
mStringMap["ScraperRegion"] = {"eu", "eu"};
|
|
|
|
mStringMap["ScraperLanguage"] = {"en", "en"};
|
2023-02-21 17:44:31 +00:00
|
|
|
mIntMap["ScraperRetryOnErrorCount"] = {3, 3};
|
2023-02-11 11:32:51 +00:00
|
|
|
mIntMap["ScraperRetryOnErrorTimer"] = {3, 3};
|
2023-08-03 18:48:54 +00:00
|
|
|
mIntMap["ScraperSearchFileHashMaxSize"] = {128, 128};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScraperOverwriteData"] = {true, true};
|
|
|
|
mBoolMap["ScraperHaltOnInvalidMedia"] = {true, true};
|
2023-08-03 18:48:54 +00:00
|
|
|
mBoolMap["ScraperSearchFileHash"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScraperSearchMetadataName"] = {true, true};
|
2022-01-03 17:20:49 +00:00
|
|
|
mBoolMap["ScraperIncludeFolders"] = {true, true};
|
2022-04-06 21:53:21 +00:00
|
|
|
mBoolMap["ScraperInteractive"] = {false, false};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScraperSemiautomatic"] = {true, true};
|
|
|
|
mBoolMap["ScraperRespectExclusions"] = {true, true};
|
|
|
|
mBoolMap["ScraperExcludeRecursively"] = {true, true};
|
2022-04-09 13:14:48 +00:00
|
|
|
mBoolMap["ScraperConvertUnderscores"] = {true, true};
|
2022-09-20 20:45:32 +00:00
|
|
|
mBoolMap["ScraperAutomaticRemoveDots"] = {true, true};
|
2022-06-16 17:56:41 +00:00
|
|
|
mBoolMap["ScraperRegionFallback"] = {true, true};
|
2020-11-05 17:18:11 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// UI settings.
|
2023-01-17 22:37:51 +00:00
|
|
|
mStringMap["ThemeSet"] = {"slate-es-de", "slate-es-de"};
|
2022-01-29 17:41:22 +00:00
|
|
|
mStringMap["ThemeVariant"] = {"", ""};
|
2022-10-31 18:32:13 +00:00
|
|
|
mStringMap["ThemeColorScheme"] = {"", ""};
|
2022-01-29 17:41:22 +00:00
|
|
|
mStringMap["ThemeAspectRatio"] = {"", ""};
|
2023-01-16 21:43:56 +00:00
|
|
|
mStringMap["ThemeTransitions"] = {"automatic", "automatic"};
|
2022-12-07 17:09:05 +00:00
|
|
|
mStringMap["QuickSystemSelect"] = {"leftrightshoulders", "leftrightshoulders"};
|
2022-02-01 17:06:32 +00:00
|
|
|
mStringMap["StartupSystem"] = {"", ""};
|
2023-08-13 19:32:54 +00:00
|
|
|
mStringMap["SystemsSorting"] = {"default", "default"};
|
2023-08-13 16:19:25 +00:00
|
|
|
mStringMap["DefaultSortOrder"] = {"name, ascending", "name, ascending"};
|
2023-07-01 20:05:30 +00:00
|
|
|
mStringMap["MenuColorScheme"] = {"dark", "dark"};
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["MenuOpeningEffect"] = {"scale-up", "scale-up"};
|
|
|
|
mStringMap["LaunchScreenDuration"] = {"normal", "normal"};
|
2022-02-01 17:06:32 +00:00
|
|
|
mStringMap["UIMode"] = {"full", "full"};
|
2023-03-06 18:27:59 +00:00
|
|
|
mStringMap["RandomEntryButton"] = {"games", "games"};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-05-16 11:12:31 +00:00
|
|
|
// UI settings -> media viewer settings.
|
2023-06-28 18:32:49 +00:00
|
|
|
mStringMap["MediaViewerHelpPrompts"] = {"top", "top"};
|
2023-07-05 21:19:57 +00:00
|
|
|
mBoolMap["MediaViewerShowTypes"] = {false, false};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["MediaViewerKeepVideoRunning"] = {true, true};
|
|
|
|
mBoolMap["MediaViewerStretchVideos"] = {false, false};
|
2022-04-19 15:29:29 +00:00
|
|
|
#if defined(RASPBERRY_PI)
|
2021-11-07 22:54:52 +00:00
|
|
|
mBoolMap["MediaViewerVideoScanlines"] = {false, false};
|
|
|
|
#else
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["MediaViewerVideoScanlines"] = {true, true};
|
2021-11-07 22:54:52 +00:00
|
|
|
#endif
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["MediaViewerVideoBlur"] = {false, false};
|
|
|
|
mBoolMap["MediaViewerScreenshotScanlines"] = {true, true};
|
2021-05-16 11:12:31 +00:00
|
|
|
|
2020-11-05 17:18:11 +00:00
|
|
|
// UI settings -> screensaver settings.
|
2021-08-17 16:41:45 +00:00
|
|
|
mIntMap["ScreensaverTimer"] = {5 * 60 * 1000, 5 * 60 * 1000}; // 5 minutes.
|
|
|
|
mStringMap["ScreensaverType"] = {"video", "video"};
|
|
|
|
mBoolMap["ScreensaverControls"] = {true, true};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
// UI settings -> screensaver settings -> slideshow screensaver settings.
|
2021-08-17 16:41:45 +00:00
|
|
|
mIntMap["ScreensaverSwapImageTimeout"] = {10000, 10000};
|
2023-07-01 13:57:29 +00:00
|
|
|
mBoolMap["ScreensaverSlideshowOnlyFavorites"] = {false, false};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScreensaverStretchImages"] = {false, false};
|
|
|
|
mBoolMap["ScreensaverSlideshowGameInfo"] = {true, true};
|
|
|
|
mBoolMap["ScreensaverSlideshowScanlines"] = {true, true};
|
|
|
|
mBoolMap["ScreensaverSlideshowCustomImages"] = {false, false};
|
|
|
|
mBoolMap["ScreensaverSlideshowRecurse"] = {false, false};
|
|
|
|
mStringMap["ScreensaverSlideshowImageDir"] = {"~/.emulationstation/slideshow/custom_images",
|
|
|
|
"~/.emulationstation/slideshow/custom_images"};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2020-09-13 11:21:38 +00:00
|
|
|
// UI settings -> screensaver settings -> video screensaver settings.
|
2021-08-17 16:41:45 +00:00
|
|
|
mIntMap["ScreensaverSwapVideoTimeout"] = {0, 0};
|
2023-07-01 13:57:29 +00:00
|
|
|
mBoolMap["ScreensaverVideoOnlyFavorites"] = {false, false};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScreensaverStretchVideos"] = {false, false};
|
|
|
|
mBoolMap["ScreensaverVideoGameInfo"] = {true, true};
|
2022-04-19 15:29:29 +00:00
|
|
|
#if defined(RASPBERRY_PI)
|
2021-11-07 22:54:52 +00:00
|
|
|
mBoolMap["ScreensaverVideoScanlines"] = {false, false};
|
|
|
|
#else
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScreensaverVideoScanlines"] = {true, true};
|
2021-11-07 22:54:52 +00:00
|
|
|
#endif
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ScreensaverVideoBlur"] = {false, false};
|
2020-09-13 11:21:38 +00:00
|
|
|
|
2023-01-31 18:26:39 +00:00
|
|
|
mBoolMap["ThemeVariantTriggers"] = {true, true};
|
2021-08-22 12:29:43 +00:00
|
|
|
mBoolMap["MenuBlurBackground"] = {true, true};
|
|
|
|
mBoolMap["FoldersOnTop"] = {true, true};
|
|
|
|
mBoolMap["FavoritesFirst"] = {true, true};
|
|
|
|
mBoolMap["FavoritesStar"] = {true, true};
|
|
|
|
mBoolMap["ListScrollOverlay"] = {false, false};
|
2021-09-17 20:23:41 +00:00
|
|
|
mBoolMap["VirtualKeyboard"] = {true, true};
|
2021-08-22 12:29:43 +00:00
|
|
|
mBoolMap["FavoritesAddButton"] = {true, true};
|
|
|
|
mBoolMap["GamelistFilters"] = {true, true};
|
|
|
|
mBoolMap["ShowHelpPrompts"] = {true, true};
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Sound settings.
|
2021-11-07 22:54:52 +00:00
|
|
|
mIntMap["SoundVolumeNavigation"] = {70, 70};
|
|
|
|
mIntMap["SoundVolumeVideos"] = {80, 80};
|
2022-02-20 15:07:27 +00:00
|
|
|
mBoolMap["ViewsVideoAudio"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["MediaViewerVideoAudio"] = {true, true};
|
2022-02-01 19:54:36 +00:00
|
|
|
mBoolMap["ScreensaverVideoAudio"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["NavigationSounds"] = {true, true};
|
2021-05-23 09:45:45 +00:00
|
|
|
|
|
|
|
// Input device settings.
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["InputControllerType"] = {"xbox", "xbox"};
|
|
|
|
mBoolMap["InputOnlyFirstController"] = {false, false};
|
2022-09-19 17:05:06 +00:00
|
|
|
mBoolMap["InputIgnoreKeyboard"] = {false, false};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
// Game collection settings.
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["CollectionSystemsAuto"] = {"", ""};
|
|
|
|
mStringMap["CollectionSystemsCustom"] = {"", ""};
|
2023-01-12 18:45:54 +00:00
|
|
|
mStringMap["CollectionCustomGrouping"] = {"unthemed", "unthemed"};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["FavFirstCustom"] = {false, false};
|
|
|
|
mBoolMap["FavStarCustom"] = {false, false};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-08-22 12:29:43 +00:00
|
|
|
// Other settings.
|
|
|
|
mStringMap["MediaDirectory"] = {"", ""};
|
2022-09-27 15:38:02 +00:00
|
|
|
#if defined(STEAM_DECK) || defined(RETRODECK)
|
2022-04-03 11:37:41 +00:00
|
|
|
mIntMap["MaxVRAM"] = {512, 512};
|
2022-04-19 15:29:29 +00:00
|
|
|
#elif defined(RASPBERRY_PI)
|
2022-10-30 08:11:59 +00:00
|
|
|
mIntMap["MaxVRAM"] = {192, 192};
|
2021-07-07 18:31:46 +00:00
|
|
|
#else
|
2022-10-30 08:11:59 +00:00
|
|
|
mIntMap["MaxVRAM"] = {512, 512};
|
2021-07-07 18:31:46 +00:00
|
|
|
#endif
|
2023-01-09 16:55:54 +00:00
|
|
|
#if !defined(USE_OPENGLES)
|
|
|
|
mIntMap["AntiAliasing"] = {0, 0};
|
|
|
|
#endif
|
2023-02-06 22:38:35 +00:00
|
|
|
mIntMap["DisplayIndex"] = {1, 1};
|
|
|
|
mIntMap["ScreenRotate"] = {0, 0};
|
2022-05-31 20:06:47 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
mStringMap["KeyboardQuitShortcut"] = {"CmdQ", "CmdQ"};
|
|
|
|
#else
|
|
|
|
mStringMap["KeyboardQuitShortcut"] = {"AltF4", "AltF4"};
|
|
|
|
#endif
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["SaveGamelistsMode"] = {"always", "always"};
|
2023-02-18 11:42:19 +00:00
|
|
|
mStringMap["ApplicationUpdaterFrequency"] = {"always", "always"};
|
2023-07-31 17:25:54 +00:00
|
|
|
mStringMap["ApplicationUpdaterDownloadDirectory"] = {"", ""};
|
2023-02-18 11:42:19 +00:00
|
|
|
mBoolMap["ApplicationUpdaterPrereleases"] = {false, false};
|
2021-07-07 18:31:46 +00:00
|
|
|
#if defined(_WIN64)
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["HideTaskbar"] = {false, false};
|
2021-07-07 18:31:46 +00:00
|
|
|
#endif
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["RunInBackground"] = {false, false};
|
2021-11-08 16:58:36 +00:00
|
|
|
#if defined(VIDEO_HW_DECODING)
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["VideoHardwareDecoding"] = {false, false};
|
2021-07-14 17:13:25 +00:00
|
|
|
#endif
|
2022-09-27 15:38:02 +00:00
|
|
|
#if defined(STEAM_DECK) || defined(RETRODECK)
|
|
|
|
mBoolMap["VideoUpscaleFrameRate"] = {true, true};
|
|
|
|
#else
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["VideoUpscaleFrameRate"] = {false, false};
|
2022-09-27 15:38:02 +00:00
|
|
|
#endif
|
2021-09-04 09:21:55 +00:00
|
|
|
mBoolMap["AlternativeEmulatorPerGame"] = {true, true};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ShowHiddenFiles"] = {true, true};
|
|
|
|
mBoolMap["ShowHiddenGames"] = {true, true};
|
|
|
|
mBoolMap["CustomEventScripts"] = {false, false};
|
|
|
|
mBoolMap["ParseGamelistOnly"] = {false, false};
|
2023-02-14 16:28:43 +00:00
|
|
|
mBoolMap["MAMENameStripExtraInfo"] = {true, true};
|
2021-07-07 18:31:46 +00:00
|
|
|
#if defined(__unix__)
|
2023-01-09 17:20:36 +00:00
|
|
|
mBoolMap["DisableComposition"] = {false, false};
|
2021-07-07 18:31:46 +00:00
|
|
|
#endif
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["DisplayGPUStatistics"] = {false, false};
|
2022-02-19 16:16:38 +00:00
|
|
|
mBoolMap["EnableMenuKidMode"] = {false, false};
|
2021-07-07 18:31:46 +00:00
|
|
|
// macOS requires root privileges to reboot and power off so it doesn't make much
|
|
|
|
// sense to enable this setting and menu entry for that operating system.
|
|
|
|
#if !defined(__APPLE__)
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["ShowQuitMenu"] = {false, false};
|
2021-07-07 18:31:46 +00:00
|
|
|
#endif
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Settings configured via command-line arguments.
|
|
|
|
//
|
|
|
|
|
|
|
|
// Options listed using --help
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["Debug"] = {false, false};
|
|
|
|
mBoolMap["ForceFull"] = {false, false};
|
|
|
|
mBoolMap["ForceKid"] = {false, false};
|
|
|
|
mBoolMap["ForceKiosk"] = {false, false};
|
|
|
|
mBoolMap["IgnoreGamelist"] = {false, false};
|
|
|
|
mBoolMap["SplashScreen"] = {true, true};
|
|
|
|
mBoolMap["VSync"] = {true, true};
|
2023-02-12 21:14:09 +00:00
|
|
|
mBoolMap["FullscreenPadding"] = {false, false};
|
2021-08-17 16:41:45 +00:00
|
|
|
mIntMap["ScreenWidth"] = {0, 0};
|
|
|
|
mIntMap["ScreenHeight"] = {0, 0};
|
|
|
|
mIntMap["ScreenOffsetX"] = {0, 0};
|
|
|
|
mIntMap["ScreenOffsetY"] = {0, 0};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
//
|
2021-06-16 17:05:24 +00:00
|
|
|
// Settings that can be changed in es_settings.xml
|
2020-07-14 17:16:21 +00:00
|
|
|
// but that are not configurable via the GUI.
|
2020-06-21 12:25:28 +00:00
|
|
|
//
|
|
|
|
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["DebugSkipInputLogging"] = {false, false};
|
2022-10-29 11:04:00 +00:00
|
|
|
mBoolMap["DebugSkipMissingThemeFiles"] = {false, false};
|
|
|
|
mBoolMap["DebugSkipMissingThemeFilesCustomCollections"] = {true, true};
|
2022-12-20 19:20:02 +00:00
|
|
|
mBoolMap["LegacyGamelistFileLocation"] = {false, false};
|
2022-04-10 12:54:21 +00:00
|
|
|
mStringMap["OpenGLVersion"] = {"", ""};
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["ROMDirectory"] = {"", ""};
|
|
|
|
mStringMap["UIMode_passkey"] = {"uuddlrlrba", "uuddlrlrba"};
|
2023-04-06 09:40:32 +00:00
|
|
|
mStringMap["UserThemeDirectory"] = {"", ""};
|
2022-01-09 12:45:44 +00:00
|
|
|
mIntMap["LottieMaxFileCache"] = {150, 150};
|
2022-01-08 14:04:10 +00:00
|
|
|
mIntMap["LottieMaxTotalCache"] = {1024, 1024};
|
2023-02-10 16:24:50 +00:00
|
|
|
mIntMap["ScraperConnectionTimeout"] = {30, 30};
|
2022-06-29 15:28:39 +00:00
|
|
|
mIntMap["ScraperTransferTimeout"] = {120, 120};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Hardcoded or program-internal settings.
|
|
|
|
//
|
|
|
|
|
2021-08-17 16:41:45 +00:00
|
|
|
mStringMap["ApplicationVersion"] = {"", ""};
|
2023-02-18 11:42:19 +00:00
|
|
|
mStringMap["ApplicationUpdaterLastCheck"] = {"", ""};
|
|
|
|
mBoolMap["PortableMode"] = {false, false};
|
2021-08-17 16:41:45 +00:00
|
|
|
mBoolMap["DebugGrid"] = {false, false};
|
|
|
|
mBoolMap["DebugText"] = {false, false};
|
|
|
|
mBoolMap["DebugImage"] = {false, false};
|
|
|
|
mIntMap["ScraperFilter"] = {0, 0};
|
2023-01-08 16:00:36 +00:00
|
|
|
mIntMap["TransitionsSystemToSystem"] = {ViewTransitionAnimation::INSTANT,
|
|
|
|
ViewTransitionAnimation::INSTANT};
|
|
|
|
mIntMap["TransitionsSystemToGamelist"] = {ViewTransitionAnimation::INSTANT,
|
|
|
|
ViewTransitionAnimation::INSTANT};
|
|
|
|
mIntMap["TransitionsGamelistToGamelist"] = {ViewTransitionAnimation::INSTANT,
|
|
|
|
ViewTransitionAnimation::INSTANT};
|
|
|
|
mIntMap["TransitionsGamelistToSystem"] = {ViewTransitionAnimation::INSTANT,
|
|
|
|
ViewTransitionAnimation::INSTANT};
|
|
|
|
mIntMap["TransitionsStartupToSystem"] = {ViewTransitionAnimation::INSTANT,
|
|
|
|
ViewTransitionAnimation::INSTANT};
|
|
|
|
mIntMap["TransitionsStartupToGamelist"] = {ViewTransitionAnimation::INSTANT,
|
|
|
|
ViewTransitionAnimation::INSTANT};
|
2013-06-17 19:01:03 +00:00
|
|
|
}
|
|
|
|
|
2013-06-19 21:02:42 +00:00
|
|
|
void Settings::saveFile()
|
|
|
|
{
|
2021-06-16 17:05:24 +00:00
|
|
|
LOG(LogDebug) << "Settings::saveFile(): Saving settings to es_settings.xml";
|
2021-07-07 18:31:46 +00:00
|
|
|
const std::string path =
|
|
|
|
Utils::FileSystem::getHomePath() + "/.emulationstation/es_settings.xml";
|
2013-06-19 21:02:42 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
pugi::xml_document doc;
|
2013-06-19 21:02:42 +00:00
|
|
|
|
2020-12-14 16:25:41 +00:00
|
|
|
saveMap<std::string, std::pair<bool, bool>>(doc, mBoolMap, "bool");
|
|
|
|
saveMap<std::string, std::pair<int, int>>(doc, mIntMap, "int");
|
|
|
|
saveMap<std::string, std::pair<float, float>>(doc, mFloatMap, "float");
|
2013-06-19 21:02:42 +00:00
|
|
|
|
2021-11-17 16:48:49 +00:00
|
|
|
for (auto it = mStringMap.cbegin(); it != mStringMap.cend(); ++it) {
|
2023-01-06 17:37:41 +00:00
|
|
|
if (std::find(settingsSkipSaving.cbegin(), settingsSkipSaving.cend(), it->first) !=
|
|
|
|
settingsSkipSaving.cend()) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
pugi::xml_node node = doc.append_child("string");
|
2021-11-17 16:48:49 +00:00
|
|
|
node.append_attribute("name").set_value(it->first.c_str());
|
|
|
|
node.append_attribute("value").set_value(it->second.second.c_str());
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2014-03-22 16:44:57 +00:00
|
|
|
|
2021-07-07 18:31:46 +00:00
|
|
|
#if defined(_WIN64)
|
2020-07-10 16:32:23 +00:00
|
|
|
doc.save_file(Utils::String::stringToWideString(path).c_str());
|
2021-07-07 18:31:46 +00:00
|
|
|
#else
|
2020-06-21 12:25:28 +00:00
|
|
|
doc.save_file(path.c_str());
|
2021-07-07 18:31:46 +00:00
|
|
|
#endif
|
2018-01-30 00:49:08 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
Scripting::fireEvent("config-changed");
|
|
|
|
Scripting::fireEvent("settings-changed");
|
2013-06-19 21:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::loadFile()
|
|
|
|
{
|
2023-02-13 19:35:12 +00:00
|
|
|
const std::string configFile {Utils::FileSystem::getHomePath() +
|
|
|
|
"/.emulationstation/es_settings.xml"};
|
2021-06-16 17:05:24 +00:00
|
|
|
|
|
|
|
if (!Utils::FileSystem::exists(configFile))
|
2020-06-21 12:25:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
pugi::xml_document doc;
|
2021-07-07 18:31:46 +00:00
|
|
|
#if defined(_WIN64)
|
2023-02-13 19:35:12 +00:00
|
|
|
pugi::xml_parse_result result {
|
|
|
|
doc.load_file(Utils::String::stringToWideString(configFile).c_str())};
|
2021-07-07 18:31:46 +00:00
|
|
|
#else
|
2023-02-13 19:35:12 +00:00
|
|
|
pugi::xml_parse_result result {doc.load_file(configFile.c_str())};
|
2021-07-07 18:31:46 +00:00
|
|
|
#endif
|
2020-06-21 12:25:28 +00:00
|
|
|
if (!result) {
|
2022-06-29 15:17:31 +00:00
|
|
|
LOG(LogError) << "Couldn't parse the es_settings.xml file: " << result.description();
|
2020-06-21 12:25:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pugi::xml_node node = doc.child("bool"); node; node = node.next_sibling("bool"))
|
|
|
|
setBool(node.attribute("name").as_string(), node.attribute("value").as_bool());
|
|
|
|
for (pugi::xml_node node = doc.child("int"); node; node = node.next_sibling("int"))
|
|
|
|
setInt(node.attribute("name").as_string(), node.attribute("value").as_int());
|
|
|
|
for (pugi::xml_node node = doc.child("float"); node; node = node.next_sibling("float"))
|
|
|
|
setFloat(node.attribute("name").as_string(), node.attribute("value").as_float());
|
|
|
|
for (pugi::xml_node node = doc.child("string"); node; node = node.next_sibling("string"))
|
|
|
|
setString(node.attribute("name").as_string(), node.attribute("value").as_string());
|
2013-10-06 02:56:06 +00:00
|
|
|
}
|
|
|
|
|
2021-07-08 16:18:59 +00:00
|
|
|
// Macro to create the get and set functions for the various data types.
|
2021-07-07 18:31:46 +00:00
|
|
|
#define SETTINGS_GETSET(type, mapName, getFunction, getDefaultFunction, setFunction) \
|
|
|
|
type Settings::getFunction(const std::string& name) \
|
|
|
|
{ \
|
|
|
|
if (mapName.find(name) == mapName.cend()) { \
|
|
|
|
LOG(LogError) << "Tried to use unset setting " << name; \
|
|
|
|
} \
|
|
|
|
return mapName[name].second; \
|
|
|
|
} \
|
|
|
|
type Settings::getDefaultFunction(const std::string& name) \
|
|
|
|
{ \
|
|
|
|
if (mapName.find(name) == mapName.cend()) { \
|
|
|
|
LOG(LogError) << "Tried to use unset setting " << name; \
|
|
|
|
} \
|
|
|
|
return mapName[name].first; \
|
|
|
|
} \
|
|
|
|
bool Settings::setFunction(const std::string& name, type value) \
|
|
|
|
{ \
|
|
|
|
if (mapName.count(name) == 0 || mapName[name].second != value) { \
|
|
|
|
mapName[name].second = value; \
|
|
|
|
\
|
|
|
|
if (std::find(settingsSkipSaving.cbegin(), settingsSkipSaving.cend(), name) == \
|
|
|
|
settingsSkipSaving.cend()) \
|
|
|
|
mWasChanged = true; \
|
|
|
|
\
|
|
|
|
return true; \
|
|
|
|
} \
|
|
|
|
return false; \
|
|
|
|
}
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2021-07-07 18:31:46 +00:00
|
|
|
// Parameters for the macro defined above.
|
2021-09-18 07:53:26 +00:00
|
|
|
SETTINGS_GETSET(bool, mBoolMap, getBool, getDefaultBool, setBool)
|
|
|
|
SETTINGS_GETSET(int, mIntMap, getInt, getDefaultInt, setInt)
|
|
|
|
SETTINGS_GETSET(float, mFloatMap, getFloat, getDefaultFloat, setFloat)
|
|
|
|
SETTINGS_GETSET(const std::string&, mStringMap, getString, getDefaultString, setString)
|