From 6fc065922268c6dfb83fac6ded31dca076822754 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sat, 30 Sep 2017 23:27:56 +0100 Subject: SUPERNOVA: Start using strings from the engine data file This means that now all that remains to be done to play in English is to move all the strings to the engine data file and to translate them. --- engines/supernova/msn_def.h | 36 ++++++++++++++++++------------------ engines/supernova/rooms.cpp | 8 ++++---- engines/supernova/state.cpp | 7 ++++--- engines/supernova/supernova.h | 20 ++++++++++++++++++++ 4 files changed, 46 insertions(+), 25 deletions(-) (limited to 'engines/supernova') diff --git a/engines/supernova/msn_def.h b/engines/supernova/msn_def.h index a02df72593..403ba147f8 100644 --- a/engines/supernova/msn_def.h +++ b/engines/supernova/msn_def.h @@ -400,27 +400,27 @@ enum ObjectID { TICKETS }; +enum StringID { + kCommandGo = 0, kCommandLook, kCommandTake, kCommandOpen, kCommandClose, + kCommandPress, kCommandPull, kCommandUse, kCommandTalk, kCommandGive, + kStatusCommandGo, kStatusCommandLook, kStatusCommandTake, kStatusCommandOpen, kStatusCommandClose, + kStatusCommandPress, kStatusCommandPull, kStatusCommandUse, kStatusCommandTalk, kStatusCommandGive, + kBroken, kIntro1, kIntro2, kIntro3, kIntro4, + kIntro5, kIntro6, kIntro7, kIntro8, kIntro9, + kIntro10, kIntro11, kIntro12, kIntro13, kKeycard, + kKeycardDesc, kKnife, kKnifeDesc, kWatch, kDiscman, + kDiscmanDesc +}; -static const char *const broken_DE = "Hmm, er scheint kaputt zu sein."; -static const char *const broken_EN = "Hmm, it seems to be broken."; - -static const char *const guiCommand_DE[] = { - "Gehe", - "Schau", - "Nimm", - "\231ffne", - "Schlie\341e", - "Dr\201cke", - "Ziehe", - "Benutze", - "Rede", - "Gib" +static StringID guiCommands[] = { + kCommandGo, kCommandLook, kCommandTake, kCommandOpen, kCommandClose, + kCommandPress, kCommandPull, kCommandUse, kCommandTalk, kCommandGive }; -static const char *const guiStatusCommand_DE[10] = -{"Gehe zu ","Schau ","Nimm ","\231ffne ","Schlie\341e ","Dr\201cke ","Ziehe ","Benutze ","Rede mit ","Gib "}; -static const char *const guiStatusCommand_EN[10] = -{"Go to ", "Look at ", "Take ", "Open ", "Close ", "Press ", "Pull ", "Use ", "Talk to ", "Give "}; +static StringID guiStatusCommands[] = { + kStatusCommandGo, kStatusCommandLook, kStatusCommandTake, kStatusCommandOpen, kStatusCommandClose, + kStatusCommandPress, kStatusCommandPull, kStatusCommandUse, kStatusCommandTalk, kStatusCommandGive +}; ObjectType operator|(ObjectType a, ObjectType b); ObjectType operator&(ObjectType a, ObjectType b); diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp index 4214a1178d..f4a3084fb6 100644 --- a/engines/supernova/rooms.cpp +++ b/engines/supernova/rooms.cpp @@ -2757,7 +2757,7 @@ bool AxacussOffice1::interact(Action verb, Object &obj1, Object &obj2) { _vm->playSound(kAudioUndef2); } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { if (isSectionVisible(4)) - _vm->renderMessage(broken_DE); + _vm->renderMessage(kBroken); else _gm->telomat(0); } else if (((verb == ACTION_OPEN) || (verb == ACTION_USE)) && @@ -2840,7 +2840,7 @@ bool AxacussOffice2::interact(Action verb, Object &obj1, Object &obj2) { _vm->playSound(kAudioUndef2); } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { if (isSectionVisible(4)) - _vm->renderMessage(broken_DE); + _vm->renderMessage(kBroken); else _gm->telomat(1); } else @@ -2865,7 +2865,7 @@ bool AxacussOffice3::interact(Action verb, Object &obj1, Object &obj2) { _vm->playSound(kAudioUndef2); } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { if (isSectionVisible(4)) - _vm->renderMessage(broken_DE); + _vm->renderMessage(kBroken); else _gm->telomat(2); } else if ((verb == ACTION_LOOK) && (obj1._id == PAINTING)) { @@ -2894,7 +2894,7 @@ bool AxacussOffice4::interact(Action verb, Object &obj1, Object &obj2) { _vm->playSound(kAudioUndef2); } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { if (isSectionVisible(4)) - _vm->renderMessage(broken_DE); + _vm->renderMessage(kBroken); else _gm->telomat(3); } else diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index 4c54cbe952..cbb740f1fa 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -398,14 +398,15 @@ void GameManager::initRooms() { void GameManager::initGui() { int commandButtonX = 0; for (int i = 0; i < ARRAYSIZE(_guiCommandButton); ++i) { + const Common::String &text = _vm->getGameString(guiCommands[i]); int width; if (i < 9) - width = _vm->textWidth(guiCommand_DE[i]) + 2; + width = _vm->textWidth(text) + 2; else width = 320 - commandButtonX; _guiCommandButton[i].setSize(commandButtonX, 150, commandButtonX + width, 159); - _guiCommandButton[i].setText(guiCommand_DE[i]); + _guiCommandButton[i].setText(text.c_str()); _guiCommandButton[i].setColor(kColorWhite25, kColorDarkGreen, kColorWhite44, kColorGreen); commandButtonX += width + 2; } @@ -1174,7 +1175,7 @@ void GameManager::takeMoney(int amount) { void GameManager::drawStatus() { int index = static_cast(_inputVerb); _vm->renderBox(0, 140, 320, 9, kColorWhite25); - _vm->renderText(guiStatusCommand_DE[index], 1, 141, kColorDarkGreen); + _vm->renderText(_vm->getGameString(guiStatusCommands[index]), 1, 141, kColorDarkGreen); if (Object::isNullObject(_inputObject[0])) { _vm->renderText(_currentInputObject->_name.c_str()); diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 356cfe482c..cc6cfbb479 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -154,6 +154,26 @@ public: return _nullString; return _gameStrings[idx]; } + int textWidth(const Common::String &text) { + if (text.empty()) + return 0; + return textWidth(text.c_str()); + } + void renderMessage(StringID stringId, MessagePosition position = kMessageNormal) { + renderMessage(getGameString(stringId), position); + } + void renderMessage(const Common::String &text, MessagePosition position = kMessageNormal) { + if (!text.empty()) + renderMessage(text.c_str(), position); + } + void renderText(const Common::String &text, int x, int y, byte color) { + if (!text.empty()) + renderText(text.c_str(), x, y, color); + } + void renderText(const Common::String &text) { + if (!text.empty()) + renderText(text.c_str()); + } Common::MemoryReadStream *convertToMod(const char *filename, int version = 1); -- cgit v1.2.3