aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/util.cpp46
-rw-r--r--common/util.h13
2 files changed, 59 insertions, 0 deletions
diff --git a/common/util.cpp b/common/util.cpp
index f6c89fc4a5..6bcb7cc617 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -371,6 +371,52 @@ const char *getRenderModeDescription(RenderMode id) {
return 0;
}
+const struct GameOpt {
+ uint32 option;
+ const char *desc;
+} g_gameOptions[] = {
+ { GUIO_NOSUBTITLES, "sndNoSubs" },
+ { GUIO_NOMUSIC, "sndNoMusic" },
+ { GUIO_NOSPEECH, "sndNoSpeech" },
+ { GUIO_NOSFX, "sndNoSFX" },
+ { GUIO_NOMIDI, "sndNoMIDI" },
+ { GUIO_NOLAUNCHLOAD, "launchNoLoad" },
+ { GUIO_NONE, 0 }
+};
+
+bool checkGameGUIOption(GameGUIOption option, const String &str) {
+ for (int i = 0; g_gameOptions[i].desc; i++) {
+ if (g_gameOptions[i].option & option) {
+ if (str.contains(g_gameOptions[i].desc))
+ return true;
+ else
+ return false;
+ }
+ }
+ return false;
+}
+
+uint32 parseGameGUIOptions(const String &str) {
+ uint32 res = 0;
+
+ for (int i = 0; g_gameOptions[i].desc; i++)
+ if (str.contains(g_gameOptions[i].desc))
+ res |= g_gameOptions[i].option;
+
+ return res;
+}
+
+String getGameGUIOptionsDescription(uint32 options) {
+ String res = "";
+
+ for (int i = 0; g_gameOptions[i].desc; i++)
+ if (options & g_gameOptions[i].option)
+ res += String(g_gameOptions[i].desc) + " ";
+
+ res.trim();
+
+ return res;
+}
} // End of namespace Common
diff --git a/common/util.h b/common/util.h
index a7d6260583..319f80ec86 100644
--- a/common/util.h
+++ b/common/util.h
@@ -268,6 +268,19 @@ extern RenderMode parseRenderMode(const String &str);
extern const char *getRenderModeCode(RenderMode id);
extern const char *getRenderModeDescription(RenderMode id);
+enum GameGUIOption {
+ GUIO_NONE = 0,
+ GUIO_NOSUBTITLES = (1 << 0),
+ GUIO_NOMUSIC = (1 << 1),
+ GUIO_NOSPEECH = (1 << 2),
+ GUIO_NOSFX = (1 << 3),
+ GUIO_NOMIDI = (1 << 4),
+ GUIO_NOLAUNCHLOAD = (1 << 5)
+};
+
+bool checkGameGUIOption(GameGUIOption option, const String &str);
+uint32 parseGameGUIOptions(const String &str);
+String getGameGUIOptionsDescription(uint32 options);
} // End of namespace Common