Added a new LureLanguage enumeration of supported languages, and changed game code to use it

svn-id: r47019
This commit is contained in:
Paul Gilbert 2010-01-05 08:24:27 +00:00
parent c8f991e89b
commit 43f19bc722
4 changed files with 28 additions and 5 deletions

View File

@ -43,6 +43,19 @@ uint32 LureEngine::getFeatures() const { return _gameDescription->features; }
Common::Language LureEngine::getLanguage() const { return _gameDescription->desc.language; }
Common::Platform LureEngine::getPlatform() const { return _gameDescription->desc.platform; }
LureLanguage LureEngine::getLureLanguage() const {
switch (_gameDescription->desc.language) {
case IT_ITA: return LANG_IT_ITA;
case FR_FRA: return LANG_FR_FRA;
case DE_DEU: return LANG_DE_DEU;
case ES_ESP: return LANG_ES_ESP;
case EN_ANY: return LANG_EN_ANY;
case UNK_LANG: return LANG_UNKNOWN;
default:
error("Unknown game language");
}
}
} // End of namespace Lure
static const PlainGameDescriptor lureGames[] = {

View File

@ -115,7 +115,7 @@ void Disk::openFile(uint8 fileNum) {
error("The file %s is not a valid Lure support file", sFilename);
// Scan for the correct language block
Common::Language language = LureEngine::getReference().getLanguage();
LureLanguage language = LureEngine::getReference().getLureLanguage();
bool foundFlag = false;
while (!foundFlag) {
@ -123,7 +123,7 @@ void Disk::openFile(uint8 fileNum) {
if ((byte)buffer[0] == 0xff)
error("Could not find language data in support file");
if ((language == (Common::Language)buffer[0]) || (language == UNK_LANG)) {
if ((language == (LureLanguage)buffer[0]) || (language == LANG_UNKNOWN)) {
foundFlag = true;
_dataOffset = READ_LE_UINT32(&buffer[1]);
_fileHandle->seek(_dataOffset);

View File

@ -186,7 +186,7 @@ bool LureEngine::saveGame(uint8 slotNumber, Common::String &caption) {
return false;
f->write("lure", 5);
f->writeByte(getLanguage());
f->writeByte(getLureLanguage());
f->writeByte(LURE_SAVEGAME_MINOR);
f->writeString(caption);
f->writeByte(0); // End of string terminator
@ -221,7 +221,7 @@ bool LureEngine::loadGame(uint8 slotNumber) {
// Check language version
uint8 language = f->readByte();
_saveVersion = f->readByte();
if ((language != getLanguage()) || (_saveVersion < LURE_MIN_SAVEGAME_MINOR)) {
if ((language != getLureLanguage()) || (_saveVersion < LURE_MIN_SAVEGAME_MINOR)) {
warning("loadGame: Failed to load slot %d - incorrect version", slotNumber);
delete f;
return false;
@ -274,7 +274,7 @@ Common::String *LureEngine::detectSave(int slotNumber) {
// Check language version
uint8 language = f->readByte();
uint8 version = f->readByte();
if ((language == getLanguage()) && (version >= LURE_MIN_SAVEGAME_MINOR)) {
if ((language == getLureLanguage()) && (version >= LURE_MIN_SAVEGAME_MINOR)) {
// Read in the savegame title
char saveName[MAX_DESC_SIZE];
char *p = saveName;

View File

@ -54,6 +54,15 @@ namespace Lure {
#define RandomNumberGen LureEngine::getReference().rnd()
enum LureLanguage {
LANG_IT_ITA = 10,
LANG_FR_FRA = 6,
LANG_DE_DEU = 7,
LANG_ES_ESP = 17,
LANG_EN_ANY = 3,
LANG_UNKNOWN = -1
};
struct LureGameDescription;
class LureEngine : public Engine {
@ -107,6 +116,7 @@ public:
void GUIError(const char *msg, ...) GCC_PRINTF(2, 3);
uint32 getFeatures() const;
LureLanguage getLureLanguage() const;
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
virtual GUI::Debugger *getDebugger();