[Scummvm-cvs-logs] scummvm master -> 9257597160bf70b6c7e323d27f3f8b6a47daa182

m-kiewitz m_kiewitz at users.sourceforge.net
Sat Jan 30 16:23:47 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9257597160 SHERLOCK: SS: make inventory hotkeys multilingual


Commit: 9257597160bf70b6c7e323d27f3f8b6a47daa182
    https://github.com/scummvm/scummvm/commit/9257597160bf70b6c7e323d27f3f8b6a47daa182
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-01-30T16:23:23+01:00

Commit Message:
SHERLOCK: SS: make inventory hotkeys multilingual

Changed paths:
    engines/sherlock/scalpel/scalpel_fixed_text.cpp
    engines/sherlock/scalpel/scalpel_inventory.cpp
    engines/sherlock/scalpel/scalpel_inventory.h
    engines/sherlock/scalpel/scalpel_screen.cpp
    engines/sherlock/scalpel/scalpel_user_interface.cpp
    engines/sherlock/scalpel/scalpel_user_interface.h



diff --git a/engines/sherlock/scalpel/scalpel_fixed_text.cpp b/engines/sherlock/scalpel/scalpel_fixed_text.cpp
index d2bbf4f..7d0faf3 100644
--- a/engines/sherlock/scalpel/scalpel_fixed_text.cpp
+++ b/engines/sherlock/scalpel/scalpel_fixed_text.cpp
@@ -33,10 +33,10 @@ static const char *const fixedTextEN[] = {
 	"Up",
 	"Down",
 	// SH1: Inventory buttons
-	"Exit",
-	"Look",
-	"Use",
-	"Give",
+	"EExit",
+	"LLook",
+	"UUse",
+	"GGive",
 	// SH1: Journal text
 	"Watson's Journal",
 	"Page %d",
@@ -178,10 +178,10 @@ static const char *const fixedTextDE[] = {
 	"Hoch",
 	"Runter",
 	// SH1: Inventory buttons
-	"Zur\201ck",
-	"Schau",
-	"Benutze",
-	"Gib",
+	"ZZur\201ck",
+	"SSchau",
+	"BBenutze",
+	"GGib",
 	// SH1: Journal text
 	"Watsons Tagebuch",
 	"Seite %d",
@@ -322,10 +322,10 @@ static const char *const fixedTextES[] = {
 	"Subir",
 	"Bajar",
 	// SH1: Inventory buttons
-	"Salir", // original interpreter: "Exit"
-	"Mirar",
-	"Usar",
-	"Dar",
+	"SSalir", // original interpreter: "Exit"
+	"MMirar",
+	"UUsar",
+	"DDar",
 	// SH1: Journal text
 	"Diario de Watson",
 	"Pagina %d",
diff --git a/engines/sherlock/scalpel/scalpel_inventory.cpp b/engines/sherlock/scalpel/scalpel_inventory.cpp
index 6cce32f..ec1ab3c 100644
--- a/engines/sherlock/scalpel/scalpel_inventory.cpp
+++ b/engines/sherlock/scalpel/scalpel_inventory.cpp
@@ -32,13 +32,39 @@ namespace Scalpel {
 
 ScalpelInventory::ScalpelInventory(SherlockEngine *vm) : Inventory(vm) {
 	_invShapes.resize(6);
+
+	_fixedTextExit = FIXED(Inventory_Exit);
+	_fixedTextLook = FIXED(Inventory_Look);
+	_fixedTextUse  = FIXED(Inventory_Use);
+	_fixedTextGive = FIXED(Inventory_Give);
+
+	_hotkeyExit = toupper(_fixedTextExit[0]);
+	_hotkeyLook = toupper(_fixedTextLook[0]);
+	_hotkeyUse = toupper(_fixedTextUse[0]);
+	_hotkeyGive = toupper(_fixedTextGive[0]);
+
+	_hotkeysIndexed[0] = _hotkeyExit;
+	_hotkeysIndexed[1] = _hotkeyLook;
+	_hotkeysIndexed[2] = _hotkeyUse;
+	_hotkeysIndexed[3] = _hotkeyGive;
+	_hotkeysIndexed[4] = '-';
+	_hotkeysIndexed[5] = '+';
+	_hotkeysIndexed[6] = ',';
+	_hotkeysIndexed[7] = '.';
 }
 
 ScalpelInventory::~ScalpelInventory() {
 }
 
+int ScalpelInventory::identifyUserButton(int key) {
+	for (uint16 hotkeyNr = 0; hotkeyNr < sizeof(_hotkeysIndexed); hotkeyNr++) {
+		if (key == _hotkeysIndexed[hotkeyNr])
+			return hotkeyNr;
+	}
+	return -1;
+}
+
 void ScalpelInventory::drawInventory(InvNewMode mode) {
-	FixedText &fixedText = *_vm->_fixedText;
 	ScalpelScreen &screen = *(ScalpelScreen *)_vm->_screen;
 	UserInterface &ui = *_vm->_ui;
 	InvNewMode tempMode = mode;
@@ -61,19 +87,14 @@ void ScalpelInventory::drawInventory(InvNewMode mode) {
 		INV_BACKGROUND);
 
 	// Draw the buttons
-	Common::String fixedText_Exit = fixedText.getText(kFixedText_Inventory_Exit);
-	Common::String fixedText_Look = fixedText.getText(kFixedText_Inventory_Look);
-	Common::String fixedText_Use  = fixedText.getText(kFixedText_Inventory_Use);
-	Common::String fixedText_Give = fixedText.getText(kFixedText_Inventory_Give);
-
 	screen.makeButton(Common::Rect(INVENTORY_POINTS[0][0], CONTROLS_Y1, INVENTORY_POINTS[0][1],
-		CONTROLS_Y1 + 10), INVENTORY_POINTS[0][2], fixedText_Exit);
+		CONTROLS_Y1 + 10), INVENTORY_POINTS[0][2], _fixedTextExit, true);
 	screen.makeButton(Common::Rect(INVENTORY_POINTS[1][0], CONTROLS_Y1, INVENTORY_POINTS[1][1],
-		CONTROLS_Y1 + 10), INVENTORY_POINTS[1][2], fixedText_Look);
+		CONTROLS_Y1 + 10), INVENTORY_POINTS[1][2], _fixedTextLook, true);
 	screen.makeButton(Common::Rect(INVENTORY_POINTS[2][0], CONTROLS_Y1, INVENTORY_POINTS[2][1],
-		CONTROLS_Y1 + 10), INVENTORY_POINTS[2][2], fixedText_Use);
+		CONTROLS_Y1 + 10), INVENTORY_POINTS[2][2], _fixedTextUse, true);
 	screen.makeButton(Common::Rect(INVENTORY_POINTS[3][0], CONTROLS_Y1, INVENTORY_POINTS[3][1],
-		CONTROLS_Y1 + 10), INVENTORY_POINTS[3][2], fixedText_Give);
+		CONTROLS_Y1 + 10), INVENTORY_POINTS[3][2], _fixedTextGive, true);
 	screen.makeButton(Common::Rect(INVENTORY_POINTS[4][0], CONTROLS_Y1, INVENTORY_POINTS[4][1],
 		CONTROLS_Y1 + 10), INVENTORY_POINTS[4][2] + 8, "^^"); // 2 arrows pointing to the left
 	screen.makeButton(Common::Rect(INVENTORY_POINTS[5][0], CONTROLS_Y1, INVENTORY_POINTS[5][1],
@@ -88,7 +109,8 @@ void ScalpelInventory::drawInventory(InvNewMode mode) {
 	_invMode = (InvMode)((int)mode);
 
 	if (mode != PLAIN_INVENTORY) {
-		ui._oldKey = INVENTORY_COMMANDS[(int)mode];
+		assert(mode < sizeof(_hotkeysIndexed));
+		ui._oldKey = _hotkeysIndexed[mode];
 	} else {
 		ui._oldKey = -1;
 	}
@@ -114,28 +136,22 @@ void ScalpelInventory::drawInventory(InvNewMode mode) {
 }
 
 void ScalpelInventory::invCommands(bool slamIt) {
-	FixedText &fixedText = *_vm->_fixedText;
 	ScalpelScreen &screen = *(ScalpelScreen *)_vm->_screen;
 	UserInterface &ui = *_vm->_ui;
 
-	Common::String fixedText_Exit = fixedText.getText(kFixedText_Inventory_Exit);
-	Common::String fixedText_Look = fixedText.getText(kFixedText_Inventory_Look);
-	Common::String fixedText_Use  = fixedText.getText(kFixedText_Inventory_Use);
-	Common::String fixedText_Give = fixedText.getText(kFixedText_Inventory_Give);
-
 	if (slamIt) {
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1),
 			_invMode == INVMODE_EXIT ? COMMAND_HIGHLIGHTED :COMMAND_FOREGROUND,
-			true, fixedText_Exit);
+			true, _fixedTextExit, true);
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1),
 			_invMode == INVMODE_LOOK ? COMMAND_HIGHLIGHTED :COMMAND_FOREGROUND,
-			true, fixedText_Look);
+			true, _fixedTextLook, true);
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1),
 			_invMode == INVMODE_USE ? COMMAND_HIGHLIGHTED : COMMAND_FOREGROUND,
