From dc29b97e91866e7dca444ec65008d5559fa1d601 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 16 Jun 2021 19:05:24 +0200 Subject: [PATCH] Changed es_settings.cfg to es_settings.xml --- es-app/src/CollectionSystemsManager.cpp | 2 +- es-app/src/SystemData.cpp | 2 +- es-app/src/VolumeControl.cpp | 2 +- .../src/guis/GuiCollectionSystemsOptions.cpp | 2 +- es-app/src/guis/GuiMenu.cpp | 2 +- es-app/src/guis/GuiScraperMenu.cpp | 2 +- es-app/src/guis/GuiSettings.cpp | 2 +- es-app/src/guis/GuiSettings.h | 2 +- es-app/src/main.cpp | 6 ++-- es-app/src/scrapers/ScreenScraper.h | 4 +-- es-core/src/AudioManager.cpp | 2 +- es-core/src/Settings.cpp | 28 ++++++++++++------- es-core/src/Settings.h | 2 +- es-core/src/renderers/Renderer.cpp | 2 +- 14 files changed, 34 insertions(+), 26 deletions(-) diff --git a/es-app/src/CollectionSystemsManager.cpp b/es-app/src/CollectionSystemsManager.cpp index 1ce5f9555..6648a6a35 100644 --- a/es-app/src/CollectionSystemsManager.cpp +++ b/es-app/src/CollectionSystemsManager.cpp @@ -1180,7 +1180,7 @@ void CollectionSystemsManager::populateCustomCollection(CollectionSystemData* sy std::unordered_map allFilesMap = getAllGamesCollection()->getRootFolder()->getChildrenByFilename(); - // Get the ROM directory, either as configured in es_settings.cfg, or if no value + // Get the ROM directory, either as configured in es_settings.xml, or if no value // is set there, then use the default hardcoded path. const std::string rompath = FileData::getROMDirectory(); diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index d06fe56ff..9cf499f4d 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -269,7 +269,7 @@ bool SystemData::loadConfig() // If there is a %ROMPATH% variable set for the system, expand it. By doing this // it's possible to use either absolute ROM paths in es_systems.xml or to utilize - // the ROM path configured as ROMDirectory in es_settings.cfg. If it's set to "" + // the ROM path configured as ROMDirectory in es_settings.xml. If it's set to "" // in this configuration file, the default hardcoded path $HOME/ROMs/ will be used. path = Utils::String::replace(path, "%ROMPATH%", rompath); #if defined(_WIN64) diff --git a/es-app/src/VolumeControl.cpp b/es-app/src/VolumeControl.cpp index 0a9261aa0..c164d5b31 100644 --- a/es-app/src/VolumeControl.cpp +++ b/es-app/src/VolumeControl.cpp @@ -82,7 +82,7 @@ void VolumeControl::init() #if defined(__linux__) // Try to open mixer device. if (mixerHandle == nullptr) { - // Allow user to override the AudioCard and AudioDevice in es_settings.cfg. + // Allow user to override the AudioCard and AudioDevice in es_settings.xml. #if defined(_RPI_) mixerCard = Settings::getInstance()->getString("AudioCard"); mixerName = Settings::getInstance()->getString("AudioDevice"); diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index b1153b161..aded41fc0 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -249,7 +249,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions( collectionsConfigEntry += (*it); } } - // If the system to be deleted was present in es_settings.cfg, we + // If the system to be deleted was present in es_settings.xml, we // need to re-write it. if (collectionsConfigEntry != Settings::getInstance()->getString("CollectionSystemsCustom")) { diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 50931afc4..8b20d0044 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -307,7 +307,7 @@ void GuiMenu::openUIOptions() break; } } - // If an invalid sort order was defined in es_settings.cfg, then apply the default + // If an invalid sort order was defined in es_settings.xml, then apply the default // sort order 'filename, ascending'. if (sortOrder == "") sortOrder = Settings::getInstance()->getDefaultString("DefaultSortOrder"); diff --git a/es-app/src/guis/GuiScraperMenu.cpp b/es-app/src/guis/GuiScraperMenu.cpp index 87930ae56..6d402fdd7 100644 --- a/es-app/src/guis/GuiScraperMenu.cpp +++ b/es-app/src/guis/GuiScraperMenu.cpp @@ -62,7 +62,7 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title) mMenu.setNeedsSaving(); } // The filter setting is only retained during the program session i.e. it's not saved - // to es_settings.cfg. + // to es_settings.xml. if (mFilters->getSelectedId() != Settings::getInstance()->getInt("ScraperFilter")) Settings::getInstance()->setInt("ScraperFilter", mFilters->getSelectedId()); }); diff --git a/es-app/src/guis/GuiSettings.cpp b/es-app/src/guis/GuiSettings.cpp index 0ac329774..2b6e20077 100644 --- a/es-app/src/guis/GuiSettings.cpp +++ b/es-app/src/guis/GuiSettings.cpp @@ -4,7 +4,7 @@ // GuiSettings.cpp // // User interface template for a settings GUI. -// The saving of es_settings.cfg, the reload of gamelists and some other actions are +// The saving of es_settings.xml, the reload of gamelists and some other actions are // also triggered to be executed here via flags set by the menu entries' lambda functions. // diff --git a/es-app/src/guis/GuiSettings.h b/es-app/src/guis/GuiSettings.h index 0cc975ec4..73b5b75fa 100644 --- a/es-app/src/guis/GuiSettings.h +++ b/es-app/src/guis/GuiSettings.h @@ -4,7 +4,7 @@ // GuiSettings.h // // User interface template for a settings GUI. -// The saving of es_settings.cfg, the reload of gamelists and some other actions are +// The saving of es_settings.xml, the reload of gamelists and some other actions are // also triggered to be executed here via flags set by the menu entries' lambda functions. // diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 4dc5a95e2..d0c0fd627 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -14,7 +14,7 @@ // main.cpp // // Main program loop. Interprets command-line arguments, checks for the -// home folder and es_settings.cfg configuration file, sets up the application +// home folder and es_settings.xml configuration file, sets up the application // environment and starts listening to SDL events. // @@ -466,8 +466,8 @@ int main(int argc, char* argv[]) // Check if the configuration file exists, and if not, create it. // This should only happen on first application startup. if (!Utils::FileSystem::exists(Utils::FileSystem::getHomePath() + - "/.emulationstation/es_settings.cfg")) { - LOG(LogInfo) << "Settings file es_settings.cfg does not exist, creating it..."; + "/.emulationstation/es_settings.xml")) { + LOG(LogInfo) << "Settings file es_settings.xml does not exist, creating it..."; Settings::getInstance()->saveFile(); } else if (settingsNeedSaving) { diff --git a/es-app/src/scrapers/ScreenScraper.h b/es-app/src/scrapers/ScreenScraper.h index 5ca88e911..921fab82f 100644 --- a/es-app/src/scrapers/ScreenScraper.h +++ b/es-app/src/scrapers/ScreenScraper.h @@ -75,11 +75,11 @@ public: // Which Region to use when selecting the artwork. // Applies to: artwork, name of the game, date of release. - // This is read from es_settings.cfg, setting 'ScraperRegion'. + // This is read from es_settings.xml, setting 'ScraperRegion'. // Which Language to use when selecting the textual information. // Applies to: description, genre. - // This is read from es_settings.cfg, setting 'ScraperLanguage'. + // This is read from es_settings.xml, setting 'ScraperLanguage'. ScreenScraperConfig() {}; } configuration; diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index 28073d9a1..f692d3cda 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -107,7 +107,7 @@ void AudioManager::init() " could not be set, obtained " << std::to_string(sAudioFormat.samples); } - // Just in case someone changed the es_settings.cfg file manually to invalid values. + // Just in case someone changed the es_settings.xml file manually to invalid values. if (Settings::getInstance()->getInt("SoundVolumeNavigation") > 100) Settings::getInstance()->setInt("SoundVolumeNavigation", 100); if (Settings::getInstance()->getInt("SoundVolumeNavigation") < 0) diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 2ed9579ba..82503d0b0 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -3,7 +3,7 @@ // EmulationStation Desktop Edition // Settings.cpp // -// Functions to read from and write to the configuration file es_settings.cfg. +// Functions to read from and write to the configuration file es_settings.xml. // The default values for the application settings are defined here as well. // @@ -21,7 +21,7 @@ Settings* Settings::sInstance = nullptr; -// These values are NOT saved to es_settings.cfg since they're not set via +// These values are NOT saved to es_settings.xml since they're not set via // the in-program settings menu. Most can be set using command-line arguments, // but some are debug flags that are either hardcoded or set by internal debug // functions. @@ -310,7 +310,7 @@ void Settings::setDefaults() mIntMap["ScreenRotate"] = { 0, 0 }; // - // Settings that can be changed in es_settings.cfg + // Settings that can be changed in es_settings.xml // but that are not configurable via the GUI. // @@ -345,9 +345,9 @@ void saveMap(pugi::xml_document& doc, std::map& map, const std::string& ty void Settings::saveFile() { - LOG(LogDebug) << "Settings::saveFile(): Saving settings to es_settings.cfg"; + LOG(LogDebug) << "Settings::saveFile(): Saving settings to es_settings.xml"; const std::string path = Utils::FileSystem::getHomePath() + - "/.emulationstation/es_settings.cfg"; + "/.emulationstation/es_settings.xml"; pugi::xml_document doc; @@ -373,20 +373,28 @@ void Settings::saveFile() void Settings::loadFile() { - const std::string path = Utils::FileSystem::getHomePath() + + // Prior to ES-DE v1.1, the configuration file had the .cfg suffix instead of .xml + const std::string legacyConfigFile = Utils::FileSystem::getHomePath() + "/.emulationstation/es_settings.cfg"; - if (!Utils::FileSystem::exists(path)) + const std::string configFile = Utils::FileSystem::getHomePath() + + "/.emulationstation/es_settings.xml"; + + if (Utils::FileSystem::exists(legacyConfigFile) && !Utils::FileSystem::exists(configFile)) + Utils::FileSystem::renameFile(legacyConfigFile, configFile, false); + + if (!Utils::FileSystem::exists(configFile)) return; pugi::xml_document doc; #if defined(_WIN64) - pugi::xml_parse_result result = doc.load_file(Utils::String::stringToWideString(path).c_str()); + pugi::xml_parse_result result = + doc.load_file(Utils::String::stringToWideString(configFile).c_str()); #else - pugi::xml_parse_result result = doc.load_file(path.c_str()); + pugi::xml_parse_result result = doc.load_file(configFile.c_str()); #endif if (!result) { - LOG(LogError) << "Could not parse the es_settings.cfg file\n " << result.description(); + LOG(LogError) << "Could not parse the es_settings.xml file\n " << result.description(); return; } diff --git a/es-core/src/Settings.h b/es-core/src/Settings.h index 822fc27ce..61b8cf2c0 100644 --- a/es-core/src/Settings.h +++ b/es-core/src/Settings.h @@ -3,7 +3,7 @@ // EmulationStation Desktop Edition // Settings.h // -// Functions to read from and write to the configuration file es_settings.cfg. +// Functions to read from and write to the configuration file es_settings.xml. // The default values for the application settings are defined here as well. // diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index 9a6d2a70e..e80b01516 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -89,7 +89,7 @@ namespace Renderer initialCursorState = (SDL_ShowCursor(0) != 0); int displayIndex = Settings::getInstance()->getInt("DisplayIndex"); - // Check that an invalid value has not been manually entered in the es_settings.cfg file. + // Check that an invalid value has not been manually entered in the es_settings.xml file. if (displayIndex != 1 && displayIndex != 2 && displayIndex != 3 && displayIndex != 4) { Settings::getInstance()->setInt("DisplayIndex", 1); displayIndex = 0;