Changed es_settings.cfg to es_settings.xml

This commit is contained in:
Leon Styhre 2021-06-16 19:05:24 +02:00
parent fa624f9f2c
commit dc29b97e91
14 changed files with 34 additions and 26 deletions

View file

@ -1180,7 +1180,7 @@ void CollectionSystemsManager::populateCustomCollection(CollectionSystemData* sy
std::unordered_map<std::string,FileData*> std::unordered_map<std::string,FileData*>
allFilesMap = getAllGamesCollection()->getRootFolder()->getChildrenByFilename(); 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. // is set there, then use the default hardcoded path.
const std::string rompath = FileData::getROMDirectory(); const std::string rompath = FileData::getROMDirectory();

View file

@ -269,7 +269,7 @@ bool SystemData::loadConfig()
// If there is a %ROMPATH% variable set for the system, expand it. By doing this // 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 // 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. // in this configuration file, the default hardcoded path $HOME/ROMs/ will be used.
path = Utils::String::replace(path, "%ROMPATH%", rompath); path = Utils::String::replace(path, "%ROMPATH%", rompath);
#if defined(_WIN64) #if defined(_WIN64)

View file

@ -82,7 +82,7 @@ void VolumeControl::init()
#if defined(__linux__) #if defined(__linux__)
// Try to open mixer device. // Try to open mixer device.
if (mixerHandle == nullptr) { 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_) #if defined(_RPI_)
mixerCard = Settings::getInstance()->getString("AudioCard"); mixerCard = Settings::getInstance()->getString("AudioCard");
mixerName = Settings::getInstance()->getString("AudioDevice"); mixerName = Settings::getInstance()->getString("AudioDevice");

View file

@ -249,7 +249,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(
collectionsConfigEntry += (*it); 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. // need to re-write it.
if (collectionsConfigEntry != if (collectionsConfigEntry !=
Settings::getInstance()->getString("CollectionSystemsCustom")) { Settings::getInstance()->getString("CollectionSystemsCustom")) {

View file

@ -307,7 +307,7 @@ void GuiMenu::openUIOptions()
break; 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'. // sort order 'filename, ascending'.
if (sortOrder == "") if (sortOrder == "")
sortOrder = Settings::getInstance()->getDefaultString("DefaultSortOrder"); sortOrder = Settings::getInstance()->getDefaultString("DefaultSortOrder");

View file

@ -62,7 +62,7 @@ GuiScraperMenu::GuiScraperMenu(Window* window, std::string title)
mMenu.setNeedsSaving(); mMenu.setNeedsSaving();
} }
// The filter setting is only retained during the program session i.e. it's not saved // 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")) if (mFilters->getSelectedId() != Settings::getInstance()->getInt("ScraperFilter"))
Settings::getInstance()->setInt("ScraperFilter", mFilters->getSelectedId()); Settings::getInstance()->setInt("ScraperFilter", mFilters->getSelectedId());
}); });

View file

@ -4,7 +4,7 @@
// GuiSettings.cpp // GuiSettings.cpp
// //
// User interface template for a settings GUI. // 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. // also triggered to be executed here via flags set by the menu entries' lambda functions.
// //

View file

@ -4,7 +4,7 @@
// GuiSettings.h // GuiSettings.h
// //
// User interface template for a settings GUI. // 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. // also triggered to be executed here via flags set by the menu entries' lambda functions.
// //

View file

@ -14,7 +14,7 @@
// main.cpp // main.cpp
// //
// Main program loop. Interprets command-line arguments, checks for the // 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. // 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. // Check if the configuration file exists, and if not, create it.
// This should only happen on first application startup. // This should only happen on first application startup.
if (!Utils::FileSystem::exists(Utils::FileSystem::getHomePath() + if (!Utils::FileSystem::exists(Utils::FileSystem::getHomePath() +
"/.emulationstation/es_settings.cfg")) { "/.emulationstation/es_settings.xml")) {
LOG(LogInfo) << "Settings file es_settings.cfg does not exist, creating it..."; LOG(LogInfo) << "Settings file es_settings.xml does not exist, creating it...";
Settings::getInstance()->saveFile(); Settings::getInstance()->saveFile();
} }
else if (settingsNeedSaving) { else if (settingsNeedSaving) {

View file

@ -75,11 +75,11 @@ public:
// Which Region to use when selecting the artwork. // Which Region to use when selecting the artwork.
// Applies to: artwork, name of the game, date of release. // 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. // Which Language to use when selecting the textual information.
// Applies to: description, genre. // Applies to: description, genre.
// This is read from es_settings.cfg, setting 'ScraperLanguage'. // This is read from es_settings.xml, setting 'ScraperLanguage'.
ScreenScraperConfig() {}; ScreenScraperConfig() {};
} configuration; } configuration;

View file

@ -107,7 +107,7 @@ void AudioManager::init()
" could not be set, obtained " << std::to_string(sAudioFormat.samples); " 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) if (Settings::getInstance()->getInt("SoundVolumeNavigation") > 100)
Settings::getInstance()->setInt("SoundVolumeNavigation", 100); Settings::getInstance()->setInt("SoundVolumeNavigation", 100);
if (Settings::getInstance()->getInt("SoundVolumeNavigation") < 0) if (Settings::getInstance()->getInt("SoundVolumeNavigation") < 0)

View file

@ -3,7 +3,7 @@
// EmulationStation Desktop Edition // EmulationStation Desktop Edition
// Settings.cpp // 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. // The default values for the application settings are defined here as well.
// //
@ -21,7 +21,7 @@
Settings* Settings::sInstance = nullptr; 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, // 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 // but some are debug flags that are either hardcoded or set by internal debug
// functions. // functions.
@ -310,7 +310,7 @@ void Settings::setDefaults()
mIntMap["ScreenRotate"] = { 0, 0 }; 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. // but that are not configurable via the GUI.
// //
@ -345,9 +345,9 @@ void saveMap(pugi::xml_document& doc, std::map<K, V>& map, const std::string& ty
void Settings::saveFile() 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() + const std::string path = Utils::FileSystem::getHomePath() +
"/.emulationstation/es_settings.cfg"; "/.emulationstation/es_settings.xml";
pugi::xml_document doc; pugi::xml_document doc;
@ -373,20 +373,28 @@ void Settings::saveFile()
void Settings::loadFile() 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"; "/.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; return;
pugi::xml_document doc; pugi::xml_document doc;
#if defined(_WIN64) #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 #else
pugi::xml_parse_result result = doc.load_file(path.c_str()); pugi::xml_parse_result result = doc.load_file(configFile.c_str());
#endif #endif
if (!result) { 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; return;
} }

View file

@ -3,7 +3,7 @@
// EmulationStation Desktop Edition // EmulationStation Desktop Edition
// Settings.h // 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. // The default values for the application settings are defined here as well.
// //

View file

@ -89,7 +89,7 @@ namespace Renderer
initialCursorState = (SDL_ShowCursor(0) != 0); initialCursorState = (SDL_ShowCursor(0) != 0);
int displayIndex = Settings::getInstance()->getInt("DisplayIndex"); 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) { if (displayIndex != 1 && displayIndex != 2 && displayIndex != 3 && displayIndex != 4) {
Settings::getInstance()->setInt("DisplayIndex", 1); Settings::getInstance()->setInt("DisplayIndex", 1);
displayIndex = 0; displayIndex = 0;