From 418cec512f177a0f523c80916770382dd0e4fdaf Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 23 Jun 2019 09:31:37 +0200 Subject: CRYOMNI3D: Add internationalization through external DAT file --- engines/cryomni3d/versailles/logic.cpp | 42 +++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'engines/cryomni3d/versailles/logic.cpp') diff --git a/engines/cryomni3d/versailles/logic.cpp b/engines/cryomni3d/versailles/logic.cpp index e46c1a7ca0..952489c41e 100644 --- a/engines/cryomni3d/versailles/logic.cpp +++ b/engines/cryomni3d/versailles/logic.cpp @@ -187,7 +187,7 @@ void CryOmni3DEngine_Versailles::obj_126hk(Graphics::ManagedSurface &surface) { Graphics::Surface bmpLetters[28]; loadBMPs("bomb_%02d.bmp", bmpLetters, 28); - drawEpigraphLetters(surface, bmpLetters, kEpigraphPassword); + drawEpigraphLetters(surface, bmpLetters, _epigraphPassword); for (uint i = 0; i < 28; i++) { bmpLetters[i].free(); @@ -2361,7 +2361,7 @@ bool CryOmni3DEngine_Versailles::handleEpigraph(ZonFixedImage *fimg) { continue; } // Find which letter got clicked - char letter = kEpigraphContent[fimg->_currentZone]; + char letter = _epigraphContent[fimg->_currentZone]; password += letter; // Reset the surface and redraw digits on it tempSurf.blitFrom(*fimgSurface); @@ -2379,7 +2379,7 @@ bool CryOmni3DEngine_Versailles::handleEpigraph(ZonFixedImage *fimg) { } if (keyCode >= Common::KEYCODE_a && keyCode <= Common::KEYCODE_z && - strchr(kEpigraphContent, keyCode - Common::KEYCODE_a + 'A')) { + _epigraphContent.contains(keyCode - Common::KEYCODE_a + 'A')) { password += keyCode - Common::KEYCODE_a + 'A'; } else { continue; @@ -2391,7 +2391,7 @@ bool CryOmni3DEngine_Versailles::handleEpigraph(ZonFixedImage *fimg) { fimg->updateSurface(&tempSurf.rawSurface()); } - if (password == kEpigraphPassword) { + if (password == _epigraphPassword) { success = true; break; } @@ -2403,9 +2403,6 @@ bool CryOmni3DEngine_Versailles::handleEpigraph(ZonFixedImage *fimg) { return success; } -const char *CryOmni3DEngine_Versailles::kEpigraphContent = "FELIXFORTUNADIVINUMEXPLORATUMACTUIIT"; -const char *CryOmni3DEngine_Versailles::kEpigraphPassword = "LELOUPETLATETE"; - void CryOmni3DEngine_Versailles::drawEpigraphLetters(Graphics::ManagedSurface &surface, const Graphics::Surface(&bmpLetters)[28], const Common::String &letters) { for (uint i = 0; i < letters.size() && i < kEpigraphMaxLetters; i++) { @@ -2934,14 +2931,14 @@ bool CryOmni3DEngine_Versailles::handleBomb(ZonFixedImage *fimg) { unsigned char bombCurrentLetters[60]; Graphics::ManagedSurface tempSurf; - const uint kBombPasswordLength = strlen(kBombPassword); - if (kBombPasswordLength >= kBombPasswordMaxLength) { + const uint bombPasswordLength = _bombPassword.size(); + if (bombPasswordLength >= kBombPasswordMaxLength) { error("Bomb password is too long"); } loadBMPs("bomb_%02d.bmp", bmpLetters, 28); - for (uint i = 0; i < kBombPasswordLength; i++) { - bombPossibilites[i][0] = toupper(kBombPassword[i]); + for (uint i = 0; i < bombPasswordLength; i++) { + bombPossibilites[i][0] = toupper(_bombPassword[i]); for (uint j = 1; j < 5; j++) { bool foundSameLetter; do { @@ -2957,7 +2954,7 @@ bool CryOmni3DEngine_Versailles::handleBomb(ZonFixedImage *fimg) { bombCurrentLetters[i] = rnd.getRandomNumber(4); } - if (kBombPasswordLength <= kBombPasswordSmallLength) { + if (bombPasswordLength <= kBombPasswordSmallLength) { fimg->load("70z_16.GIF"); } else { fimg->load("70z_17.GIF"); @@ -2965,7 +2962,7 @@ bool CryOmni3DEngine_Versailles::handleBomb(ZonFixedImage *fimg) { const Graphics::Surface *fimgSurface = fimg->surface(); tempSurf.create(fimgSurface->w, fimgSurface->h, fimgSurface->format); tempSurf.blitFrom(*fimgSurface); - drawBombLetters(tempSurf, bmpLetters, kBombPasswordLength, bombPossibilites, bombCurrentLetters); + drawBombLetters(tempSurf, bmpLetters, bombPasswordLength, bombPossibilites, bombCurrentLetters); drawCountdown(&tempSurf); fimg->updateSurface(&tempSurf.rawSurface()); @@ -2975,12 +2972,12 @@ bool CryOmni3DEngine_Versailles::handleBomb(ZonFixedImage *fimg) { break; } if (fimg->_zoneUse) { - if (fimg->_currentZone < kBombPasswordLength) { + if (fimg->_currentZone < bombPasswordLength) { // Safe digit bombCurrentLetters[fimg->_currentZone] = (bombCurrentLetters[fimg->_currentZone] + 1) % 5; // Reset the surface and redraw letters on it tempSurf.blitFrom(*fimgSurface); - drawBombLetters(tempSurf, bmpLetters, kBombPasswordLength, bombPossibilites, bombCurrentLetters); + drawBombLetters(tempSurf, bmpLetters, bombPasswordLength, bombPossibilites, bombCurrentLetters); drawCountdown(&tempSurf); fimg->updateSurface(&tempSurf.rawSurface()); @@ -2988,9 +2985,9 @@ bool CryOmni3DEngine_Versailles::handleBomb(ZonFixedImage *fimg) { // Check if password is OK success = true; - for (uint i = 0; i < kBombPasswordLength; i++) { + for (uint i = 0; i < bombPasswordLength; i++) { unsigned char letterChar = bombPossibilites[i][bombCurrentLetters[i]]; - if (letterChar != kBombPassword[i]) { + if (letterChar != _bombPassword[i]) { success = false; break; } @@ -3013,7 +3010,6 @@ bool CryOmni3DEngine_Versailles::handleBomb(ZonFixedImage *fimg) { return success; } -const char *CryOmni3DEngine_Versailles::kBombPassword = "JEMENVAISMAISLETATDEMEURERATOUJOURS"; const uint16 CryOmni3DEngine_Versailles::kBombLettersPos[2][kBombPasswordMaxLength][2] = { { {26, 91}, @@ -3122,11 +3118,11 @@ const uint16 CryOmni3DEngine_Versailles::kBombLettersPos[2][kBombPasswordMaxLeng }; void CryOmni3DEngine_Versailles::drawBombLetters(Graphics::ManagedSurface &surface, - const Graphics::Surface(&bmpLetters)[28], const uint kBombPasswordLength, + const Graphics::Surface(&bmpLetters)[28], const uint bombPasswordLength, const unsigned char (&bombPossibilites)[kBombPasswordMaxLength][5], const unsigned char (&bombCurrentLetters)[kBombPasswordMaxLength]) { - uint table = kBombPasswordLength <= kBombPasswordSmallLength ? 0 : 1; - for (uint i = 0; i < kBombPasswordLength; i++) { + uint table = bombPasswordLength <= kBombPasswordSmallLength ? 0 : 1; + for (uint i = 0; i < bombPasswordLength; i++) { unsigned char letterChar = bombPossibilites[i][bombCurrentLetters[i]]; uint letterId = 0; if (letterChar >= 'A' && letterChar <= 'Z') { @@ -3232,8 +3228,8 @@ FILTER_EVENT(1, 2) { INIT_PLACE(1, 3) { if (!_gameVariables[GameVariables::kHasPlayedLebrun]) { Common::File *audioFile = new Common::File(); - if (!audioFile->open("LEB001__.WAV")) { - warning("Failed to open sound file %s", "LEB001__.WAV"); + if (!audioFile->open(_localizedFilenames[LocalizedFilenames::kLeb001])) { + warning("Failed to open sound file %s", _localizedFilenames[LocalizedFilenames::kLeb001].c_str()); delete audioFile; return; } -- cgit v1.2.3