WINTERMUTE: Add hack to allow language-selection in James Peris demo.

This commit is contained in:
Einar Johan Trøan Sømåen 2013-07-31 04:25:08 +02:00
parent f691e005f8
commit 1396052dc9
2 changed files with 25 additions and 5 deletions

View File

@ -1276,11 +1276,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(2);
const char *key = stack->pop()->getString();
const char *initVal = stack->pop()->getString();
Common::String privKey = "wme_" + StringUtil::encodeSetting(key);
Common::String result = initVal;
if (ConfMan.hasKey(privKey)) {
result = StringUtil::decodeSetting(ConfMan.get(key));
}
Common::String result = readRegistryString(key, initVal);
stack->pushString(result.c_str());
return STATUS_OK;
}
@ -3902,4 +3898,26 @@ char *BaseGame::getKeyFromStringTable(const char *str) const {
return _settings->getKeyFromStringTable(str);
}
Common::String BaseGame::readRegistryString(const Common::String &key, const Common::String &initValue) const {
// Game specific hacks:
Common::String result = initValue;
// James Peris:
if (BaseEngine::instance().getGameId() == "jamesperis" && key == "Language") {
Common::Language language = BaseEngine::instance().getLanguage();
if (language == Common::EN_ANY) {
result = "english";
} else if (language == Common::ES_ESP) {
result = "spanish";
} else {
error("Invalid language set for James Peris");
}
} else { // Just fallback to using ConfMan for now
Common::String privKey = "wme_" + StringUtil::encodeSetting(key);
if (ConfMan.hasKey(privKey)) {
result = StringUtil::decodeSetting(ConfMan.get(key));
}
}
return result;
}
} // end of namespace Wintermute

View File

@ -343,6 +343,8 @@ private:
bool isDoubleClick(int32 buttonIndex);
uint32 _usedMem;
// TODO: This should be expanded into a proper class eventually:
Common::String readRegistryString(const Common::String &key, const Common::String &initValue) const;
protected: