aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2009-07-13 18:47:32 +0000
committerJohannes Schickel2009-07-13 18:47:32 +0000
commit51a9bfc9e2881aa7c7ddaa9cc6b2709acab5e725 (patch)
tree4bd15f96d8e57b252e55c37d25b4773d6d3a290e
parent88e0fc2c43a9f8b1c729bf2f509815601b4d495d (diff)
downloadscummvm-rg350-51a9bfc9e2881aa7c7ddaa9cc6b2709acab5e725.tar.gz
scummvm-rg350-51a9bfc9e2881aa7c7ddaa9cc6b2709acab5e725.tar.bz2
scummvm-rg350-51a9bfc9e2881aa7c7ddaa9cc6b2709acab5e725.zip
Refactor GUI options update into a function in Common: updateGameGUIOptions.
svn-id: r42446
-rw-r--r--common/util.cpp9
-rw-r--r--common/util.h7
-rw-r--r--engines/advancedDetector.cpp8
-rw-r--r--engines/scumm/detection.cpp8
4 files changed, 18 insertions, 14 deletions
diff --git a/common/util.cpp b/common/util.cpp
index e99bbeb12d..869cec4c48 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -24,6 +24,7 @@
#include "common/util.h"
#include "common/system.h"
+#include "common/config-manager.h"
#include "gui/debugger.h"
#include "engines/engine.h"
@@ -420,6 +421,14 @@ String getGameGUIOptionsDescription(uint32 options) {
return res;
}
+void updateGameGUIOptions(const uint32 options) {
+ if ((options && !ConfMan.hasKey("guioptions")) ||
+ (ConfMan.hasKey("guioptions") && options != parseGameGUIOptions(ConfMan.get("guioptions")))) {
+ ConfMan.set("guioptions", getGameGUIOptionsDescription(options));
+ ConfMan.flushToDisk();
+ }
+}
+
} // End of namespace Common
diff --git a/common/util.h b/common/util.h
index e50dcebff0..aeadcd1483 100644
--- a/common/util.h
+++ b/common/util.h
@@ -284,6 +284,13 @@ bool checkGameGUIOption(GameGUIOption option, const String &str);
uint32 parseGameGUIOptions(const String &str);
String getGameGUIOptionsDescription(uint32 options);
+/**
+ * Updates the GUI options of the current config manager
+ * domain, when they differ to the ones passed as
+ * parameter.
+ */
+void updateGameGUIOptions(const uint32 options);
+
} // End of namespace Common
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index d1395fbe04..7d86f3ef32 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -296,13 +296,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
// If the GUI options were updated, we catch this here and update them in the users config
// file transparently.
- const uint32 guiOptions = agdDesc->guioptions | params.guioptions;
-
- if ((guiOptions && !ConfMan.hasKey("guioptions")) ||
- (ConfMan.hasKey("guioptions") && parseGameGUIOptions(ConfMan.get("guioptions")) != guiOptions)) {
- ConfMan.set("guioptions", Common::getGameGUIOptionsDescription(guiOptions));
- ConfMan.flushToDisk();
- }
+ Common::updateGameGUIOptions(agdDesc->guioptions | params.guioptions);
debug(2, "Running %s", toGameDescriptor(*agdDesc, params.list).description().c_str());
if (!createInstance(syst, engine, agdDesc))
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index e1de825049..5fa74d22c3 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -884,13 +884,7 @@ Common::Error ScummMetaEngine::createInstance(OSystem *syst, Engine **engine) co
// If the GUI options were updated, we catch this here and update them in the users config
// file transparently.
- const uint32 guiOptions = res.game.guioptions;
-
- if ((guiOptions && !ConfMan.hasKey("guioptions")) ||
- (ConfMan.hasKey("guioptions") && parseGameGUIOptions(ConfMan.get("guioptions")) != guiOptions)) {
- ConfMan.set("guioptions", Common::getGameGUIOptionsDescription(guiOptions));
- ConfMan.flushToDisk();
- }
+ Common::updateGameGUIOptions(res.game.guioptions);
// Finally, we have massaged the GameDescriptor to our satisfaction, and can
// instantiate the appropriate game engine. Hooray!