From 1bd06d88f9af46bb439507ed213bf7ad57e989ae Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Mon, 15 Feb 2016 02:26:20 +0100 Subject: SHERLOCK: RT: Make darts game properly multilingual Hopefully all issues were caught Also added a "wait for keypress" right after result of latest dart throw is shown like in the original, so that dart results are not immediately cleared. Also added support for "1 point" instead of writing "1 points" --- engines/sherlock/tattoo/tattoo_darts.cpp | 105 ++++++++++++++++++-------- engines/sherlock/tattoo/tattoo_fixed_text.cpp | 84 +++++++++++---------- engines/sherlock/tattoo/tattoo_fixed_text.h | 38 +++++----- 3 files changed, 141 insertions(+), 86 deletions(-) (limited to 'engines/sherlock') diff --git a/engines/sherlock/tattoo/tattoo_darts.cpp b/engines/sherlock/tattoo/tattoo_darts.cpp index a430ad5a62..fe707a8c13 100644 --- a/engines/sherlock/tattoo/tattoo_darts.cpp +++ b/engines/sherlock/tattoo/tattoo_darts.cpp @@ -83,7 +83,6 @@ void Darts::playDarts(GameType gameType) { int numHits = 0; bool gameOver = false; bool done = false; - const char *const NUM_HITS_STR[3] = { "a", FIXED(Double), FIXED(Triple) }; // Set the game mode _gameType = gameType; @@ -166,49 +165,82 @@ void Darts::playDarts(GameType gameType) { showStatus(playerNum); screen._backBuffer2.blitFrom(screen._backBuffer1, Common::Point(_dartInfo.left, _dartInfo.top - 1), Common::Rect(_dartInfo.left, _dartInfo.top - 1, _dartInfo.right, _dartInfo.bottom - 1)); - screen.print(Common::Point(_dartInfo.left, _dartInfo.top), 0, "%s # %d", FIXED(Dart), idx + 1); + screen.print(Common::Point(_dartInfo.left, _dartInfo.top), 0, FIXED(DartsCurrentDart), idx + 1); if (_gameType == GAME_301) { - if (_vm->getLanguage() == Common::FR_FRA) - screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, - "%s %s: %d", FIXED(Scored), FIXED(Points), lastDart); - else - screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, - "%s %d %s", FIXED(Scored), lastDart, FIXED(Points)); + // "Scored x points" + Common::String scoredPoints; + + // original treated 1 point and multiple points the same. Wrote "Scored 1 points" + if (lastDart == 1) { + scoredPoints = Common::String::format(FIXED(DartsScoredPoint), lastDart); + } else { + scoredPoints = Common::String::format(FIXED(DartsScoredPoints), lastDart); + } + + screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, scoredPoints.c_str()); } else { - if (lastDart != 25) - screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, - "%s %s %d", FIXED(Hit), NUM_HITS_STR[numHits - 1], lastDart); - else - screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, - "%s %s %s", FIXED(Hit), NUM_HITS_STR[numHits - 1], FIXED(Bullseye)); + Common::String hitText; + + if (lastDart != 25) { + // Regular hit + switch (numHits) { + case 1: // "Hit a X" + hitText = Common::String::format(FIXED(DartsHitSingle), lastDart); + break; + case 2: // "Hit double X" + hitText = Common::String::format(FIXED(DartsHitDouble), lastDart); + break; + case 3: // "Hit triple X" + hitText = Common::String::format(FIXED(DartsHitTriple), lastDart); + break; + default: + break; + } + } else { + // Bullseye + switch (numHits) { + case 1: + hitText = Common::String(FIXED(DartsHitSingleBullseye)); + break; + case 2: + hitText = Common::String(FIXED(DartsHitDoubleBullseye)); + break; + case 3: + hitText = Common::String(FIXED(DartsHitTripleBullseye)); + break; + default: + break; + } + } + screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, hitText.c_str()); } if (score != 0 && playerNum == 0 && !gameOver) screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 3), 0, - "%s", FIXED(PressAKey)); + "%s", FIXED(DartsPressKey)); if (gameOver) { screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 3), - 0, "%s", FIXED(GameOver)); + 0, "%s", FIXED(DartsGameOver)); if (playerNum == 0) { screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 4), 0, - "%s %s", FIXED(Holmes), FIXED(Wins)); + FIXED(DartsWins), FIXED(DartsPlayerHolmes)); _vm->setFlagsDirect(531); } else { screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 4), 0, - "%s %s!", _opponent.c_str(), FIXED(Wins)); + FIXED(DartsWins), _opponent.c_str()); _vm->setFlagsDirect(530); } screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 5), 0, - "%s", FIXED(PressAKey)); + "%s", FIXED(DartsPressKey)); done = true; idx = 10; } else if (_gameType == GAME_301 && score < 0) { screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 2), 0, - "%s!", FIXED(Busted)); + "%s!", FIXED(DartsBusted)); // End turn idx = 10; @@ -227,10 +259,15 @@ void Darts::playDarts(GameType gameType) { done = true; break; } + // Wait for keypress + do { + events.pollEventsAndWait(); + events.setButtonState(); + } while (!_vm->shouldQuit() && !events.kbHit() && !events._pressed); } else { - events.wait(20); + events.wait(40); } - + // Clears the status part of the board screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_dartInfo.left, _dartInfo.top - 1), Common::Rect(_dartInfo.left, _dartInfo.top - 1, _dartInfo.right, _dartInfo.bottom - 1)); screen.blitFrom(screen._backBuffer1); @@ -306,7 +343,7 @@ void Darts::initDarts() { } } - _opponent = FIXED(Jock); + _opponent = FIXED(DartsPlayerJock); } void Darts::loadDarts() { @@ -349,7 +386,7 @@ void Darts::showNames(int playerNum) { byte color; color = playerNum == 0 ? PLAYER_COLOR : DART_COLOR_FORE; - screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y), 0, "%s", FIXED(Holmes)); + screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y), 0, "%s", FIXED(DartsPlayerHolmes)); screen._backBuffer1.fillRect(Common::Rect(STATUS_INFO_X, STATUS_INFO_Y + _spacing + 1, STATUS_INFO_X + 50, STATUS_INFO_Y + _spacing + 3), color); screen.fillRect(Common::Rect(STATUS_INFO_X, STATUS_INFO_Y + _spacing + 1, @@ -367,7 +404,7 @@ void Darts::showNames(int playerNum) { void Darts::showStatus(int playerNum) { Screen &screen = *_vm->_screen; - const char *const CRICKET_SCORE_NAME[7] = { "20", "19", "18", "17", "16", "15", FIXED(Bull) }; + const char *const CRICKET_SCORE_NAME[7] = { "20", "19", "18", "17", "16", "15", FIXED(DartsBull) }; screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(STATUS_INFO_X, STATUS_INFO_Y + 10), Common::Rect(STATUS_INFO_X, STATUS_INFO_Y + 10, STATUS_INFO_X + STATUS_INFO_WIDTH, @@ -377,10 +414,15 @@ void Darts::showStatus(int playerNum) { screen.print(Common::Point(STATUS2_INFO_X + 30, STATUS_INFO_Y + _spacing + 4), 0, "%d", _score2); int temp = (_gameType == GAME_CRICKET) ? STATUS_INFO_Y + 10 * _spacing + 5 : STATUS_INFO_Y + 55; - screen.print(Common::Point(STATUS_INFO_X, temp), 0, "%s: %d", FIXED(Round), _roundNum); + + // "Round: x" + Common::String dartsRoundStatus = Common::String::format(FIXED(DartsCurrentRound), _roundNum); + screen.print(Common::Point(STATUS_INFO_X, temp), 0, dartsRoundStatus.c_str()); if (_gameType == GAME_301) { - screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y + 75), 0, "%s: %d", FIXED(TurnTotal), _roundScore); + // "Turn Total: x" + Common::String dartsTotalPoints = Common::String::format(FIXED(DartsCurrentTotalPoints), _roundScore); + screen.print(Common::Point(STATUS_INFO_X, STATUS_INFO_Y + 75), 0, dartsTotalPoints.c_str()); } else { // Show cricket scores for (int x = 0; x < 7; ++x) { @@ -890,13 +932,16 @@ int Darts::throwDart(int dartNum, int computer) { events.clearEvents(); erasePowerBars(); - screen.print(Common::Point(_dartInfo.left, _dartInfo.top), 0, "%s # %d", FIXED(Dart), dartNum); + + // "Dart # x" + Common::String currentDart = Common::String::format(FIXED(DartsCurrentDart), dartNum); + screen.print(Common::Point(_dartInfo.left, _dartInfo.top), 0, currentDart.c_str()); drawDartsLeft(dartNum, computer); if (!computer) { - screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, "%s", FIXED(HitAKey)); - screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 2), 0, "%s", FIXED(ToStart)); + screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing), 0, "%s", FIXED(DartsStartPressKey1)); + screen.print(Common::Point(_dartInfo.left, _dartInfo.top + _spacing * 2), 0, "%s", FIXED(DartsStartPressKey2)); } if (!computer) { diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.cpp b/engines/sherlock/tattoo/tattoo_fixed_text.cpp index 4d90625ad1..f48bf39c8e 100644 --- a/engines/sherlock/tattoo/tattoo_fixed_text.cpp +++ b/engines/sherlock/tattoo/tattoo_fixed_text.cpp @@ -66,25 +66,27 @@ static const char *const fixedTextEN[] = { "Search Backwards", "Search Forwards", "Text Not Found !", - + // Darts "Holmes", "Jock", "Bull", - "Round", - "Turn Total", - "Dart", - "to start", + "Round: %d", + "Turn Total: %d", + "Dart # %d", "Hit a key", + "To start", "Press a key", - "bullseye", // ?? - "GAME OVER", - "BUSTED", - "Wins", - "Scored", - "points", - "Hit %s %d", - "Double", - "Triple", + "GAME OVER!", + "BUSTED!", + "%s Wins", + "Scored %d point", // original: treated 1 point and multiple points the same ("Scored 1 points") + "Scored %d points", + "Hit a %d", + "Hit double %d", + "Hit triple %d", + "Hit a bullseye", + "Hit double bullseye", + "Hit triple bullseye", "Apply", "Water", @@ -249,25 +251,27 @@ static const char *const fixedTextDE[] = { "R\201ckw\204rts suchen ", "Vorw\204rts suchen ", "Text nicht gefunden", - + // Darts "Holmes", "Jock", "Bull", "Runde: %d", "Gesamt: %d", "Pfeil # %d", - "zum Starten", "Taste dr\201cken", + "zum Starten", "Taste dr\201cken", - "Bullseye", // ?? "SPIEL BEENDET!", "VERLOREN!", - "Gewinnt!", // "Holmes Gewinnt!", "%s Gewinnt!" + "%s gewinnt!", // "Holmes Gewinnt!", "%s Gewinnt!", original: "%s Gewinnt!" + "Erzielte %d Punkt", // original: treated 1 point and multiple points the same ("Scored 1 points") "Erzielte %d Punkte", - "Punkte", // ?? - "Treffer %s %d", - "Doppel", - "Dreifach", + "%d getroffen", // original: "Treffer %s %d" + "Doppel %d getroffen", // original: see above + "Dreifach %d getroffen", // original: see above + "Bullseye getroffen", + "Doppel Bullseye getroffen", + "Dreifach Bullseye getroffen", "Benutze", "Wasser", @@ -432,25 +436,27 @@ static const char *const fixedTextFR[] = { "Chercher avant", "Chercher apr\212s", "Texte introuvable !", - + // Darts "Holmes", "Jock", "Bull", "Tour: %d", "Total: %d", "Fl\202chette # %d", - "pour commencer", "Appuyez sur C", + "pour commencer", "Appuyez sur C", - "Bullseye", // ?? "FIN DE LA PARTIE!", // original: "Fin de la partie!" "FIASCO!", - "Gagnant!", // "Holmes Gagnant!", "%s Gagnant!" - "Total des points: %d", - "Punkte", // ?? - "Treffer %s %d", - "double", - "triple", + "%s a gagné!", // "Holmes Gagnant!", "%s Gagnant!" <--- FIXXXX + "Rapporte %d point", // original: treated 1 point and multiple points the same ("Scored 1 points") + "Rapporte %d points", // original: Total des points: %d", + "Touche un %d", // original: ??? + "Touche double %d", + "Touche triple %d", + "Touche le Bullseye", + "Touche double Bullseye", + "Touche triple Bullseye", "Mouillez", "Puis", @@ -623,18 +629,20 @@ static const char *const fixedTextES[] = { "Vuelta: %d", "Total del Turno: %d", "Dardo # %d", - "para empezar", "Pulsa una tecla", + "para empezar", "Pulsa una tecla", - "Golpe %s ojo de buey", // ?? "FIN DE LA PARTIDA!", "ROTO!", - "Gana!", // "Holmes Gana!", "%s Gana!" + "%s gana!", // "Holmes Gana!", "%s Gana!", original: "%s Gana!" + "Puntuado %d punto", // original: treated 1 point and multiple points the same ("Scored 1 points") "Puntuado %d puntos", - "puntos", // ?? - "Golpe %s %d", - "doble", - "triple", + "Golpe un %d", + "Gople doble %d", + "Gople triple %d", + "Golpe un ojo de buey", + "Gople doble ojo de buey", + "Gople triple ojo de buey", "aplicar", "Agua", diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.h b/engines/sherlock/tattoo/tattoo_fixed_text.h index 48d237db3c..da1159eec9 100644 --- a/engines/sherlock/tattoo/tattoo_fixed_text.h +++ b/engines/sherlock/tattoo/tattoo_fixed_text.h @@ -68,24 +68,26 @@ enum FixedTextId { kFixedText_SearchForwards, kFixedText_TextNotFound, - kFixedText_Holmes, - kFixedText_Jock, - kFixedText_Bull, - kFixedText_Round, - kFixedText_TurnTotal, - kFixedText_Dart, - kFixedText_ToStart, - kFixedText_HitAKey, - kFixedText_PressAKey, - kFixedText_Bullseye, - kFixedText_GameOver, - kFixedText_Busted, - kFixedText_Wins, - kFixedText_Scored, - kFixedText_Points, - kFixedText_Hit, - kFixedText_Double, - kFixedText_Triple, + kFixedText_DartsPlayerHolmes, + kFixedText_DartsPlayerJock, + kFixedText_DartsBull, + kFixedText_DartsCurrentRound, + kFixedText_DartsCurrentTotalPoints, + kFixedText_DartsCurrentDart, + kFixedText_DartsStartPressKey1, + kFixedText_DartsStartPressKey2, + kFixedText_DartsPressKey, + kFixedText_DartsGameOver, + kFixedText_DartsBusted, + kFixedText_DartsWins, + kFixedText_DartsScoredPoint, + kFixedText_DartsScoredPoints, + kFixedText_DartsHitSingle, + kFixedText_DartsHitDouble, + kFixedText_DartsHitTriple, + kFixedText_DartsHitSingleBullseye, + kFixedText_DartsHitDoubleBullseye, + kFixedText_DartsHitTripleBullseye, kFixedText_Apply, kFixedText_Water, -- cgit v1.2.3