diff options
author | Martin Kiewitz | 2015-06-14 14:13:55 +0200 |
---|---|---|
committer | Martin Kiewitz | 2015-06-14 14:13:55 +0200 |
commit | e7dcf4905e2cacd0d726aad08fd4a857a3459120 (patch) | |
tree | 4e671d172cc09ba6ea13bde92ba7603b3dcfe90f | |
parent | 9e1ae6d82a7c6dbf08f78488d99daaff416c47ae (diff) | |
download | scummvm-rg350-e7dcf4905e2cacd0d726aad08fd4a857a3459120.tar.gz scummvm-rg350-e7dcf4905e2cacd0d726aad08fd4a857a3459120.tar.bz2 scummvm-rg350-e7dcf4905e2cacd0d726aad08fd4a857a3459120.zip |
SHERLOCK: fixedText class to support localizations
also implemented text for windows (exit/up/down) using this class
-rw-r--r-- | engines/sherlock/fixed_text.cpp | 80 | ||||
-rw-r--r-- | engines/sherlock/fixed_text.h | 59 | ||||
-rw-r--r-- | engines/sherlock/module.mk | 1 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel_talk.cpp | 24 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel_user_interface.cpp | 27 | ||||
-rw-r--r-- | engines/sherlock/sherlock.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/sherlock.h | 2 | ||||
-rw-r--r-- | engines/sherlock/talk.cpp | 36 |
8 files changed, 200 insertions, 32 deletions
diff --git a/engines/sherlock/fixed_text.cpp b/engines/sherlock/fixed_text.cpp new file mode 100644 index 0000000000..0633ce65d1 --- /dev/null +++ b/engines/sherlock/fixed_text.cpp @@ -0,0 +1,80 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "sherlock/sherlock.h" +#include "sherlock/fixed_text.h" + +namespace Sherlock { + +static const Common::String fixedTextEN[] = { + // Window buttons + "Exit", + "Up", + "Down" +}; + +// sharp-s : 0xE1 / octal 341 +// small a-umlaut: 0x84 / octal 204 +// small o-umlaut: 0x94 / octal 224 +// small u-umlaut: 0x81 / octal 201 +static const Common::String fixedTextDE[] = { + // Window buttons + "Zur\201ck", + "Hoch", + "Runter" +}; + +static const Common::String fixedTextES[] = { + // Window buttons + "Exit", + "Subir", + "Bajar" +}; + +static const SherlockFixedTextLanguageEntry fixedTextLanguages[] = { + { Common::DE_DEU, fixedTextDE }, + { Common::ES_ESP, fixedTextES }, + { Common::EN_ANY, fixedTextEN }, + { Common::UNK_LANG, fixedTextEN } +}; + + +FixedText::FixedText(SherlockEngine *vm) : _vm(vm) { + // Figure out which fixed texts to use + Common::Language curLanguage = _vm->getLanguage(); + + const SherlockFixedTextLanguageEntry *curLanguageEntry = fixedTextLanguages; + + while (curLanguageEntry->language != Common::UNK_LANG) { + if (curLanguageEntry->language == curLanguage) + break; // found current language + curLanguageEntry++; + } + _fixedText = curLanguageEntry->fixedTextArray; +} + +const Common::String FixedText::getText(FixedTextId fixedTextId) { + return _fixedText[fixedTextId]; +} + + +} // End of namespace Sherlock diff --git a/engines/sherlock/fixed_text.h b/engines/sherlock/fixed_text.h new file mode 100644 index 0000000000..016a1fb493 --- /dev/null +++ b/engines/sherlock/fixed_text.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHERLOCK_FIXED_TEXT_H +#define SHERLOCK_FIXED_TEXT_H + +#include "common/scummsys.h" + +namespace Sherlock { + +enum FixedTextId { + kFixedText_Window_Exit = 0, + kFixedText_Window_Up, + kFixedText_Window_Down +}; + +struct SherlockFixedTextLanguageEntry { + Common::Language language; + const Common::String *fixedTextArray; +}; + +class FixedText { +private: + SherlockEngine *_vm; + + const Common::String *_fixedText; + +public: + FixedText(SherlockEngine *vm); + ~FixedText() {} + + /** + * Gets hardcoded text + */ + const Common::String getText(FixedTextId fixedTextId); +}; + +} // End of namespace Sherlock + +#endif diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk index 9e0d14a2c1..ab4990b58d 100644 --- a/engines/sherlock/module.mk +++ b/engines/sherlock/module.mk @@ -25,6 +25,7 @@ MODULE_OBJS = \ debugger.o \ detection.o \ events.o \ + fixed_text.o \ fonts.o \ image_file.o \ inventory.o \ diff --git a/engines/sherlock/scalpel/scalpel_talk.cpp b/engines/sherlock/scalpel/scalpel_talk.cpp index e53692c2b7..c514ab1522 100644 --- a/engines/sherlock/scalpel/scalpel_talk.cpp +++ b/engines/sherlock/scalpel/scalpel_talk.cpp @@ -171,6 +171,7 @@ ScalpelTalk::ScalpelTalk(SherlockEngine *vm) : Talk(vm) { } void ScalpelTalk::talkInterface(const byte *&str) { + FixedText &fixedText = *_vm->_fixedText; People &people = *_vm->_people; Screen &screen = *_vm->_screen; UserInterface &ui = *_vm->_ui; @@ -181,9 +182,12 @@ void ScalpelTalk::talkInterface(const byte *&str) { drawInterface(); if (_talkTo != -1) { - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, false, "Exit"); - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, false, "Up"); - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, false, "Down"); + Common::String fixedText_Exit = fixedText.getText(kFixedText_Window_Exit); + Common::String fixedText_Up = fixedText.getText(kFixedText_Window_Up); + Common::String fixedText_Down = fixedText.getText(kFixedText_Window_Down); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, false, fixedText_Exit); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, false, fixedText_Up); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, false, fixedText_Down); } } @@ -498,8 +502,9 @@ OpcodeReturn ScalpelTalk::cmdSfxCommand(const byte *&str) { } OpcodeReturn ScalpelTalk::cmdSummonWindow(const byte *&str) { - Events &events = *_vm->_events; - Screen &screen = *_vm->_screen; + Events &events = *_vm->_events; + FixedText &fixedText = *_vm->_fixedText; + Screen &screen = *_vm->_screen; drawInterface(); events._pressed = events._released = false; @@ -507,9 +512,12 @@ OpcodeReturn ScalpelTalk::cmdSummonWindow(const byte *&str) { _noTextYet = false; if (_speaker != -1) { - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, false, "Exit"); - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, false, "Up"); - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, false, "Down"); + Common::String fixedText_Exit = fixedText.getText(kFixedText_Window_Exit); + Common::String fixedText_Up = fixedText.getText(kFixedText_Window_Up); + Common::String fixedText_Down = fixedText.getText(kFixedText_Window_Down); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, false, fixedText_Exit); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, false, fixedText_Up); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, false, fixedText_Down); } return RET_SUCCESS; diff --git a/engines/sherlock/scalpel/scalpel_user_interface.cpp b/engines/sherlock/scalpel/scalpel_user_interface.cpp index bbe17d9cb5..f40d6b4c19 100644 --- a/engines/sherlock/scalpel/scalpel_user_interface.cpp +++ b/engines/sherlock/scalpel/scalpel_user_interface.cpp @@ -1475,6 +1475,7 @@ void ScalpelUserInterface::doPickControl() { void ScalpelUserInterface::doTalkControl() { Events &events = *_vm->_events; + FixedText &fixedText = *_vm->_fixedText; Journal &journal = *_vm->_journal; ScalpelPeople &people = *(ScalpelPeople *)_vm->_people; Screen &screen = *_vm->_screen; @@ -1485,24 +1486,28 @@ void ScalpelUserInterface::doTalkControl() { _key = _oldKey = -1; _keyboardInput = false; + Common::String fixedText_Exit = fixedText.getText(kFixedText_Window_Exit); + Common::String fixedText_Up = fixedText.getText(kFixedText_Window_Up); + Common::String fixedText_Down = fixedText.getText(kFixedText_Window_Down); + if (events._pressed || events._released) { events.clearKeyboard(); // Handle button printing if (mousePos.x > 99 && mousePos.x < 138 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) && !_endKeyActive) - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, "Exit"); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, fixedText_Exit); else if (_endKeyActive) - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_FOREGROUND, true, "Exit"); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_FOREGROUND, true, fixedText_Exit); if (mousePos.x > 140 && mousePos.x < 170 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) && talk._moreTalkUp) - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, "Up"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, fixedText_Up); else if (talk._moreTalkUp) - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, true, "Up"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, true, fixedText_Up); if (mousePos.x > 181&& mousePos.x < 220 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) && talk._moreTalkDown) - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, "Down"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, fixedText_Down); else if (talk._moreTalkDown) - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, true, "Down"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, true, fixedText_Down); bool found = false; for (_selector = talk._talkIndex; _selector < (int)talk._statements.size() && !found; ++_selector) { @@ -1587,9 +1592,9 @@ void ScalpelUserInterface::doTalkControl() { screen.slamRect(Common::Rect(5, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH - 5, SHERLOCK_SCREEN_HEIGHT - 2)); } else if (_selector != -1) { - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, true, "Exit"); - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, true, "Up"); - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, true, "Down"); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, true, fixedText_Exit); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, true, fixedText_Up); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, true, fixedText_Down); // If the reply is new, add it to the journal if (!talk._talkHistory[talk._converseNum][_selector]) { @@ -1686,9 +1691,9 @@ void ScalpelUserInterface::doTalkControl() { !talk._statements[select]._statement.hasPrefix("^")) { // Not a reply first file, so display the new selections if (_endKeyActive) - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_FOREGROUND, true, "Exit"); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_FOREGROUND, true, fixedText_Exit); else - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, true, "Exit"); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, true, fixedText_Exit); talk.displayTalk(true); events.setCursor(ARROW); diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index 3c12d84aa4..fe92ff227f 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -33,6 +33,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam _animation = nullptr; _debugger = nullptr; _events = nullptr; + _fixedText = nullptr; _inventory = nullptr; _journal = nullptr; _map = nullptr; @@ -56,6 +57,7 @@ SherlockEngine::~SherlockEngine() { delete _animation; delete _debugger; delete _events; + delete _fixedText; delete _journal; delete _map; delete _people; @@ -93,6 +95,7 @@ void SherlockEngine::initialize() { _animation = new Animation(this); _debugger = new Debugger(this); _events = new Events(this); + _fixedText = new FixedText(this); _inventory = new Inventory(this); _map = Map::init(this); _music = new Music(this, _mixer); diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h index 6e87c1c5ef..f06ee5e30a 100644 --- a/engines/sherlock/sherlock.h +++ b/engines/sherlock/sherlock.h @@ -35,6 +35,7 @@ #include "sherlock/animation.h" #include "sherlock/debugger.h" #include "sherlock/events.h" +#include "sherlock/fixed_text.h" #include "sherlock/inventory.h" #include "sherlock/journal.h" #include "sherlock/map.h" @@ -107,6 +108,7 @@ public: Animation *_animation; Debugger *_debugger; Events *_events; + FixedText *_fixedText; Inventory *_inventory; Journal *_journal; Map *_map; diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index c298b87ac7..c800881da8 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -133,6 +133,7 @@ Talk::Talk(SherlockEngine *vm) : _vm(vm) { void Talk::talkTo(const Common::String &filename) { Events &events = *_vm->_events; + FixedText &fixedText = *_vm->_fixedText; Inventory &inv = *_vm->_inventory; Journal &journal = *_vm->_journal; People &people = *_vm->_people; @@ -390,10 +391,11 @@ void Talk::talkTo(const Common::String &filename) { // If the window is already open, simply draw. Otherwise, do it // to the back buffer and then summon the window + Common::String fixedText_Exit = fixedText.getText(kFixedText_Window_Exit); if (ui._windowOpen) { - screen.buttonPrint(Common::Point(119, CONTROLS_Y), color, true, "Exit"); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), color, true, fixedText_Exit); } else { - screen.buttonPrint(Common::Point(119, CONTROLS_Y), color, false, "Exit"); + screen.buttonPrint(Common::Point(119, CONTROLS_Y), color, false, fixedText_Exit); if (!ui._slideWindows) { screen.slamRect(Common::Rect(0, CONTROLS_Y, @@ -632,6 +634,7 @@ void Talk::setTalkMap() { } void Talk::drawInterface() { + FixedText &fixedText = *_vm->_fixedText; Screen &screen = *_vm->_screen; Surface &bb = *screen._backBuffer; @@ -645,12 +648,16 @@ void Talk::drawInterface() { SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); if (_talkTo != -1) { + Common::String fixedText_Exit = fixedText.getText(kFixedText_Window_Exit); + Common::String fixedText_Up = fixedText.getText(kFixedText_Window_Up); + Common::String fixedText_Down = fixedText.getText(kFixedText_Window_Down); + screen.makeButton(Common::Rect(99, CONTROLS_Y, 139, CONTROLS_Y + 10), - 119 - screen.stringWidth("Exit") / 2, "Exit"); + 119 - screen.stringWidth(fixedText_Exit) / 2, fixedText_Exit); screen.makeButton(Common::Rect(140, CONTROLS_Y, 180, CONTROLS_Y + 10), - 159 - screen.stringWidth("Up") / 2, "Up"); + 159 - screen.stringWidth(fixedText_Up) / 2, fixedText_Up); screen.makeButton(Common::Rect(181, CONTROLS_Y, 221, CONTROLS_Y + 10), - 200 - screen.stringWidth("Down") / 2, "Down"); + 200 - screen.stringWidth(fixedText_Down) / 2, fixedText_Down); } else { int strWidth = screen.stringWidth(Scalpel::PRESS_KEY_TO_CONTINUE); screen.makeButton(Common::Rect(46, CONTROLS_Y, 273, CONTROLS_Y + 10), @@ -660,6 +667,7 @@ void Talk::drawInterface() { } bool Talk::displayTalk(bool slamIt) { + FixedText &fixedText = *_vm->_fixedText; Screen &screen = *_vm->_screen; int yp = CONTROLS_Y + 14; int lineY = -1; @@ -677,20 +685,22 @@ bool Talk::displayTalk(bool slamIt) { } // Display the up arrow and enable Up button if the first option is scrolled off-screen + Common::String fixedText_Up = fixedText.getText(kFixedText_Window_Up); + Common::String fixedText_Down = fixedText.getText(kFixedText_Window_Down); if (_moreTalkUp) { if (slamIt) { screen.print(Common::Point(5, CONTROLS_Y + 13), INV_FOREGROUND, "~"); - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, true, "Up"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, true, fixedText_Up); } else { screen.gPrint(Common::Point(5, CONTROLS_Y + 12), INV_FOREGROUND, "~"); - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, false, "Up"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, false, fixedText_Up); } } else { if (slamIt) { - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, true, "Up"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, true, fixedText_Up); screen.vgaBar(Common::Rect(5, CONTROLS_Y + 11, 15, CONTROLS_Y + 22), INV_BACKGROUND); } else { - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, false, "Up"); + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_NULL, false, fixedText_Up); screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, 15, CONTROLS_Y + 22), INV_BACKGROUND); } @@ -725,17 +735,17 @@ bool Talk::displayTalk(bool slamIt) { if (slamIt) { screen.print(Common::Point(5, 190), INV_FOREGROUND, "|"); - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, true, "Down"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, true, fixedText_Down); } else { screen.gPrint(Common::Point(5, 189), INV_FOREGROUND, "|"); - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, false, "Down"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, false, fixedText_Down); } } else { if (slamIt) { - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, true, "Down"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, true, fixedText_Down); screen.vgaBar(Common::Rect(5, 189, 16, 199), INV_BACKGROUND); } else { - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, false, "Down"); + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_NULL, false, fixedText_Down); screen._backBuffer1.fillRect(Common::Rect(5, 189, 16, 199), INV_BACKGROUND); } } |