-			true, fixedText_Use);
+			true, _fixedTextUse, true);
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1),
 			_invMode == INVMODE_GIVE ? COMMAND_HIGHLIGHTED : COMMAND_FOREGROUND,
-			true, fixedText_Give);
+			true, _fixedTextGive, true);
 		screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1),
 			_invIndex == 0 ? COMMAND_NULL : COMMAND_FOREGROUND,
 			"^^"); // 2 arrows pointing to the left
@@ -153,16 +169,16 @@ void ScalpelInventory::invCommands(bool slamIt) {
 	} else {
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1),
 			_invMode == INVMODE_EXIT ? COMMAND_HIGHLIGHTED : COMMAND_FOREGROUND,
-			false, fixedText_Exit);
+			false, _fixedTextExit, true);
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1),
 			_invMode == INVMODE_LOOK ? COMMAND_HIGHLIGHTED : COMMAND_FOREGROUND,
-			false, fixedText_Look);
+			false, _fixedTextLook, true);
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1),
 			_invMode == INVMODE_USE ? COMMAND_HIGHLIGHTED : COMMAND_FOREGROUND,
-			false, fixedText_Use);
+			false, _fixedTextUse, true);
 		screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1),
 			_invMode == INVMODE_GIVE ? COMMAND_HIGHLIGHTED : COMMAND_FOREGROUND,
