[Scummvm-git-logs] scummvm master -> 6392a3df4db6a8f2fac2801a250deabd01e04d82

kelmer44 noreply at scummvm.org
Mon Oct 6 20:15:08 UTC 2025


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

Summary:
6392a3df4d TOT: Fixes caret issues in original save/load screen


Commit: 6392a3df4db6a8f2fac2801a250deabd01e04d82
    https://github.com/scummvm/scummvm/commit/6392a3df4db6a8f2fac2801a250deabd01e04d82
Author: kelmer (kelmer at gmail.com)
Date: 2025-10-06T22:14:39+02:00

Commit Message:
TOT: Fixes caret issues in original save/load screen

Changed paths:
    engines/tot/engine.cpp
    engines/tot/events.cpp
    engines/tot/events.h
    engines/tot/graphics.cpp
    engines/tot/graphics.h
    engines/tot/saveload.cpp
    engines/tot/tot.h


diff --git a/engines/tot/engine.cpp b/engines/tot/engine.cpp
index 57bb7127148..dbdd435908b 100644
--- a/engines/tot/engine.cpp
+++ b/engines/tot/engine.cpp
@@ -4823,6 +4823,15 @@ void TotEngine::readAlphaGraph(Common::String &output, int length, int posx, int
 	}
 }
 
