[Scummvm-cvs-logs] scummvm master -> f0c0fd5922fbad5cfb577abe885c9b8e1ac56174

dreammaster dreammaster at scummvm.org
Wed Jun 24 01:02:38 CEST 2015


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:
f0c0fd5922 SHERLOCK: RT: Implement message box ui mode


Commit: f0c0fd5922fbad5cfb577abe885c9b8e1ac56174
    https://github.com/scummvm/scummvm/commit/f0c0fd5922fbad5cfb577abe885c9b8e1ac56174
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-06-23T19:01:41-04:00

Commit Message:
SHERLOCK: RT: Implement message box ui mode

Changed paths:
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h
    engines/sherlock/tattoo/widget_text.cpp
    engines/sherlock/tattoo/widget_text.h



diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 01b0b63..f81ea4c 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -618,7 +618,22 @@ void TattooUserInterface::doTalkControl() {
 }
 
 void TattooUserInterface::doMessageControl() {
-	warning("TODO: ui control (message)");
+	Events &events = *_vm->_events;
+	--_menuCounter;
+
+	// Check if a mouse or keypress has occurred, or the display counter has expired
+	if (events._pressed || events._released || events._rightPressed || events._rightReleased ||
+			_keyState.keycode || !_menuCounter) {
+		// Close the window
+		banishWindow();
+
+		// Reset cursor and switch back to standard mode
+		events.setCursor(ARROW);
+		events.clearEvents();
+		_key = -1;
+		_oldBgFound = -1;
+		_menuMode = STD_MODE;
+	}
 }
 
 void TattooUserInterface::doLabControl() {
@@ -675,8 +690,26 @@ void TattooUserInterface::freeMenu() {
 	}
 }
 
-void TattooUserInterface::putMessage(const Common::String &str) {
-	// TODO
+void TattooUserInterface::putMessage(const char *formatStr, ...) {
+	Events &events = *_vm->_events;
+	Screen &screen = *_vm->_screen;
+	Common::Point mousePos = events.mousePos();
+
+	// Create the string to display
+	va_list args;
+	va_start(args, formatStr);
+	Common::String str = Common::String::vformat(formatStr, args);
+	va_end(args);
+
+	// Calculate display bounds and load a text window
+	Common::Rect r(screen.stringWidth(str) + screen.widestChar() * 2 + 6, screen.fontHeight() + 10);
+	r.moveTo(mousePos.x - r.width() / 2, mousePos.y - r.height() / 2);
+	_textWidget.load(str, r);
+	_textWidget.summonWindow();
+
+	_menuMode = MESSAGE_MODE;
+	events._pressed = events._released = events._rightReleased = false;
+	_menuCounter = 25;
 }
 
 void TattooUserInterface::setupBGArea(const byte cMap[PALETTE_SIZE]) {
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index bb9e1d9..44ba7ca 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -198,7 +198,10 @@ public:
 	 */
 	void pickUpObject(int objNum);
 
-	void putMessage(const Common::String &str);
+	/**
+	 * This will display a text message in a dialog at the bottom of the screen
+	 */
+	void putMessage(const char *formatStr, ...) GCC_PRINTF(2, 3);
 
 	/**
 	 * Makes a greyscale translation table for each palette entry in the table
diff --git a/engines/sherlock/tattoo/widget_text.cpp b/engines/sherlock/tattoo/widget_text.cpp
index 58eade1..44680da 100644
--- a/engines/sherlock/tattoo/widget_text.cpp
+++ b/engines/sherlock/tattoo/widget_text.cpp
@@ -71,6 +71,12 @@ void WidgetText::load(const Common::String &str) {
 		_remainingText = splitLines(str, lines, _bounds.width() - _surface.widestChar() * 2, 
 			(_bounds.height() - _surface.fontHeight() / 2) / (_surface.fontHeight() + 1));
 	}
+}
+
+void WidgetText::load(const Common::String &str, const Common::Rect &bounds) {
+	Common::StringArray lines;
+	_remainingText = splitLines(str, lines, bounds.width() - _surface.widestChar() * 2,
+		bounds.height() / (_surface.fontHeight() + 1));
 
 	// Allocate a surface for the window
 	_surface.create(_bounds.width(), _bounds.height());
diff --git a/engines/sherlock/tattoo/widget_text.h b/engines/sherlock/tattoo/widget_text.h
index 2608d75..c213f2d 100644
--- a/engines/sherlock/tattoo/widget_text.h
+++ b/engines/sherlock/tattoo/widget_text.h
@@ -40,6 +40,8 @@ public:
 	virtual ~WidgetText() {}
 
 	void load(const Common::String &str);
+
+	void load(const Common::String &str, const Common::Rect &bounds);
 };
 
 } // End of namespace Tattoo






More information about the Scummvm-git-logs mailing list