diff options
author | Paul Gilbert | 2015-06-23 19:01:41 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-06-23 19:01:41 -0400 |
commit | f0c0fd5922fbad5cfb577abe885c9b8e1ac56174 (patch) | |
tree | 8264eeec7ff6a1fa9f29c8c145b7d6ca8c820275 /engines | |
parent | 239784b13dd12c3f731312c5277dbc9fb0ab47ed (diff) | |
download | scummvm-rg350-f0c0fd5922fbad5cfb577abe885c9b8e1ac56174.tar.gz scummvm-rg350-f0c0fd5922fbad5cfb577abe885c9b8e1ac56174.tar.bz2 scummvm-rg350-f0c0fd5922fbad5cfb577abe885c9b8e1ac56174.zip |
SHERLOCK: RT: Implement message box ui mode
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.cpp | 39 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.h | 5 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_text.cpp | 6 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_text.h | 2 |
4 files changed, 48 insertions, 4 deletions
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp index 01b0b6386d..f81ea4cffb 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 bb9e1d91a2..44ba7caf96 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 58eade17b0..44680dab53 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 2608d75b32..c213f2da6d 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 |