-			false, fixedText_Give);
+			false, _fixedTextGive, true);
 		screen.gPrint(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1),
 			_invIndex == 0 ? COMMAND_NULL : COMMAND_FOREGROUND,
 			"^^"); // 2 arrows pointing to the left
diff --git a/engines/sherlock/scalpel/scalpel_inventory.h b/engines/sherlock/scalpel/scalpel_inventory.h
index afafb0b..49d0555 100644
--- a/engines/sherlock/scalpel/scalpel_inventory.h
+++ b/engines/sherlock/scalpel/scalpel_inventory.h
@@ -34,6 +34,18 @@ public:
 	ScalpelInventory(SherlockEngine *vm);
 	~ScalpelInventory();
 
+	Common::String _fixedTextExit;
+	Common::String _fixedTextLook;
+	Common::String _fixedTextUse;
+	Common::String _fixedTextGive;
+
+	byte _hotkeyExit;
+	byte _hotkeyLook;
+	byte _hotkeyUse;
+	byte _hotkeyGive;
+
+	byte _hotkeysIndexed[8];
+
 	/**
 	 * Put the game into inventory mode and open the interface window.
 	 */
@@ -65,6 +77,11 @@ public:
 	 * and then calls loadGraphics to load the associated graphics
 	 */
 	virtual void loadInv();
