diff options
author | Strangerke | 2013-11-09 20:06:42 +0100 |
---|---|---|
committer | Strangerke | 2013-11-09 20:06:42 +0100 |
commit | 582a681c67487c717686c21bd82bf8e930f6987e (patch) | |
tree | 3515b33a6b8ab86a44facd37507b254d311f2945 /engines/hopkins | |
parent | 6a1b3f40fcf568c9c573ef543ce404070b985a3b (diff) | |
download | scummvm-rg350-582a681c67487c717686c21bd82bf8e930f6987e.tar.gz scummvm-rg350-582a681c67487c717686c21bd82bf8e930f6987e.tar.bz2 scummvm-rg350-582a681c67487c717686c21bd82bf8e930f6987e.zip |
HOPKINS: Replace cascades of if by switches for language checks
Diffstat (limited to 'engines/hopkins')
-rw-r--r-- | engines/hopkins/computer.cpp | 33 | ||||
-rw-r--r-- | engines/hopkins/dialogs.cpp | 11 | ||||
-rw-r--r-- | engines/hopkins/globals.cpp | 2 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 33 | ||||
-rw-r--r-- | engines/hopkins/menu.cpp | 40 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 18 | ||||
-rw-r--r-- | engines/hopkins/sound.cpp | 57 | ||||
-rw-r--r-- | engines/hopkins/talk.cpp | 11 |
8 files changed, 140 insertions, 65 deletions
diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index c09d748b97..f9e3ecafcd 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -349,15 +349,21 @@ void ComputerManager::loadMenu() { char *ptr; if (_vm->_fileIO->fileExists("COMPUTAN.TXT")) { ptr = (char *)_vm->_fileIO->loadFile("COMPUTAN.TXT"); - } else if (_vm->_globals->_language == LANG_FR) { - ptr = (char *)_vm->_globals->allocMemory(sizeof(_frenchText)); - strcpy(ptr, _frenchText); - } else if (_vm->_globals->_language == LANG_SP) { - ptr = (char *)_vm->_globals->allocMemory(sizeof(_spanishText)); - strcpy(ptr, _spanishText); } else { - ptr = (char *)_vm->_globals->allocMemory(sizeof(_englishText)); - strcpy(ptr, _englishText); + switch (_vm->_globals->_language) { + case LANG_FR: + ptr = (char *)_vm->_globals->allocMemory(sizeof(_frenchText)); + strcpy(ptr, _frenchText); + break; + case LANG_SP: + ptr = (char *)_vm->_globals->allocMemory(sizeof(_spanishText)); + strcpy(ptr, _spanishText); + break; + default: + ptr = (char *)_vm->_globals->allocMemory(sizeof(_englishText)); + strcpy(ptr, _englishText); + break; + } } char *tmpPtr = ptr; @@ -479,12 +485,17 @@ void ComputerManager::readText(int idx) { _vm->_events->_escKeyFl = false; Common::String filename; - if (_vm->_globals->_language == LANG_EN) + switch (_vm->_globals->_language) { + case LANG_EN: filename = "THOPKAN.TXT"; - else if (_vm->_globals->_language == LANG_FR) + break; + case LANG_FR: filename = "THOPK.TXT"; - else if (_vm->_globals->_language == LANG_SP) + break; + case LANG_SP: filename = "THOPKES.TXT"; + break; + } byte *ptr = _vm->_fileIO->loadFile(filename); uint16 fileSize = _vm->_fileIO->fileSize(filename); diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index 3b8fedf0ee..8c944167ae 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -84,12 +84,17 @@ void DialogsManager::showOptionsDialog() { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "OPTION.SPR"; else { - if (_vm->_globals->_language == LANG_FR) + switch (_vm->_globals->_language) { + case LANG_FR: filename = "OPTIFR.SPR"; - else if (_vm->_globals->_language == LANG_EN) + break; + case LANG_EN: filename = "OPTIAN.SPR"; - else if (_vm->_globals->_language == LANG_SP) + break; + case LANG_SP: filename = "OPTIES.SPR"; + break; + } } _vm->_globals->_optionDialogSpr = _vm->_fileIO->loadFile(filename); diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index a9a0a81f08..cd66a84b73 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -148,7 +148,7 @@ void Globals::setConfig() { _language = LANG_SP; break; default: - warning("Unknown language in internal language mapping"); + error("Hopkins - SetConfig(): Unknown language in internal language mapping"); break; } // End of CHECKME diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index 9e317804ca..adf7580e6b 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -210,12 +210,17 @@ bool HopkinsEngine::runWin95Demo() { if (getPlatform() == Common::kPlatformOS2 || getPlatform() == Common::kPlatformBeOS) _graphicsMan->loadImage("fond"); else { - if (_globals->_language == LANG_FR) + switch (_globals->_language) { + case LANG_FR: _graphicsMan->loadImage("fondfr"); - else if (_globals->_language == LANG_EN) + break; + case LANG_EN: _graphicsMan->loadImage("fondan"); - else if (_globals->_language == LANG_SP) + break; + case LANG_SP: _graphicsMan->loadImage("fondes"); + break; + } } _graphicsMan->fadeInLong(); _events->delay(500); @@ -521,12 +526,17 @@ bool HopkinsEngine::runLinuxDemo() { if (getPlatform() == Common::kPlatformOS2 || getPlatform() == Common::kPlatformBeOS) _graphicsMan->loadImage("fond"); else { - if (_globals->_language == LANG_FR) + switch (_globals->_language) { + case LANG_FR: _graphicsMan->loadImage("fondfr"); - else if (_globals->_language == LANG_EN) + break; + case LANG_EN: _graphicsMan->loadImage("fondan"); - else if (_globals->_language == LANG_SP) + break; + case LANG_SP: _graphicsMan->loadImage("fondes"); + break; + } } _graphicsMan->fadeInLong(); _events->delay(500); @@ -867,12 +877,17 @@ bool HopkinsEngine::runFull() { if (getPlatform() == Common::kPlatformOS2 || getPlatform() == Common::kPlatformBeOS) _graphicsMan->loadImage("fond"); else { - if (_globals->_language == LANG_FR) + switch (_globals->_language) { + case LANG_FR: _graphicsMan->loadImage("fondfr"); - else if (_globals->_language == LANG_EN) + break; + case LANG_EN: _graphicsMan->loadImage("fondan"); - else if (_globals->_language == LANG_SP) + break; + case LANG_SP: _graphicsMan->loadImage("fondes"); + break; + } } _graphicsMan->fadeInLong(); _events->delay(500); diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp index b63fd0ff6c..048d1b2cef 100644 --- a/engines/hopkins/menu.cpp +++ b/engines/hopkins/menu.cpp @@ -69,25 +69,37 @@ int MenuManager::menu() { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) _vm->_graphicsMan->loadImage("MENU"); - else if (_vm->_globals->_language == LANG_EN) - _vm->_graphicsMan->loadImage("MENUAN"); - else if (_vm->_globals->_language == LANG_FR) - _vm->_graphicsMan->loadImage("MENUFR"); - else if (_vm->_globals->_language == LANG_SP) - _vm->_graphicsMan->loadImage("MENUES"); + else { + switch (_vm->_globals->_language) { + case LANG_EN: + _vm->_graphicsMan->loadImage("MENUAN"); + break; + case LANG_FR: + _vm->_graphicsMan->loadImage("MENUFR"); + break; + case LANG_SP: + _vm->_graphicsMan->loadImage("MENUES"); + break; + } + } _vm->_graphicsMan->fadeInLong(); if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) spriteData = _vm->_objectsMan->loadSprite("MENU.SPR"); - else if (_vm->_globals->_language == LANG_EN) - spriteData = _vm->_objectsMan->loadSprite("MENUAN.SPR"); - else if (_vm->_globals->_language == LANG_FR) - spriteData = _vm->_objectsMan->loadSprite("MENUFR.SPR"); - else if (_vm->_globals->_language == LANG_SP) - spriteData = _vm->_objectsMan->loadSprite("MENUES.SPR"); - else - error("Hopkins::MenuManager - Unknown version of the game."); + else { + switch (_vm->_globals->_language) { + case LANG_EN: + spriteData = _vm->_objectsMan->loadSprite("MENUAN.SPR"); + break; + case LANG_FR: + spriteData = _vm->_objectsMan->loadSprite("MENUFR.SPR"); + break; + case LANG_SP: + spriteData = _vm->_objectsMan->loadSprite("MENUES.SPR"); + break; + } + } _vm->_events->mouseOn(); _vm->_events->changeMouseCursor(0); diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index 7e150624b8..09b0641a12 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -148,12 +148,18 @@ int ScriptManager::handleOpcode(const byte *dataP) { _vm->_soundMan->mixVoice(635, 4, displayedTxtFl); } else { int textPosX = READ_LE_INT16(dataP + 9); - if (_vm->_globals->_language == LANG_FR && !_vm->_soundMan->_textOffFl) - _vm->_fontMan->initTextBuffers(9, mesgId, "OBJET1.TXT", 2 * textPosX, 60, 6, dataP[7], 253); - else if (_vm->_globals->_language == LANG_EN && !_vm->_soundMan->_textOffFl) - _vm->_fontMan->initTextBuffers(9, mesgId, "OBJETAN.TXT", 2 * textPosX, 60, 6, dataP[7], 253); - else if (_vm->_globals->_language == LANG_SP && !_vm->_soundMan->_textOffFl) { - _vm->_fontMan->initTextBuffers(9, mesgId, "OBJETES.TXT", 2 * textPosX, 60, 6, dataP[7], 253); + if (!_vm->_soundMan->_textOffFl) { + switch (_vm->_globals->_language) { + case LANG_FR: + _vm->_fontMan->initTextBuffers(9, mesgId, "OBJET1.TXT", 2 * textPosX, 60, 6, dataP[7], 253); + break; + case LANG_EN: + _vm->_fontMan->initTextBuffers(9, mesgId, "OBJETAN.TXT", 2 * textPosX, 60, 6, dataP[7], 253); + break; + case LANG_SP: + _vm->_fontMan->initTextBuffers(9, mesgId, "OBJETES.TXT", 2 * textPosX, 60, 6, dataP[7], 253); + break; + } } bool displayedTxtFl = false; diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index bf816c08a4..92c5f51462 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -520,12 +520,19 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names - else if (_vm->_globals->_language == LANG_FR) - filename = "RES_VFR.RES"; - else if (_vm->_globals->_language == LANG_EN) - filename = "RES_VAN.RES"; - else if (_vm->_globals->_language == LANG_SP) - filename = "RES_VES.RES"; + else { + switch (_vm->_globals->_language) { + case LANG_FR: + filename = "RES_VFR.RES"; + break; + case LANG_EN: + filename = "RES_VAN.RES"; + break; + case LANG_SP: + filename = "RES_VES.RES"; + break; + } + } catPos = _vm->_fileIO->_catalogPos; catLen = _vm->_fileIO->_catalogSize; @@ -535,12 +542,19 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names - else if (_vm->_globals->_language == LANG_FR) - filename = "RES_VFR.RES"; - else if (_vm->_globals->_language == LANG_EN) - filename = "RES_VAN.RES"; - else if (_vm->_globals->_language == LANG_SP) - filename = "RES_VES.RES"; + else { + switch (_vm->_globals->_language) { + case LANG_FR: + filename = "RES_VFR.RES"; + break; + case LANG_EN: + filename = "RES_VAN.RES"; + break; + case LANG_SP: + filename = "RES_VES.RES"; + break; + } + } catPos = _vm->_fileIO->_catalogPos; catLen = _vm->_fileIO->_catalogSize; @@ -550,12 +564,19 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names - else if (_vm->_globals->_language == LANG_FR) - filename = "RES_VFR.RES"; - else if (_vm->_globals->_language == LANG_EN) - filename = "RES_VAN.RES"; - else if (_vm->_globals->_language == LANG_SP) - filename = "RES_VES.RES"; + else { + switch (_vm->_globals->_language) { + case LANG_FR: + filename = "RES_VFR.RES"; + break; + case LANG_EN: + filename = "RES_VAN.RES"; + break; + case LANG_SP: + filename = "RES_VES.RES"; + break; + } + } catPos = _vm->_fileIO->_catalogPos; catLen = _vm->_fileIO->_catalogSize; diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index 736ec9865c..1bb6701fc8 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -68,12 +68,17 @@ void TalkManager::startAnimatedCharacterDialogue(const Common::String &filename) getStringFromBuffer(40, spriteFilename, (const char *)_characterBuffer); getStringFromBuffer(0, _questionsFilename, (const char *)_characterBuffer); getStringFromBuffer(20, _answersFilename, (const char *)_characterBuffer); - if (_vm->_globals->_language == LANG_FR) { + + switch (_vm->_globals->_language) { + case LANG_FR: _answersFilename = _questionsFilename = "RUE.TXT"; - } else if (_vm->_globals->_language == LANG_EN) { + break; + case LANG_EN: _answersFilename = _questionsFilename = "RUEAN.TXT"; - } else if (_vm->_globals->_language == LANG_SP) { + break; + case LANG_SP: _answersFilename = _questionsFilename = "RUEES.TXT"; + break; } _dialogueMesgId1 = READ_LE_INT16((uint16 *)_characterBuffer + 40); _paletteBufferIdx = 20 * READ_LE_INT16((uint16 *)_characterBuffer + 42) + 110; |