+bool getEvent(Common::Event &e, Common::Event &firstEvent) {
+	if (firstEvent.type != Common::EVENT_INVALID) {
+		e = firstEvent;
+		firstEvent.type = Common::EVENT_INVALID;
+		return true;
+	}
+	return g_system->getEventManager()->pollEvent(e);
+}
+
 void TotEngine::readAlphaGraphSmall(
 	Common::String &output,
 	int length,
@@ -4830,26 +4839,17 @@ void TotEngine::readAlphaGraphSmall(
 	int posy,
 	byte barColor,
 	byte textColor,
-	char startChar) {
+	Common::Event event) {
 	int pun = 1;
 	bool removeCaret = false;
-	if (startChar != 0) {
-		output.append(1, startChar);
-
-		pun += 1;
-		bar(posx, (posy + 2), (posx + length * 6), (posy + 9), barColor);
-		euroText(posx, posy, output, textColor);
-		euroText((posx + (output.size()) * 6), posy, "-", textColor);
-		removeCaret = true;
-	}
-	else {
-		bar(posx, posy + 2, posx + length * 6, posy + 9, barColor);
-		euroText(posx, posy, "-", textColor);
-	}
+
+	output = "";
+	bar(posx, posy + 2, posx + length * 6, posy + 9, barColor);
+	euroText(posx, posy, "-", textColor);
 	Common::Event e;
 	bool done = false;
 	while (!done && !shouldQuit()) {
-		while (g_system->getEventManager()->pollEvent(e)) {
+		while (getEvent(e, event)) {
 			if (e.type == Common::EVENT_KEYDOWN) {
 				int keycode = e.kbd.keycode;
 				int asciiCode = e.kbd.ascii;
@@ -4858,18 +4858,19 @@ void TotEngine::readAlphaGraphSmall(
 				if (keycode == Common::KEYCODE_RETURN || keycode == Common::KEYCODE_KP_ENTER) {
 					if (output.size() > 0) {
 						done = true;
+						removeCaret = true;
 						continue;
 					}
 				}
 				if (pun > length && asciiCode != 8) {
 					_sound->beep(750, 60);
-					bar((posx + (output.size()) * 6), (posy + 2), (posx + (output.size() + 1) * 6), (posy + 9), barColor);
+					bar((posx + (output.size()) * 6), (posy + 2), (posx + (output.size() + 1) * 6), (posy + 10), barColor);
 				} else if (asciiCode == 8 && pun > 1) {
 					output = output.substr(0, output.size() - 1);
 
-					bar(posx, (posy + 2), (posx + length * 6), (posy + 9), barColor);
+					bar(posx, (posy + 2), (posx + length * 6), (posy + 10), barColor);
 					euroText(posx, posy, output, textColor);
-					euroText((posx + (output.size()) * 6), posy, "-", textColor);
+					euroText(posx + _graphics->euroTextWidth(output), posy, "-", textColor);
 					pun -= 1;
 					removeCaret = true;
 				} else if (
@@ -4885,7 +4886,8 @@ void TotEngine::readAlphaGraphSmall(
 
 					bar(posx, (posy + 2), (posx + length * 6), (posy + 9), barColor);
 					euroText(posx, posy, output, textColor);
-					euroText((posx + (output.size()) * 6), posy, "-", textColor);
+
+					euroText(posx + _graphics->euroTextWidth(output), posy, "-", textColor);
 					removeCaret = true;
 				}
 			}
@@ -4895,8 +4897,9 @@ void TotEngine::readAlphaGraphSmall(
 		_screen->update();
 	}
 
-	if (removeCaret)
-		bar(posx + (output.size()) * 6, posy + 2, (posx + (output.size()) * 6) + 6, posy + 9, barColor);
+	if (removeCaret) {
+		bar(posx + _graphics->euroTextWidth(output), posy + 2, (posx + _graphics->euroTextWidth(output)) + 6, posy + 9, barColor);
+	}
 }
 
 void TotEngine::displayObjectDescription(const Common::String &textString) {
diff --git a/engines/tot/events.cpp b/engines/tot/events.cpp
index af2ecbf7304..1d8a73d579b 100644
--- a/engines/tot/events.cpp
+++ b/engines/tot/events.cpp
@@ -54,11 +54,9 @@ void TotEventManager::pollEvent(bool allowDrag) {
 		case Common::EVENT_KEYDOWN:
 			changeGameSpeed(_event);
 			_keyPressed = true;
-			_lastChar = _event.kbd.ascii;
-			// _keyState[(byte)toupper(_event.kbd.ascii)] = true;
+			_lastKeyEvent = _event;
 			return;
 		case Common::EVENT_KEYUP:
-			// _keyState[(byte)toupper(_event.kbd.ascii)] = false;
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mouseX = _event.mouse.x;
@@ -94,7 +92,7 @@ void TotEventManager::zeroEvents(bool allowDrag) {
 	_escKeyFl = false;
 	_gameKey = KEY_NONE;
 	_keyPressed = 0;
-	_lastChar = '\0';
+	_lastKeyEvent = Common::Event();
 }
 
 void TotEventManager::waitForPress() {
diff --git a/engines/tot/events.h b/engines/tot/events.h
index e9455c41bf5..ff8d6c201df 100644
--- a/engines/tot/events.h
+++ b/engines/tot/events.h
@@ -54,7 +54,7 @@ public:
 	bool _rightMouseButton = 0;
 	int16 _mouseX = 0;
 	int16 _mouseY = 0;
-	uint16 _lastChar = '\0';
+	Common::Event _lastKeyEvent;
 
 	TotEventManager();
 
diff --git a/engines/tot/graphics.cpp b/engines/tot/graphics.cpp
index a1960639b6f..b514930ea10 100644
--- a/engines/tot/graphics.cpp
+++ b/engines/tot/graphics.cpp
@@ -443,6 +443,10 @@ void GraphicsManager::euroText(const Common::String &str, int x, int y, uint32 c
 	_euro->drawString(g_engine->_screen, str, x, y, 320, color, align);
 }
 
+int GraphicsManager::euroTextWidth(const Common::String &str) {
+	return (int)_euro->getBoundingBox(str).width();
+}
+
 void GraphicsManager::biosText(const Common::String &str, int x, int y, uint32 color) {
 	_dosFont->drawString(g_engine->_screen, str, x, y, 320, color, Graphics::TextAlign::kTextAlignLeft);
 }
diff --git a/engines/tot/graphics.h b/engines/tot/graphics.h
index 64a931f36ca..7f017e019fc 100644
--- a/engines/tot/graphics.h
+++ b/engines/tot/graphics.h
@@ -57,6 +57,7 @@ public:
 
 	void littText(const Common::String &str, int x, int y, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool alignCenterY = false);
 	void euroText(const Common::String &str, int x, int y, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool alignCenterY = false);
+	int euroTextWidth(const Common::String &str);
 	void biosText(const Common::String &str, int x, int y, uint32 color);
 
 	void clear();
diff --git a/engines/tot/saveload.cpp b/engines/tot/saveload.cpp
index 7c6fa226e18..fdf3858ffc4 100644
--- a/engines/tot/saveload.cpp
+++ b/engines/tot/saveload.cpp
@@ -635,7 +635,7 @@ void TotEngine::originalSaveLoadScreen() {
 	do {
 		bool mouseClicked = false;
 		bool keyPressed = false;
-		char lastInputChar = '\0';
+		Common::Event lastKeyboardEvent = Common::Event();
 		do {
 			_chrono->updateChrono();
 			if (_chrono->_gameTick) {
@@ -646,7 +646,7 @@ void TotEngine::originalSaveLoadScreen() {
 				mouseClicked = true;
 			} else if (g_engine->_events->_keyPressed) {
 				keyPressed = true;
-				lastInputChar = g_engine->_events->_lastChar;
+				lastKeyboardEvent = g_engine->_events->_lastKeyEvent;
 			}
 
 			g_engine->_screen->update();
@@ -738,7 +738,7 @@ void TotEngine::originalSaveLoadScreen() {
 		if (keyPressed && _saveAllowed) {
 			_mouse->hide();
 			byte ytext = 29 + (selectedGame * 15);
-			readAlphaGraphSmall(saveName, 30, 65, ytext, 251, 254, lastInputChar);
+			readAlphaGraphSmall(saveName, 30, 65, ytext, 251, 254, lastKeyboardEvent);
 			modified = true;
 			_mouse->show();
 			keyPressed = false;
diff --git a/engines/tot/tot.h b/engines/tot/tot.h
index e5634473ae3..f73858d3fa0 100644
--- a/engines/tot/tot.h
+++ b/engines/tot/tot.h
@@ -157,7 +157,7 @@ private:
 	void introduction();
 	void firstIntroduction();
 	void readAlphaGraph(Common::String &data, int length, int x, int y, byte barColor);
-	void readAlphaGraphSmall(Common::String &data, int length, int x, int y, byte barColor, byte textColor, char startChar = '\0');
+	void readAlphaGraphSmall(Common::String &data, int length, int x, int y, byte barColor, byte textColor, Common::Event startEvent);
 	void displayObjectDescription(const Common::String &text);
 	void copyProtection();
 	void initialLogo();




More information about the Scummvm-git-logs mailing list