aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/util.cpp20
-rw-r--r--common/util.h55
2 files changed, 39 insertions, 36 deletions
diff --git a/common/util.cpp b/common/util.cpp
index 699950dac3..bd2ebc4937 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -315,7 +315,7 @@ const char *getRenderModeDescription(RenderMode id) {
}
const struct GameOpt {
- uint32 option;
+ const char *option;
const char *desc;
} g_gameOptions[] = {
{ GUIO_NOSUBTITLES, "sndNoSubs" },
@@ -341,9 +341,9 @@ const struct GameOpt {
{ GUIO_NONE, 0 }
};
-bool checkGameGUIOption(GameGUIOption option, const String &str) {
+bool checkGameGUIOption(const String &option, const String &str) {
for (int i = 0; g_gameOptions[i].desc; i++) {
- if (g_gameOptions[i].option & option) {
+ if (option.contains(g_gameOptions[i].option)) {
if (str.contains(g_gameOptions[i].desc))
return true;
else
@@ -370,21 +370,21 @@ const String getGameGUIOptionsDescriptionLanguage(Language lang) {
return String(String("lang_") + getLanguageDescription(lang));
}
-uint32 parseGameGUIOptions(const String &str) {
- uint32 res = 0;
+String parseGameGUIOptions(const String &str) {
+ Common::String res;
for (int i = 0; g_gameOptions[i].desc; i++)
if (str.contains(g_gameOptions[i].desc))
- res |= g_gameOptions[i].option;
+ res += g_gameOptions[i].option;
return res;
}
-const String getGameGUIOptionsDescription(uint32 options) {
+const String getGameGUIOptionsDescription(const String &options) {
String res = "";
for (int i = 0; g_gameOptions[i].desc; i++)
- if (options & g_gameOptions[i].option)
+ if (options.contains(g_gameOptions[i].option[0]))
res += String(g_gameOptions[i].desc) + " ";
res.trim();
@@ -392,10 +392,10 @@ const String getGameGUIOptionsDescription(uint32 options) {
return res;
}
-void updateGameGUIOptions(const uint32 options, const String &langOption) {
+void updateGameGUIOptions(const String &options, const String &langOption) {
const String newOptionString = getGameGUIOptionsDescription(options) + " " + langOption;
- if ((options && !ConfMan.hasKey("guioptions")) ||
+ if ((!options.empty() && !ConfMan.hasKey("guioptions")) ||
(ConfMan.hasKey("guioptions") && ConfMan.get("guioptions") != newOptionString)) {
ConfMan.set("guioptions", newOptionString);
ConfMan.flushToDisk();
diff --git a/common/util.h b/common/util.h
index bccb17c6da..725e0d8cc7 100644
--- a/common/util.h
+++ b/common/util.h
@@ -78,6 +78,31 @@ template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
# define SCUMMVM_CURRENT_FUNCTION "<unknown>"
#endif
+#define GUIO_NONE "\000"
+#define GUIO_NOSUBTITLES "\001"
+#define GUIO_NOMUSIC "\002"
+#define GUIO_NOSPEECH "\003"
+#define GUIO_NOSFX "\003"
+#define GUIO_NOMIDI "\004"
+#define GUIO_NOLAUNCHLOAD "\005"
+
+#define GUIO_MIDIPCSPK "\006"
+#define GUIO_MIDICMS "\007"
+#define GUIO_MIDIPCJR "\010"
+#define GUIO_MIDIADLIB "\011"
+#define GUIO_MIDIC64 "\012"
+#define GUIO_MIDIAMIGA "\013"
+#define GUIO_MIDIAPPLEIIGS "\014"
+#define GUIO_MIDITOWNS "\015"
+#define GUIO_MIDIPC98 "\016"
+#define GUIO_MIDIMT32 "\017"
+#define GUIO_MIDIGM "\020"
+
+#define GUIO1(a) (a "\0")
+#define GUIO2(a,b) (a b "\0")
+#define GUIO3(a,b,c) (a b c "\0")
+#define GUIO4(a,b,c,d) (a b c d "\0")
+
namespace Common {
/**
@@ -224,32 +249,10 @@ 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),
-
- GUIO_MIDIPCSPK = (1 << 6),
- GUIO_MIDICMS = (1 << 7),
- GUIO_MIDIPCJR = (1 << 8),
- GUIO_MIDIADLIB = (1 << 9),
- GUIO_MIDIC64 = (1 << 10),
- GUIO_MIDIAMIGA = (1 << 11),
- GUIO_MIDIAPPLEIIGS = (1 << 12),
- GUIO_MIDITOWNS = (1 << 13),
- GUIO_MIDIPC98 = (1 << 14),
- GUIO_MIDIMT32 = (1 << 15),
- GUIO_MIDIGM = (1 << 16)
-};
-
-bool checkGameGUIOption(GameGUIOption option, const String &str);
+bool checkGameGUIOption(const String &option, const String &str);
bool checkGameGUIOptionLanguage(Language lang, const String &str);
-uint32 parseGameGUIOptions(const String &str);
-const String getGameGUIOptionsDescription(uint32 options);
+String parseGameGUIOptions(const String &str);
+const String getGameGUIOptionsDescription(const String &options);
const String getGameGUIOptionsDescriptionLanguage(Language lang);
/**
@@ -257,7 +260,7 @@ const String getGameGUIOptionsDescriptionLanguage(Language lang);
* domain, when they differ to the ones passed as
* parameter.
*/
-void updateGameGUIOptions(const uint32 options, const String &langOption);
+void updateGameGUIOptions(const String &options, const String &langOption);
} // End of namespace Common