Permalink
Browse files

AD: Swtich GUI options to a char array.

This eliminates nasty limitation of caping number of flags to 31.
Current code has limitation of 255 flags, though.

Only SCUMM engine is converted, rest do not even compile.
Detection of fan talkie MI is broken as it has to be implemented
differently.
  • Loading branch information...
1 parent 2efcee5 commit 77c65648b1db8f8b7b245510681eafd856798d26 @sev- sev- committed Oct 23, 2011
View
@@ -55,27 +55,30 @@ const byte MidiDriver::_gmToMt32[128] = {
101, 103, 100, 120, 117, 113, 99, 128, 128, 128, 128, 124, 123, 128, 128, 128, // 7x
};
-static const uint32 GUIOMapping[] = {
- MT_PCSPK, Common::GUIO_MIDIPCSPK,
- MT_CMS, Common::GUIO_MIDICMS,
- MT_PCJR, Common::GUIO_MIDIPCJR,
- MT_ADLIB, Common::GUIO_MIDIADLIB,
- MT_C64, Common::GUIO_MIDIC64,
- MT_AMIGA, Common::GUIO_MIDIAMIGA,
- MT_APPLEIIGS, Common::GUIO_MIDIAPPLEIIGS,
- MT_TOWNS, Common::GUIO_MIDITOWNS,
- MT_PC98, Common::GUIO_MIDIPC98,
- MT_GM, Common::GUIO_MIDIGM,
- MT_MT32, Common::GUIO_MIDIMT32,
- 0, 0
+static const struct {
+ uint32 type;
+ const char *guio;
+} GUIOMapping[] = {
+ { MT_PCSPK, GUIO_MIDIPCSPK, },
+ { MT_CMS, GUIO_MIDICMS, },
+ { MT_PCJR, GUIO_MIDIPCJR, },
+ { MT_ADLIB, GUIO_MIDIADLIB, },
+ { MT_C64, GUIO_MIDIC64, },
+ { MT_AMIGA, GUIO_MIDIAMIGA, },
+ { MT_APPLEIIGS, GUIO_MIDIAPPLEIIGS, },
+ { MT_TOWNS, GUIO_MIDITOWNS, },
+ { MT_PC98, GUIO_MIDIPC98, },
+ { MT_GM, GUIO_MIDIGM, },
+ { MT_MT32, GUIO_MIDIMT32, },
+ { 0, 0 },
};
-uint32 MidiDriver::musicType2GUIO(uint32 musicType) {
- uint32 res = 0;
+Common::String MidiDriver::musicType2GUIO(uint32 musicType) {
+ Common::String res = "";
- for (int i = 0; GUIOMapping[i] || GUIOMapping[i + 1]; i += 2) {
- if (musicType == GUIOMapping[i] || musicType == (uint32)-1)
- res |= GUIOMapping[i + 1];
+ for (int i = 0; GUIOMapping[i].guio; i++) {
+ if (musicType == GUIOMapping[i].type || musicType == (uint32)-1)
+ res += GUIOMapping[i].guio;
}
return res;
View
@@ -146,7 +146,7 @@ class MidiDriver : public MidiDriver_BASE {
kDeviceId
};
- static uint32 musicType2GUIO(uint32 musicType);
+ static Common::String musicType2GUIO(uint32 musicType);
/** Create music driver matching the given device handle, or NULL if there is no match. */
static MidiDriver *createMidi(DeviceHandle handle);
View
@@ -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,32 +370,32 @@ 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();
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();
View
@@ -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,40 +249,18 @@ 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);
/**
* Updates the GUI options of the current config manager
* 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
@@ -104,7 +104,7 @@ void AdvancedMetaEngine::updateGameDescriptor(GameDescriptor &desc, const ADGame
if (_flags & kADFlagUseExtraAsHint)
desc["extra"] = realDesc->extra;
- desc.setGUIOptions(realDesc->guioptions | _guioptions);
+ desc.setGUIOptions(realDesc->guioptions + _guioptions);
desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language));
if (realDesc->flags & ADGF_ADDENGLISH)
@@ -257,7 +257,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
if (agdDesc->flags & ADGF_ADDENGLISH)
lang += " " + getGameGUIOptionsDescriptionLanguage(Common::EN_ANY);
- Common::updateGameGUIOptions(agdDesc->guioptions | _guioptions, lang);
+ Common::updateGameGUIOptions(agdDesc->guioptions + _guioptions, lang);
GameDescriptor gameDescriptor = toGameDescriptor(*agdDesc, _gameids);
@@ -568,7 +568,7 @@ AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, con
_md5Bytes = 5000;
_singleid = NULL;
_flags = 0;
- _guioptions = Common::GUIO_NONE;
+ _guioptions = GUIO_NONE;
_maxScanDepth = 1;
_directoryGlobs = NULL;
}
@@ -88,7 +88,7 @@ struct ADGameDescription {
*/
uint32 flags;
- uint32 guioptions;
+ const char *guioptions;
};
/**
@@ -181,11 +181,11 @@ class AdvancedMetaEngine : public MetaEngine {
uint32 _flags;
/**
- * A bitmask of game GUI options which will be added to each
+ * A list of game GUI options which will be added to each
* entry in addition to per-game options. Refer to GameGUIOption
* enum for the list.
*/
- uint32 _guioptions;
+ Common::String _guioptions;
/**
* Maximum depth of directories to look up.
View
@@ -38,29 +38,29 @@ GameDescriptor::GameDescriptor() {
setVal("description", "");
}
-GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd, uint32 guioptions) {
+GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd, Common::String guioptions) {
setVal("gameid", pgd.gameid);
setVal("description", pgd.description);
- if (guioptions != 0)
+ if (!guioptions.empty())
setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
}
-GameDescriptor::GameDescriptor(const Common::String &g, const Common::String &d, Common::Language l, Common::Platform p, uint32 guioptions, GameSupportLevel gsl) {
+GameDescriptor::GameDescriptor(const Common::String &g, const Common::String &d, Common::Language l, Common::Platform p, Common::String guioptions, GameSupportLevel gsl) {
setVal("gameid", g);
setVal("description", d);
if (l != Common::UNK_LANG)
setVal("language", Common::getLanguageCode(l));
if (p != Common::kPlatformUnknown)
setVal("platform", Common::getPlatformCode(p));
- if (guioptions != 0)
+ if (!guioptions.empty())
setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
setSupportLevel(gsl);
}
-void GameDescriptor::setGUIOptions(uint32 guioptions) {
- if (guioptions != 0)
+void GameDescriptor::setGUIOptions(Common::String guioptions) {
+ if (!guioptions.empty())
setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
else
erase("guioptions");
View
@@ -65,12 +65,12 @@ enum GameSupportLevel {
class GameDescriptor : public Common::StringMap {
public:
GameDescriptor();
- GameDescriptor(const PlainGameDescriptor &pgd, uint32 guioptions = 0);
+ GameDescriptor(const PlainGameDescriptor &pgd, Common::String guioptions = "");
GameDescriptor(const Common::String &gameid,
const Common::String &description,
Common::Language language = Common::UNK_LANG,
Common::Platform platform = Common::kPlatformUnknown,
- uint32 guioptions = 0,
+ Common::String guioptions = "",
GameSupportLevel gsl = kStableGame);
/**
@@ -80,7 +80,7 @@ class GameDescriptor : public Common::StringMap {
*/
void updateDesc(const char *extra = 0);
- void setGUIOptions(uint32 options);
+ void setGUIOptions(Common::String options);
void appendGUIOptions(const Common::String &str);
/**
@@ -649,8 +649,8 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
dr.language = detectLanguage(fslist, g->id);
// Detect if there are speech files in this unknown game
- if (detectSpeech(fslist, g))
- dr.game.guioptions &= ~GUIO_NOSPEECH;
+ //if (detectSpeech(fslist, g))
+ // dr.game.guioptions &= ~GUIO_NOSPEECH;
// Add the game/variant to the candidates list if it is consistent
// with the file(s) we are seeing.
@@ -1001,7 +1001,7 @@ GameList ScummMetaEngine::detectGames(const Common::FSList &fslist) const {
}
}
- dg.setGUIOptions(x->game.guioptions | MidiDriver::musicType2GUIO(x->game.midi));
+ dg.setGUIOptions(x->game.guioptions + MidiDriver::musicType2GUIO(x->game.midi));
dg.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(x->language));
detectedGames.push_back(dg);
@@ -89,7 +89,7 @@ struct GameSettings {
/**
* Game GUI options. Used to enable/disable certain GUI widgets
*/
- uint32 guioptions;
+ const char *guioptions;
};
enum FilenameGenMethod {
Oops, something went wrong.

0 comments on commit 77c6564

Please sign in to comment.