+
+	/**
+	 * Identifies a button number according to the key, that the user pressed
+	 */
+	int identifyUserButton(int key);
 };
 
 } // End of namespace Scalpel
diff --git a/engines/sherlock/scalpel/scalpel_screen.cpp b/engines/sherlock/scalpel/scalpel_screen.cpp
index 433d773..18aa56f 100644
--- a/engines/sherlock/scalpel/scalpel_screen.cpp
+++ b/engines/sherlock/scalpel/scalpel_screen.cpp
@@ -62,12 +62,13 @@ void ScalpelScreen::buttonPrint(const Common::Point &pt, uint color, bool slamIt
 		// Hotkey needs to be highlighted
 		if (textContainsHotkey) {
 			Common::String prefixText = Common::String(str.c_str() + 1);
+			uint16 prefixTextLen = prefixText.size();
 			uint16 prefixTextPos = 0;
 
 			// Hotkey was passed additionally, we search for the hotkey inside the button text and
 			// remove it from there. We then draw the whole text as highlighted and afterward
 			// the processed text again as regular text (without the hotkey)
-			while (prefixTextPos < prefixText.size()) {
+			while (prefixTextPos < prefixTextLen) {
 				if (prefixText[prefixTextPos] == hotkey) {
 					// Hotkey found, remove remaining text
 					while (prefixTextPos < prefixText.size()) {
@@ -78,7 +79,7 @@ void ScalpelScreen::buttonPrint(const Common::Point &pt, uint color, bool slamIt
 				prefixTextPos++;
 			}
 
-			if (prefixTextPos < prefixText.size()) {
+			if (prefixTextPos < prefixTextLen) {
 				// only adjust in case hotkey character was actually found
 				prefixOffsetX = stringWidth(prefixText);
 			}
diff --git a/engines/sherlock/scalpel/scalpel_user_interface.cpp b/engines/sherlock/scalpel/scalpel_user_interface.cpp
index 2ed4971..3a64178 100644
--- a/engines/sherlock/scalpel/scalpel_user_interface.cpp
+++ b/engines/sherlock/scalpel/scalpel_user_interface.cpp
@@ -66,7 +66,6 @@ const int INVENTORY_POINTS[8][3] = {
 
 const char COMMANDS[13] = "LMTPOCIUGJFS";
 const char COMMANDS_3DO[13] = "LMTPOCIUGSFF";
-const char INVENTORY_COMMANDS[9] = { "ELUG-+,." };
 const int UI_OFFSET_3DO = 16;	// (320 - 288) / 2
 
 /*----------------------------------------------------------------*/
@@ -980,7 +979,6 @@ void ScalpelUserInterface::doEnvControl() {
 
 void ScalpelUserInterface::doInvControl() {
 	Events &events = *_vm->_events;
-	FixedText &fixedText = *_vm->_fixedText;
 	ScalpelInventory &inv = *(ScalpelInventory *)_vm->_inventory;
 	Scene &scene = *_vm->_scene;
 	ScalpelScreen &screen = *(ScalpelScreen *)_vm->_screen;
@@ -1006,20 +1004,15 @@ void ScalpelUserInterface::doInvControl() {
 	if (events._pressed || events._released) {
 		events.clearKeyboard();
 
-		Common::String fixedText_Exit = fixedText.getText(kFixedText_Inventory_Exit);
-		Common::String fixedText_Look = fixedText.getText(kFixedText_Inventory_Look);
-		Common::String fixedText_Use  = fixedText.getText(kFixedText_Inventory_Use);
-		Common::String fixedText_Give = fixedText.getText(kFixedText_Inventory_Give);
-
 		if (found != -1)
 			// If a slot highlighted, set its color
 			colors[found] = COMMAND_HIGHLIGHTED;
-		screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), colors[0], true, fixedText_Exit);
+		screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), colors[0], true, inv._fixedTextExit);
 
 		if (found >= 0 && found <= 3) {
-			screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, fixedText_Look);
-			screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[2], true, fixedText_Use);
-			screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[3], true, fixedText_Give);
+			screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, inv._fixedTextLook);
+			screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[2], true, inv._fixedTextUse);
+			screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[3], true, inv._fixedTextGive);
 			inv._invMode = (InvMode)found;
 			_selector = -1;
 		}
@@ -1053,19 +1046,19 @@ void ScalpelUserInterface::doInvControl() {
 
 		if (_key == Common::KEYCODE_ESCAPE)
 			// Escape will also 'E'xit out of inventory display
-			_key = 'E';
+			_key = inv._hotkeyExit;
+
+		int buttonIndex = inv.identifyUserButton(_key);
 
-		if (_key == 'E' || _key == 'L' || _key == 'U' || _key == 'G'
-				|| _key == '-' || _key == '+') {
+		if ((buttonIndex >= 0) && (buttonIndex <= 5)) {
 			InvMode temp = inv._invMode;
 
-			const char *chP = strchr(INVENTORY_COMMANDS, _key);
-			inv._invMode = !chP ? INVMODE_INVALID : (InvMode)(chP - INVENTORY_COMMANDS);
+			inv._invMode = (InvMode)buttonIndex;
 			inv.invCommands(true);
 
 			inv._invMode = temp;
 			_keyboardInput = true;
-			if (_key == 'E')
+			if (_key == inv._hotkeyExit)
 				inv._invMode = INVMODE_EXIT;
 			_selector = -1;
 		} else {
@@ -1087,7 +1080,7 @@ void ScalpelUserInterface::doInvControl() {
 	}
 
 	if (events._released || _keyboardInput) {
-		if ((found == 0 && events._released) || _key == 'E') {
+		if ((found == 0 && events._released) || _key == inv._hotkeyExit) {
 			inv.freeInv();
 			_infoFlag = true;
 			clearInfo();
@@ -1095,11 +1088,11 @@ void ScalpelUserInterface::doInvControl() {
 			_key = -1;
 			events.clearEvents();
 			events.setCursor(ARROW);
-		} else if ((found == 1 && events._released) || (_key == 'L')) {
+		} else if ((found == 1 && events._released) || (_key == inv._hotkeyLook)) {
 			inv._invMode = INVMODE_LOOK;
-		} else if ((found == 2 && events._released) || (_key == 'U')) {
+		} else if ((found == 2 && events._released) || (_key == inv._hotkeyUse)) {
 			inv._invMode = INVMODE_USE;
-		} else if ((found == 3 && events._released) || (_key == 'G')) {
+		} else if ((found == 3 && events._released) || (_key == inv._hotkeyGive)) {
 			inv._invMode = INVMODE_GIVE;
 		} else if (((found == 4 && events._released) || _key == ',') && inv._invIndex) {
 			if (inv._invIndex >= 6)
diff --git a/engines/sherlock/scalpel/scalpel_user_interface.h b/engines/sherlock/scalpel/scalpel_user_interface.h
index 8c2f3f9..c8ecefb 100644
--- a/engines/sherlock/scalpel/scalpel_user_interface.h
+++ b/engines/sherlock/scalpel/scalpel_user_interface.h
@@ -38,7 +38,6 @@ extern const char COMMANDS_3DO[13];
 extern const int MENU_POINTS[12][4];
 
 extern const int INVENTORY_POINTS[8][3];
-extern const char INVENTORY_COMMANDS[9];
 
 class Settings;
 






More information about the Scummvm-git-logs mailing list