COMMON: Add a helper to update a ConfMan entry and flush to disk
This commit is contained in:
parent
b4e9f6696b
commit
bad365c97e
3 changed files with 20 additions and 6 deletions
|
@ -527,6 +527,19 @@ void ConfigManager::set(const String &key, const String &value) {
|
||||||
_appDomain[key] = value;
|
_appDomain[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigManager::setAndFlush(const String &key, const Common::String &value) {
|
||||||
|
if (value.empty() && !hasKey(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasKey(key) && get(key) == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key, value);
|
||||||
|
flushToDisk();
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigManager::set(const String &key, const String &value, const String &domName) {
|
void ConfigManager::set(const String &key, const String &value, const String &domName) {
|
||||||
// FIXME: For now we continue to allow empty domName to indicate
|
// FIXME: For now we continue to allow empty domName to indicate
|
||||||
// "use 'default' domain". This is mainly needed for the SCUMM ConfigDialog
|
// "use 'default' domain". This is mainly needed for the SCUMM ConfigDialog
|
||||||
|
|
|
@ -118,6 +118,12 @@ public:
|
||||||
const String & get(const String &key) const;
|
const String & get(const String &key) const;
|
||||||
void set(const String &key, const String &value);
|
void set(const String &key, const String &value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a configuration entry for the active domain and flush
|
||||||
|
* the configuration file to disk if the value changed
|
||||||
|
*/
|
||||||
|
void setAndFlush(const String &key, const Common::String &value);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
//
|
//
|
||||||
// Domain specific access methods: Acces *one specific* domain and modify it.
|
// Domain specific access methods: Acces *one specific* domain and modify it.
|
||||||
|
|
|
@ -128,12 +128,7 @@ const String getGameGUIOptionsDescription(const String &options) {
|
||||||
|
|
||||||
void updateGameGUIOptions(const String &options, const String &langOption) {
|
void updateGameGUIOptions(const String &options, const String &langOption) {
|
||||||
const String newOptionString = getGameGUIOptionsDescription(options) + " " + langOption;
|
const String newOptionString = getGameGUIOptionsDescription(options) + " " + langOption;
|
||||||
|
ConfMan.setAndFlush("guioptions", newOptionString);
|
||||||
if ((!options.empty() && !ConfMan.hasKey("guioptions")) ||
|
|
||||||
(ConfMan.hasKey("guioptions") && ConfMan.get("guioptions") != newOptionString)) {
|
|
||||||
ConfMan.set("guioptions", newOptionString);
|
|
||||||
ConfMan.flushToDisk();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue