From 73085bf57034adc2dbf5994ce2c6930b416eee7d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 23 Mar 2015 20:34:34 -0400 Subject: SHERLOCK: Beginnings of UserInterface class --- engines/sherlock/user_interface.cpp | 306 ++++++++++++++++++++++++++++++++++++ 1 file changed, 306 insertions(+) create mode 100644 engines/sherlock/user_interface.cpp (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp new file mode 100644 index 0000000000..d80aaecb54 --- /dev/null +++ b/engines/sherlock/user_interface.cpp @@ -0,0 +1,306 @@ +/* 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/user_interface.h" +#include "sherlock/sherlock.h" + +namespace Sherlock { + +// Main user interface menu control locations +const int MENU_POINTS[12][4] = { + { 13, 153, 72, 165 }, + { 13, 169, 72, 181 }, + { 13, 185, 72, 197 }, + { 88, 153, 152, 165 }, + { 88, 169, 152, 181 }, + { 88, 185, 152, 197 }, + { 165, 153, 232, 165 }, + { 165, 169, 232, 181 }, + { 165, 185, 233, 197 }, + { 249, 153, 305, 165 }, + { 249, 169, 305, 181 }, + { 249, 185, 305, 197 } +}; + +// Inventory control locations */ +const int INVENTORY_POINTS[8][3] = { + { 4, 50, 28 }, + { 52, 99, 76 }, + { 101, 140, 122 }, + { 142, 187, 165 }, + { 189, 219, 197 }, + { 221, 251, 233 }, + { 253, 283, 265 }, + { 285, 315, 293 } +}; + +const char COMMANDS[13] = "LMTPOCIUGJFS"; + +/*----------------------------------------------------------------*/ + +UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { + _bgFound = 0; + _oldBgFound = -1; + _keycode = Common::KEYCODE_INVALID; + _helpStyle = 0; + _menuCounter = 0; + _menuMode = STD_MODE; + _help = _oldHelp = 0; + _lookHelp = 0; + _key = _oldKey = 0; + _temp = _oldTemp = 0; + _invLookFlag = 0; + _windowOpen = false; + _oldLook = false; + _keyboardInput = false; + + _controls = nullptr; // new ImageFile("menu.all"); +} + +UserInterface::~UserInterface() { + delete _controls; +} + +void UserInterface::handleInput() { + Events &events = *_vm->_events; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + + if (_menuCounter) + whileMenuCounter(); + + Common::Point pt = events.mousePos(); + _bgFound = scene.findBgShape(Common::Rect(pt.x, pt.y, pt.x + 1, pt.y + 1)); + _keycode = Common::KEYCODE_INVALID; + + // Check kbd and set the mouse released flag if Enter or space is pressed. + // Otherwise, the pressed key is stored for later use + if (events.kbHit()) { + Common::KeyState keyState = events.getKey(); + + if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) { + _vm->quitGame(); + return; + } else if (keyState.keycode == Common::KEYCODE_SPACE || + keyState.keycode == Common::KEYCODE_RETURN) { + events._pressed = events._oldButtons = 0; + _keycode = Common::KEYCODE_INVALID; + } + } + + // Do button highlighting check + if (!_vm->_scriptMoreFlag) { // Don't if scripts are running + if (((events._rightPressed || events._rightReleased) && _helpStyle) || + (!_helpStyle && !_menuCounter)) { + // Handle any default commands if we're in STD_MODE + if (_menuMode == STD_MODE) { + if (pt.y < CONTROLS_Y && + (events._rightPressed || (!_helpStyle && !events._released)) && + (_bgFound != -1) && (_bgFound < 1000) && + (scene._bgShapes[_bgFound]._defaultCommand || + scene._bgShapes[_bgFound]._description[0])) { + // If there is no default command, so set it to Look + if (scene._bgShapes[_bgFound]._defaultCommand) + _help = scene._bgShapes[_bgFound]._defaultCommand - 1; + else + _help = 0; + + // Reset 'help' if it is an invalid command + if (_help > 5) + _help = -1; + } else if (pt.y < CONTROLS_Y && + ((events._rightReleased && _helpStyle) || (events._released && !_helpStyle)) && + (_bgFound != -1 && _bgFound < 1000) && + (scene._bgShapes[_bgFound]._defaultCommand || + scene._bgShapes[_bgFound]._description[0])) { + // If there is no default command, set it to Look + if (scene._bgShapes[_bgFound]._defaultCommand) + _menuMode = (MenuMode)scene._bgShapes[_bgFound]._defaultCommand; + else + _menuMode = LOOK_MODE; + events._released = true; + events._pressed = events._oldButtons = false; + _help = _oldHelp = -1; + + if (_menuMode == LOOK_MODE) { + // Set the flag to tell the game that this was a right-click + // call to look and should exit without the look button being pressed + _lookHelp = true; + } + } else { + _help = -1; + } + + // Check if highlighting a different button than last time + if (_help != _oldHelp) { + // If another button was highlighted previously, restore it + if (_oldHelp != -1) + restoreButton(_oldHelp); + + // If we're highlighting a new button, then draw it pressed + if (_help != -1) + depressButton(_help); + + _help = _oldHelp; + } + + if (_bgFound != _oldBgFound) { + _infoFlag = true; + clearInfo(); + + if (_help != -1 && (scene._bgShapes[_bgFound]._description[0] != 32 && + scene._bgShapes[_bgFound]._description[0])) + screen.print(Common::Point(0, INFO_LINE + 1), + INFO_FOREGROUND, INFO_BACKGROUND, "%s", + scene._bgShapes[_bgFound]._description); + } + } else { + // We're not in STD_MODE + // If there isn't a window open, then revert back to STD_MODE + if (!_windowOpen && events._rightReleased) { + // Restore all buttons + for (int idx = 0; idx < 12; ++idx) + restoreButton(idx); + + _menuMode = STD_MODE; + _key = _oldKey = -1; + _temp = _oldTemp = _lookHelp = _invLookFlag = 0; + events.clearEvents(); + } + } + } + } + + // TODO +} + +/** + * Draws the image for a user interface button in the down/pressed state. + */ +void UserInterface::depressButton(int num) { + Screen &screen = *_vm->_screen; + Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); + + Graphics::Surface &s = (*_controls)[num]._frame; + screen._backBuffer.transBlitFrom(s, pt); + screen.slamArea(pt.x, pt.y, pt.x + s.w, pt.y + s.h); +} + +/** + * Draws the image for the given user interface button in the up + * (not selected) position + */ +void UserInterface::restoreButton(int num) { + Screen &screen = *_vm->_screen; + Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); + + screen._backBuffer.blitFrom(screen._backBuffer2, pt, + Common::Rect(pt.x, pt.y, pt.x + 90, pt.y + 19)); + screen._backBuffer.blitFrom(screen._backBuffer, pt, + Common::Rect(pt.x, pt.y, pt.x + (*_controls)[num]._frame.w, + (*_controls)[num]._frame.h)); + + if (!_menuCounter) { + _infoFlag++; + clearInfo(); + } +} + +/** + * If he mouse button is pressed, then calls depressButton to draw the button + * as pressed; if not, it will show it as released with a call to "restoreButton". + */ +void UserInterface::pushButton(int num) { + Events &events = *_vm->_events; + _oldKey = -1; + + if (!events._released) { + if (_oldHelp != -1) + restoreButton(_oldHelp); + if (_help != -1) + restoreButton(_help); + + depressButton(num); + events.wait(6); + } + + restoreButton(num); +} + +/** + * By the time this method has been called, the graphics for the button change + * have already been drawn. This simply takes care of switching the mode around + * accordingly + */ +void UserInterface::toggleButton(int num) { + Screen &screen = *_vm->_screen; + + if (_menuMode != (num + 1)) { + _menuMode = (MenuMode)(num + 1); + _oldKey = COMMANDS[num]; + _oldTemp = num; + + if (_keyboardInput) { + if (_oldHelp != -1 && _oldHelp != num) + restoreButton(_oldHelp); + if (_help != -1 && _help != num) + restoreButton(_help); + + _keyboardInput = false; + + Graphics::Surface &s = (*_controls)[num]._frame; + Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); + screen._backBuffer.transBlitFrom(s, pt); + screen.slamArea(pt.x, pt.y, pt.x + s.w, pt.y + s.h); + } + } else { + _menuMode = STD_MODE; + _oldKey = -1; + restoreButton(num); + } +} + + +/** + * Clears the info line of the screen + */ +void UserInterface::clearInfo() { + if (_infoFlag) { + _vm->_screen->fillRect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 200, INFO_LINE + 9, + INFO_BLACK); + _infoFlag = false; + _oldLook = -1; + } +} + +/** + * Handles counting down whilst checking for input, then clears the info line. + */ +void UserInterface::whileMenuCounter() { + if (!(--_menuCounter) || _vm->_events->checkInput()) { + _menuCounter = 0; + ++_infoFlag; + clearInfo(); + } +} + +} // End of namespace Sherlock -- cgit v1.2.3 From 73de00b72f002c09c173226e85b0f96f35551d10 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 23 Mar 2015 21:52:20 -0400 Subject: SHERLOCK: Implemented UserInterface::handleInput --- engines/sherlock/user_interface.cpp | 185 +++++++++++++++++++++++++++++++++++- 1 file changed, 184 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index d80aaecb54..5ed5494c5e 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -72,6 +72,8 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _windowOpen = false; _oldLook = false; _keyboardInput = false; + _invMode = 0; + _pause = false; _controls = nullptr; // new ImageFile("menu.all"); } @@ -82,8 +84,10 @@ UserInterface::~UserInterface() { void UserInterface::handleInput() { Events &events = *_vm->_events; + People &people = *_vm->_people; Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; if (_menuCounter) whileMenuCounter(); @@ -190,7 +194,146 @@ void UserInterface::handleInput() { } } - // TODO + // Reset the old bgshape number if the mouse button is released, so that + // it can e re-highlighted when we come back here + if ((events._rightReleased && _helpStyle) || (events._released && !_helpStyle)) + _oldBgFound = -1; + + // Do routines that should be done before input processing + switch (_menuMode) { + case LOOK_MODE: + if (!_windowOpen) { + if (events._released && _bgFound >= 0 && _bgFound < 1000) { + if (!scene._bgShapes[_bgFound]._examine.empty()) + examine(); + } else { + lookScreen(pt); + } + } + break; + + case MOVE_MODE: + case OPEN_MODE: + case CLOSE_MODE: + case PICKUP_MODE: + lookScreen(pt); + break; + + case TALK_MODE: + if (!_windowOpen) { + bool personFound; + + if (_bgFound >= 1000) { + personFound = false; + if (!events._released) + lookScreen(pt); + } else { + personFound = scene._bgShapes[_bgFound]._aType == PERSON && _bgFound != -1; + } + + if (events._released && personFound) + talk.talk(_bgFound); + else if (personFound) + lookScreen(pt); + else if (_bgFound < 1000) + clearInfo(); + } + break; + + case USE_MODE: + case GIVE_MODE: + case INV_MODE: + if (_invMode == 1 || _invMode == 2 || _invMode == 3) { + if (pt.y < CONTROLS_Y) + lookInv(); + else + lookScreen(pt); + } + break; + + default: + break; + } + + // + // Do input processing + // + if (events._pressed || events._released || events._rightPressed || + _keycode != Common::KEYCODE_INVALID || _pause) { + if (((events._released && (_helpStyle || _help == -1)) || (events._rightReleased && !_helpStyle)) && + (pt.y <= CONTROLS_Y) && (_menuMode == STD_MODE)) { + // The mouse was clicked in the playing area with no action buttons down. + // Check if the mouse was clicked in a script zone. If it was, + // then execute the script. Otherwise, walk to the given position + if (scene.checkForZones(pt, SCRIPT_ZONE) != 0) { + // Mouse clicked in script zone + events._pressed = events._released = false; + } else { + people._walkDest = pt; + people._allowWalkAbort = false; + people.goAllTheWay(); + } + + if (_oldKey != -1) { + restoreButton(_oldTemp); + _oldKey = -1; + } + } + + // Handle action depending on selected mode + switch (_menuMode) { + case LOOK_MODE: + if (_windowOpen) + doLookControl(); + break; + + case MOVE_MODE: + doMiscControl(ALLOW_MOVEMENT); + break; + + case TALK_MODE: + if (_windowOpen) + doTalkControl(); + break; + + case OPEN_MODE: + doMiscControl(ALLOW_OPEN); + break; + + case CLOSE_MODE: + doMiscControl(ALLOW_CLOSE); + break; + + case PICKUP_MODE: + doPickControl(); + break; + + case USE_MODE: + case GIVE_MODE: + case INV_MODE: + doInvControl(); + break; + + case FILES_MODE: + doEnvControl(); + break; + + default: + break; + } + + // As long as there isn't an open window, do main input processing. + // Windows are opened when in TALK, USE, INV, and GIVE modes + if ((!_windowOpen && !_menuCounter && pt.y > CONTROLS_Y) || + _keycode != Common::KEYCODE_INVALID) { + if (events._pressed || events._released || _pause || + _keycode != Common::KEYCODE_INVALID) + doMainControl(); + } + + if (pt.y < CONTROLS_Y && events._pressed && _oldTemp != (_menuMode - 1) && _oldKey != -1) + restoreButton(_oldTemp); + } } /** @@ -303,4 +446,44 @@ void UserInterface::whileMenuCounter() { } } +void UserInterface::examine() { + // TODO +} + +void UserInterface::lookScreen(const Common::Point &pt) { + // TODO +} + +void UserInterface::lookInv() { + // TODO +} + +void UserInterface::doEnvControl() { + // TODO +} + +void UserInterface::doInvControl() { + // TODO +} + +void UserInterface::doLookControl() { + // TODO +} + +void UserInterface::doMainControl() { + // TODO +} + +void UserInterface::doMiscControl(int allowed) { + // TODO +} + +void UserInterface::doPickControl() { + // TODO +} + +void UserInterface::doTalkControl() { + // TODO +} + } // End of namespace Sherlock -- cgit v1.2.3 From d44a9e3f5a390837ce88b95d6afa2e7a5ee9e26e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 23 Mar 2015 22:27:07 -0400 Subject: SHERLOCK: Fix loading of user interface controls --- engines/sherlock/user_interface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 5ed5494c5e..1cd5b80980 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -75,13 +75,16 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _invMode = 0; _pause = false; - _controls = nullptr; // new ImageFile("menu.all"); + _controls = new ImageFile("menu.all"); } UserInterface::~UserInterface() { delete _controls; } +/** + * Main input handler for the user interface + */ void UserInterface::handleInput() { Events &events = *_vm->_events; People &people = *_vm->_people; @@ -355,12 +358,12 @@ void UserInterface::depressButton(int num) { void UserInterface::restoreButton(int num) { Screen &screen = *_vm->_screen; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); + Graphics::Surface &frame = (*_controls)[num]._frame; screen._backBuffer.blitFrom(screen._backBuffer2, pt, Common::Rect(pt.x, pt.y, pt.x + 90, pt.y + 19)); screen._backBuffer.blitFrom(screen._backBuffer, pt, - Common::Rect(pt.x, pt.y, pt.x + (*_controls)[num]._frame.w, - (*_controls)[num]._frame.h)); + Common::Rect(pt.x, pt.y, pt.x + frame.w, pt.y + frame.h)); if (!_menuCounter) { _infoFlag++; -- cgit v1.2.3 From f2ee94c0ab646d3efe93e0c782494f5888d7cc36 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 24 Mar 2015 08:35:08 -0400 Subject: SHERLOCK: Implement font drawing --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 1cd5b80980..1f201c74b8 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -431,7 +431,7 @@ void UserInterface::toggleButton(int num) { */ void UserInterface::clearInfo() { if (_infoFlag) { - _vm->_screen->fillRect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 200, INFO_LINE + 9, + _vm->_screen->fillRect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 20, INFO_LINE + 9, INFO_BLACK); _infoFlag = false; _oldLook = -1; -- cgit v1.2.3 From 97e58fb0171af885019d997493db33fab9af0091 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 24 Mar 2015 20:14:13 -0400 Subject: SHERLOCK: Fix display of scene hotspots --- engines/sherlock/user_interface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 1f201c74b8..661604e4bf 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -268,7 +268,8 @@ void UserInterface::handleInput() { // The mouse was clicked in the playing area with no action buttons down. // Check if the mouse was clicked in a script zone. If it was, // then execute the script. Otherwise, walk to the given position - if (scene.checkForZones(pt, SCRIPT_ZONE) != 0) { + if (scene.checkForZones(pt, SCRIPT_ZONE) != 0 || + scene.checkForZones(pt, NOWALK_ZONE) != 0) { // Mouse clicked in script zone events._pressed = events._released = false; } else { @@ -431,8 +432,8 @@ void UserInterface::toggleButton(int num) { */ void UserInterface::clearInfo() { if (_infoFlag) { - _vm->_screen->fillRect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 20, INFO_LINE + 9, - INFO_BLACK); + _vm->_screen->bar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 20, + INFO_LINE + 9), INFO_BLACK); _infoFlag = false; _oldLook = -1; } -- cgit v1.2.3 From 03a969bd0f696f9a7fa0dc56c47c2b05d28a5a47 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 24 Mar 2015 22:24:45 -0400 Subject: SHERLOCK: Implementing walk code --- engines/sherlock/user_interface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 661604e4bf..fc94cc5a5c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -82,6 +82,12 @@ UserInterface::~UserInterface() { delete _controls; } +void UserInterface::reset() { + _oldKey = -1; + _help = _oldHelp = -1; + _oldTemp = _temp = -1; +} + /** * Main input handler for the user interface */ -- cgit v1.2.3 From b280d72ab8de6f6fe77d0957de1b651b9fdb264c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 25 Mar 2015 22:23:53 -0400 Subject: SHERLOCK: Sprite positioning fixes --- engines/sherlock/user_interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index fc94cc5a5c..b0ac0b169b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -176,7 +176,7 @@ void UserInterface::handleInput() { _help = _oldHelp; } - if (_bgFound != _oldBgFound) { + if (_bgFound != _oldBgFound || _oldBgFound == -1) { _infoFlag = true; clearInfo(); @@ -438,8 +438,8 @@ void UserInterface::toggleButton(int num) { */ void UserInterface::clearInfo() { if (_infoFlag) { - _vm->_screen->bar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 20, - INFO_LINE + 9), INFO_BLACK); + _vm->_screen->bar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 19, + INFO_LINE + 10), INFO_BLACK); _infoFlag = false; _oldLook = -1; } -- cgit v1.2.3 From a8350c48e93143dd2d6344efce1b36c4e2eb34be Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 25 Mar 2015 22:56:56 -0400 Subject: SHERLOCK: Fix display of hotspot tooltips --- engines/sherlock/user_interface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index b0ac0b169b..bcf460a821 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -173,7 +173,7 @@ void UserInterface::handleInput() { if (_help != -1) depressButton(_help); - _help = _oldHelp; + _oldHelp = _help; } if (_bgFound != _oldBgFound || _oldBgFound == -1) { @@ -185,6 +185,8 @@ void UserInterface::handleInput() { screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, INFO_BACKGROUND, "%s", scene._bgShapes[_bgFound]._description); + + _oldBgFound = _bgFound; } } else { // We're not in STD_MODE -- cgit v1.2.3 From 0f52dcc561fbe05816452d2a20b3f09f6cd9e0fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 25 Mar 2015 23:07:56 -0400 Subject: SHERLOCK: Highlight default action button when highlighting hotspots --- engines/sherlock/user_interface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index bcf460a821..df3ac9352c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -371,8 +371,7 @@ void UserInterface::restoreButton(int num) { screen._backBuffer.blitFrom(screen._backBuffer2, pt, Common::Rect(pt.x, pt.y, pt.x + 90, pt.y + 19)); - screen._backBuffer.blitFrom(screen._backBuffer, pt, - Common::Rect(pt.x, pt.y, pt.x + frame.w, pt.y + frame.h)); + screen.slamArea(pt.x, pt.y, pt.x + frame.w, pt.y + frame.h); if (!_menuCounter) { _infoFlag++; -- cgit v1.2.3 From 5e45abcca4b76955cc0ebcfa54a1b9f9be12bfa0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 26 Mar 2015 21:40:24 -0400 Subject: SHERLOCK: Implemented printObjectDesc --- engines/sherlock/user_interface.cpp | 252 +++++++++++++++++++++++++++++++++++- 1 file changed, 249 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index df3ac9352c..b0388b4e29 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -54,6 +54,8 @@ const int INVENTORY_POINTS[8][3] = { }; const char COMMANDS[13] = "LMTPOCIUGJFS"; +const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; +const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; /*----------------------------------------------------------------*/ @@ -74,6 +76,11 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _keyboardInput = false; _invMode = 0; _pause = false; + _cNum = 0; + _selector = _oldSelector = -1; + _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, + SHERLOCK_SCREEN_HEIGHT - 1); + _windowStyle = 0; _controls = new ImageFile("menu.all"); } @@ -183,8 +190,7 @@ void UserInterface::handleInput() { if (_help != -1 && (scene._bgShapes[_bgFound]._description[0] != 32 && scene._bgShapes[_bgFound]._description[0])) screen.print(Common::Point(0, INFO_LINE + 1), - INFO_FOREGROUND, INFO_BACKGROUND, "%s", - scene._bgShapes[_bgFound]._description); + INFO_FOREGROUND, scene._bgShapes[_bgFound]._description.c_str()); _oldBgFound = _bgFound; } @@ -457,8 +463,53 @@ void UserInterface::whileMenuCounter() { } } +/** + * Creates a text window and uses it to display the in-depth description + * of the highlighted object + */ void UserInterface::examine() { - // TODO + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + People &people = *_vm->_people; + Scene &scene = *_vm->_scene; + Talk &talk = *_vm->_talk; + Common::Point pt = events.mousePos(); + int canimSpeed; + + if (pt.y < (CONTROLS_Y + 9)) { + Object &obj = scene._bgShapes[_bgFound]; + + if (obj._lookcAnim != 0) { + canimSpeed = ((obj._lookcAnim & 0xe0) >> 5) + 1; + scene._cAnimFramePause = obj._lookFrames; + _cAnimStr = obj._examine; + _cNum = (obj._lookcAnim & 0x1f) - 1; + + scene.startCAnim(_cNum, canimSpeed); + } else if (obj._lookPosition.y != 0) { + // Need to walk to the object to be examined + people.walkToCoords(obj._lookPosition, obj._lookFacing); + } + + if (talk._talkToAbort) { + _cAnimStr = obj._examine; + if (obj._lookFlag) + _vm->setFlags(obj._lookFlag); + } + } else { + // Looking at an inventory item + _cAnimStr = inv[_selector]._examine; + if (inv[_selector]._lookFlag) + _vm->setFlags(inv[_selector]._lookFlag); + } + + if (!talk._talkToAbort) { + if (!scene._cAnimFramePause) + printObjectDesc(_cAnimStr, true); + else + // description was already printed in startCAnimation + scene._cAnimFramePause = 0; + } } void UserInterface::lookScreen(const Common::Point &pt) { @@ -497,4 +548,199 @@ void UserInterface::doTalkControl() { // TODO } + +/** +* Print the description of an object +*/ +void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + int savedSelector; + + if (str.hasPrefix("_")) { + _lookScriptFlag = true; + events.setCursor(MAGNIFY); + savedSelector = _selector; + talk.talkTo(str.c_str() + 1); + _lookScriptFlag = false; + + if (talk._talkToAbort) { + events.setCursor(ARROW); + return; + } + + // Check if looking at an inventory object + if (!_invLookFlag) { + // See if this look was called by a right button click or not + if (!_lookHelp) { + // If it wasn't a right button click, then we need depress + // the look button before we close the window. So save a copy of the + // menu area, and draw the controls onto it + Surface tempSurface((*_controls)[0]._frame.w, (*_controls)[0]._frame.h); + Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); + + tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), + Common::Rect(pt.x, pt.y, pt.x + tempSurface.w, pt.y + tempSurface.h)); + screen._backBuffer2.transBlitFrom((*_controls)[0]._frame, pt); + + banishWindow(1); + events.setCursor(MAGNIFY); + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = COMMANDS[LOOK_MODE - 1]; + _temp = _oldTemp = 0; + _menuMode = LOOK_MODE; + events.clearEvents(); + + screen._backBuffer2.blitFrom(tempSurface, pt); + } else { + events.setCursor(ARROW); + banishWindow(true); + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = -1; + _temp = _oldTemp = 0; + _menuMode = STD_MODE; + _lookHelp = 0; + events.clearEvents(); + } + } else { + // Looking at an inventory object + _selector = _oldSelector = savedSelector; + + // Reload the inventory graphics and draw the inventory + inv.loadInv(); + inv.putInv(2); + inv.freeInv(); + banishWindow(1); + + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = COMMANDS[INV_MODE - 1]; + _temp = _oldTemp = 0; + events.clearEvents(); + + _invLookFlag = 0; + _menuMode = INV_MODE; + _windowOpen = true; + } + + return; + } + + if (firstTime) { + // Only draw the border on the first call + _infoFlag = true; + clearInfo(); + + screen.bar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, + CONTROLS_Y1 + 10), BORDER_COLOR); + screen.bar(Common::Rect(0, CONTROLS_Y + 10, 1, SHERLOCK_SCREEN_HEIGHT - 1), + BORDER_COLOR); + screen.bar(Common::Rect(SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y + 10, + SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); + screen.bar(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 1, SHERLOCK_SCREEN_WIDTH, + SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); + } + + // Clear background + screen.bar(Common::Rect(2, CONTROLS_Y + 10, SHERLOCK_SCREEN_WIDTH - 2, + SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); + + _windowBounds.top = CONTROLS_Y; + events.clearEvents(); + + bool endOfStr = false; + const char *msgP = str.c_str(); + for (int lineNum = 0; lineNum < 5 && !endOfStr; ++lineNum) { + int width = 0; + const char *lineStartP = msgP; + + // Determine how much can be displayed on the line + do { + width += screen.charWidth(*msgP++); + } while (width < 300 && *msgP); + + if (*msgP) + --msgP; + else + endOfStr = true; + + // If the line needs to be wrapped, scan backwards to find + // the end of the previous word as a splitting point + if (width >= 300) { + while (*msgP != ' ') + --msgP; + endOfStr = false; + } + + // Print out the line + Common::String line(lineStartP, msgP); + screen.gPrint(Common::Point(16, CONTROLS_Y + 12 + lineNum * 9), + INV_FOREGROUND, line.c_str()); + } + + // Handle display depending on whether all the message was shown + if (!endOfStr) { + makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), + (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2, + PRESS_KEY_FOR_MORE); + screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - + screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2, CONTROLS_Y), + COM_FOREGROUND, "P"); + _descStr = msgP; + } else { + makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), + (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, + PRESS_KEY_FOR_MORE); + screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - + screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, CONTROLS_Y), + COM_FOREGROUND, "P"); + _descStr = ""; + } + + if (firstTime) { + if (!_windowStyle) { + screen.slamRect(Common::Rect(0, CONTROLS_Y, + SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + } + else { + Surface tempSurface(SHERLOCK_SCREEN_WIDTH, + (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y) + 10); + Common::Rect r(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); + + tempSurface.blitFrom(screen._backBuffer, Common::Point(0, CONTROLS_Y), r); + screen._backBuffer.blitFrom(screen._backBuffer2, + Common::Point(0, CONTROLS_Y), r); + + summonWindow(); + } + + _selector = _oldSelector = -1; + _windowOpen = true; + } else { + screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, + SHERLOCK_SCREEN_HEIGHT)); + } +} + +/** +* Print the previously selected object's decription +*/ +void UserInterface::printObjectDesc() { + printObjectDesc(_cAnimStr, true); +} + +void UserInterface::banishWindow(bool flag) { + // TODO +} + +void UserInterface::makeButton(const Common::Rect &bounds, int textX, + const Common::String &str) { + // TODO +} + +void UserInterface::summonWindow() { + // TODO +} + } // End of namespace Sherlock -- cgit v1.2.3 From 9f21575c564cb1aff07f0265a47af59ce31ec93e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 26 Mar 2015 23:10:10 -0400 Subject: SHERLOCK: Implemented banishWindow --- engines/sherlock/user_interface.cpp | 97 ++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 7 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index b0388b4e29..8e5cbb68ef 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -649,6 +649,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { _windowBounds.top = CONTROLS_Y; events.clearEvents(); + // Loop through displaying up to five lines bool endOfStr = false; const char *msgP = str.c_str(); for (int lineNum = 0; lineNum < 5 && !endOfStr; ++lineNum) { @@ -712,7 +713,8 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { screen._backBuffer.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y), r); - summonWindow(); + // Display the window + summonWindow(tempSurface); } _selector = _oldSelector = -1; @@ -730,17 +732,98 @@ void UserInterface::printObjectDesc() { printObjectDesc(_cAnimStr, true); } -void UserInterface::banishWindow(bool flag) { - // TODO -} - void UserInterface::makeButton(const Common::Rect &bounds, int textX, const Common::String &str) { // TODO } -void UserInterface::summonWindow() { - // TODO +/** + * Displays a passed window by gradually displaying it up vertically + */ +void UserInterface::summonWindow(const Surface &bgSurface) { + Events &events = *_vm->_events; + Screen &screen = *_vm->_screen; + + if (_windowOpen) + // A window is already open, so can't open another one + return; + + // Gradually slide up the display of the window + for (int idx = 1; idx <= (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y); idx += 2) { + screen.blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), + Common::Rect(0, 0, bgSurface.w, idx)); + screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx, + SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + + events.delay(10); + } + + // Final display of the entire window + screen._backBuffer.blitFrom(bgSurface, Common::Point(0, CONTROLS_Y), + Common::Rect(0, 0, bgSurface.w, bgSurface.h)); + screen.slamArea(0, CONTROLS_Y, bgSurface.w, bgSurface.h); + + _windowOpen = true; +} + +/** + * Close a currently open window + * @param flag 0 = slide old window down, 1 = slide old window up + */ +void UserInterface::banishWindow(bool flag) { + Events &events = *_vm->_events; + Screen &screen = *_vm->_screen; + + if (_windowOpen) { + if (!flag || !_windowStyle) { + // Slide window up + // Only slide the window up if the window style allows it + if (_windowStyle) { + for (int idx = 2; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y); idx += 2) { + byte *pSrc = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y); + Common::copy(pSrc, pSrc + (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y + idx) + * SHERLOCK_SCREEN_WIDTH, pSrc - SHERLOCK_SCREEN_WIDTH * 2); + screen._backBuffer.blitFrom(screen._backBuffer2, + Common::Point(0, CONTROLS_Y), + Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_HEIGHT, CONTROLS_Y + idx)); + + screen.slamArea(0, CONTROLS_Y + idx - 2, SHERLOCK_SCREEN_WIDTH, + SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y - idx + 2); + events.delay(10); + } + + // Restore final two old lines + screen._backBuffer.blitFrom(screen._backBuffer2, + Common::Point(0, SHERLOCK_SCREEN_HEIGHT - 2), + Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 2, + SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - 2, SHERLOCK_SCREEN_WIDTH, 2); + } else { + // Restore old area to completely erase window + screen._backBuffer.blitFrom(screen._backBuffer2, + Common::Point(0, CONTROLS_Y), + Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, + SHERLOCK_SCREEN_HEIGHT)); + } + } else { + for (int idx = SHERLOCK_SCREEN_HEIGHT - 1 - CONTROLS_Y1; idx >= 0; idx -= 2) { + byte *pSrc = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y1 + idx); + byte *pDest = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y1); + + Common::copy(pSrc, pSrc + (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1 - idx) + * SHERLOCK_SCREEN_WIDTH, pDest); + screen.slamArea(0, CONTROLS_Y1 + idx, SHERLOCK_SCREEN_WIDTH, + SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1 - idx); + events.delay(10); + } + } + + _infoFlag = false; + _windowOpen = false; + } + + _menuMode = STD_MODE; } } // End of namespace Sherlock -- cgit v1.2.3 From 4fad808aad87bc15827eed180f395c04c260e447 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 27 Mar 2015 08:36:04 -0400 Subject: SHERLOCK: Implemented doMainControl --- engines/sherlock/user_interface.cpp | 191 +++++++++++++++++++++++++++++++++++- 1 file changed, 189 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 8e5cbb68ef..2827e80b78 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -528,12 +528,188 @@ void UserInterface::doInvControl() { // TODO } +/** + * Handles waiting whilst an object's description window is open. + */ void UserInterface::doLookControl() { - // TODO + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Screen &screen = *_vm->_screen; + + _key = _oldKey = -1; + _keyboardInput = _keycode != Common::KEYCODE_INVALID; + + if (events._released || events._rightReleased || _keyboardInput) { + // Is an inventory object being looked at? + if (!_invLookFlag) { + // Is there any remaining text to display? + if (!_descStr.empty()) { + printObjectDesc(_descStr, false); + } else if (!_lookHelp) { + // Need to close the window and depress the Look button + Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); + Surface tempSurface((*_controls)[0]._frame.w, (*_controls)[0]._frame.h); + tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), + Common::Rect(pt.x, pt.y, pt.x + (*_controls)[0]._frame.w, + pt.y + (*_controls)[1]._frame.h)); + + screen._backBuffer2.blitFrom((*_controls)[0]._frame, pt); + banishWindow(true); + + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = COMMANDS[LOOK_MODE - 1]; + _temp = _oldTemp = 0; + _menuMode = LOOK_MODE; + events.clearEvents(); + + screen._backBuffer2.blitFrom(tempSurface, pt); + } + } else { + // Looking at an inventory object + // Backup the user interface + Surface tempSurface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1); + tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), + Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + + inv.invent(128); + banishWindow(true); + + // Restore the ui + screen._backBuffer2.blitFrom(tempSurface, Common::Point(0, CONTROLS_Y1)); + } + + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = COMMANDS[LOOK_MODE - 1]; + _temp = _oldTemp = 0; + events.clearEvents(); + _invLookFlag = false; + _menuMode = INV_MODE; + _windowOpen = true; + } } +/** + * Handles input until one of the user interface buttons/commands is selected + */ void UserInterface::doMainControl() { - // TODO + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Common::Point pt = events.mousePos(); + + if ((events._pressed || events._released) && pt.y > CONTROLS_Y) { + events.clearKeyboard(); + _key = -1; + + // Check whether the mouse is in any of the command areas + for (_temp = 0; (_temp < 12) && (_key == -1); ++_temp) { + Common::Rect r(MENU_POINTS[_temp][0], MENU_POINTS[_temp][1], + MENU_POINTS[_temp][2], MENU_POINTS[_temp][3]); + if (r.contains(pt)) + _key = COMMANDS[_temp]; + } + --_temp; + } else if (_keycode != Common::KEYCODE_INVALID) { + // Keyboard control + _keyboardInput = true; + + if (_keycode >= Common::KEYCODE_a && _keycode <= Common::KEYCODE_z) { + const char *c = strchr(COMMANDS, _keycode); + _temp = !c ? 12 : c - COMMANDS; + } else { + _temp = 12; + } + + if (_temp == 12) + _key = -1; + + if (events._rightPressed) { + _temp = 12; + _key = -1; + } + } else if (!events._released) { + _key = -1; + } + + // Check if the button being pointed to has changed + if (_oldKey != _key && !_windowOpen) { + // Clear the info line + _infoFlag++; + clearInfo(); + + // If there was an old button selected, restore it + if (_oldKey != -1) { + _menuMode = STD_MODE; + restoreButton(_oldTemp); + } + + // If a new button is being pointed to, highlight it + if (_key != -1 && _temp < 12 && !_keyboardInput) + depressButton(_temp); + + // Save the new button selection + _oldKey = _key; + _oldTemp = _temp; + } + + if (!events._pressed && !_windowOpen) { + switch (_key) { + case 'L': + toggleButton(0); + break; + case 'M': + toggleButton(1); + break; + case 'T': + toggleButton(2); + break; + case 'P': + toggleButton(3); + break; + case 'O': + toggleButton(4); + break; + case 'C': + toggleButton(5); + break; + case 'I': + pushButton(6); + _selector = _oldSelector = -1; + _menuMode = INV_MODE; + inv.invent(1); + break; + case 'U': + pushButton(7); + _selector = _oldSelector = -1; + _menuMode = USE_MODE; + inv.invent(2); + break; + case 'G': + pushButton(8); + _selector = _oldSelector = -1; + _menuMode = GIVE_MODE; + inv.invent(3); + break; + case 'J': + pushButton(9); + _menuMode = JOURNAL_MODE; + journalControl(); + break; + case 'F': + pushButton(10); + _menuMode = FILES_MODE; + environment(); + break; + case 'S': + pushButton(11); + _menuMode = SETUP_MODE; + doControls(); + break; + default: + break; + } + + _help = _oldHelp = _oldBgFound = -1; + } } void UserInterface::doMiscControl(int allowed) { @@ -548,6 +724,17 @@ void UserInterface::doTalkControl() { // TODO } +void UserInterface::journalControl() { + // TODO +} + +void UserInterface::environment() { + // TODO +} + +void UserInterface::doControls() { + // TODO +} /** * Print the description of an object -- cgit v1.2.3 From 56a854e2292f420a6ab03c65174f9fc0310bc2fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 27 Mar 2015 19:52:46 -0400 Subject: SHERLOCK: Fixes for examine dialog display --- engines/sherlock/user_interface.cpp | 57 ++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 16 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 2827e80b78..c15685d82b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -60,6 +60,8 @@ const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; /*----------------------------------------------------------------*/ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { + _controls = new ImageFile("menu.all"); + _controlPanel = new ImageFile("controls.vgs"); _bgFound = 0; _oldBgFound = -1; _keycode = Common::KEYCODE_INVALID; @@ -81,12 +83,11 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); _windowStyle = 0; - - _controls = new ImageFile("menu.all"); } UserInterface::~UserInterface() { delete _controls; + delete _controlPanel; } void UserInterface::reset() { @@ -95,6 +96,17 @@ void UserInterface::reset() { _oldTemp = _temp = -1; } +/** + * Draw the user interface onto the screen's back buffers + */ +void UserInterface::drawInterface() { + Screen &screen = *_vm->_screen; + + screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK); + screen._backBuffer.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); + screen._backBuffer2.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); +} + /** * Main input handler for the user interface */ @@ -137,7 +149,7 @@ void UserInterface::handleInput() { (events._rightPressed || (!_helpStyle && !events._released)) && (_bgFound != -1) && (_bgFound < 1000) && (scene._bgShapes[_bgFound]._defaultCommand || - scene._bgShapes[_bgFound]._description[0])) { + !scene._bgShapes[_bgFound]._description.empty())) { // If there is no default command, so set it to Look if (scene._bgShapes[_bgFound]._defaultCommand) _help = scene._bgShapes[_bgFound]._defaultCommand - 1; @@ -151,7 +163,7 @@ void UserInterface::handleInput() { ((events._rightReleased && _helpStyle) || (events._released && !_helpStyle)) && (_bgFound != -1 && _bgFound < 1000) && (scene._bgShapes[_bgFound]._defaultCommand || - scene._bgShapes[_bgFound]._description[0])) { + !scene._bgShapes[_bgFound]._description.empty())) { // If there is no default command, set it to Look if (scene._bgShapes[_bgFound]._defaultCommand) _menuMode = (MenuMode)scene._bgShapes[_bgFound]._defaultCommand; @@ -491,7 +503,7 @@ void UserInterface::examine() { people.walkToCoords(obj._lookPosition, obj._lookFacing); } - if (talk._talkToAbort) { + if (!talk._talkToAbort) { _cAnimStr = obj._examine; if (obj._lookFlag) _vm->setFlags(obj._lookFlag); @@ -548,11 +560,6 @@ void UserInterface::doLookControl() { } else if (!_lookHelp) { // Need to close the window and depress the Look button Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); - Surface tempSurface((*_controls)[0]._frame.w, (*_controls)[0]._frame.h); - tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), - Common::Rect(pt.x, pt.y, pt.x + (*_controls)[0]._frame.w, - pt.y + (*_controls)[1]._frame.h)); - screen._backBuffer2.blitFrom((*_controls)[0]._frame, pt); banishWindow(true); @@ -562,7 +569,8 @@ void UserInterface::doLookControl() { _menuMode = LOOK_MODE; events.clearEvents(); - screen._backBuffer2.blitFrom(tempSurface, pt); + // Restore UI + drawInterface(); } } else { // Looking at an inventory object @@ -865,6 +873,10 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { Common::String line(lineStartP, msgP); screen.gPrint(Common::Point(16, CONTROLS_Y + 12 + lineNum * 9), INV_FOREGROUND, line.c_str()); + + if (!endOfStr) + // Start next line at start of the nxet word after space + ++msgP; } // Handle display depending on whether all the message was shown @@ -874,7 +886,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { PRESS_KEY_FOR_MORE); screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2, CONTROLS_Y), - COM_FOREGROUND, "P"); + COMMAND_FOREGROUND, "P"); _descStr = msgP; } else { makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), @@ -882,7 +894,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { PRESS_KEY_FOR_MORE); screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, CONTROLS_Y), - COM_FOREGROUND, "P"); + COMMAND_FOREGROUND, "P"); _descStr = ""; } @@ -913,15 +925,28 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { } /** -* Print the previously selected object's decription -*/ + * Print the previously selected object's decription + */ void UserInterface::printObjectDesc() { printObjectDesc(_cAnimStr, true); } +/** + * Draws a button for use in the inventory, talk, and examine dialogs. + */ void UserInterface::makeButton(const Common::Rect &bounds, int textX, const Common::String &str) { - // TODO + Screen &screen = *_vm->_screen; + + screen.bar(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP); + screen.bar(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP); + screen.bar(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM); + screen.bar(Common::Rect(bounds.left + 1, bounds.bottom - 1, bounds.right, bounds.bottom), BUTTON_BOTTOM); + screen.bar(Common::Rect(bounds.left + 1, bounds.top + 1, bounds.right - 1, bounds.bottom - 1), BUTTON_MIDDLE); + + screen.gPrint(Common::Point(textX, bounds.top), COMMAND_HIGHLIGHTED, "%c", str[0]); + screen.gPrint(Common::Point(textX + screen.charWidth(str[0]), bounds.top), + COMMAND_FOREGROUND, "%s", str.c_str() + 1); } /** -- cgit v1.2.3 From e122b752b7faf6a0307e74523771860367f7227e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 27 Mar 2015 22:12:37 -0400 Subject: SHERLOCK: Fix scrolling examine window on-screen --- engines/sherlock/user_interface.cpp | 40 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index c15685d82b..6af698baa6 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -82,7 +82,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _selector = _oldSelector = -1; _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); - _windowStyle = 0; + _windowStyle = 1; // Sliding windows } UserInterface::~UserInterface() { @@ -457,7 +457,7 @@ void UserInterface::toggleButton(int num) { */ void UserInterface::clearInfo() { if (_infoFlag) { - _vm->_screen->bar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 19, + _vm->_screen->vgaBar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 19, INFO_LINE + 10), INFO_BLACK); _infoFlag = false; _oldLook = -1; @@ -822,23 +822,24 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { return; } + Surface &bb = screen._backBuffer; if (firstTime) { // Only draw the border on the first call _infoFlag = true; clearInfo(); - screen.bar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, + bb.fillRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y1 + 10), BORDER_COLOR); - screen.bar(Common::Rect(0, CONTROLS_Y + 10, 1, SHERLOCK_SCREEN_HEIGHT - 1), + bb.fillRect(Common::Rect(0, CONTROLS_Y + 10, 1, SHERLOCK_SCREEN_HEIGHT - 1), BORDER_COLOR); - screen.bar(Common::Rect(SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y + 10, + bb.fillRect(Common::Rect(SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y + 10, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); - screen.bar(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 1, SHERLOCK_SCREEN_WIDTH, + bb.fillRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); } // Clear background - screen.bar(Common::Rect(2, CONTROLS_Y + 10, SHERLOCK_SCREEN_WIDTH - 2, + bb.fillRect(Common::Rect(2, CONTROLS_Y + 10, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); _windowBounds.top = CONTROLS_Y; @@ -904,15 +905,17 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); } else { + // Extract the window that's been drawn on the back buffer Surface tempSurface(SHERLOCK_SCREEN_WIDTH, - (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y) + 10); + (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y)); Common::Rect r(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); + tempSurface.blitFrom(screen._backBuffer, Common::Point(0, 0), r); - tempSurface.blitFrom(screen._backBuffer, Common::Point(0, CONTROLS_Y), r); + // Remove drawn window with original user interface screen._backBuffer.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y), r); - // Display the window + // Display the window gradually on-screen summonWindow(tempSurface); } @@ -938,11 +941,12 @@ void UserInterface::makeButton(const Common::Rect &bounds, int textX, const Common::String &str) { Screen &screen = *_vm->_screen; - screen.bar(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP); - screen.bar(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP); - screen.bar(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM); - screen.bar(Common::Rect(bounds.left + 1, bounds.bottom - 1, bounds.right, bounds.bottom), BUTTON_BOTTOM); - screen.bar(Common::Rect(bounds.left + 1, bounds.top + 1, bounds.right - 1, bounds.bottom - 1), BUTTON_MIDDLE); + Surface &bb = screen._backBuffer; + bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP); + bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP); + bb.fillRect(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM); + bb.fillRect(Common::Rect(bounds.left + 1, bounds.bottom - 1, bounds.right, bounds.bottom), BUTTON_BOTTOM); + bb.fillRect(Common::Rect(bounds.left + 1, bounds.top + 1, bounds.right - 1, bounds.bottom - 1), BUTTON_MIDDLE); screen.gPrint(Common::Point(textX, bounds.top), COMMAND_HIGHLIGHTED, "%c", str[0]); screen.gPrint(Common::Point(textX + screen.charWidth(str[0]), bounds.top), @@ -950,7 +954,7 @@ void UserInterface::makeButton(const Common::Rect &bounds, int textX, } /** - * Displays a passed window by gradually displaying it up vertically + * Displays a passed window by gradually scrolling it vertically on-screen */ void UserInterface::summonWindow(const Surface &bgSurface) { Events &events = *_vm->_events; @@ -961,8 +965,8 @@ void UserInterface::summonWindow(const Surface &bgSurface) { return; // Gradually slide up the display of the window - for (int idx = 1; idx <= (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y); idx += 2) { - screen.blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), + for (int idx = 1; idx <= bgSurface.h; idx += 2) { + screen._backBuffer.blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), Common::Rect(0, 0, bgSurface.w, idx)); screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); -- cgit v1.2.3 From 5b1ad857b7cd0b6065c01e000dfadb80526a1729 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 27 Mar 2015 23:04:49 -0400 Subject: SHERLOCK: Fix for sliding examine dialog off-screen --- engines/sherlock/user_interface.cpp | 45 ++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 6af698baa6..61d6c6a76e 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -571,6 +571,14 @@ void UserInterface::doLookControl() { // Restore UI drawInterface(); + } else { + events.setCursor(ARROW); + banishWindow(true); + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = -1; + _temp = _oldTemp = 0; + _menuMode = STD_MODE; + events.clearEvents(); } } else { // Looking at an inventory object @@ -984,24 +992,28 @@ void UserInterface::summonWindow(const Surface &bgSurface) { /** * Close a currently open window - * @param flag 0 = slide old window down, 1 = slide old window up + * @param flag 0 = slide old window down, 1 = slide prior UI back up */ void UserInterface::banishWindow(bool flag) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; if (_windowOpen) { - if (!flag || !_windowStyle) { - // Slide window up - // Only slide the window up if the window style allows it + if (flag || !_windowStyle) { + // Slide window down + // Only slide the window if the window style allows it if (_windowStyle) { for (int idx = 2; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y); idx += 2) { - byte *pSrc = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y); - Common::copy(pSrc, pSrc + (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y + idx) - * SHERLOCK_SCREEN_WIDTH, pSrc - SHERLOCK_SCREEN_WIDTH * 2); + // Shift the window down by 2 lines + byte *pSrc = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y + idx - 2); + byte *pSrcEnd = (byte *)screen._backBuffer.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - 2); + byte *pDest = (byte *)screen._backBuffer.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT); + Common::copy_backward(pSrc, pSrcEnd, pDest); + + // Restore lines from the ui in the secondary back buffer screen._backBuffer.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y), - Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_HEIGHT, CONTROLS_Y + idx)); + Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + idx)); screen.slamArea(0, CONTROLS_Y + idx - 2, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y - idx + 2); @@ -1023,14 +1035,15 @@ void UserInterface::banishWindow(bool flag) { SHERLOCK_SCREEN_HEIGHT)); } } else { - for (int idx = SHERLOCK_SCREEN_HEIGHT - 1 - CONTROLS_Y1; idx >= 0; idx -= 2) { - byte *pSrc = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y1 + idx); - byte *pDest = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y1); - - Common::copy(pSrc, pSrc + (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1 - idx) - * SHERLOCK_SCREEN_WIDTH, pDest); - screen.slamArea(0, CONTROLS_Y1 + idx, SHERLOCK_SCREEN_WIDTH, - SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1 - idx); + // Slide the original user interface up to cover the dialog + for (int idx = 1; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1); idx += 2) { + byte *pSrc = (byte *)screen._backBuffer2.getBasePtr(0, CONTROLS_Y1); + byte *pSrcEnd = (byte *)screen._backBuffer2.getBasePtr(0, CONTROLS_Y1 + idx); + byte *pDest = (byte *)screen._backBuffer.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - idx); + Common::copy(pSrc, pSrcEnd, pDest); + + screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - idx, SHERLOCK_SCREEN_WIDTH, + SHERLOCK_SCREEN_HEIGHT); events.delay(10); } } -- cgit v1.2.3 From c047009ee10d8de67ee17088aad4ca131d907a8a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 27 Mar 2015 23:10:36 -0400 Subject: SHERLOCK: Fix hotspots working again after examining an object --- engines/sherlock/user_interface.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 61d6c6a76e..54c1f8e0fc 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -580,7 +580,8 @@ void UserInterface::doLookControl() { _menuMode = STD_MODE; events.clearEvents(); } - } else { + } + else { // Looking at an inventory object // Backup the user interface Surface tempSurface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1); @@ -592,15 +593,15 @@ void UserInterface::doLookControl() { // Restore the ui screen._backBuffer2.blitFrom(tempSurface, Common::Point(0, CONTROLS_Y1)); - } - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = COMMANDS[LOOK_MODE - 1]; - _temp = _oldTemp = 0; - events.clearEvents(); - _invLookFlag = false; - _menuMode = INV_MODE; - _windowOpen = true; + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = COMMANDS[LOOK_MODE - 1]; + _temp = _oldTemp = 0; + events.clearEvents(); + _invLookFlag = false; + _menuMode = INV_MODE; + _windowOpen = true; + } } } @@ -900,7 +901,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { } else { makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, - PRESS_KEY_FOR_MORE); + PRESS_KEY_TO_CONTINUE); screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, CONTROLS_Y), COMMAND_FOREGROUND, "P"); -- cgit v1.2.3 From ebda40038b72fd34673e2a6e8a29b4ec47d1ee54 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 28 Mar 2015 10:32:00 -0400 Subject: SHERLOCK: Add partial on-screen clipping to blitFrom --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 54c1f8e0fc..61933cf9f3 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -257,7 +257,7 @@ void UserInterface::handleInput() { if (!events._released) lookScreen(pt); } else { - personFound = scene._bgShapes[_bgFound]._aType == PERSON && _bgFound != -1; + personFound = _bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON; } if (events._released && personFound) -- cgit v1.2.3 From 35df6bb7ed44f78548ff7ab6b63fccc4e5b1609f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 28 Mar 2015 16:28:48 -0400 Subject: SHERLOCK: Implemented doInvControl --- engines/sherlock/user_interface.cpp | 241 +++++++++++++++++++++++++++++++++++- 1 file changed, 240 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 61933cf9f3..10b13cedbe 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -77,12 +77,14 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _oldLook = false; _keyboardInput = false; _invMode = 0; + _invIndex = 0; _pause = false; _cNum = 0; _selector = _oldSelector = -1; _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); _windowStyle = 1; // Sliding windows + _find = 0; } UserInterface::~UserInterface() { @@ -451,6 +453,10 @@ void UserInterface::toggleButton(int num) { } } +void UserInterface::buttonPrint(const Common::Point &pt, int color, bool slamIt, + const Common::String &str) { + // TODO +} /** * Clears the info line of the screen @@ -536,8 +542,235 @@ void UserInterface::doEnvControl() { // TODO } +/** + * Handle input whilst the inventory is active + */ void UserInterface::doInvControl() { - // TODO + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; + int colors[8]; + Common::Point mousePos = events.mousePos(); + + _key = _oldKey = -1; + _keyboardInput = false; + + // Check whether any inventory slot is highlighted + int found = -1; + Common::fill(&colors[0], &colors[8], (int)COMMAND_FOREGROUND); + for (int idx = 0; idx < 8; ++idx) { + Common::Rect r(INVENTORY_POINTS[idx][0], CONTROLS_Y1, + INVENTORY_POINTS[idx][1], CONTROLS_Y1 + 10); + if (r.contains(mousePos)) { + found = idx; + break; + } + } + + if (events._pressed || events._released) { + events.clearKeyboard(); + + if (found != -1) + // If a slot highlighted, set it's color + colors[found] = COMMAND_HIGHLIGHTED; + buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), + colors[0], true, "Exit"); + + if (found >= 0 && found <= 3) { + buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, "Look"); + buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[1], true, "Use"); + buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[1], true, "Give"); + _invMode = found; + _selector = -1; + } + + if (_invIndex) { + screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), + colors[4], "^^"); + screen.print(Common::Point(INVENTORY_POINTS[5][2], CONTROLS_Y1 + 1), + colors[5], "^"); + } + + if ((inv._holdings - _invIndex) > 6) { + screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), + colors[6], "^^"); + screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), + colors[7], "^"); + } + + bool flag = false; + if (_invMode == 1 || _invMode == 2 || _invMode == 3) { + Common::Rect r(15, CONTROLS_Y1 + 11, 314, SHERLOCK_SCREEN_HEIGHT - 2); + flag = (_selector < inv._holdings); + } + + if (!flag && mousePos.y >(CONTROLS_Y1 + 11)) + _selector = -1; + } + + if (_keycode != Common::KEYCODE_INVALID) { + _key = toupper(_keycode); + + if (_key == Common::KEYCODE_ESCAPE) + // Escape will also 'E'xit out of inventory display + _key = Common::KEYCODE_e; + + if (_key == 'E' || _key == 'L' || _key == 'U' || _key == 'G' + || _key == '-' || _key == '+') { + int temp = _invMode; + + const char *chP = strchr(INVENTORY_COMMANDS, _key); + _invMode = !chP ? 8 : chP - INVENTORY_COMMANDS; + inv.invCommands(true); + + _invMode = temp; + _keyboardInput = true; + if (_key == 'E') + _invMode = STD_MODE; + _selector = -1; + } else { + _selector = -1; + } + } + + if (_selector != _oldSelector) { + if (_oldSelector != -1) { + // Un-highlight + if (_oldSelector >= _invIndex && _oldSelector < (_invIndex + 6)) + inv.doInvLite(_oldSelector, BUTTON_MIDDLE); + } + + if (_selector != -1) + inv.doInvLite(_selector, 235); + + _oldSelector = _selector; + } + + if (events._released || _keyboardInput) { + if ((!found && events._released) && _key == 'E') { + inv.freeInv(); + _infoFlag = true; + clearInfo(); + banishWindow(false); + _key = -1; + events.clearEvents(); + events.setCursor(ARROW); + } else if ((found == 1 && events._released) || (_key == 'L')) { + _invMode = 1; + } else if ((found == 2 && events._released) || (_key == 'U')) { + _invMode = 2; + } else if ((found == 3 && events._released) || (_key == 'G')) { + _invMode = 3; + } else if (((found == 4 && events._released) || _key == ',') && _invIndex) { + if (_invIndex >= 6) + _invIndex -= 6; + else + _invIndex = 0; + + screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), + COMMAND_HIGHLIGHTED, "^^"); + inv.freeGraphics(); + inv.loadGraphics(); + inv.putInv(1); + inv.invCommands(true); + } else if (((found == 5 && events._released) || _key == '-') && _invIndex) { + --_invIndex; + screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), + COMMAND_HIGHLIGHTED, "^"); + inv.freeGraphics(); + inv.loadGraphics(); + inv.putInv(1); + inv.invCommands(true); + } else if (((found == 6 && events._released) || _key == '+') && (inv._holdings - _invIndex) > 6) { + ++_invIndex; + screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), + COMMAND_HIGHLIGHTED, "_"); + inv.freeGraphics(); + inv.loadGraphics(); + inv.putInv(1); + inv.invCommands(true); + } else if (((found == 7 && events._released) || _key == '.') && (inv._holdings - _invIndex) > 6) { + _invIndex += 6; + if ((inv._holdings - 6) < _invIndex) + _invIndex = inv._holdings - 6; + + screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), + COMMAND_HIGHLIGHTED, "_"); + inv.freeGraphics(); + inv.loadGraphics(); + inv.putInv(1); + inv.invCommands(true); + } else { + // If something is being given, make sure it's to a person + if (_invMode == 3) { + if (_bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON) + _find = _bgFound; + else + _find = -1; + } else { + _find = _bgFound; + } + + if ((mousePos.y < CONTROLS_Y1) && (_invMode == 1) && (_find >= 0) && (_find < 1000)) { + if (!scene._bgShapes[_find]._examine.empty() && + scene._bgShapes[_find]._examine[0] >= ' ') + inv.doInvJF(); + } else if (_selector != -1 || _find >= 0) { + // Selector is the inventory object that was clicked on, or selected. + // If it's -1, then no inventory item is highlighted yet. Otherwise, + // an object in the scene has been clicked. + + if (_selector != -1 && _invMode == 1 && mousePos.y >(CONTROLS_Y1 + 11)) + inv.doInvJF(); + + if (talk._talkToAbort) + return; + + // Now check for the Use and Give actions. If inv_mode is 3, + // that means GIVE is in effect, _selector is the object being + // given, and _find is the target. + // The same applies to USE, except if _selector is -1, then USE + // is being tried on an object in the scene without an inventory + // object being highlighted first. + + if ((_invMode == 2 || (_selector != -1 && _invMode == 3)) && _find >= 0) { + events._pressed = events._released = false; + _infoFlag = true; + clearInfo(); + + int temp = _selector; // Save the selector + _selector = -1; + + inv.putInv(1); + _selector = temp; // Restore it + temp = _invMode; + _invMode = -1; + inv.invCommands(true); + + _infoFlag = true; + clearInfo(); + banishWindow(false); + _key = -1; + + inv.freeInv(); + + if (_selector >= 0) + // Use/Give inv object with scene object + checkUseAction(scene._bgShapes[_find]._use[0], inv[_selector]._name, + _muse, _find, temp - 2); + else + // Now inv object has been highlighted + checkUseAction(scene._bgShapes[_find]._use[0], "*SELF", _muse, + _find, temp - 2); + + _selector = _oldSelector = -1; + } + } + } + } } /** @@ -1056,4 +1289,10 @@ void UserInterface::banishWindow(bool flag) { _menuMode = STD_MODE; } +void UserInterface::checkUseAction(UseType &use, const Common::String &invName, + const Common::String &msg, int objNum, int giveMode) { + // TODO +} + + } // End of namespace Sherlock -- cgit v1.2.3 From 073b7e075ccac02ecab922e03781b3663c92af6c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 28 Mar 2015 17:36:46 -0400 Subject: SHERLOCK: Implemented lookScreen --- engines/sherlock/user_interface.cpp | 139 +++++++++++++++++++++++++++++++++++- 1 file changed, 137 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 10b13cedbe..9710c3a74a 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -530,12 +530,147 @@ void UserInterface::examine() { } } +/** + * Print the name of an object in the scene + */ void UserInterface::lookScreen(const Common::Point &pt) { - // TODO + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Common::Point mousePos = events.mousePos(); + int temp; + Common::String tempStr; + int x, width, width1, width2 = 0; + + // Don't display anything for right button command + if ((events._rightPressed || events._rightPressed) && !events._pressed) + return; + + if (mousePos.y < CONTROLS_Y && (temp = _bgFound) != -1) { + if (temp != _oldLook) { + _infoFlag = true; + clearInfo(); + + if (temp < 1000) + tempStr = scene._bgShapes[temp]._description; + else + tempStr = scene._bgShapes[temp - 1000]._description; + + _infoFlag = true; + clearInfo(); + + // Only print description if there is one + if (!tempStr.empty() && tempStr[0] != ' ') { + // If inventory is active and an item is selected for a Use or Give action + if ((_menuMode == INV_MODE || _menuMode == USE_MODE || _menuMode == GIVE_MODE) && + (_invMode == 2 || _invMode == 3)) { + width1 = screen.stringWidth(inv[_selector]._name); + + if (_invMode == 2) { + // Using an object + x = width = screen.stringWidth("Use "); + + if (temp < 1000 && scene._bgShapes[temp]._aType != PERSON) + // It's not a person, so make it lowercase + tempStr.setChar(tolower(tempStr[0]), 0); + + x += screen.stringWidth(tempStr); + + // If we're using an inventory object, add in the width + // of the object name and the " on " + if (_selector != -1) { + x += width1; + width2 = screen.stringWidth(" on "); + x += width2; + } + + // If the line will be too long, keep cutting off characters + // until the string will fit + while (x > 280) { + x -= screen.charWidth(tempStr.lastChar()); + tempStr.deleteLastChar(); + } + + int xStart = (SHERLOCK_SCREEN_HEIGHT - x) / 2; + screen.print(Common::Point(xStart, INFO_LINE + 1), + INFO_FOREGROUND, "Use "); + + if (_selector != -1) { + screen.print(Common::Point(xStart + width, INFO_LINE + 1), + TALK_FOREGROUND, inv[_selector]._name.c_str()); + screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), + INFO_FOREGROUND, " on "); + screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), + INFO_FOREGROUND, tempStr.c_str()); + } else { + screen.print(Common::Point(xStart + width, INFO_LINE + 1), + INFO_FOREGROUND, tempStr.c_str()); + } + } else if (temp >= 0 && temp < 1000 && _selector != -1 && + scene._bgShapes[temp]._aType == PERSON) { + // Giving an object to a person + x = width = screen.stringWidth("Give "); + x += width1; + width2 = screen.stringWidth(" to "); + x += width2; + x += screen.stringWidth(tempStr); + + // Ensure string will fit on-screen + while (x > 280) { + x -= screen.charWidth(tempStr.lastChar()); + tempStr.deleteLastChar(); + } + + int xStart = (SHERLOCK_SCREEN_WIDTH - x) / 2; + screen.print(Common::Point(xStart, INFO_LINE + 1), + INFO_FOREGROUND, "Give "); + screen.print(Common::Point(xStart + width, INFO_LINE + 1), + TALK_FOREGROUND, inv[_selector]._name.c_str()); + screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), + INFO_FOREGROUND, " to "); + screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), + INFO_FOREGROUND, tempStr.c_str()); + } + } else { + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, tempStr.c_str()); + } + + _infoFlag = true; + _oldLook = temp; + } + } + } else { + clearInfo(); + } } +/** + * Gets the item in the inventory the mouse is on and display's it's description + */ void UserInterface::lookInv() { - // TODO + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Screen &screen = *_vm->_screen; + Common::Point mousePos = events.mousePos(); + + if (mousePos.x > 15 && mousePos.x < 314 && mousePos.y > (CONTROLS_Y1 + 11) + && mousePos.y < (SHERLOCK_SCREEN_HEIGHT - 2)) { + int temp = (mousePos.x - 6) / 52 + _invIndex; + if (temp < inv._holdings) { + if (temp < inv._holdings) { + clearInfo(); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, + inv[temp]._description.c_str()); + _infoFlag = true; + _oldLook = temp; + } + } else { + clearInfo(); + } + } else { + clearInfo(); + } } void UserInterface::doEnvControl() { -- cgit v1.2.3 From c28416f38ef77eef0858756d0b3265c44ad90216 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 28 Mar 2015 20:13:57 -0400 Subject: SHERLOCK: Change the screen _backBuffer to be a pointer --- engines/sherlock/user_interface.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9710c3a74a..dbc9108212 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -105,7 +105,7 @@ void UserInterface::drawInterface() { Screen &screen = *_vm->_screen; screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK); - screen._backBuffer.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); + screen._backBuffer1.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); screen._backBuffer2.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); } @@ -376,7 +376,7 @@ void UserInterface::depressButton(int num) { Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); Graphics::Surface &s = (*_controls)[num]._frame; - screen._backBuffer.transBlitFrom(s, pt); + screen._backBuffer1.transBlitFrom(s, pt); screen.slamArea(pt.x, pt.y, pt.x + s.w, pt.y + s.h); } @@ -389,7 +389,7 @@ void UserInterface::restoreButton(int num) { Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); Graphics::Surface &frame = (*_controls)[num]._frame; - screen._backBuffer.blitFrom(screen._backBuffer2, pt, + screen._backBuffer1.blitFrom(screen._backBuffer2, pt, Common::Rect(pt.x, pt.y, pt.x + 90, pt.y + 19)); screen.slamArea(pt.x, pt.y, pt.x + frame.w, pt.y + frame.h); @@ -443,7 +443,7 @@ void UserInterface::toggleButton(int num) { Graphics::Surface &s = (*_controls)[num]._frame; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); - screen._backBuffer.transBlitFrom(s, pt); + screen._backBuffer1.transBlitFrom(s, pt); screen.slamArea(pt.x, pt.y, pt.x + s.w, pt.y + s.h); } } else { @@ -1199,7 +1199,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { return; } - Surface &bb = screen._backBuffer; + Surface &bb = *screen._backBuffer; if (firstTime) { // Only draw the border on the first call _infoFlag = true; @@ -1286,10 +1286,10 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { Surface tempSurface(SHERLOCK_SCREEN_WIDTH, (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y)); Common::Rect r(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); - tempSurface.blitFrom(screen._backBuffer, Common::Point(0, 0), r); + tempSurface.blitFrom(screen._backBuffer1, Common::Point(0, 0), r); // Remove drawn window with original user interface - screen._backBuffer.blitFrom(screen._backBuffer2, + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y), r); // Display the window gradually on-screen @@ -1318,7 +1318,7 @@ void UserInterface::makeButton(const Common::Rect &bounds, int textX, const Common::String &str) { Screen &screen = *_vm->_screen; - Surface &bb = screen._backBuffer; + Surface &bb = *screen._backBuffer; bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP); bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP); bb.fillRect(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM); @@ -1343,7 +1343,7 @@ void UserInterface::summonWindow(const Surface &bgSurface) { // Gradually slide up the display of the window for (int idx = 1; idx <= bgSurface.h; idx += 2) { - screen._backBuffer.blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), + screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), Common::Rect(0, 0, bgSurface.w, idx)); screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); @@ -1352,7 +1352,7 @@ void UserInterface::summonWindow(const Surface &bgSurface) { } // Final display of the entire window - screen._backBuffer.blitFrom(bgSurface, Common::Point(0, CONTROLS_Y), + screen._backBuffer->blitFrom(bgSurface, Common::Point(0, CONTROLS_Y), Common::Rect(0, 0, bgSurface.w, bgSurface.h)); screen.slamArea(0, CONTROLS_Y, bgSurface.w, bgSurface.h); @@ -1374,13 +1374,13 @@ void UserInterface::banishWindow(bool flag) { if (_windowStyle) { for (int idx = 2; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y); idx += 2) { // Shift the window down by 2 lines - byte *pSrc = (byte *)screen._backBuffer.getBasePtr(0, CONTROLS_Y + idx - 2); - byte *pSrcEnd = (byte *)screen._backBuffer.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - 2); - byte *pDest = (byte *)screen._backBuffer.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT); + byte *pSrc = (byte *)screen._backBuffer1.getBasePtr(0, CONTROLS_Y + idx - 2); + byte *pSrcEnd = (byte *)screen._backBuffer1.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - 2); + byte *pDest = (byte *)screen._backBuffer1.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT); Common::copy_backward(pSrc, pSrcEnd, pDest); // Restore lines from the ui in the secondary back buffer - screen._backBuffer.blitFrom(screen._backBuffer2, + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y), Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + idx)); @@ -1390,14 +1390,14 @@ void UserInterface::banishWindow(bool flag) { } // Restore final two old lines - screen._backBuffer.blitFrom(screen._backBuffer2, + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - 2), Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 2, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - 2, SHERLOCK_SCREEN_WIDTH, 2); } else { // Restore old area to completely erase window - screen._backBuffer.blitFrom(screen._backBuffer2, + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y), Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, @@ -1408,7 +1408,7 @@ void UserInterface::banishWindow(bool flag) { for (int idx = 1; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1); idx += 2) { byte *pSrc = (byte *)screen._backBuffer2.getBasePtr(0, CONTROLS_Y1); byte *pSrcEnd = (byte *)screen._backBuffer2.getBasePtr(0, CONTROLS_Y1 + idx); - byte *pDest = (byte *)screen._backBuffer.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - idx); + byte *pDest = (byte *)screen._backBuffer1.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - idx); Common::copy(pSrc, pSrcEnd, pDest); screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - idx, SHERLOCK_SCREEN_WIDTH, -- cgit v1.2.3 From 7fec58a57d9c45f7b899f67042af57b54ca80252 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 28 Mar 2015 22:31:18 -0400 Subject: SHERLOCK: Beginnings of inventory display --- engines/sherlock/user_interface.cpp | 109 +++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 52 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index dbc9108212..a993965429 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -54,6 +54,7 @@ const int INVENTORY_POINTS[8][3] = { }; const char COMMANDS[13] = "LMTPOCIUGJFS"; +const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; @@ -85,6 +86,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { SHERLOCK_SCREEN_HEIGHT - 1); _windowStyle = 1; // Sliding windows _find = 0; + _oldUse = 0; } UserInterface::~UserInterface() { @@ -686,7 +688,6 @@ void UserInterface::doInvControl() { Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; Talk &talk = *_vm->_talk; - const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; int colors[8]; Common::Point mousePos = events.mousePos(); @@ -956,7 +957,7 @@ void UserInterface::doLookControl() { tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - inv.invent(128); + inv.drawInventory(128); banishWindow(true); // Restore the ui @@ -1060,19 +1061,19 @@ void UserInterface::doMainControl() { pushButton(6); _selector = _oldSelector = -1; _menuMode = INV_MODE; - inv.invent(1); + inv.drawInventory(1); break; case 'U': pushButton(7); _selector = _oldSelector = -1; _menuMode = USE_MODE; - inv.invent(2); + inv.drawInventory(2); break; case 'G': pushButton(8); _selector = _oldSelector = -1; _menuMode = GIVE_MODE; - inv.invent(3); + inv.drawInventory(3); break; case 'J': pushButton(9); @@ -1259,7 +1260,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { // Handle display depending on whether all the message was shown if (!endOfStr) { - makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), + screen.makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2, PRESS_KEY_FOR_MORE); screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - @@ -1267,7 +1268,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { COMMAND_FOREGROUND, "P"); _descStr = msgP; } else { - makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), + screen.makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, PRESS_KEY_TO_CONTINUE); screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - @@ -1280,20 +1281,9 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { if (!_windowStyle) { screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - } - else { - // Extract the window that's been drawn on the back buffer - Surface tempSurface(SHERLOCK_SCREEN_WIDTH, - (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y)); - Common::Rect r(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); - tempSurface.blitFrom(screen._backBuffer1, Common::Point(0, 0), r); - - // Remove drawn window with original user interface - screen._backBuffer1.blitFrom(screen._backBuffer2, - Common::Point(0, CONTROLS_Y), r); - - // Display the window gradually on-screen - summonWindow(tempSurface); + } else { + // Display the window + summonWindow(); } _selector = _oldSelector = -1; @@ -1311,29 +1301,10 @@ void UserInterface::printObjectDesc() { printObjectDesc(_cAnimStr, true); } -/** - * Draws a button for use in the inventory, talk, and examine dialogs. - */ -void UserInterface::makeButton(const Common::Rect &bounds, int textX, - const Common::String &str) { - Screen &screen = *_vm->_screen; - - Surface &bb = *screen._backBuffer; - bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP); - bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP); - bb.fillRect(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM); - bb.fillRect(Common::Rect(bounds.left + 1, bounds.bottom - 1, bounds.right, bounds.bottom), BUTTON_BOTTOM); - bb.fillRect(Common::Rect(bounds.left + 1, bounds.top + 1, bounds.right - 1, bounds.bottom - 1), BUTTON_MIDDLE); - - screen.gPrint(Common::Point(textX, bounds.top), COMMAND_HIGHLIGHTED, "%c", str[0]); - screen.gPrint(Common::Point(textX + screen.charWidth(str[0]), bounds.top), - COMMAND_FOREGROUND, "%s", str.c_str() + 1); -} - /** * Displays a passed window by gradually scrolling it vertically on-screen */ -void UserInterface::summonWindow(const Surface &bgSurface) { +void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; @@ -1341,34 +1312,68 @@ void UserInterface::summonWindow(const Surface &bgSurface) { // A window is already open, so can't open another one return; - // Gradually slide up the display of the window - for (int idx = 1; idx <= bgSurface.h; idx += 2) { - screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), - Common::Rect(0, 0, bgSurface.w, idx)); - screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx, - SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + if (slideUp) { + // Gradually slide up the display of the window + for (int idx = 1; idx <= bgSurface.h; idx += 2) { + screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), + Common::Rect(0, 0, bgSurface.w, idx)); + screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx, + SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - events.delay(10); + events.delay(10); + } + } else { + // Gradually slide down the display of the window + for (int idx = 1; idx <= bgSurface.h; idx += 2) { + screen._backBuffer->blitFrom(bgSurface, + Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h), + Common::Rect(0, bgSurface.h - idx, bgSurface.w, bgSurface.h)); + screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h, + SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - bgSurface.h + idx)); + + events.delay(10); + } } // Final display of the entire window - screen._backBuffer->blitFrom(bgSurface, Common::Point(0, CONTROLS_Y), + screen._backBuffer->blitFrom(bgSurface, Common::Point(0, + SHERLOCK_SCREEN_HEIGHT - bgSurface.h), Common::Rect(0, 0, bgSurface.w, bgSurface.h)); - screen.slamArea(0, CONTROLS_Y, bgSurface.w, bgSurface.h); + screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h, bgSurface.w, bgSurface.h); _windowOpen = true; } +/** + * Slide the window stored in the back buffer onto the screen + */ +void UserInterface::summonWindow(bool slideUp, int height) { + Screen &screen = *_vm->_screen; + + // Extract the window that's been drawn on the back buffer + Surface tempSurface(SHERLOCK_SCREEN_WIDTH, + (SHERLOCK_SCREEN_HEIGHT - height)); + Common::Rect r(0, height, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); + tempSurface.blitFrom(screen._backBuffer1, Common::Point(0, 0), r); + + // Remove drawn window with original user interface + screen._backBuffer1.blitFrom(screen._backBuffer2, + Common::Point(0, height), r); + + // Display the window gradually on-screen + summonWindow(tempSurface, slideUp); +} + /** * Close a currently open window * @param flag 0 = slide old window down, 1 = slide prior UI back up */ -void UserInterface::banishWindow(bool flag) { +void UserInterface::banishWindow(bool slideUp) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; if (_windowOpen) { - if (flag || !_windowStyle) { + if (slideUp || !_windowStyle) { // Slide window down // Only slide the window if the window style allows it if (_windowStyle) { -- cgit v1.2.3 From 3149ce0204f658e7420f16a151710f43052506f2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Mar 2015 09:52:23 -0400 Subject: SHERLOCK: Added inventory list and display images in inventory mode --- engines/sherlock/user_interface.cpp | 86 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 45 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index a993965429..5e8b3287f0 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -77,8 +77,6 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _windowOpen = false; _oldLook = false; _keyboardInput = false; - _invMode = 0; - _invIndex = 0; _pause = false; _cNum = 0; _selector = _oldSelector = -1; @@ -116,6 +114,7 @@ void UserInterface::drawInterface() { */ void UserInterface::handleInput() { Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; People &people = *_vm->_people; Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; @@ -276,7 +275,7 @@ void UserInterface::handleInput() { case USE_MODE: case GIVE_MODE: case INV_MODE: - if (_invMode == 1 || _invMode == 2 || _invMode == 3) { + if (inv._invMode == 1 || inv._invMode == 2 || inv._invMode == 3) { if (pt.y < CONTROLS_Y) lookInv(); else @@ -455,11 +454,6 @@ void UserInterface::toggleButton(int num) { } } -void UserInterface::buttonPrint(const Common::Point &pt, int color, bool slamIt, - const Common::String &str) { - // TODO -} - /** * Clears the info line of the screen */ @@ -566,10 +560,10 @@ void UserInterface::lookScreen(const Common::Point &pt) { if (!tempStr.empty() && tempStr[0] != ' ') { // If inventory is active and an item is selected for a Use or Give action if ((_menuMode == INV_MODE || _menuMode == USE_MODE || _menuMode == GIVE_MODE) && - (_invMode == 2 || _invMode == 3)) { + (inv._invMode == 2 || inv._invMode == 3)) { width1 = screen.stringWidth(inv[_selector]._name); - if (_invMode == 2) { + if (inv._invMode == 2) { // Using an object x = width = screen.stringWidth("Use "); @@ -658,7 +652,7 @@ void UserInterface::lookInv() { if (mousePos.x > 15 && mousePos.x < 314 && mousePos.y > (CONTROLS_Y1 + 11) && mousePos.y < (SHERLOCK_SCREEN_HEIGHT - 2)) { - int temp = (mousePos.x - 6) / 52 + _invIndex; + int temp = (mousePos.x - 6) / 52 + inv._invIndex; if (temp < inv._holdings) { if (temp < inv._holdings) { clearInfo(); @@ -712,25 +706,25 @@ void UserInterface::doInvControl() { if (found != -1) // If a slot highlighted, set it's color colors[found] = COMMAND_HIGHLIGHTED; - buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), + screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), colors[0], true, "Exit"); if (found >= 0 && found <= 3) { - buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, "Look"); - buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[1], true, "Use"); - buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[1], true, "Give"); - _invMode = found; + screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, "Look"); + screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[1], true, "Use"); + screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[1], true, "Give"); + inv._invMode = found; _selector = -1; } - if (_invIndex) { + if (inv._invIndex) { screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), colors[4], "^^"); screen.print(Common::Point(INVENTORY_POINTS[5][2], CONTROLS_Y1 + 1), colors[5], "^"); } - if ((inv._holdings - _invIndex) > 6) { + if ((inv._holdings - inv._invIndex) > 6) { screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), colors[6], "^^"); screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), @@ -738,7 +732,7 @@ void UserInterface::doInvControl() { } bool flag = false; - if (_invMode == 1 || _invMode == 2 || _invMode == 3) { + if (inv._invMode == 1 || inv._invMode == 2 || inv._invMode == 3) { Common::Rect r(15, CONTROLS_Y1 + 11, 314, SHERLOCK_SCREEN_HEIGHT - 2); flag = (_selector < inv._holdings); } @@ -756,16 +750,16 @@ void UserInterface::doInvControl() { if (_key == 'E' || _key == 'L' || _key == 'U' || _key == 'G' || _key == '-' || _key == '+') { - int temp = _invMode; + int temp = inv._invMode; const char *chP = strchr(INVENTORY_COMMANDS, _key); - _invMode = !chP ? 8 : chP - INVENTORY_COMMANDS; + inv._invMode = !chP ? 8 : chP - INVENTORY_COMMANDS; inv.invCommands(true); - _invMode = temp; + inv._invMode = temp; _keyboardInput = true; if (_key == 'E') - _invMode = STD_MODE; + inv._invMode = STD_MODE; _selector = -1; } else { _selector = -1; @@ -775,7 +769,7 @@ void UserInterface::doInvControl() { if (_selector != _oldSelector) { if (_oldSelector != -1) { // Un-highlight - if (_oldSelector >= _invIndex && _oldSelector < (_invIndex + 6)) + if (_oldSelector >= inv._invIndex && _oldSelector < (inv._invIndex + 6)) inv.doInvLite(_oldSelector, BUTTON_MIDDLE); } @@ -795,16 +789,16 @@ void UserInterface::doInvControl() { events.clearEvents(); events.setCursor(ARROW); } else if ((found == 1 && events._released) || (_key == 'L')) { - _invMode = 1; + inv._invMode = 1; } else if ((found == 2 && events._released) || (_key == 'U')) { - _invMode = 2; + inv._invMode = 2; } else if ((found == 3 && events._released) || (_key == 'G')) { - _invMode = 3; - } else if (((found == 4 && events._released) || _key == ',') && _invIndex) { - if (_invIndex >= 6) - _invIndex -= 6; + inv._invMode = 3; + } else if (((found == 4 && events._released) || _key == ',') && inv._invIndex) { + if (inv._invIndex >= 6) + inv._invIndex -= 6; else - _invIndex = 0; + inv._invIndex = 0; screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "^^"); @@ -812,26 +806,28 @@ void UserInterface::doInvControl() { inv.loadGraphics(); inv.putInv(1); inv.invCommands(true); - } else if (((found == 5 && events._released) || _key == '-') && _invIndex) { - --_invIndex; + } else if (((found == 5 && events._released) || _key == '-') && inv._invIndex) { + --inv._invIndex; screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "^"); inv.freeGraphics(); inv.loadGraphics(); inv.putInv(1); inv.invCommands(true); - } else if (((found == 6 && events._released) || _key == '+') && (inv._holdings - _invIndex) > 6) { - ++_invIndex; + } else if (((found == 6 && events._released) || _key == '+') && + (inv._holdings - inv._invIndex) > 6) { + ++inv._invIndex; screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); inv.freeGraphics(); inv.loadGraphics(); inv.putInv(1); inv.invCommands(true); - } else if (((found == 7 && events._released) || _key == '.') && (inv._holdings - _invIndex) > 6) { - _invIndex += 6; - if ((inv._holdings - 6) < _invIndex) - _invIndex = inv._holdings - 6; + } else if (((found == 7 && events._released) || _key == '.') && + (inv._holdings - inv._invIndex) > 6) { + inv._invIndex += 6; + if ((inv._holdings - 6) < inv._invIndex) + inv._invIndex = inv._holdings - 6; screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); @@ -841,7 +837,7 @@ void UserInterface::doInvControl() { inv.invCommands(true); } else { // If something is being given, make sure it's to a person - if (_invMode == 3) { + if (inv._invMode == 3) { if (_bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON) _find = _bgFound; else @@ -850,7 +846,7 @@ void UserInterface::doInvControl() { _find = _bgFound; } - if ((mousePos.y < CONTROLS_Y1) && (_invMode == 1) && (_find >= 0) && (_find < 1000)) { + if ((mousePos.y < CONTROLS_Y1) && (inv._invMode == 1) && (_find >= 0) && (_find < 1000)) { if (!scene._bgShapes[_find]._examine.empty() && scene._bgShapes[_find]._examine[0] >= ' ') inv.doInvJF(); @@ -859,7 +855,7 @@ void UserInterface::doInvControl() { // If it's -1, then no inventory item is highlighted yet. Otherwise, // an object in the scene has been clicked. - if (_selector != -1 && _invMode == 1 && mousePos.y >(CONTROLS_Y1 + 11)) + if (_selector != -1 && inv._invMode == 1 && mousePos.y >(CONTROLS_Y1 + 11)) inv.doInvJF(); if (talk._talkToAbort) @@ -872,7 +868,7 @@ void UserInterface::doInvControl() { // is being tried on an object in the scene without an inventory // object being highlighted first. - if ((_invMode == 2 || (_selector != -1 && _invMode == 3)) && _find >= 0) { + if ((inv._invMode == 2 || (_selector != -1 && inv._invMode == 3)) && _find >= 0) { events._pressed = events._released = false; _infoFlag = true; clearInfo(); @@ -882,8 +878,8 @@ void UserInterface::doInvControl() { inv.putInv(1); _selector = temp; // Restore it - temp = _invMode; - _invMode = -1; + temp = inv._invMode; + inv._invMode = -1; inv.invCommands(true); _infoFlag = true; -- cgit v1.2.3 From 943d0a702fe468f14fb40f73ef68588705488037 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Mar 2015 21:07:01 -0400 Subject: SHERLOCK: Beginnings of talk loading, added skeleton Scripts class --- engines/sherlock/user_interface.cpp | 58 ++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 5e8b3287f0..9fe8a0979f 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -43,14 +43,14 @@ const int MENU_POINTS[12][4] = { // Inventory control locations */ const int INVENTORY_POINTS[8][3] = { - { 4, 50, 28 }, - { 52, 99, 76 }, - { 101, 140, 122 }, - { 142, 187, 165 }, - { 189, 219, 197 }, - { 221, 251, 233 }, - { 253, 283, 265 }, - { 285, 315, 293 } + { 4, 50, 29 }, + { 52, 99, 77 }, + { 101, 140, 123 }, + { 142, 187, 166 }, + { 189, 219, 198 }, + { 221, 251, 234 }, + { 253, 283, 266 }, + { 285, 315, 294 } }; const char COMMANDS[13] = "LMTPOCIUGJFS"; @@ -85,6 +85,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _windowStyle = 1; // Sliding windows _find = 0; _oldUse = 0; + _endKeyActive = true; } UserInterface::~UserInterface() { @@ -101,12 +102,15 @@ void UserInterface::reset() { /** * Draw the user interface onto the screen's back buffers */ -void UserInterface::drawInterface() { +void UserInterface::drawInterface(int bufferNum) { Screen &screen = *_vm->_screen; - screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK); - screen._backBuffer1.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); - screen._backBuffer2.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); + if (bufferNum & 1) + screen._backBuffer1.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); + if (bufferNum & 2) + screen._backBuffer2.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); + if (bufferNum == 3) + screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK); } /** @@ -118,6 +122,7 @@ void UserInterface::handleInput() { People &people = *_vm->_people; Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; + Scripts &scripts = *_vm->_scripts; Talk &talk = *_vm->_talk; if (_menuCounter) @@ -143,7 +148,7 @@ void UserInterface::handleInput() { } // Do button highlighting check - if (!_vm->_scriptMoreFlag) { // Don't if scripts are running + if (!scripts._scriptMoreFlag) { // Don't if scripts are running if (((events._rightPressed || events._rightReleased) && _helpStyle) || (!_helpStyle && !_menuCounter)) { // Handle any default commands if we're in STD_MODE @@ -276,7 +281,7 @@ void UserInterface::handleInput() { case GIVE_MODE: case INV_MODE: if (inv._invMode == 1 || inv._invMode == 2 || inv._invMode == 3) { - if (pt.y < CONTROLS_Y) + if (pt.y > CONTROLS_Y) lookInv(); else lookScreen(pt); @@ -713,7 +718,7 @@ void UserInterface::doInvControl() { screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, "Look"); screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[1], true, "Use"); screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[1], true, "Give"); - inv._invMode = found; + inv._invMode = (InvMode)found; _selector = -1; } @@ -734,7 +739,11 @@ void UserInterface::doInvControl() { bool flag = false; if (inv._invMode == 1 || inv._invMode == 2 || inv._invMode == 3) { Common::Rect r(15, CONTROLS_Y1 + 11, 314, SHERLOCK_SCREEN_HEIGHT - 2); - flag = (_selector < inv._holdings); + if (r.contains(mousePos)) { + _selector = (mousePos.x - 6) / 52 + inv._invIndex; + if (_selector < inv._holdings) + flag = true; + } } if (!flag && mousePos.y >(CONTROLS_Y1 + 11)) @@ -753,13 +762,13 @@ void UserInterface::doInvControl() { int temp = inv._invMode; const char *chP = strchr(INVENTORY_COMMANDS, _key); - inv._invMode = !chP ? 8 : chP - INVENTORY_COMMANDS; + inv._invMode = !chP ? INVMODE_INVALID : (InvMode)(chP - INVENTORY_COMMANDS); inv.invCommands(true); - inv._invMode = temp; + inv._invMode = (InvMode)temp; _keyboardInput = true; if (_key == 'E') - inv._invMode = STD_MODE; + inv._invMode = INVMODE_EXIT; _selector = -1; } else { _selector = -1; @@ -789,11 +798,11 @@ void UserInterface::doInvControl() { events.clearEvents(); events.setCursor(ARROW); } else if ((found == 1 && events._released) || (_key == 'L')) { - inv._invMode = 1; + inv._invMode = INVMODE_LOOK; } else if ((found == 2 && events._released) || (_key == 'U')) { - inv._invMode = 2; + inv._invMode = INVMODE_USE; } else if ((found == 3 && events._released) || (_key == 'G')) { - inv._invMode = 3; + inv._invMode = INVMODE_GIVE; } else if (((found == 4 && events._released) || _key == ',') && inv._invIndex) { if (inv._invIndex >= 6) inv._invIndex -= 6; @@ -855,7 +864,8 @@ void UserInterface::doInvControl() { // If it's -1, then no inventory item is highlighted yet. Otherwise, // an object in the scene has been clicked. - if (_selector != -1 && inv._invMode == 1 && mousePos.y >(CONTROLS_Y1 + 11)) + if (_selector != -1 && inv._invMode == INVMODE_LOOK + && mousePos.y >(CONTROLS_Y1 + 11)) inv.doInvJF(); if (talk._talkToAbort) @@ -879,7 +889,7 @@ void UserInterface::doInvControl() { inv.putInv(1); _selector = temp; // Restore it temp = inv._invMode; - inv._invMode = -1; + inv._invMode = INVMODE_USE55; inv.invCommands(true); _infoFlag = true; -- cgit v1.2.3 From cf4226be45ddea933ef17722eac0f5ccadc7357b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 31 Mar 2015 07:55:54 -0400 Subject: SHERLOCK: Implemented talkTo --- engines/sherlock/user_interface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9fe8a0979f..74142ab80e 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -471,6 +471,16 @@ void UserInterface::clearInfo() { } } +/** + * Clear any active text window + */ +void UserInterface::clearWindow() { + if (_windowOpen) { + _vm->_screen->vgaBar(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, + SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); + } +} + /** * Handles counting down whilst checking for input, then clears the info line. */ -- cgit v1.2.3 From 8ee021434236b454faf52995fb102322f2e7bd8f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 2 Apr 2015 08:44:07 -0400 Subject: SHERLOCK: Implemented Inventory::highlight --- engines/sherlock/user_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 74142ab80e..6f60049e31 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -789,11 +789,11 @@ void UserInterface::doInvControl() { if (_oldSelector != -1) { // Un-highlight if (_oldSelector >= inv._invIndex && _oldSelector < (inv._invIndex + 6)) - inv.doInvLite(_oldSelector, BUTTON_MIDDLE); + inv.highlight(_oldSelector, BUTTON_MIDDLE); } if (_selector != -1) - inv.doInvLite(_selector, 235); + inv.highlight(_selector, 235); _oldSelector = _selector; } -- cgit v1.2.3 From 9c24ae75909088742aae7b303f80de43cb31a7a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 2 Apr 2015 18:30:16 -0400 Subject: SHERLOCK: Implemented Journal::drawInterface --- engines/sherlock/user_interface.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 6f60049e31..01b08ffd71 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1127,6 +1127,10 @@ void UserInterface::doTalkControl() { } void UserInterface::journalControl() { + Journal &journal = *_vm->_journal; + + journal.drawInterface(); + // TODO } -- cgit v1.2.3 From 005438570492b88a152a7a11e6d4df45687ba0bd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 4 Apr 2015 17:09:59 -0500 Subject: SHERLOCK: Implement journal event handling --- engines/sherlock/user_interface.cpp | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 01b08ffd71..289bff814f 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1127,10 +1127,51 @@ void UserInterface::doTalkControl() { } void UserInterface::journalControl() { + Events &events = *_vm->_events; Journal &journal = *_vm->_journal; - + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + int found; + bool doneFlag = false; + + // Draw the journal screen journal.drawInterface(); + // Handle journal events + do { + found = _key = -1; + events.setButtonState(); + + // Handle keypresses + if (events.kbHit()) { + Common::KeyState keyState = events.getKey(); + if (keyState.keycode == Common::KEYCODE_x && (keyState.flags & Common::KBD_ALT)) { + _vm->quitGame(); + return; + } else if (keyState.keycode == Common::KEYCODE_e || keyState.keycode == Common::KEYCODE_ESCAPE) { + doneFlag = true; + } else { + _key = toupper(keyState.keycode); + } + } + + if (!doneFlag) + doneFlag = journal.handleEvents(_key); + } while (!_vm->shouldQuit() && !doneFlag); + + // Finish up + _infoFlag = _keyboardInput = false; + _keycode = Common::KEYCODE_INVALID; + _windowOpen = false; + _windowBounds.top = CONTROLS_Y1; + _key = -1; + + // Reset the palette + screen.setPalette(screen._cMap); + + screen._backBuffer1.blitFrom(screen._backBuffer2); + scene.updateBackground(); + screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); // TODO } -- cgit v1.2.3 From 96e04ab797253bbe853f172ea1d734ebe812d419 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 10 Apr 2015 23:35:26 -0500 Subject: SHERLOCK: Implemented doScript and support methods --- engines/sherlock/user_interface.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 289bff814f..88265f6a19 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -122,7 +122,6 @@ void UserInterface::handleInput() { People &people = *_vm->_people; Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; - Scripts &scripts = *_vm->_scripts; Talk &talk = *_vm->_talk; if (_menuCounter) @@ -148,7 +147,7 @@ void UserInterface::handleInput() { } // Do button highlighting check - if (!scripts._scriptMoreFlag) { // Don't if scripts are running + if (!talk._scriptMoreFlag) { // Don't if scripts are running if (((events._rightPressed || events._rightReleased) && _helpStyle) || (!_helpStyle && !_menuCounter)) { // Handle any default commands if we're in STD_MODE @@ -532,6 +531,13 @@ void UserInterface::examine() { _vm->setFlags(inv[_selector]._lookFlag); } + if (_invLookFlag) { + // Dont close the inventory window when starting an examine display, since it's + // window will slide up to replace the inventory display + _windowOpen = false; + _menuMode = LOOK_MODE; + } + if (!talk._talkToAbort) { if (!scene._cAnimFramePause) printObjectDesc(_cAnimStr, true); -- cgit v1.2.3 From 0f0321eb43fa321319805db8264601d0f2646282 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 11 Apr 2015 17:50:07 -0500 Subject: SHERLOCK: Fix startup initialization --- engines/sherlock/user_interface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 88265f6a19..2b808a085a 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -86,6 +86,8 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _find = 0; _oldUse = 0; _endKeyActive = true; + _lookScriptFlag = false; + _infoFlag = false; } UserInterface::~UserInterface() { -- cgit v1.2.3 From 461d5c64f27c2cf86890a9ba8d7df8a63f6278e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 11 Apr 2015 23:42:11 -0500 Subject: SHERLOCK: Fixes for opening door --- engines/sherlock/user_interface.cpp | 197 +++++++++++++++++++++++++++++++++++- 1 file changed, 195 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 2b808a085a..ebbe00ffbc 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -58,6 +58,25 @@ const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; +const char *const MOPEN[] = { + "This cannot be opened", "It is already open", "It is locked", "Wait for Watson", " ", "." +}; +const char *const MCLOSE[] = { + "This cannot be closed", "It is already closed", "The safe door is in the way" +}; +const char *const MMOVE[] = { + "This cannot be moved", "It is bolted to the floor", "It is too heavy", "The other crate is in the way" +}; +const char *const MPICK[] = { + "Nothing of interest here", "It is bolted down", "It is too big to carry", "It is too heavy", + "I think a girl would be more your type", "Those flowers belong to Penny", "She's far too young for you!", + "I think a girl would be more your type!", "Government property for official use only" +}; +const char *const MUSE[] = { + "You can't do that", "It had no effect", "You can't reach it", "OK, the door looks bigger! Happy?", + "Doors don't smoke" +}; + /*----------------------------------------------------------------*/ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { @@ -327,7 +346,7 @@ void UserInterface::handleInput() { break; case MOVE_MODE: - doMiscControl(ALLOW_MOVEMENT); + doMiscControl(ALLOW_MOVE); break; case TALK_MODE: @@ -1122,8 +1141,56 @@ void UserInterface::doMainControl() { } } +/** + * Handles the input for the MOVE, OPEN, and CLOSE commands + */ void UserInterface::doMiscControl(int allowed) { - // TODO + Events &events = *_vm->_events; + Scene &scene = *_vm->_scene; + Talk &talk = *_vm->_talk; + + if (events._released) { + _temp = _bgFound; + if (_bgFound != -1) { + // Only allow pointing to objects, not people + if (_bgFound < 1000) { + events.clearEvents(); + Object &obj = scene._bgShapes[_bgFound]; + + switch (allowed) { + case ALLOW_OPEN: + checkAction(obj._aOpen, MOPEN, _temp); + if (_menuMode && !talk._talkToAbort) { + _menuMode = STD_MODE; + restoreButton(OPEN_MODE - 1); + _key = _oldKey = -1; + } + break; + + case ALLOW_CLOSE: + checkAction(obj._aClose, MCLOSE, _temp); + if (_menuMode != TALK_MODE && !talk._talkToAbort) { + _menuMode = STD_MODE; + restoreButton(CLOSE_MODE - 1); + _key = _oldKey = -1; + } + break; + + case ALLOW_MOVE: + checkAction(obj._aMove, MMOVE, _temp); + if (_menuMode != TALK_MODE && !talk._talkToAbort) { + _menuMode = STD_MODE; + restoreButton(MOVE_MODE - 1); + _key = _oldKey = -1; + } + break; + + default: + break; + } + } + } + } } void UserInterface::doPickControl() { @@ -1503,5 +1570,131 @@ void UserInterface::checkUseAction(UseType &use, const Common::String &invName, // TODO } +/** + * Called for OPEN, CLOSE, and MOVE actions are being done + */ +void UserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) { + Events &events = *_vm->_events; + People &people = *_vm->_people; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + bool printed = false; + bool doCAnim = true; + int cAnimNum; + Common::Point pt(-1, -1); + int dir = -1; + + if (objNum >= 1000) + // Ignore actions done on characters + return; + Object &obj = scene._bgShapes[objNum]; + + if (action._cAnimNum == 0) + // Really a 10 + cAnimNum = 9; + else + cAnimNum = action._cAnimNum - 1; + CAnim &anim = scene._cAnim[cAnimNum]; + + if (action._cAnimNum != 99) { + if (action._cAnimSpeed & REVERSE_DIRECTION) { + pt = anim._teleportPos; + dir = anim._teleportDir; + } else { + pt = anim._goto; + dir = anim._gotoDir; + } + } + + if (action._cAnimSpeed) { + // Has a value, so do action + // Show wait cursor whilst walking to object and doing action + events.setCursor(WAIT); + + for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { + if (action._names[nameIdx].hasPrefix("*") && toupper(action._names[nameIdx][1]) == 'W') { + if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), messages)) { + if (!talk._talkToAbort) + printed = true; + } + } + } + + for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { + if (action._names[nameIdx].hasPrefix("*")) { + char ch = toupper(action._names[nameIdx][1]); + + if (ch == 'T' || ch == 'B') { + printed = true; + if (pt.x != -1) + // Holmes needs to walk to object before the action is done + people.walkToCoords(pt, dir); + + if (!talk._talkToAbort) { + // Ensure Holmes is on the exact intended location + people[AL]._position = pt; + people[AL]._sequenceNumber = dir; + people.gotoStand(people[AL]); + + talk.talkTo(action._names[nameIdx] + 2); + if (ch == 'T') + doCAnim = false; + } + } + } + } + + if (doCAnim && !talk._talkToAbort) { + if (pt.x != -1) + // Holmes needs to walk to object before the action is done + people.walkToCoords(pt, dir); + } + + for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { + if (action._names[nameIdx].hasPrefix("*") && toupper(action._names[nameIdx][1]) == 'F') { + if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, messages)) { + if (!talk._talkToAbort) + printed = true; + } + } + } + + if (doCAnim && !talk._talkToAbort && action._cAnimNum != 99) + scene.startCAnim(cAnimNum, action._cAnimSpeed); + + if (!talk._talkToAbort) { + for (int nameIdx = 0; nameIdx < 4 && !talk._talkToAbort; ++nameIdx) { + if (obj.checkNameForCodes(action._names[nameIdx], messages)) { + if (!talk._talkToAbort) + printed = true; + } + } + + // Unless we're leaving the scene, print a "Done" message unless the printed flag has been set + if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { + _infoFlag = true; + clearInfo(); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[action._cAnimNum]); + + // Set how long to show the message + _menuCounter = 30; + } + } + } else { + // Invalid action, to print error message + _infoFlag = true; + clearInfo(); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[action._cAnimNum]); + _infoFlag = true; + + // Set how long to show the message + _menuCounter = 30; + } + + // Reset cursor back to arrow + events.setCursor(ARROW); +} + } // End of namespace Sherlock -- cgit v1.2.3 From 454b6a2bbe38a4540769ad5cf51290b7a19524e4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Apr 2015 11:06:25 -0500 Subject: SHERLOCK: Implemented pick up code --- engines/sherlock/user_interface.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ebbe00ffbc..9104c761a0 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -92,6 +92,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _lookHelp = 0; _key = _oldKey = 0; _temp = _oldTemp = 0; + _temp1 = 0; _invLookFlag = 0; _windowOpen = false; _oldLook = false; @@ -711,6 +712,9 @@ void UserInterface::lookInv() { } } +/** + * Handles input when the file list window is being displayed + */ void UserInterface::doEnvControl() { // TODO } @@ -1193,8 +1197,29 @@ void UserInterface::doMiscControl(int allowed) { } } +/** + * Handles input for picking up items + */ void UserInterface::doPickControl() { - // TODO + Events &events = *_vm->_events; + Scene &scene = *_vm->_scene; + + if (events._released) { + if ((_temp = _bgFound) != -1) { + events.clearEvents(); + + // Don't allow characters to be picked up + if (_bgFound < 1000) { + scene._bgShapes[_bgFound].pickUpObject(MPICK); + + if (_menuMode != TALK_MODE) { + _key = _oldKey = -1; + _menuMode = STD_MODE; + restoreButton(PICKUP_MODE - 1); + } + } + } + } } void UserInterface::doTalkControl() { -- cgit v1.2.3 From c9890cbacc7bf6a1216cadf6eddc04832f0ebbe4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Apr 2015 17:55:55 -0500 Subject: SHERLOCK: Implementing event handling for talk display --- engines/sherlock/user_interface.cpp | 254 +++++++++++++++++++++++++++++++++++- 1 file changed, 253 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9104c761a0..70f284c359 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1222,8 +1222,260 @@ void UserInterface::doPickControl() { } } +/** + * Handles input when in talk mode. It highlights the buttons and available statements, + * and handles allowing the user to click on them + */ void UserInterface::doTalkControl() { - // TODO + Events &events = *_vm->_events; + Journal &journal = *_vm->_journal; + People &people = *_vm->_people; + Screen &screen = *_vm->_screen; + Sound &sound = *_vm->_sound; + Talk &talk = *_vm->_talk; + UserInterface &ui = *_vm->_ui; + Common::Point mousePos = events.mousePos(); + int select; + + _key = _oldKey = -1; + _keyboardInput = false; + + 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"); + else if (_endKeyActive) + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_FOREGROUND, true, "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"); + else if (talk._moreTalkUp) + screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, true, "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"); + else if (talk._moreTalkDown) + screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, true, "Down"); + + bool found = false; + for (_selector = talk._talkIndex; _selector < (int)talk._statements.size() && !found; ++_selector) { + if (mousePos.y > talk._statements[_selector]._talkPos.top && + mousePos.y < talk._statements[_selector]._talkPos.bottom) + found = true; + } + --_selector; + if (!found) + _selector = -1; + } + + if (_keycode != Common::KEYCODE_INVALID) { + _key = toupper(_keycode); + if (_key == Common::KEYCODE_ESCAPE) + _key = 'E'; + + // Check for number press indicating reply line + if (_key >= '1' && _key <= ('1' + (int)talk._statements.size() - 1)) { + for (uint idx = 0; idx < talk._statements.size(); ++idx) { + if (talk._statements[idx]._talkMap == (_key - '1')) { + // Found the given statement + _selector = idx; + _key = -1; + _keyboardInput = true; + break; + } + } + } else if (_key == 'E' || _key == 'U' || _key == 'D') { + _keyboardInput = true; + } else { + _selector = -1; + } + } + + if (_selector != _oldSelector) { + // Remove highlighting from previous line, if any + if (_oldSelector != -1) { + if (!((talk._talkHistory[talk._converseNum][_oldSelector] >> (_oldSelector & 7)) & 1)) + talk.talkLine(_oldSelector, talk._statements[_oldSelector]._talkMap, INV_FOREGROUND, + talk._statements[_oldSelector]._talkPos.top, true); + else + talk.talkLine(_oldSelector, talk._statements[_oldSelector]._talkMap, TALK_NULL, + talk._statements[_oldSelector]._talkPos.top, true); + } + + // Add highlighting to new line, if any + if (_selector != -1) + talk.talkLine(_selector, talk._statements[_selector]._talkMap, TALK_FOREGROUND, + talk._statements[_selector]._talkPos.top, true); + } + + if (events._released || _keyboardInput) { + if (_endKeyActive && ((mousePos.x > 99 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) + && talk._moreTalkUp && events._released) || _key == 'E')) { + talk.freeTalkVars(); + talk.pullSequence(); + banishWindow(); + _windowBounds.top = CONTROLS_Y1; + } else if ((mousePos.x > 140 && mousePos.x < 179 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) + && talk._moreTalkUp && events._released) || (talk._moreTalkUp && _key == 'U')) { + while (talk._statements[--talk._talkIndex]._talkMap == -1) + ; + screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, + SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); + talk.displayTalk(false); + + screen.slamRect(Common::Rect(5, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH - 5, SHERLOCK_SCREEN_HEIGHT - 2)); + } else if ((mousePos.x > 181 && mousePos.x < 220 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) + && talk._moreTalkDown && events._released) || (talk._moreTalkDown && _key == 'D')) { + do { + ++talk._talkIndex; + } while (talk._talkIndex < (int)talk._statements.size() && talk._statements[talk._talkIndex]._talkMap == -1); + + screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, + SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); + talk.displayTalk(false); + + 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"); + + // If the reply is new, add it to the journal + if (!talk._talkHistory[talk._converseNum][_selector]) { + journal.record(talk._converseNum, _selector); + + // Add any Holmes point to Holmes' total, if any + if (talk._statements[_selector]._quotient) + people._homesQuotient += talk._statements[_selector]._quotient; + } + + // Flag the response as having been used + talk._talkHistory[talk._converseNum][_selector] = true; + + clearWindow(); + screen.print(Common::Point(16, CONTROLS_Y + 12), TALK_FOREGROUND, "Sherlock Holmes"); + talk.talkLine(_selector + 128, talk._statements[_selector]._talkMap, COMMAND_FOREGROUND, CONTROLS_Y + 21, true); + + switch (talk._statements[_selector]._portraitSide & 3) { + case 0: + case 1: + people._portraitSide = 20; + break; + case 2: + people._portraitSide = 220; + break; + case 3: + people._portraitSide = 120; + break; + } + + // Check for flipping Holmes + if (talk._statements[_selector]._portraitSide & REVERSE_DIRECTION) + people._holmesFlip = true; + + talk._speaker = 0; + people.setTalking(0); + + if (!talk._statements[_selector]._voiceFile.empty() && sound._voices) { + sound.playSound(talk._statements[_selector]._voiceFile); + + // Set voices as an indicator for waiting + sound._voices = 2; + sound._speechOn = *sound._soundIsOn; + } else { + sound._speechOn = false; + } + + // Set the _scriptCurrentIndex so if the statement is irrupted, the entire + // reply will be shown when it's restarted + talk._scriptCurrentIndex = 0; + talk.waitForMore(talk._statements[_selector]._statement.size()); + if (talk._talkToAbort) + return; + + people.clearTalking(); + if (talk._talkToAbort) + return; + + while (!_vm->shouldQuit()) { + talk._scriptSelect = _selector; + talk._speaker = talk._talkTo; + talk.doScript(talk._statements[_selector]._reply); + + if (!talk._talkToAbort) { + if (!talk._talkStealth) + clearWindow(); + + if (!talk._statements[_selector]._modified.empty()) { + for (uint idx = 0; idx < talk._statements[_selector]._modified.size(); ++idx) { + _vm->setFlags(talk._statements[_selector]._modified[idx]); + } + + talk.setTalkMap(); + } + + // Check for another linked talk file + Common::String linkFilename = talk._statements[_selector]._linkFile; + if (!linkFilename.empty() && !talk._scriptMoreFlag) { + talk.freeTalkVars(); + talk.loadTalkFile(linkFilename); + + // Find the first new statement + select = _selector = _oldSelector = -1; + for (uint idx = 0; idx < talk._statements.size() && select == -1; ++idx) { + if (!talk._statements[idx]._talkMap) + select = talk._talkIndex = idx; + } + + // See if the new statement is a stealth reply + talk._talkStealth = talk._statements[select]._statement.hasPrefix("^") ? 2 : 0; + + // Is the new talk file a standard file, reply first file, or a stealth file + if (!talk._statements[select]._statement.hasPrefix("*") && + !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"); + else + screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, true, "Exit"); + + talk.displayTalk(true); + events.setCursor(ARROW); + break; + } else { + _selector = select; + + if (!talk._talkHistory[talk._converseNum][_selector]) + journal.record(talk._converseNum, _selector); + + talk._talkHistory[talk._converseNum][_selector] = true; + } + } else { + talk.freeTalkVars(); + talk.pullSequence(); + banishWindow(); + _windowBounds.top = CONTROLS_Y1; + break; + } + } else { + break; + } + } + + events._pressed = events._released = false; + events._oldButtons = 0; + talk._talkStealth = 0; + + // If a script was pushed onto the script stack, restore it + if (!talk._scriptStack.empty()) { + SequenceEntry seqEntry = talk._scriptStack.pop(); +// talk._scriptName = seqEntry. + // TODO + } + } + } } void UserInterface::journalControl() { -- cgit v1.2.3 From e8e095aa2ad7f3914b3b8dd4826c2d13e35b1163 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Apr 2015 19:11:34 -0500 Subject: SHERLOCK: Fix mixups with sequence stack and script stack --- engines/sherlock/user_interface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 70f284c359..e20813822e 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1233,7 +1233,6 @@ void UserInterface::doTalkControl() { Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; Talk &talk = *_vm->_talk; - UserInterface &ui = *_vm->_ui; Common::Point mousePos = events.mousePos(); int select; @@ -1470,9 +1469,10 @@ void UserInterface::doTalkControl() { // If a script was pushed onto the script stack, restore it if (!talk._scriptStack.empty()) { - SequenceEntry seqEntry = talk._scriptStack.pop(); -// talk._scriptName = seqEntry. - // TODO + ScriptStackEntry stackEntry = talk._scriptStack.pop(); + talk._scriptName = stackEntry._name; + talk._scriptSaveIndex = stackEntry._currentIndex; + talk._scriptSelect = stackEntry._select; } } } -- cgit v1.2.3 From cf878316ea66e75b715f8467ff82594fa3a32604 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Apr 2015 23:20:22 -0500 Subject: SHERLOCK: Implement settings window code --- engines/sherlock/user_interface.cpp | 317 +++++++++++++++++++++++++++++++++++- 1 file changed, 316 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index e20813822e..651844fd66 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -53,6 +53,23 @@ const int INVENTORY_POINTS[8][3] = { { 285, 315, 294 } }; +const int SETUP_POINTS[12][4] = { + { 4, 154, 101, 53 }, // Exit + { 4, 165, 101, 53 }, // Music Toggle + { 219, 165, 316, 268 }, // Voice Toggle + { 103, 165, 217, 160 }, // Sound Effects Toggle + { 219, 154, 316, 268 }, // Help Button Left/Right + { 103, 154, 217, 160 }, // New Font Style + { 4, 187, 101, 53 }, // Joystick Toggle + { 103, 187, 217, 160 }, // Calibrate Joystick + { 219, 176, 316, 268 }, // Fade Style + { 103, 176, 217, 160 }, // Window Open Style + { 4, 176, 101, 53 }, // Portraits Toggle + { 219, 187, 316, 268 } // Key Pad Accel. Toggle +}; + + + const char COMMANDS[13] = "LMTPOCIUGJFS"; const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; @@ -77,6 +94,162 @@ const char *const MUSE[] = { "Doors don't smoke" }; +const char *const SETUP_STRS0[2] = { "off", "on" }; +const char *const SETUP_STRS1[2] = { "Directly", "by Pixel" }; +const char *const SETUP_STRS2[2] = { "Left", "Right" }; +const char *const SETUP_STRS3[2] = { "Appear", "Slide" }; +const char *const SETUP_STRS4[2] = { "Slow", "Fast" }; +const char *const SETUP_STRS5[2] = { "Left", "Right" }; +const char *const SETUP_NAMES[12] = { + "Exit", "M", "V", "S", "B", "New Font Style", "J", "Calibrate Joystick", "F", "W", "P", "K" +}; + +/*----------------------------------------------------------------*/ + +/** + * Draws the interface for the settings window + */ +void Settings::drawInteface(bool flag) { + People &people = *_vm->_people; + Screen &screen = *_vm->_screen; + Sound &sound = *_vm->_sound; + UserInterface &ui = *_vm->_ui; + Common::String tempStr; + + if (!flag) { + screen._backBuffer1.fillRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y1 + 1), BORDER_COLOR); + screen._backBuffer1.fillRect(Common::Rect(0, CONTROLS_Y1 + 1, 2, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); + screen._backBuffer1.fillRect(Common::Rect(SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y1 + 1, SHERLOCK_SCREEN_WIDTH, + SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); + screen._backBuffer1.hLine(0, SHERLOCK_SCREEN_HEIGHT - 1, SHERLOCK_SCREEN_WIDTH - 1, BORDER_COLOR); + screen._backBuffer1.fillRect(Common::Rect(2, CONTROLS_Y1 + 1, SHERLOCK_SCREEN_WIDTH - 2, + SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); + } + + screen.makeButton(Common::Rect(SETUP_POINTS[0][0], SETUP_POINTS[0][1], SETUP_POINTS[0][2], SETUP_POINTS[0][1] + 10), + SETUP_POINTS[0][3] - screen.stringWidth("Exit") / 2, "Exit"); + + tempStr = Common::String::format("Music %s", SETUP_STRS0[sound._music]); + screen.makeButton(Common::Rect(SETUP_POINTS[1][0], SETUP_POINTS[1][1], SETUP_POINTS[1][2], SETUP_POINTS[1][1] + 10), + SETUP_POINTS[1][3] - screen.stringWidth(tempStr) / 2, tempStr); + + tempStr = Common::String::format("Voices %s", SETUP_STRS0[sound._voices]); + screen.makeButton(Common::Rect(SETUP_POINTS[2][0], SETUP_POINTS[2][1], SETUP_POINTS[2][2], SETUP_POINTS[2][1] + 10), + SETUP_POINTS[2][3] - screen.stringWidth(tempStr) / 2, tempStr); + + tempStr = Common::String::format("Sound Effects %s", SETUP_STRS0[sound._digitized]); + screen.makeButton(Common::Rect(SETUP_POINTS[3][0], SETUP_POINTS[3][1], SETUP_POINTS[3][2], SETUP_POINTS[3][1] + 10), + SETUP_POINTS[3][3] - screen.stringWidth(tempStr) / 2, tempStr); + + tempStr = Common::String::format("Auto Help %s", SETUP_STRS5[ui._helpStyle]); + screen.makeButton(Common::Rect(SETUP_POINTS[4][0], SETUP_POINTS[4][1], SETUP_POINTS[4][2], SETUP_POINTS[4][1] + 10), + SETUP_POINTS[4][3] - screen.stringWidth(tempStr) / 2, tempStr); + screen.makeButton(Common::Rect(SETUP_POINTS[5][0], SETUP_POINTS[5][1], SETUP_POINTS[5][2], SETUP_POINTS[5][1] + 10), + SETUP_POINTS[5][3] - screen.stringWidth("New Font Style") / 2, "New Font Style"); + tempStr = Common::String::format("Joystick %s", SETUP_STRS0[_vm->_joystick ? 1 : 0]); + screen.makeButton(Common::Rect(SETUP_POINTS[6][0], SETUP_POINTS[6][1], SETUP_POINTS[6][2], SETUP_POINTS[6][1] + 10), + SETUP_POINTS[6][3] - screen.stringWidth(tempStr) / 2, tempStr); + screen.makeButton(Common::Rect(SETUP_POINTS[7][0], SETUP_POINTS[7][1], SETUP_POINTS[7][2], SETUP_POINTS[7][1] + 10), + SETUP_POINTS[7][3] - screen.stringWidth("Calibrate Joystick") / 2, "Calibrate Joystick"); + + tempStr = Common::String::format("Fade %s", screen._fadeStyle ? "by Pixel" : "Directly"); + screen.makeButton(Common::Rect(SETUP_POINTS[8][0], SETUP_POINTS[8][1], SETUP_POINTS[8][2], SETUP_POINTS[8][1] + 10), + SETUP_POINTS[8][3] - screen.stringWidth(tempStr) / 2, tempStr); + + tempStr = Common::String::format("Windows %s", ui._windowStyle ? "Slide" : "Appear"); + screen.makeButton(Common::Rect(SETUP_POINTS[9][0], SETUP_POINTS[9][1], SETUP_POINTS[9][2], SETUP_POINTS[9][1] + 10), + SETUP_POINTS[9][3] - screen.stringWidth(tempStr) / 2, tempStr); + + tempStr = Common::String::format("Portraits %s", SETUP_STRS0[people._portraitsOn]); + screen.makeButton(Common::Rect(SETUP_POINTS[10][0], SETUP_POINTS[10][1], SETUP_POINTS[10][2], SETUP_POINTS[10][1] + 10), + SETUP_POINTS[10][3] - screen.stringWidth(tempStr) / 2, tempStr); + tempStr = Common::String::format("Key Pad %s", _vm->_keyPadSpeed ? "Fast" : "Slow"); + + screen.makeButton(Common::Rect(SETUP_POINTS[11][0], SETUP_POINTS[11][1], SETUP_POINTS[11][2], SETUP_POINTS[11][1] + 10), + SETUP_POINTS[11][3] - screen.stringWidth(tempStr) / 2, tempStr); + + // Show the window immediately, or slide it on-screen + if (!flag) { + if (!ui._windowStyle) { + screen.slamRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + } else { + ui.summonWindow(true, CONTROLS_Y1); + } + + ui._windowOpen = true; + } else { + screen.slamRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + } +} + +int Settings::drawButtons(const Common::Point &pt, int key) { + Events &events = *_vm->_events; + People &people = *_vm->_people; + Screen &screen = *_vm->_screen; + Sound &sound = *_vm->_sound; + UserInterface &ui = *_vm->_ui; + int found = -1; + byte color; + Common::String tempStr; + + for (int idx = 0; idx < 12; ++idx) { + if ((pt.x > SETUP_POINTS[idx][0] && pt.x < SETUP_POINTS[idx][2] && pt.y > SETUP_POINTS[idx][1] + && pt.y < (SETUP_POINTS[idx][1] + 10) && (events._released || events._released)) + || (key == SETUP_NAMES[idx][0])) { + found = idx; + color = COMMAND_HIGHLIGHTED; + } else { + color = COMMAND_FOREGROUND; + } + + // Print the button text + switch (idx) { + case 1: + tempStr = Common::String::format("Music %s", SETUP_STRS0[sound._music]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 2: + tempStr = Common::String::format("Voices %s", SETUP_STRS0[sound._voices]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 3: + tempStr = Common::String::format("Sound Effects %s", SETUP_STRS0[sound._digitized]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 4: + tempStr = Common::String::format("Auto Help %s", SETUP_STRS2[ui._helpStyle]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 6: + tempStr = Common::String::format("Joystick %s", SETUP_STRS0[_vm->_joystick]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 8: + tempStr = Common::String::format("Fade %s", SETUP_STRS1[screen._fadeStyle]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 9: + tempStr = Common::String::format("Windows %s", SETUP_STRS3[ui._windowStyle]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 10: + tempStr = Common::String::format("Portraits %s", SETUP_STRS0[people._portraitsOn]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + case 11: + tempStr = Common::String::format("Key Pad %s", SETUP_STRS4[_vm->_keyPadSpeed]); + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + break; + default: + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, SETUP_NAMES[idx]); + break; + } + } + + return found; +} + + /*----------------------------------------------------------------*/ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { @@ -1531,8 +1704,150 @@ void UserInterface::environment() { // TODO } +/** + * Handles input when the settings window is being shown + */ void UserInterface::doControls() { - // TODO + Events &events = *_vm->_events; + People &people = *_vm->_people; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Sound &sound = *_vm->_sound; + Talk &talk = *_vm->_talk; + UserInterface &ui = *_vm->_ui; + int found; + byte color; + bool updateConfig = false; + + Settings settings(_vm); + settings.drawInteface(false); + + do { + if (_menuCounter) + whileMenuCounter(); + + found = -1; + _key = -1; + + scene.doBgAnim(); + if (talk._talkToAbort) + return; + + events.setButtonState(); + Common::Point pt = events.mousePos(); + + if (events._pressed || events._released || events.kbHit()) { + clearInfo(); + _key = -1; + + if (events.kbHit()) { + Common::KeyState keyState = events.getKey(); + _key = toupper(keyState.keycode); + + if (_key == Common::KEYCODE_RETURN || _key == Common::KEYCODE_SPACE) { + events._pressed = false; + events._oldButtons = 0; + _keycode = Common::KEYCODE_INVALID; + events._released = true; + } + } + + // Handle highlighting button under mouse + found = settings.drawButtons(pt, _key); + } + + if ((found == 0 && events._released) || (_key == 'E' || _key == Common::KEYCODE_ESCAPE)) + // Exit + break; + + if ((found == 1 && events._released) || _key == 'M') { + // Toggle music + if (sound._music) { + sound.stopSound(); + sound._music = false; + } else { + sound._music = true; + sound.startSong(); + } + + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 2 && events._released) || _key == 'V') { + sound._voices = !sound._voices; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 3 && events._released) || _key == 'S') { + // Toggle sound effects + sound._digitized = !sound._digitized; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 4 && events._released) || _key == 'A') { + // Help button style + ui._helpStyle ^= 1; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 5 && events._released) || _key == 'N') { + // New font style + screen.setFont((screen.fontNumber() + 1) & 3); + } + + if ((found == 6 && events._released) || _key == 'J') { + // Toggle joystick + _vm->_joystick = !_vm->_joystick; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 7 && events._released) || _key == 'C') { + // Calibrate joystick - No implementation in ScummVM + } + + if ((found == 8 && events._released) || _key == 'F') { + // Toggle fade style + screen._fadeStyle = !screen._fadeStyle; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 9 && events._released) || _key == 'W') { + // Window style + ui._windowStyle ^= 1; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 10 && events._released) || _key == 'P') { + // Toggle portraits being shown + people._portraitsOn = !people._portraitsOn; + updateConfig = true; + settings.drawInteface(true); + } + + if ((found == 11 && events._released) || _key == 'K') { + // Toggle keypad acceleration speed + _vm->_keyPadSpeed ^= 1; + updateConfig = true; + settings.drawInteface(true); + } + } while (!_vm->shouldQuit()); + + banishWindow(); + + if (updateConfig) + _vm->saveConfig(); + + _keycode = Common::KEYCODE_INVALID; + _keyboardInput = false; + _windowBounds.top = CONTROLS_Y1; + _key = -1; } /** -- cgit v1.2.3 From 3be28b495dbedc3a94b366edd6178cbf0941cc77 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 13 Apr 2015 20:10:35 -0500 Subject: SHERLOCK: Implemented checkUseAction --- engines/sherlock/user_interface.cpp | 105 +++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 8 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 651844fd66..dc87cf130c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1115,12 +1115,10 @@ void UserInterface::doInvControl() { if (_selector >= 0) // Use/Give inv object with scene object - checkUseAction(scene._bgShapes[_find]._use[0], inv[_selector]._name, - _muse, _find, temp - 2); + checkUseAction(&scene._bgShapes[_find]._use[0], inv[_selector]._name, MUSE, _find, temp - 2); else // Now inv object has been highlighted - checkUseAction(scene._bgShapes[_find]._use[0], "*SELF", _muse, - _find, temp - 2); + checkUseAction(&scene._bgShapes[_find]._use[0], "*SELF", MUSE, _find, temp - 2); _selector = _oldSelector = -1; } @@ -1716,7 +1714,6 @@ void UserInterface::doControls() { Talk &talk = *_vm->_talk; UserInterface &ui = *_vm->_ui; int found; - byte color; bool updateConfig = false; Settings settings(_vm); @@ -2157,9 +2154,101 @@ void UserInterface::banishWindow(bool slideUp) { _menuMode = STD_MODE; } -void UserInterface::checkUseAction(UseType &use, const Common::String &invName, - const Common::String &msg, int objNum, int giveMode) { - // TODO +/** + * Checks to see whether a USE action is valid on the given object + */ +void UserInterface::checkUseAction(const UseType *use, const Common::String &invName, + const char *const messages[], int objNum, int giveMode) { + Events &events = *_vm->_events; + Inventory &inv = *_vm->_inventory; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + bool printed = messages == nullptr; + + if (objNum >= 1000) { + // Holmes was specified, so do nothing + _infoFlag = true; + clearInfo(); + _infoFlag = true; + + // Display error message + _menuCounter = 30; + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "You can't do that to yourself."); + return; + } + + // Scan for target item + int targetNum = -1; + if (giveMode) { + for (int idx = 0; idx < 4 && targetNum == -1; ++idx) { + if ((scumm_stricmp(use[idx]._target.c_str(), "*GIVE*") == 0 || scumm_stricmp(use[idx]._target.c_str(), "*GIVEP*") == 0) + && scumm_stricmp(use[idx]._names[0].c_str(), invName.c_str()) == 0) { + // Found a match + targetNum = idx; + if (scumm_stricmp(use[idx]._target.c_str(), "*GIVE*") == 0) + inv.deleteItemFromInventory(invName); + } + } + } else { + for (int idx = 0; idx < 4 && targetNum == -1; ++idx) { + if (scumm_stricmp(use[idx]._target.c_str(), invName.c_str()) == 0) + targetNum = idx; + } + } + + if (targetNum != -1) { + // Found a target, so do the action + const UseType &action = use[targetNum]; + int messageNum = action._cAnimNum; + + events.setCursor(WAIT); + + if (action._useFlag) + _vm->setFlags(action._useFlag); + + if (action._cAnimNum != 99) { + if (action._cAnimNum == 0) + scene.startCAnim(9, action._cAnimSpeed); + else + scene.startCAnim(action._cAnimNum - 1, action._cAnimSpeed); + } + + if (!talk._talkToAbort) { + Object &obj = scene._bgShapes[objNum]; + for (int idx = 0; idx < 4 && !talk._talkToAbort; ++idx) { + if (obj.checkNameForCodes(action._names[idx], messages)) { + if (!talk._talkToAbort) + printed = true; + } + } + + // Print "Done..." as an ending, unless flagged for leaving scene or otherwise flagged + if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { + _infoFlag++; + clearInfo(); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); + _menuCounter = 25; + } + } + } else { + // Couldn't find target, so print error + _infoFlag = true; + clearInfo(); + + if (giveMode) { + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "No, thank you."); + } else if (messages == nullptr) { + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "You can't do that."); + } else { + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[0]); + } + + _infoFlag = true; + _menuCounter = 30; + } + + events.setCursor(ARROW); } /** -- cgit v1.2.3 From 38b6aa70a82fb05ee7e1581a239e054a9d304827 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 13 Apr 2015 22:55:07 -0500 Subject: SHERLOCK: Fixes for talk setup and portrait loading --- engines/sherlock/user_interface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index dc87cf130c..43ae76f94b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2200,7 +2200,6 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv if (targetNum != -1) { // Found a target, so do the action const UseType &action = use[targetNum]; - int messageNum = action._cAnimNum; events.setCursor(WAIT); @@ -2318,7 +2317,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] people[AL]._sequenceNumber = dir; people.gotoStand(people[AL]); - talk.talkTo(action._names[nameIdx] + 2); + talk.talkTo(action._names[nameIdx].c_str() + 2); if (ch == 'T') doCAnim = false; } -- cgit v1.2.3 From a81686b0e1108fc5e9cac79e8e5890ad8c0f8c23 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 21 Apr 2015 02:06:24 -0500 Subject: SHERLOCK: Fix Setup dialog button handling --- engines/sherlock/user_interface.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 43ae76f94b..3ab705e26c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -146,7 +146,8 @@ void Settings::drawInteface(bool flag) { SETUP_POINTS[4][3] - screen.stringWidth(tempStr) / 2, tempStr); screen.makeButton(Common::Rect(SETUP_POINTS[5][0], SETUP_POINTS[5][1], SETUP_POINTS[5][2], SETUP_POINTS[5][1] + 10), SETUP_POINTS[5][3] - screen.stringWidth("New Font Style") / 2, "New Font Style"); - tempStr = Common::String::format("Joystick %s", SETUP_STRS0[_vm->_joystick ? 1 : 0]); + + tempStr = Common::String::format("Joystick %s", SETUP_STRS0[0]); screen.makeButton(Common::Rect(SETUP_POINTS[6][0], SETUP_POINTS[6][1], SETUP_POINTS[6][2], SETUP_POINTS[6][1] + 10), SETUP_POINTS[6][3] - screen.stringWidth(tempStr) / 2, tempStr); screen.makeButton(Common::Rect(SETUP_POINTS[7][0], SETUP_POINTS[7][1], SETUP_POINTS[7][2], SETUP_POINTS[7][1] + 10), @@ -221,7 +222,7 @@ int Settings::drawButtons(const Common::Point &pt, int key) { screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); break; case 6: - tempStr = Common::String::format("Joystick %s", SETUP_STRS0[_vm->_joystick]); + tempStr = Common::String::format("Joystick %s", SETUP_STRS0[0]); screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); break; case 8: @@ -1793,16 +1794,19 @@ void UserInterface::doControls() { if ((found == 5 && events._released) || _key == 'N') { // New font style - screen.setFont((screen.fontNumber() + 1) & 3); - } + int fontNum = screen.fontNumber() + 1; + if (fontNum == 3) + fontNum = 0; - if ((found == 6 && events._released) || _key == 'J') { - // Toggle joystick - _vm->_joystick = !_vm->_joystick; + screen.setFont(fontNum); updateConfig = true; settings.drawInteface(true); } + if ((found == 6 && events._released) || _key == 'J') { + // Toggle joystick - not implemented under ScummVM + } + if ((found == 7 && events._released) || _key == 'C') { // Calibrate joystick - No implementation in ScummVM } -- cgit v1.2.3 From 31860163709b12a38856fc017a217eb5e32610a7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 21 Apr 2015 18:25:06 -0500 Subject: SHERLOCK: Implemented save game dialog event handling --- engines/sherlock/user_interface.cpp | 325 ++++++++++++++++++++++++++++++++++-- 1 file changed, 311 insertions(+), 14 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 3ab705e26c..c8cd300b5e 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -65,15 +65,15 @@ const int SETUP_POINTS[12][4] = { { 219, 176, 316, 268 }, // Fade Style { 103, 176, 217, 160 }, // Window Open Style { 4, 176, 101, 53 }, // Portraits Toggle - { 219, 187, 316, 268 } // Key Pad Accel. Toggle + { 219, 187, 316, 268 } // _key Pad Accel. Toggle }; const char COMMANDS[13] = "LMTPOCIUGJFS"; const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; -const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; -const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; +const char *const PRESS_KEY_FOR_MORE = "Press any _key for More."; +const char *const PRESS_KEY_TO_CONTINUE = "Press any _key to Continue."; const char *const MOPEN[] = { "This cannot be opened", "It is already open", "It is locked", "Wait for Watson", " ", "." @@ -164,7 +164,7 @@ void Settings::drawInteface(bool flag) { tempStr = Common::String::format("Portraits %s", SETUP_STRS0[people._portraitsOn]); screen.makeButton(Common::Rect(SETUP_POINTS[10][0], SETUP_POINTS[10][1], SETUP_POINTS[10][2], SETUP_POINTS[10][1] + 10), SETUP_POINTS[10][3] - screen.stringWidth(tempStr) / 2, tempStr); - tempStr = Common::String::format("Key Pad %s", _vm->_keyPadSpeed ? "Fast" : "Slow"); + tempStr = Common::String::format("_key Pad %s", _vm->_keyPadSpeed ? "Fast" : "Slow"); screen.makeButton(Common::Rect(SETUP_POINTS[11][0], SETUP_POINTS[11][1], SETUP_POINTS[11][2], SETUP_POINTS[11][1] + 10), SETUP_POINTS[11][3] - screen.stringWidth(tempStr) / 2, tempStr); @@ -183,7 +183,7 @@ void Settings::drawInteface(bool flag) { } } -int Settings::drawButtons(const Common::Point &pt, int key) { +int Settings::drawButtons(const Common::Point &pt, int _key) { Events &events = *_vm->_events; People &people = *_vm->_people; Screen &screen = *_vm->_screen; @@ -196,7 +196,7 @@ int Settings::drawButtons(const Common::Point &pt, int key) { for (int idx = 0; idx < 12; ++idx) { if ((pt.x > SETUP_POINTS[idx][0] && pt.x < SETUP_POINTS[idx][2] && pt.y > SETUP_POINTS[idx][1] && pt.y < (SETUP_POINTS[idx][1] + 10) && (events._released || events._released)) - || (key == SETUP_NAMES[idx][0])) { + || (_key == SETUP_NAMES[idx][0])) { found = idx; color = COMMAND_HIGHLIGHTED; } else { @@ -238,7 +238,7 @@ int Settings::drawButtons(const Common::Point &pt, int key) { screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); break; case 11: - tempStr = Common::String::format("Key Pad %s", SETUP_STRS4[_vm->_keyPadSpeed]); + tempStr = Common::String::format("_key Pad %s", SETUP_STRS4[_vm->_keyPadSpeed]); screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); break; default: @@ -328,7 +328,7 @@ void UserInterface::handleInput() { _keycode = Common::KEYCODE_INVALID; // Check kbd and set the mouse released flag if Enter or space is pressed. - // Otherwise, the pressed key is stored for later use + // Otherwise, the pressed _key is stored for later use if (events.kbHit()) { Common::KeyState keyState = events.getKey(); @@ -890,7 +890,304 @@ void UserInterface::lookInv() { * Handles input when the file list window is being displayed */ void UserInterface::doEnvControl() { - // TODO + Events &events = *_vm->_events; + SaveManager &saves = *_vm->_saves; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + Common::Point mousePos = events.mousePos(); + static const char ENV_COMMANDS[7] = "ELSUDQ"; + byte color; + + _key = _oldKey = -1; + _keyboardInput = false; + int found = saves.getHighlightedButton(); + + if (events._pressed || events._released) + { + events.clearKeyboard(); + + // Check for a filename entry being highlighted + int found1 = 0; + if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10)) + { + for (_selector = 0; (_selector < 5) && !found1; ++_selector) + if (mousePos.y > (CONTROLS_Y + 11 + _selector * 10) && mousePos.y < (CONTROLS_Y + 21 + _selector * 10)) + found1 = 1; + + if (_selector + saves._savegameIndex - 1 < MAX_SAVEGAME_SLOTS + (saves._envMode != 1)) + _selector = _selector + saves._savegameIndex - 1; + else + _selector = -1; + + if (!found1) + _selector = -1; + } + + // Handle selecting buttons, if any + saves.highlightButtons(found); + + if (found == 0 || found == 5) + saves._envMode = SAVEMODE_NONE; + } + + if (_keycode) { + _key = toupper(_keycode); + + // Escape _key will close the dialog + if (_key == Common::KEYCODE_ESCAPE) + _key = 'E'; + + if (_key == 'E' || _key == 'L' || _key == 'S' || _key == 'U' || _key == 'D' || _key == 'Q') { + const char *chP = strchr(ENV_COMMANDS, _key); + int btnIndex = !chP ? -1 : chP - ENV_COMMANDS; + saves.highlightButtons(btnIndex); + _keyboardInput = true; + + if (_key == 'E' || _key == 'Q') { + saves._envMode = SAVEMODE_NONE; + } else if (_key >= '1' && _key <= '9') { + _keyboardInput = true; + _selector = _key - '1'; + if (_selector >= MAX_SAVEGAME_SLOTS + (saves._envMode == 1 ? 0 : 1)) + _selector = -1; + + if (saves.checkGameOnScreen(_selector)) + _oldSelector = _selector; + } else { + _selector = -1; + } + } + } + + if (_selector != _oldSelector) { + if (_oldSelector != -1 && _oldSelector >= saves._savegameIndex && _oldSelector < (saves._savegameIndex + 5)) { + screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), + INV_FOREGROUND, 0, "%d.", _oldSelector + 1); + screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), + INV_FOREGROUND, 0, "%s", saves._savegames[_oldSelector]); + } + + if (_selector != -1) { + screen.print(Common::Point(6, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), + TALK_FOREGROUND, 0, "%d.", _selector + 1); + screen.print(Common::Point(24, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), + TALK_FOREGROUND, 0, "%s", saves._savegames[_selector]); + } + + _oldSelector = _selector; + } + + if (events._released || _keyboardInput) { + if ((found == 0 && events._released) || _key == 'E') { + banishWindow(); + _windowBounds.top = CONTROLS_Y1; + + events._pressed = events._released = _keyboardInput = false; + _keycode = Common::KEYCODE_INVALID; + } else if ((found == 1 && events._released) || _key == 'L') { + saves._envMode = SAVEMODE_LOAD; + if (_selector != -1) { + saves.loadGame(_selector + 1); + } + } else if ((found == 2 && events._released) || _key == 'S') { + saves._envMode = SAVEMODE_SAVE; + if (_selector != -1) { + if (saves.checkGameOnScreen(_selector)) + _oldSelector = _selector; + + if (saves.getFilename(_selector)) { + saves.saveGame(_selector + 1, saves._savegames[_selector]); + + banishWindow(1); + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = -1; + _keycode = Common::KEYCODE_INVALID; + _keyboardInput = false; + } else { + if (!talk._talkToAbort) { + screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, + SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); + screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, + "%d.", _selector + 1); + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, + "%s", saves._savegames[_selector]); + + screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); + _selector = _oldSelector = -1; + } + } + } + } else if (((found == 3 && events._released) || _key == 'U') && saves._savegameIndex) { + bool moreKeys; + do { + saves._savegameIndex--; + screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, + SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); + + for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + 5); ++idx) { + color = INV_FOREGROUND; + if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + 5)) + color = TALK_FOREGROUND; + + screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%s", saves._savegames[idx]); + } + + screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); + + color = !saves._savegameIndex ? COMMAND_NULL : COMMAND_FOREGROUND; + screen.buttonPrint(Common::Point(ENV_POINTS[3][2], CONTROLS_Y), color, true, "Up"); + color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - 5) ? COMMAND_NULL : COMMAND_FOREGROUND; + screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); + + // Check for there are more pending U keys pressed + moreKeys = false; + if (events.kbHit()) { + Common::KeyState keyState = events.getKey(); + + _key = toupper(keyState.keycode); + moreKeys = _key == 'U'; + } + } while ((saves._savegameIndex) && moreKeys); + } else if (((found == 4 && events._released) || _key == 'D') && saves._savegameIndex < (MAX_SAVEGAME_SLOTS - 5)) { + bool moreKeys; + do { + saves._savegameIndex++; + screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, + SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); + + for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + 5); ++idx) { + if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + 5)) + color = TALK_FOREGROUND; + else + color = INV_FOREGROUND; + + screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, + "%d.", idx + 1); + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, + "%s", saves._savegames[idx]); + } + + screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); + + color = (!saves._savegameIndex) ? COMMAND_NULL : COMMAND_FOREGROUND; + screen.buttonPrint(Common::Point(ENV_POINTS[3][2], CONTROLS_Y), color, true, "Up"); + + color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - 5) ? COMMAND_NULL : COMMAND_FOREGROUND; + screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); + + // Check for there are more pending D keys pressed + moreKeys = false; + if (events.kbHit()) { + Common::KeyState keyState; + _key = toupper(keyState.keycode); + + moreKeys = _key == 'D'; + } + } while (saves._savegameIndex < (MAX_SAVEGAME_SLOTS - 5) && moreKeys); + } else if ((found == 5 && events._released) || _key == 'Q') { + clearWindow(); + screen.print(Common::Point(0, CONTROLS_Y + 20), INV_FOREGROUND, "Are you sure you wish to Quit ?"); + screen.vgaBar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + 10), BORDER_COLOR); + + screen.makeButton(Common::Rect(112, CONTROLS_Y, 150, CONTROLS_Y + 10), 136 - screen.stringWidth("Yes") / 2, "Yes"); + screen.makeButton(Common::Rect(161, CONTROLS_Y, 209, CONTROLS_Y + 10), 184 - screen.stringWidth("No") / 2, "No"); + screen.slamArea(112, CONTROLS_Y, 97, 10); + + do { + scene.doBgAnim(); + + if (talk._talkToAbort) + return; + + events.pollEventsAndWait(); + events.setButtonState(); + if (events.kbHit()) { + Common::KeyState keyState = events.getKey(); + _key = toupper(keyState.keycode); + + if (_key == 'X' && (keyState.flags & Common::KBD_ALT) != 0) { + _vm->quitGame(); + events.pollEvents(); + return; + } + + if (_key == Common::KEYCODE_ESCAPE) + _key = 'N'; + + if (_key == Common::KEYCODE_RETURN || _key == Common::KEYCODE_SPACE) { + events._pressed = false; + events._released = true; + events._oldButtons = 0; + _keycode = Common::KEYCODE_INVALID; + } + } + + if (events._pressed || events._released) { + if (mousePos.x > 112 && mousePos.x < 159 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9)) + color = COMMAND_HIGHLIGHTED; + else + color = COMMAND_FOREGROUND; + screen.buttonPrint(Common::Point(136, CONTROLS_Y), color, true, "Yes"); + + if (mousePos.x > 161 && mousePos.x < 208 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9)) + color = COMMAND_HIGHLIGHTED; + else + color = COMMAND_FOREGROUND; + screen.buttonPrint(Common::Point(184, CONTROLS_Y), color, true, "No"); + } + + if (mousePos.x > 112 && mousePos.x < 159 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9) && events._released) + _key = 'Y'; + + if (mousePos.x > 161 && mousePos.x < 208 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9) && events._released) + _key = 'N'; + } while (!_vm->shouldQuit() && _key != 'Y' && _key != 'N'); + + if (_key == 'Y') { + _vm->quitGame(); + events.pollEvents(); + return; + } else { + screen.buttonPrint(Common::Point(184, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, "No"); + banishWindow(1); + _windowBounds.top = CONTROLS_Y1; + _key = -1; + } + } else { + if (_selector != -1) { + // Are we already in Load mode? + if (saves._envMode == SAVEMODE_LOAD) { + saves.loadGame(_selector + 1); + } else if (saves._envMode == SAVEMODE_SAVE || _selector == MAX_SAVEGAME_SLOTS) { + // We're alreaady in save mode, or pointed to an empty save slot + if (saves.checkGameOnScreen(_selector)) + _oldSelector = _selector; + + if (saves.getFilename(_selector)) { + saves.saveGame(_selector + 1, saves._savegames[_selector]); + banishWindow(); + _windowBounds.top = CONTROLS_Y1; + _key = _oldKey = -1; + _keycode = Common::KEYCODE_INVALID; + _keyboardInput = false; + } else { + if (!talk._talkToAbort) { + screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, + 317, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); + screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), + INV_FOREGROUND, 0, "%d.", _selector + 1); + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), + INV_FOREGROUND, 0, "%s", saves._savegames[_selector]); + screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); + _selector = _oldSelector = -1; + } + } + } + } + } + } } /** @@ -1199,6 +1496,7 @@ void UserInterface::doLookControl() { void UserInterface::doMainControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; + SaveManager &saves = *_vm->_saves; Common::Point pt = events.mousePos(); if ((events._pressed || events._released) && pt.y > CONTROLS_Y) { @@ -1302,7 +1600,10 @@ void UserInterface::doMainControl() { case 'F': pushButton(10); _menuMode = FILES_MODE; - environment(); + saves.drawInterface(); + + _selector = _oldSelector = -1; + _windowOpen = true; break; case 'S': pushButton(11); @@ -1699,10 +2000,6 @@ void UserInterface::journalControl() { // TODO } -void UserInterface::environment() { - // TODO -} - /** * Handles input when the settings window is being shown */ -- cgit v1.2.3 From 0984405a0dbe718522117507d7c75dc619c586a8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 21 Apr 2015 22:51:03 -0500 Subject: SHERLOCK: Implement savegame synchronization --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index c8cd300b5e..f7f387e9ad 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1820,7 +1820,7 @@ void UserInterface::doTalkControl() { // Add any Holmes point to Holmes' total, if any if (talk._statements[_selector]._quotient) - people._homesQuotient += talk._statements[_selector]._quotient; + people._holmesQuotient += talk._statements[_selector]._quotient; } // Flag the response as having been used -- cgit v1.2.3 From e08520cca94f33cb69ee8058cb08e400e5443016 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Apr 2015 02:32:25 -0500 Subject: SHERLOCK: Fix Files saves listing and save name entry --- engines/sherlock/user_interface.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index f7f387e9ad..f95277df91 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -331,13 +331,16 @@ void UserInterface::handleInput() { // Otherwise, the pressed _key is stored for later use if (events.kbHit()) { Common::KeyState keyState = events.getKey(); + _keycode = keyState.keycode; if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) { _vm->quitGame(); + events.pollEvents(); return; } else if (keyState.keycode == Common::KEYCODE_SPACE || keyState.keycode == Common::KEYCODE_RETURN) { - events._pressed = events._oldButtons = 0; + events._pressed = false; + events._oldButtons = 0; _keycode = Common::KEYCODE_INVALID; } } @@ -963,16 +966,16 @@ void UserInterface::doEnvControl() { if (_selector != _oldSelector) { if (_oldSelector != -1 && _oldSelector >= saves._savegameIndex && _oldSelector < (saves._savegameIndex + 5)) { screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%d.", _oldSelector + 1); + INV_FOREGROUND, "%d.", _oldSelector + 1); screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%s", saves._savegames[_oldSelector]); + INV_FOREGROUND, "%s", saves._savegames[_oldSelector]); } if (_selector != -1) { screen.print(Common::Point(6, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), - TALK_FOREGROUND, 0, "%d.", _selector + 1); + TALK_FOREGROUND, "%d.", _selector + 1); screen.print(Common::Point(24, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), - TALK_FOREGROUND, 0, "%s", saves._savegames[_selector]); + TALK_FOREGROUND, "%s", saves._savegames[_selector].c_str()); } _oldSelector = _selector; @@ -1031,7 +1034,7 @@ void UserInterface::doEnvControl() { color = TALK_FOREGROUND; screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%s", saves._savegames[idx]); + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%s", saves._savegames[idx].c_str()); } screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); @@ -1066,7 +1069,7 @@ void UserInterface::doEnvControl() { screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, - "%s", saves._savegames[idx]); + "%s", saves._savegames[idx].c_str()); } screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); -- cgit v1.2.3 From 27938653a5cd05856da88142f52de44f30e26eef Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Apr 2015 04:44:55 -0500 Subject: SHERLOCK: Further fixes for entering savegame names --- engines/sherlock/user_interface.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index f95277df91..cb10606562 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -331,7 +331,7 @@ void UserInterface::handleInput() { // Otherwise, the pressed _key is stored for later use if (events.kbHit()) { Common::KeyState keyState = events.getKey(); - _keycode = keyState.keycode; + _keycode = keyState.ascii; if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) { _vm->quitGame(); @@ -968,7 +968,7 @@ void UserInterface::doEnvControl() { screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _oldSelector + 1); screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, "%s", saves._savegames[_oldSelector]); + INV_FOREGROUND, "%s", saves._savegames[_oldSelector].c_str()); } if (_selector != -1) { @@ -1014,7 +1014,7 @@ void UserInterface::doEnvControl() { screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _selector + 1); screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, - "%s", saves._savegames[_selector]); + "%s", saves._savegames[_selector].c_str()); screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); _selector = _oldSelector = -1; @@ -1180,9 +1180,9 @@ void UserInterface::doEnvControl() { screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 317, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%d.", _selector + 1); + INV_FOREGROUND, "%d.", _selector + 1); screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%s", saves._savegames[_selector]); + INV_FOREGROUND, "%s", saves._savegames[_selector].c_str()); screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); _selector = _oldSelector = -1; } -- cgit v1.2.3 From 4f04f90a97965e278f5cbda6fbbd36fa493655cb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Apr 2015 07:14:49 -0500 Subject: SHERLOCK: Fix thumbnails for savegames made via in-game files dialog --- engines/sherlock/user_interface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index cb10606562..a3631c577d 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1603,6 +1603,12 @@ void UserInterface::doMainControl() { case 'F': pushButton(10); _menuMode = FILES_MODE; + + // Create a thumbnail of the current screen before the files dialog is shown, in case + // the user saves the game + saves.createThumbnail(); + + // Display the dialog saves.drawInterface(); _selector = _oldSelector = -1; -- cgit v1.2.3 From 79a3db42e1d9809facdd551f71744656073c1eb9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 24 Apr 2015 02:29:18 -0500 Subject: SHERLOCK: Fix 'Press any key' interface messages --- engines/sherlock/user_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index a3631c577d..690eba2c84 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -72,8 +72,8 @@ const int SETUP_POINTS[12][4] = { const char COMMANDS[13] = "LMTPOCIUGJFS"; const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; -const char *const PRESS_KEY_FOR_MORE = "Press any _key for More."; -const char *const PRESS_KEY_TO_CONTINUE = "Press any _key to Continue."; +const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; +const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; const char *const MOPEN[] = { "This cannot be opened", "It is already open", "It is locked", "Wait for Watson", " ", "." -- cgit v1.2.3 From ecd50997ddaaf4c8ac648ecdb8bea1177f128610 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 24 Apr 2015 04:00:46 -0500 Subject: SHERLOCK: Fix Sherlock disappearing when walking to examine objects --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 690eba2c84..903b1e6002 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -715,7 +715,7 @@ void UserInterface::examine() { scene.startCAnim(_cNum, canimSpeed); } else if (obj._lookPosition.y != 0) { // Need to walk to the object to be examined - people.walkToCoords(obj._lookPosition, obj._lookFacing); + people.walkToCoords(Common::Point(obj._lookPosition.x, obj._lookPosition.y * 100), obj._lookFacing); } if (!talk._talkToAbort) { -- cgit v1.2.3 From 6eb51c3d50e5134c4054f9652624fe61d772b004 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 24 Apr 2015 17:27:23 -0500 Subject: SHERLOCK: Formatting fixes --- engines/sherlock/user_interface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 903b1e6002..a2a356127c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1468,8 +1468,7 @@ void UserInterface::doLookControl() { _menuMode = STD_MODE; events.clearEvents(); } - } - else { + } else { // Looking at an inventory object // Backup the user interface Surface tempSurface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1); -- cgit v1.2.3 From 3cf1afb459e29747461e21ba7db971a9c72fc9ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 24 Apr 2015 20:26:33 -0500 Subject: SHERLOCK: Fix minor gfx glitch when sliding up closing dialogs --- engines/sherlock/user_interface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index a2a356127c..12af04d608 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1304,7 +1304,7 @@ void UserInterface::doInvControl() { } if (events._released || _keyboardInput) { - if ((!found && events._released) && _key == 'E') { + if ((found == 0 && events._released) || _key == 'E') { inv.freeInv(); _infoFlag = true; clearInfo(); @@ -2454,6 +2454,11 @@ void UserInterface::banishWindow(bool slideUp) { SHERLOCK_SCREEN_HEIGHT); events.delay(10); } + + // Show entire final area + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y1), + Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + screen.slamRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); } _infoFlag = false; -- cgit v1.2.3 From 55404f01d60fb4bb454ceb8e9289debbadda8470 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 24 Apr 2015 20:59:30 -0500 Subject: SHERLOCK: Fix talk dialog buttons --- engines/sherlock/user_interface.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 12af04d608..176b1bc42b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1791,14 +1791,14 @@ void UserInterface::doTalkControl() { } if (events._released || _keyboardInput) { - if (_endKeyActive && ((mousePos.x > 99 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) - && talk._moreTalkUp && events._released) || _key == 'E')) { + if (((Common::Rect(99, CONTROLS_Y, 138, CONTROLS_Y + 10).contains(mousePos) && events._released) + || _key == 'E') && _endKeyActive) { talk.freeTalkVars(); talk.pullSequence(); banishWindow(); _windowBounds.top = CONTROLS_Y1; - } else if ((mousePos.x > 140 && mousePos.x < 179 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) - && talk._moreTalkUp && events._released) || (talk._moreTalkUp && _key == 'U')) { + } else if (((Common::Rect(140, CONTROLS_Y, 179, CONTROLS_Y + 10).contains(mousePos) && events._released) + || _key == 'U') && talk._moreTalkUp) { while (talk._statements[--talk._talkIndex]._talkMap == -1) ; screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, @@ -1806,8 +1806,8 @@ void UserInterface::doTalkControl() { talk.displayTalk(false); screen.slamRect(Common::Rect(5, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH - 5, SHERLOCK_SCREEN_HEIGHT - 2)); - } else if ((mousePos.x > 181 && mousePos.x < 220 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) - && talk._moreTalkDown && events._released) || (talk._moreTalkDown && _key == 'D')) { + } else if (((Common::Rect(181, CONTROLS_Y, 220, CONTROLS_Y + 10).contains(mousePos) && events._released) + || _key == 'D') && talk._moreTalkDown) { do { ++talk._talkIndex; } while (talk._talkIndex < (int)talk._statements.size() && talk._statements[talk._talkIndex]._talkMap == -1); -- cgit v1.2.3 From 95f25329379482555c6b1e3181fc737b80f53b40 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 25 Apr 2015 18:37:45 -0500 Subject: SHERLOCK: Disable joystick buttons in Setup dialog, since it isn't supported --- engines/sherlock/user_interface.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 176b1bc42b..53151ece55 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -147,11 +147,16 @@ void Settings::drawInteface(bool flag) { screen.makeButton(Common::Rect(SETUP_POINTS[5][0], SETUP_POINTS[5][1], SETUP_POINTS[5][2], SETUP_POINTS[5][1] + 10), SETUP_POINTS[5][3] - screen.stringWidth("New Font Style") / 2, "New Font Style"); - tempStr = Common::String::format("Joystick %s", SETUP_STRS0[0]); + // WORKAROUND: We don't support the joystick in ScummVM, so draw the next two buttons as disabled + tempStr = "Joystick Off"; screen.makeButton(Common::Rect(SETUP_POINTS[6][0], SETUP_POINTS[6][1], SETUP_POINTS[6][2], SETUP_POINTS[6][1] + 10), SETUP_POINTS[6][3] - screen.stringWidth(tempStr) / 2, tempStr); + screen.buttonPrint(Common::Point(SETUP_POINTS[6][3], SETUP_POINTS[6][1]), COMMAND_NULL, false, tempStr); + + tempStr = "Calibrate Joystick"; screen.makeButton(Common::Rect(SETUP_POINTS[7][0], SETUP_POINTS[7][1], SETUP_POINTS[7][2], SETUP_POINTS[7][1] + 10), - SETUP_POINTS[7][3] - screen.stringWidth("Calibrate Joystick") / 2, "Calibrate Joystick"); + SETUP_POINTS[7][3] - screen.stringWidth(tempStr) / 2, tempStr); + screen.buttonPrint(Common::Point(SETUP_POINTS[7][3], SETUP_POINTS[7][1]), COMMAND_NULL, false, tempStr); tempStr = Common::String::format("Fade %s", screen._fadeStyle ? "by Pixel" : "Directly"); screen.makeButton(Common::Rect(SETUP_POINTS[8][0], SETUP_POINTS[8][1], SETUP_POINTS[8][2], SETUP_POINTS[8][1] + 10), @@ -164,7 +169,7 @@ void Settings::drawInteface(bool flag) { tempStr = Common::String::format("Portraits %s", SETUP_STRS0[people._portraitsOn]); screen.makeButton(Common::Rect(SETUP_POINTS[10][0], SETUP_POINTS[10][1], SETUP_POINTS[10][2], SETUP_POINTS[10][1] + 10), SETUP_POINTS[10][3] - screen.stringWidth(tempStr) / 2, tempStr); - tempStr = Common::String::format("_key Pad %s", _vm->_keyPadSpeed ? "Fast" : "Slow"); + tempStr = Common::String::format("Key Pad %s", _vm->_keyPadSpeed ? "Fast" : "Slow"); screen.makeButton(Common::Rect(SETUP_POINTS[11][0], SETUP_POINTS[11][1], SETUP_POINTS[11][2], SETUP_POINTS[11][1] + 10), SETUP_POINTS[11][3] - screen.stringWidth(tempStr) / 2, tempStr); @@ -222,8 +227,12 @@ int Settings::drawButtons(const Common::Point &pt, int _key) { screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); break; case 6: - tempStr = Common::String::format("Joystick %s", SETUP_STRS0[0]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); + tempStr = "Joystick Off"; + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), COMMAND_NULL, true, tempStr); + break; + case 7: + tempStr = "Calibrate Joystick"; + screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), COMMAND_NULL, true, tempStr); break; case 8: tempStr = Common::String::format("Fade %s", SETUP_STRS1[screen._fadeStyle]); @@ -238,7 +247,7 @@ int Settings::drawButtons(const Common::Point &pt, int _key) { screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); break; case 11: - tempStr = Common::String::format("_key Pad %s", SETUP_STRS4[_vm->_keyPadSpeed]); + tempStr = Common::String::format("Key Pad %s", SETUP_STRS4[_vm->_keyPadSpeed]); screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); break; default: -- cgit v1.2.3 From 9044dd49dc2debd1c7d1fa4ea991320a1072235e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Apr 2015 03:45:28 -0500 Subject: SHERLOCK: Fix closing closet in Backstage scene --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 53151ece55..c623896c85 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2678,7 +2678,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { _infoFlag = true; clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[action._cAnimNum]); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); // Set how long to show the message _menuCounter = 30; -- cgit v1.2.3 From 0c68c0a53ac2ffb5837ca2eada00af7f371bc7c9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Apr 2015 04:33:24 -0500 Subject: SHERLOCK: Fix inventory display when player has more than 6 items --- engines/sherlock/user_interface.cpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index c623896c85..7a581ca63b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1247,17 +1247,13 @@ void UserInterface::doInvControl() { } if (inv._invIndex) { - screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), - colors[4], "^^"); - screen.print(Common::Point(INVENTORY_POINTS[5][2], CONTROLS_Y1 + 1), - colors[5], "^"); + screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), colors[4], "^^"); + screen.print(Common::Point(INVENTORY_POINTS[5][2], CONTROLS_Y1 + 1), colors[5], "^"); } if ((inv._holdings - inv._invIndex) > 6) { - screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), - colors[6], "^^"); - screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), - colors[7], "^"); + screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), colors[6], "_"); + screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), colors[7], "__"); } bool flag = false; @@ -1339,31 +1335,28 @@ void UserInterface::doInvControl() { inv.loadGraphics(); inv.putInv(1); inv.invCommands(true); - } else if (((found == 5 && events._released) || _key == '-') && inv._invIndex) { + } else if (((found == 5 && events._released) || _key == Common::KEYCODE_MINUS + || _key == Common::KEYCODE_KP_MINUS) && inv._invIndex > 0) { --inv._invIndex; - screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), - COMMAND_HIGHLIGHTED, "^"); + screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "^"); inv.freeGraphics(); inv.loadGraphics(); inv.putInv(1); inv.invCommands(true); - } else if (((found == 6 && events._released) || _key == '+') && - (inv._holdings - inv._invIndex) > 6) { + } else if (((found == 6 && events._released) || _key == Common::KEYCODE_PLUS + || _key == Common::KEYCODE_KP_PLUS) && (inv._holdings - inv._invIndex) > 6) { ++inv._invIndex; - screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), - COMMAND_HIGHLIGHTED, "_"); + screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); inv.freeGraphics(); inv.loadGraphics(); inv.putInv(1); inv.invCommands(true); - } else if (((found == 7 && events._released) || _key == '.') && - (inv._holdings - inv._invIndex) > 6) { + } else if (((found == 7 && events._released) || _key == '.') && (inv._holdings - inv._invIndex) > 6) { inv._invIndex += 6; if ((inv._holdings - 6) < inv._invIndex) inv._invIndex = inv._holdings - 6; - screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), - COMMAND_HIGHLIGHTED, "_"); + screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); inv.freeGraphics(); inv.loadGraphics(); inv.putInv(1); -- cgit v1.2.3 From 488ac579d7cd037dfe5c71cf20a878cf5ecdfe18 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Apr 2015 17:26:22 -0500 Subject: SHERLOCK: Fix checking single character star action names --- engines/sherlock/user_interface.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 7a581ca63b..ed3debe2fc 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2609,7 +2609,8 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] events.setCursor(WAIT); for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { - if (action._names[nameIdx].hasPrefix("*") && toupper(action._names[nameIdx][1]) == 'W') { + if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 + && toupper(action._names[nameIdx][1]) == 'W') { if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), messages)) { if (!talk._talkToAbort) printed = true; @@ -2618,7 +2619,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] } for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { - if (action._names[nameIdx].hasPrefix("*")) { + if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2) { char ch = toupper(action._names[nameIdx][1]); if (ch == 'T' || ch == 'B') { @@ -2648,7 +2649,8 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] } for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { - if (action._names[nameIdx].hasPrefix("*") && toupper(action._names[nameIdx][1]) == 'F') { + if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 + && toupper(action._names[nameIdx][1]) == 'F') { if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, messages)) { if (!talk._talkToAbort) printed = true; -- cgit v1.2.3 From 3d483400698526a79fe31ac440bb2c410889f85f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Apr 2015 21:15:33 -0500 Subject: SHERLOCK: Fix using items from inventory dialog --- engines/sherlock/user_interface.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ed3debe2fc..97f6cfd63a 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -766,7 +766,7 @@ void UserInterface::lookScreen(const Common::Point &pt) { Common::Point mousePos = events.mousePos(); int temp; Common::String tempStr; - int x, width, width1, width2 = 0; + int x, width; // Don't display anything for right button command if ((events._rightPressed || events._rightPressed) && !events._pressed) @@ -790,7 +790,7 @@ void UserInterface::lookScreen(const Common::Point &pt) { // If inventory is active and an item is selected for a Use or Give action if ((_menuMode == INV_MODE || _menuMode == USE_MODE || _menuMode == GIVE_MODE) && (inv._invMode == 2 || inv._invMode == 3)) { - width1 = screen.stringWidth(inv[_selector]._name); + int width1 = 0, width2 = 0; if (inv._invMode == 2) { // Using an object @@ -805,6 +805,7 @@ void UserInterface::lookScreen(const Common::Point &pt) { // If we're using an inventory object, add in the width // of the object name and the " on " if (_selector != -1) { + width1 = screen.stringWidth(inv[_selector]._name); x += width1; width2 = screen.stringWidth(" on "); x += width2; @@ -835,6 +836,7 @@ void UserInterface::lookScreen(const Common::Point &pt) { } else if (temp >= 0 && temp < 1000 && _selector != -1 && scene._bgShapes[temp]._aType == PERSON) { // Giving an object to a person + width1 = screen.stringWidth(inv[_selector]._name); x = width = screen.stringWidth("Give "); x += width1; width2 = screen.stringWidth(" to "); @@ -1235,13 +1237,12 @@ void UserInterface::doInvControl() { if (found != -1) // If a slot highlighted, set it's color colors[found] = COMMAND_HIGHLIGHTED; - screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), - colors[0], true, "Exit"); + screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), colors[0], true, "Exit"); if (found >= 0 && found <= 3) { screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, "Look"); - screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[1], true, "Use"); - screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[1], true, "Give"); + screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[2], true, "Use"); + screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[3], true, "Give"); inv._invMode = (InvMode)found; _selector = -1; } -- cgit v1.2.3 From 3a8aa6956812d8e69c6b5e1021ba5c05e3fe0b0b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Apr 2015 23:31:29 -0500 Subject: SHERLOCK: Fixes for using flower on lab table --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 97f6cfd63a..e4d7255774 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -818,7 +818,7 @@ void UserInterface::lookScreen(const Common::Point &pt) { tempStr.deleteLastChar(); } - int xStart = (SHERLOCK_SCREEN_HEIGHT - x) / 2; + int xStart = (SHERLOCK_SCREEN_WIDTH - x) / 2; screen.print(Common::Point(xStart, INFO_LINE + 1), INFO_FOREGROUND, "Use "); -- cgit v1.2.3 From a2e1f4cb76a6629f53a7f03c8b9bc2efa5f701e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 27 Apr 2015 02:29:34 -0500 Subject: SHERLOCK: Fix using items within the scene --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index e4d7255774..b12094638c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1422,7 +1422,7 @@ void UserInterface::doInvControl() { checkUseAction(&scene._bgShapes[_find]._use[0], inv[_selector]._name, MUSE, _find, temp - 2); else // Now inv object has been highlighted - checkUseAction(&scene._bgShapes[_find]._use[0], "*SELF", MUSE, _find, temp - 2); + checkUseAction(&scene._bgShapes[_find]._use[0], "*SELF*", MUSE, _find, temp - 2); _selector = _oldSelector = -1; } -- cgit v1.2.3 From ef4ec4cde3ec15d7370ef739e4fa6d863e7ccee5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 29 Apr 2015 21:24:34 -1000 Subject: SHERLOCK: Fix moving crates in Tabacco Shop --- engines/sherlock/user_interface.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index b12094638c..b0b0d15b5c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2592,16 +2592,22 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] cAnimNum = 9; else cAnimNum = action._cAnimNum - 1; - CAnim &anim = scene._cAnim[cAnimNum]; - + if (action._cAnimNum != 99) { - if (action._cAnimSpeed & REVERSE_DIRECTION) { - pt = anim._teleportPos; - dir = anim._teleportDir; - } else { - pt = anim._goto; - dir = anim._gotoDir; + CAnim &anim = scene._cAnim[cAnimNum]; + + if (action._cAnimNum != 99) { + if (action._cAnimSpeed & REVERSE_DIRECTION) { + pt = anim._teleportPos; + dir = anim._teleportDir; + } else { + pt = anim._goto; + dir = anim._gotoDir; + } } + } else { + pt = Common::Point(-1, -1); + dir = -1; } if (action._cAnimSpeed) { -- cgit v1.2.3 From 8e4ccdbd2c5ea543d648ef46300837c3c43ee705 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 30 Apr 2015 15:46:30 -1000 Subject: SHERLOCK: Fix trying to move items that can't be --- engines/sherlock/user_interface.cpp | 59 +++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index b0b0d15b5c..30d79aa1c9 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2585,32 +2585,42 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] if (objNum >= 1000) // Ignore actions done on characters return; - Object &obj = scene._bgShapes[objNum]; - if (action._cAnimNum == 0) - // Really a 10 - cAnimNum = 9; - else - cAnimNum = action._cAnimNum - 1; - - if (action._cAnimNum != 99) { - CAnim &anim = scene._cAnim[cAnimNum]; + if (!action._cAnimSpeed) { + // Invalid action, to print error message + _infoFlag = true; + clearInfo(); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[action._cAnimNum]); + _infoFlag = true; + + // Set how long to show the message + _menuCounter = 30; + } else { + Object &obj = scene._bgShapes[objNum]; + if (action._cAnimNum == 0) + // Really a 10 + cAnimNum = 9; + else + cAnimNum = action._cAnimNum - 1; + if (action._cAnimNum != 99) { - if (action._cAnimSpeed & REVERSE_DIRECTION) { - pt = anim._teleportPos; - dir = anim._teleportDir; - } else { - pt = anim._goto; - dir = anim._gotoDir; + CAnim &anim = scene._cAnim[cAnimNum]; + + if (action._cAnimNum != 99) { + if (action._cAnimSpeed & REVERSE_DIRECTION) { + pt = anim._teleportPos; + dir = anim._teleportDir; + } else { + pt = anim._goto; + dir = anim._gotoDir; + } } + } else { + pt = Common::Point(-1, -1); + dir = -1; } - } else { - pt = Common::Point(-1, -1); - dir = -1; - } - if (action._cAnimSpeed) { // Has a value, so do action // Show wait cursor whilst walking to object and doing action events.setCursor(WAIT); @@ -2686,15 +2696,6 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] _menuCounter = 30; } } - } else { - // Invalid action, to print error message - _infoFlag = true; - clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[action._cAnimNum]); - _infoFlag = true; - - // Set how long to show the message - _menuCounter = 30; } // Reset cursor back to arrow -- cgit v1.2.3 From 9117083e0ab8f329a93bcae647d9da78ec212738 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 30 Apr 2015 21:21:59 -1000 Subject: SHERLOCK: Fix crash in Equestrian shop --- engines/sherlock/user_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 30d79aa1c9..e7e7981966 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -414,8 +414,8 @@ void UserInterface::handleInput() { _infoFlag = true; clearInfo(); - if (_help != -1 && (scene._bgShapes[_bgFound]._description[0] != 32 && - scene._bgShapes[_bgFound]._description[0])) + if (_help != -1 && !scene._bgShapes[_bgFound]._description.empty() + && scene._bgShapes[_bgFound]._description[0] != ' ') screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, scene._bgShapes[_bgFound]._description.c_str()); -- cgit v1.2.3 From b4c3d9840c99ce5d4e23eb0f646bd995f7d2c002 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 May 2015 17:17:24 -1000 Subject: SHERLOCK: Extra method comments --- engines/sherlock/user_interface.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index e7e7981966..f60e63a574 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -188,6 +188,9 @@ void Settings::drawInteface(bool flag) { } } +/** + * Draws the buttons for the settings dialog + */ int Settings::drawButtons(const Common::Point &pt, int _key) { Events &events = *_vm->_events; People &people = *_vm->_people; @@ -259,7 +262,6 @@ int Settings::drawButtons(const Common::Point &pt, int _key) { return found; } - /*----------------------------------------------------------------*/ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { @@ -298,6 +300,9 @@ UserInterface::~UserInterface() { delete _controlPanel; } +/** + * Resets the user interface + */ void UserInterface::reset() { _oldKey = -1; _help = _oldHelp = -1; @@ -1962,6 +1967,12 @@ void UserInterface::doTalkControl() { } } +/** + * Handles events when the Journal is active. + * @remarks Whilst this would in theory be better in the Journal class, since it displays in + * the user interface, it uses so many internal UI fields, that it sort of made some sense + * to put it in the UserInterface class. + */ void UserInterface::journalControl() { Events &events = *_vm->_events; Journal &journal = *_vm->_journal; @@ -2013,6 +2024,9 @@ void UserInterface::journalControl() { /** * Handles input when the settings window is being shown + * @remarks Whilst this would in theory be better in the Journal class, since it displays in + * the user interface, it uses so many internal UI fields, that it sort of made some sense + * to put it in the UserInterface class. */ void UserInterface::doControls() { Events &events = *_vm->_events; @@ -2702,5 +2716,4 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] events.setCursor(ARROW); } - } // End of namespace Sherlock -- cgit v1.2.3 From d9a42a80ffeb9eaee957bbc858f714e5cf362946 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 May 2015 17:27:59 -1000 Subject: SHERLOCK: Fix some remaining TODOs --- engines/sherlock/user_interface.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index f60e63a574..21a53c32ff 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2019,7 +2019,6 @@ void UserInterface::journalControl() { screen._backBuffer1.blitFrom(screen._backBuffer2); scene.updateBackground(); screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); - // TODO } /** -- cgit v1.2.3 From a2ef3e240225940308c54243589014c922c38274 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 May 2015 18:29:42 -1000 Subject: SHERLOCK: Moved Settings dialog into it's own class --- engines/sherlock/user_interface.cpp | 186 +----------------------------------- 1 file changed, 1 insertion(+), 185 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 21a53c32ff..313f035bd5 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -22,6 +22,7 @@ #include "sherlock/user_interface.h" #include "sherlock/sherlock.h" +#include "sherlock/settings.h" namespace Sherlock { @@ -53,23 +54,6 @@ const int INVENTORY_POINTS[8][3] = { { 285, 315, 294 } }; -const int SETUP_POINTS[12][4] = { - { 4, 154, 101, 53 }, // Exit - { 4, 165, 101, 53 }, // Music Toggle - { 219, 165, 316, 268 }, // Voice Toggle - { 103, 165, 217, 160 }, // Sound Effects Toggle - { 219, 154, 316, 268 }, // Help Button Left/Right - { 103, 154, 217, 160 }, // New Font Style - { 4, 187, 101, 53 }, // Joystick Toggle - { 103, 187, 217, 160 }, // Calibrate Joystick - { 219, 176, 316, 268 }, // Fade Style - { 103, 176, 217, 160 }, // Window Open Style - { 4, 176, 101, 53 }, // Portraits Toggle - { 219, 187, 316, 268 } // _key Pad Accel. Toggle -}; - - - const char COMMANDS[13] = "LMTPOCIUGJFS"; const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; @@ -94,174 +78,6 @@ const char *const MUSE[] = { "Doors don't smoke" }; -const char *const SETUP_STRS0[2] = { "off", "on" }; -const char *const SETUP_STRS1[2] = { "Directly", "by Pixel" }; -const char *const SETUP_STRS2[2] = { "Left", "Right" }; -const char *const SETUP_STRS3[2] = { "Appear", "Slide" }; -const char *const SETUP_STRS4[2] = { "Slow", "Fast" }; -const char *const SETUP_STRS5[2] = { "Left", "Right" }; -const char *const SETUP_NAMES[12] = { - "Exit", "M", "V", "S", "B", "New Font Style", "J", "Calibrate Joystick", "F", "W", "P", "K" -}; - -/*----------------------------------------------------------------*/ - -/** - * Draws the interface for the settings window - */ -void Settings::drawInteface(bool flag) { - People &people = *_vm->_people; - Screen &screen = *_vm->_screen; - Sound &sound = *_vm->_sound; - UserInterface &ui = *_vm->_ui; - Common::String tempStr; - - if (!flag) { - screen._backBuffer1.fillRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y1 + 1), BORDER_COLOR); - screen._backBuffer1.fillRect(Common::Rect(0, CONTROLS_Y1 + 1, 2, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); - screen._backBuffer1.fillRect(Common::Rect(SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y1 + 1, SHERLOCK_SCREEN_WIDTH, - SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); - screen._backBuffer1.hLine(0, SHERLOCK_SCREEN_HEIGHT - 1, SHERLOCK_SCREEN_WIDTH - 1, BORDER_COLOR); - screen._backBuffer1.fillRect(Common::Rect(2, CONTROLS_Y1 + 1, SHERLOCK_SCREEN_WIDTH - 2, - SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); - } - - screen.makeButton(Common::Rect(SETUP_POINTS[0][0], SETUP_POINTS[0][1], SETUP_POINTS[0][2], SETUP_POINTS[0][1] + 10), - SETUP_POINTS[0][3] - screen.stringWidth("Exit") / 2, "Exit"); - - tempStr = Common::String::format("Music %s", SETUP_STRS0[sound._music]); - screen.makeButton(Common::Rect(SETUP_POINTS[1][0], SETUP_POINTS[1][1], SETUP_POINTS[1][2], SETUP_POINTS[1][1] + 10), - SETUP_POINTS[1][3] - screen.stringWidth(tempStr) / 2, tempStr); - - tempStr = Common::String::format("Voices %s", SETUP_STRS0[sound._voices]); - screen.makeButton(Common::Rect(SETUP_POINTS[2][0], SETUP_POINTS[2][1], SETUP_POINTS[2][2], SETUP_POINTS[2][1] + 10), - SETUP_POINTS[2][3] - screen.stringWidth(tempStr) / 2, tempStr); - - tempStr = Common::String::format("Sound Effects %s", SETUP_STRS0[sound._digitized]); - screen.makeButton(Common::Rect(SETUP_POINTS[3][0], SETUP_POINTS[3][1], SETUP_POINTS[3][2], SETUP_POINTS[3][1] + 10), - SETUP_POINTS[3][3] - screen.stringWidth(tempStr) / 2, tempStr); - - tempStr = Common::String::format("Auto Help %s", SETUP_STRS5[ui._helpStyle]); - screen.makeButton(Common::Rect(SETUP_POINTS[4][0], SETUP_POINTS[4][1], SETUP_POINTS[4][2], SETUP_POINTS[4][1] + 10), - SETUP_POINTS[4][3] - screen.stringWidth(tempStr) / 2, tempStr); - screen.makeButton(Common::Rect(SETUP_POINTS[5][0], SETUP_POINTS[5][1], SETUP_POINTS[5][2], SETUP_POINTS[5][1] + 10), - SETUP_POINTS[5][3] - screen.stringWidth("New Font Style") / 2, "New Font Style"); - - // WORKAROUND: We don't support the joystick in ScummVM, so draw the next two buttons as disabled - tempStr = "Joystick Off"; - screen.makeButton(Common::Rect(SETUP_POINTS[6][0], SETUP_POINTS[6][1], SETUP_POINTS[6][2], SETUP_POINTS[6][1] + 10), - SETUP_POINTS[6][3] - screen.stringWidth(tempStr) / 2, tempStr); - screen.buttonPrint(Common::Point(SETUP_POINTS[6][3], SETUP_POINTS[6][1]), COMMAND_NULL, false, tempStr); - - tempStr = "Calibrate Joystick"; - screen.makeButton(Common::Rect(SETUP_POINTS[7][0], SETUP_POINTS[7][1], SETUP_POINTS[7][2], SETUP_POINTS[7][1] + 10), - SETUP_POINTS[7][3] - screen.stringWidth(tempStr) / 2, tempStr); - screen.buttonPrint(Common::Point(SETUP_POINTS[7][3], SETUP_POINTS[7][1]), COMMAND_NULL, false, tempStr); - - tempStr = Common::String::format("Fade %s", screen._fadeStyle ? "by Pixel" : "Directly"); - screen.makeButton(Common::Rect(SETUP_POINTS[8][0], SETUP_POINTS[8][1], SETUP_POINTS[8][2], SETUP_POINTS[8][1] + 10), - SETUP_POINTS[8][3] - screen.stringWidth(tempStr) / 2, tempStr); - - tempStr = Common::String::format("Windows %s", ui._windowStyle ? "Slide" : "Appear"); - screen.makeButton(Common::Rect(SETUP_POINTS[9][0], SETUP_POINTS[9][1], SETUP_POINTS[9][2], SETUP_POINTS[9][1] + 10), - SETUP_POINTS[9][3] - screen.stringWidth(tempStr) / 2, tempStr); - - tempStr = Common::String::format("Portraits %s", SETUP_STRS0[people._portraitsOn]); - screen.makeButton(Common::Rect(SETUP_POINTS[10][0], SETUP_POINTS[10][1], SETUP_POINTS[10][2], SETUP_POINTS[10][1] + 10), - SETUP_POINTS[10][3] - screen.stringWidth(tempStr) / 2, tempStr); - tempStr = Common::String::format("Key Pad %s", _vm->_keyPadSpeed ? "Fast" : "Slow"); - - screen.makeButton(Common::Rect(SETUP_POINTS[11][0], SETUP_POINTS[11][1], SETUP_POINTS[11][2], SETUP_POINTS[11][1] + 10), - SETUP_POINTS[11][3] - screen.stringWidth(tempStr) / 2, tempStr); - - // Show the window immediately, or slide it on-screen - if (!flag) { - if (!ui._windowStyle) { - screen.slamRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - } else { - ui.summonWindow(true, CONTROLS_Y1); - } - - ui._windowOpen = true; - } else { - screen.slamRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - } -} - -/** - * Draws the buttons for the settings dialog - */ -int Settings::drawButtons(const Common::Point &pt, int _key) { - Events &events = *_vm->_events; - People &people = *_vm->_people; - Screen &screen = *_vm->_screen; - Sound &sound = *_vm->_sound; - UserInterface &ui = *_vm->_ui; - int found = -1; - byte color; - Common::String tempStr; - - for (int idx = 0; idx < 12; ++idx) { - if ((pt.x > SETUP_POINTS[idx][0] && pt.x < SETUP_POINTS[idx][2] && pt.y > SETUP_POINTS[idx][1] - && pt.y < (SETUP_POINTS[idx][1] + 10) && (events._released || events._released)) - || (_key == SETUP_NAMES[idx][0])) { - found = idx; - color = COMMAND_HIGHLIGHTED; - } else { - color = COMMAND_FOREGROUND; - } - - // Print the button text - switch (idx) { - case 1: - tempStr = Common::String::format("Music %s", SETUP_STRS0[sound._music]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - case 2: - tempStr = Common::String::format("Voices %s", SETUP_STRS0[sound._voices]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - case 3: - tempStr = Common::String::format("Sound Effects %s", SETUP_STRS0[sound._digitized]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - case 4: - tempStr = Common::String::format("Auto Help %s", SETUP_STRS2[ui._helpStyle]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - case 6: - tempStr = "Joystick Off"; - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), COMMAND_NULL, true, tempStr); - break; - case 7: - tempStr = "Calibrate Joystick"; - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), COMMAND_NULL, true, tempStr); - break; - case 8: - tempStr = Common::String::format("Fade %s", SETUP_STRS1[screen._fadeStyle]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - case 9: - tempStr = Common::String::format("Windows %s", SETUP_STRS3[ui._windowStyle]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - case 10: - tempStr = Common::String::format("Portraits %s", SETUP_STRS0[people._portraitsOn]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - case 11: - tempStr = Common::String::format("Key Pad %s", SETUP_STRS4[_vm->_keyPadSpeed]); - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, tempStr); - break; - default: - screen.buttonPrint(Common::Point(SETUP_POINTS[idx][3], SETUP_POINTS[idx][1]), color, true, SETUP_NAMES[idx]); - break; - } - } - - return found; -} - /*----------------------------------------------------------------*/ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { -- cgit v1.2.3 From 86dab70eae4791b84ca3891cad7db70a9683679a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 May 2015 18:34:51 -1000 Subject: SHERLOCK: Remove unused key pad speed field --- engines/sherlock/user_interface.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 313f035bd5..cab0fb0ad8 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1968,13 +1968,6 @@ void UserInterface::doControls() { updateConfig = true; settings.drawInteface(true); } - - if ((found == 11 && events._released) || _key == 'K') { - // Toggle keypad acceleration speed - _vm->_keyPadSpeed ^= 1; - updateConfig = true; - settings.drawInteface(true); - } } while (!_vm->shouldQuit()); banishWindow(); -- cgit v1.2.3 From 850bd739687129542c37db0beebd17369c71ed15 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 May 2015 18:47:13 -1000 Subject: SHERLOCK: Move Settings dialog event handling into Settings class --- engines/sherlock/user_interface.cpp | 146 +----------------------------------- 1 file changed, 1 insertion(+), 145 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index cab0fb0ad8..73058e8fd8 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1440,7 +1440,7 @@ void UserInterface::doMainControl() { case 'S': pushButton(11); _menuMode = SETUP_MODE; - doControls(); + Settings::show(_vm); break; default: break; @@ -1837,150 +1837,6 @@ void UserInterface::journalControl() { screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); } -/** - * Handles input when the settings window is being shown - * @remarks Whilst this would in theory be better in the Journal class, since it displays in - * the user interface, it uses so many internal UI fields, that it sort of made some sense - * to put it in the UserInterface class. - */ -void UserInterface::doControls() { - Events &events = *_vm->_events; - People &people = *_vm->_people; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Sound &sound = *_vm->_sound; - Talk &talk = *_vm->_talk; - UserInterface &ui = *_vm->_ui; - int found; - bool updateConfig = false; - - Settings settings(_vm); - settings.drawInteface(false); - - do { - if (_menuCounter) - whileMenuCounter(); - - found = -1; - _key = -1; - - scene.doBgAnim(); - if (talk._talkToAbort) - return; - - events.setButtonState(); - Common::Point pt = events.mousePos(); - - if (events._pressed || events._released || events.kbHit()) { - clearInfo(); - _key = -1; - - if (events.kbHit()) { - Common::KeyState keyState = events.getKey(); - _key = toupper(keyState.keycode); - - if (_key == Common::KEYCODE_RETURN || _key == Common::KEYCODE_SPACE) { - events._pressed = false; - events._oldButtons = 0; - _keycode = Common::KEYCODE_INVALID; - events._released = true; - } - } - - // Handle highlighting button under mouse - found = settings.drawButtons(pt, _key); - } - - if ((found == 0 && events._released) || (_key == 'E' || _key == Common::KEYCODE_ESCAPE)) - // Exit - break; - - if ((found == 1 && events._released) || _key == 'M') { - // Toggle music - if (sound._music) { - sound.stopSound(); - sound._music = false; - } else { - sound._music = true; - sound.startSong(); - } - - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 2 && events._released) || _key == 'V') { - sound._voices = !sound._voices; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 3 && events._released) || _key == 'S') { - // Toggle sound effects - sound._digitized = !sound._digitized; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 4 && events._released) || _key == 'A') { - // Help button style - ui._helpStyle ^= 1; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 5 && events._released) || _key == 'N') { - // New font style - int fontNum = screen.fontNumber() + 1; - if (fontNum == 3) - fontNum = 0; - - screen.setFont(fontNum); - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 6 && events._released) || _key == 'J') { - // Toggle joystick - not implemented under ScummVM - } - - if ((found == 7 && events._released) || _key == 'C') { - // Calibrate joystick - No implementation in ScummVM - } - - if ((found == 8 && events._released) || _key == 'F') { - // Toggle fade style - screen._fadeStyle = !screen._fadeStyle; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 9 && events._released) || _key == 'W') { - // Window style - ui._windowStyle ^= 1; - updateConfig = true; - settings.drawInteface(true); - } - - if ((found == 10 && events._released) || _key == 'P') { - // Toggle portraits being shown - people._portraitsOn = !people._portraitsOn; - updateConfig = true; - settings.drawInteface(true); - } - } while (!_vm->shouldQuit()); - - banishWindow(); - - if (updateConfig) - _vm->saveConfig(); - - _keycode = Common::KEYCODE_INVALID; - _keyboardInput = false; - _windowBounds.top = CONTROLS_Y1; - _key = -1; -} - /** * Print the description of an object */ -- cgit v1.2.3 From 7cf9fcd44e58a5a4b1988bb5ca6ec6862170c3d8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 May 2015 19:13:53 -1000 Subject: SHERLOCK: Change _helpStyle from int to bool --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 73058e8fd8..d75e0770b9 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -86,7 +86,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _bgFound = 0; _oldBgFound = -1; _keycode = Common::KEYCODE_INVALID; - _helpStyle = 0; + _helpStyle = false; _menuCounter = 0; _menuMode = STD_MODE; _help = _oldHelp = 0; -- cgit v1.2.3 From dceff029220aff2efcb7a533d2403c90b5651870 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 May 2015 13:53:20 -1000 Subject: SHERLOCK: Fix trying to enter theatre without talking to Lestrade --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index d75e0770b9..93dd03316d 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1469,7 +1469,7 @@ void UserInterface::doMiscControl(int allowed) { switch (allowed) { case ALLOW_OPEN: checkAction(obj._aOpen, MOPEN, _temp); - if (_menuMode && !talk._talkToAbort) { + if (_menuMode != TALK_MODE && !talk._talkToAbort) { _menuMode = STD_MODE; restoreButton(OPEN_MODE - 1); _key = _oldKey = -1; -- cgit v1.2.3 From 8a9467b09aab38649a891934c17a7b15608ddf0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 4 May 2015 13:22:43 -1000 Subject: SHERLOCK: Check _talkToAbort after calling pickupObject --- engines/sherlock/user_interface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 93dd03316d..d40e1cced1 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1508,6 +1508,7 @@ void UserInterface::doMiscControl(int allowed) { void UserInterface::doPickControl() { Events &events = *_vm->_events; Scene &scene = *_vm->_scene; + Talk &talk = *_vm->_talk; if (events._released) { if ((_temp = _bgFound) != -1) { @@ -1517,7 +1518,7 @@ void UserInterface::doPickControl() { if (_bgFound < 1000) { scene._bgShapes[_bgFound].pickUpObject(MPICK); - if (_menuMode != TALK_MODE) { + if (!talk._talkToAbort && _menuMode != TALK_MODE) { _key = _oldKey = -1; _menuMode = STD_MODE; restoreButton(PICKUP_MODE - 1); -- cgit v1.2.3 From a0661c8d5a970791a6fac3e304fe975e8e61b5f9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 May 2015 19:21:55 +0200 Subject: SHERLOCK: Reduce some more variable scopes --- engines/sherlock/user_interface.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index d40e1cced1..a134b95196 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -531,13 +531,12 @@ void UserInterface::examine() { Scene &scene = *_vm->_scene; Talk &talk = *_vm->_talk; Common::Point pt = events.mousePos(); - int canimSpeed; if (pt.y < (CONTROLS_Y + 9)) { Object &obj = scene._bgShapes[_bgFound]; if (obj._lookcAnim != 0) { - canimSpeed = ((obj._lookcAnim & 0xe0) >> 5) + 1; + int canimSpeed = ((obj._lookcAnim & 0xe0) >> 5) + 1; scene._cAnimFramePause = obj._lookFrames; _cAnimStr = obj._examine; _cNum = (obj._lookcAnim & 0x1f) - 1; @@ -587,7 +586,6 @@ void UserInterface::lookScreen(const Common::Point &pt) { Common::Point mousePos = events.mousePos(); int temp; Common::String tempStr; - int x, width; // Don't display anything for right button command if ((events._rightPressed || events._rightPressed) && !events._pressed) @@ -612,7 +610,7 @@ void UserInterface::lookScreen(const Common::Point &pt) { if ((_menuMode == INV_MODE || _menuMode == USE_MODE || _menuMode == GIVE_MODE) && (inv._invMode == 2 || inv._invMode == 3)) { int width1 = 0, width2 = 0; - + int x, width; if (inv._invMode == 2) { // Using an object x = width = screen.stringWidth("Use "); @@ -743,9 +741,9 @@ void UserInterface::doEnvControl() { events.clearKeyboard(); // Check for a filename entry being highlighted - int found1 = 0; if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10)) { + int found1 = 0; for (_selector = 0; (_selector < 5) && !found1; ++_selector) if (mousePos.y > (CONTROLS_Y + 11 + _selector * 10) && mousePos.y < (CONTROLS_Y + 21 + _selector * 10)) found1 = 1; @@ -1540,7 +1538,6 @@ void UserInterface::doTalkControl() { Sound &sound = *_vm->_sound; Talk &talk = *_vm->_talk; Common::Point mousePos = events.mousePos(); - int select; _key = _oldKey = -1; _keyboardInput = false; @@ -1728,7 +1725,7 @@ void UserInterface::doTalkControl() { talk.loadTalkFile(linkFilename); // Find the first new statement - select = _selector = _oldSelector = -1; + int select = _selector = _oldSelector = -1; for (uint idx = 0; idx < talk._statements.size() && select == -1; ++idx) { if (!talk._statements[idx]._talkMap) select = talk._talkIndex = idx; @@ -1795,7 +1792,6 @@ void UserInterface::journalControl() { Journal &journal = *_vm->_journal; Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; - int found; bool doneFlag = false; // Draw the journal screen @@ -1803,7 +1799,7 @@ void UserInterface::journalControl() { // Handle journal events do { - found = _key = -1; + _key = -1; events.setButtonState(); // Handle keypresses @@ -1846,12 +1842,11 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { Inventory &inv = *_vm->_inventory; Screen &screen = *_vm->_screen; Talk &talk = *_vm->_talk; - int savedSelector; if (str.hasPrefix("_")) { _lookScriptFlag = true; events.setCursor(MAGNIFY); - savedSelector = _selector; + int savedSelector = _selector; talk.talkTo(str.c_str() + 1); _lookScriptFlag = false; @@ -2255,11 +2250,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; Talk &talk = *_vm->_talk; - bool printed = false; - bool doCAnim = true; - int cAnimNum; Common::Point pt(-1, -1); - int dir = -1; if (objNum >= 1000) // Ignore actions done on characters @@ -2277,12 +2268,14 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] } else { Object &obj = scene._bgShapes[objNum]; + int cAnimNum; if (action._cAnimNum == 0) // Really a 10 cAnimNum = 9; else cAnimNum = action._cAnimNum - 1; + int dir = -1; if (action._cAnimNum != 99) { CAnim &anim = scene._cAnim[cAnimNum]; @@ -2303,6 +2296,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] // Has a value, so do action // Show wait cursor whilst walking to object and doing action events.setCursor(WAIT); + bool printed = false; for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 @@ -2314,6 +2308,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] } } + bool doCAnim = true; for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2) { char ch = toupper(action._names[nameIdx][1]); -- cgit v1.2.3 From d9e93f8e015ce27a95090e854494c4b3f7d1c0d4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 May 2015 19:33:44 +0200 Subject: SHERLOCK: some code formatting --- engines/sherlock/user_interface.cpp | 130 ++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 65 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index a134b95196..f048e280a8 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -27,7 +27,7 @@ namespace Sherlock { // Main user interface menu control locations -const int MENU_POINTS[12][4] = { +const int MENU_POINTS[12][4] = { { 13, 153, 72, 165 }, { 13, 169, 72, 181 }, { 13, 185, 72, 197 }, @@ -39,11 +39,11 @@ const int MENU_POINTS[12][4] = { { 165, 185, 233, 197 }, { 249, 153, 305, 165 }, { 249, 169, 305, 181 }, - { 249, 185, 305, 197 } + { 249, 185, 305, 197 } }; // Inventory control locations */ -const int INVENTORY_POINTS[8][3] = { +const int INVENTORY_POINTS[8][3] = { { 4, 50, 29 }, { 52, 99, 77 }, { 101, 140, 123 }, @@ -51,7 +51,7 @@ const int INVENTORY_POINTS[8][3] = { { 189, 219, 198 }, { 221, 251, 234 }, { 253, 283, 266 }, - { 285, 315, 294 } + { 285, 315, 294 } }; const char COMMANDS[13] = "LMTPOCIUGJFS"; @@ -59,23 +59,23 @@ const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; -const char *const MOPEN[] = { - "This cannot be opened", "It is already open", "It is locked", "Wait for Watson", " ", "." +const char *const MOPEN[] = { + "This cannot be opened", "It is already open", "It is locked", "Wait for Watson", " ", "." }; -const char *const MCLOSE[] = { - "This cannot be closed", "It is already closed", "The safe door is in the way" +const char *const MCLOSE[] = { + "This cannot be closed", "It is already closed", "The safe door is in the way" }; -const char *const MMOVE[] = { +const char *const MMOVE[] = { "This cannot be moved", "It is bolted to the floor", "It is too heavy", "The other crate is in the way" }; const char *const MPICK[] = { "Nothing of interest here", "It is bolted down", "It is too big to carry", "It is too heavy", - "I think a girl would be more your type", "Those flowers belong to Penny", "She's far too young for you!", - "I think a girl would be more your type!", "Government property for official use only" + "I think a girl would be more your type", "Those flowers belong to Penny", "She's far too young for you!", + "I think a girl would be more your type!", "Government property for official use only" }; -const char *const MUSE[] = { - "You can't do that", "It had no effect", "You can't reach it", "OK, the door looks bigger! Happy?", - "Doors don't smoke" +const char *const MUSE[] = { + "You can't do that", "It had no effect", "You can't reach it", "OK, the door looks bigger! Happy?", + "Doors don't smoke" }; /*----------------------------------------------------------------*/ @@ -198,7 +198,7 @@ void UserInterface::handleInput() { } else if (pt.y < CONTROLS_Y && ((events._rightReleased && _helpStyle) || (events._released && !_helpStyle)) && (_bgFound != -1 && _bgFound < 1000) && - (scene._bgShapes[_bgFound]._defaultCommand || + (scene._bgShapes[_bgFound]._defaultCommand || !scene._bgShapes[_bgFound]._description.empty())) { // If there is no default command, set it to Look if (scene._bgShapes[_bgFound]._defaultCommand) @@ -208,7 +208,7 @@ void UserInterface::handleInput() { events._released = true; events._pressed = events._oldButtons = false; _help = _oldHelp = -1; - + if (_menuMode == LOOK_MODE) { // Set the flag to tell the game that this was a right-click // call to look and should exit without the look button being pressed @@ -323,7 +323,7 @@ void UserInterface::handleInput() { // // Do input processing // - if (events._pressed || events._released || events._rightPressed || + if (events._pressed || events._released || events._rightPressed || _keycode != Common::KEYCODE_INVALID || _pause) { if (((events._released && (_helpStyle || _help == -1)) || (events._rightReleased && !_helpStyle)) && (pt.y <= CONTROLS_Y) && (_menuMode == STD_MODE)) { @@ -390,7 +390,7 @@ void UserInterface::handleInput() { // As long as there isn't an open window, do main input processing. // Windows are opened when in TALK, USE, INV, and GIVE modes - if ((!_windowOpen && !_menuCounter && pt.y > CONTROLS_Y) || + if ((!_windowOpen && !_menuCounter && pt.y > CONTROLS_Y) || _keycode != Common::KEYCODE_INVALID) { if (events._pressed || events._released || _pause || _keycode != Common::KEYCODE_INVALID) @@ -426,7 +426,7 @@ void UserInterface::restoreButton(int num) { screen._backBuffer1.blitFrom(screen._backBuffer2, pt, Common::Rect(pt.x, pt.y, pt.x + 90, pt.y + 19)); screen.slamArea(pt.x, pt.y, pt.x + frame.w, pt.y + frame.h); - + if (!_menuCounter) { _infoFlag++; clearInfo(); @@ -461,7 +461,7 @@ void UserInterface::pushButton(int num) { */ void UserInterface::toggleButton(int num) { Screen &screen = *_vm->_screen; - + if (_menuMode != (num + 1)) { _menuMode = (MenuMode)(num + 1); _oldKey = COMMANDS[num]; @@ -534,7 +534,7 @@ void UserInterface::examine() { if (pt.y < (CONTROLS_Y + 9)) { Object &obj = scene._bgShapes[_bgFound]; - + if (obj._lookcAnim != 0) { int canimSpeed = ((obj._lookcAnim & 0xe0) >> 5) + 1; scene._cAnimFramePause = obj._lookFrames; @@ -669,13 +669,13 @@ void UserInterface::lookScreen(const Common::Point &pt) { } int xStart = (SHERLOCK_SCREEN_WIDTH - x) / 2; - screen.print(Common::Point(xStart, INFO_LINE + 1), + screen.print(Common::Point(xStart, INFO_LINE + 1), INFO_FOREGROUND, "Give "); - screen.print(Common::Point(xStart + width, INFO_LINE + 1), + screen.print(Common::Point(xStart + width, INFO_LINE + 1), TALK_FOREGROUND, inv[_selector]._name.c_str()); - screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), + screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), INFO_FOREGROUND, " to "); - screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), + screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), INFO_FOREGROUND, tempStr.c_str()); } } else { @@ -795,16 +795,16 @@ void UserInterface::doEnvControl() { if (_selector != _oldSelector) { if (_oldSelector != -1 && _oldSelector >= saves._savegameIndex && _oldSelector < (saves._savegameIndex + 5)) { - screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), + screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _oldSelector + 1); - screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), + screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), INV_FOREGROUND, "%s", saves._savegames[_oldSelector].c_str()); } if (_selector != -1) { - screen.print(Common::Point(6, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), + screen.print(Common::Point(6, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), TALK_FOREGROUND, "%d.", _selector + 1); - screen.print(Common::Point(24, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), + screen.print(Common::Point(24, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), TALK_FOREGROUND, "%s", saves._savegames[_selector].c_str()); } @@ -815,7 +815,7 @@ void UserInterface::doEnvControl() { if ((found == 0 && events._released) || _key == 'E') { banishWindow(); _windowBounds.top = CONTROLS_Y1; - + events._pressed = events._released = _keyboardInput = false; _keycode = Common::KEYCODE_INVALID; } else if ((found == 1 && events._released) || _key == 'L') { @@ -839,13 +839,13 @@ void UserInterface::doEnvControl() { _keyboardInput = false; } else { if (!talk._talkToAbort) { - screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, + screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); - screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, + screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _selector + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, "%s", saves._savegames[_selector].c_str()); - + screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); _selector = _oldSelector = -1; } @@ -887,7 +887,7 @@ void UserInterface::doEnvControl() { bool moreKeys; do { saves._savegameIndex++; - screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, + screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + 5); ++idx) { @@ -898,10 +898,10 @@ void UserInterface::doEnvControl() { screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%s", saves._savegames[idx].c_str()); } - + screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); color = (!saves._savegameIndex) ? COMMAND_NULL : COMMAND_FOREGROUND; @@ -1007,11 +1007,11 @@ void UserInterface::doEnvControl() { _keyboardInput = false; } else { if (!talk._talkToAbort) { - screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, + screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 317, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); - screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), + screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _selector + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, "%s", saves._savegames[_selector].c_str()); screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); _selector = _oldSelector = -1; @@ -1201,14 +1201,14 @@ void UserInterface::doInvControl() { // If it's -1, then no inventory item is highlighted yet. Otherwise, // an object in the scene has been clicked. - if (_selector != -1 && inv._invMode == INVMODE_LOOK + if (_selector != -1 && inv._invMode == INVMODE_LOOK && mousePos.y >(CONTROLS_Y1 + 11)) inv.doInvJF(); if (talk._talkToAbort) return; - // Now check for the Use and Give actions. If inv_mode is 3, + // Now check for the Use and Give actions. If inv_mode is 3, // that means GIVE is in effect, _selector is the object being // given, and _find is the target. // The same applies to USE, except if _selector is -1, then USE @@ -1242,7 +1242,7 @@ void UserInterface::doInvControl() { else // Now inv object has been highlighted checkUseAction(&scene._bgShapes[_find]._use[0], "*SELF*", MUSE, _find, temp - 2); - + _selector = _oldSelector = -1; } } @@ -1251,14 +1251,14 @@ void UserInterface::doInvControl() { } /** - * Handles waiting whilst an object's description window is open. + * Handles waiting whilst an object's description window is open. */ void UserInterface::doLookControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; Screen &screen = *_vm->_screen; - _key = _oldKey = -1; + _key = _oldKey = -1; _keyboardInput = _keycode != Common::KEYCODE_INVALID; if (events._released || events._rightReleased || _keyboardInput) { @@ -1268,7 +1268,7 @@ void UserInterface::doLookControl() { if (!_descStr.empty()) { printObjectDesc(_descStr, false); } else if (!_lookHelp) { - // Need to close the window and depress the Look button + // Need to close the window and depress the Look button Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); screen._backBuffer2.blitFrom((*_controls)[0]._frame, pt); banishWindow(true); @@ -1348,7 +1348,7 @@ void UserInterface::doMainControl() { if (_temp == 12) _key = -1; - + if (events._rightPressed) { _temp = 12; _key = -1; @@ -1356,7 +1356,7 @@ void UserInterface::doMainControl() { } else if (!events._released) { _key = -1; } - + // Check if the button being pointed to has changed if (_oldKey != _key && !_windowOpen) { // Clear the info line @@ -1431,7 +1431,7 @@ void UserInterface::doMainControl() { // Display the dialog saves.drawInterface(); - + _selector = _oldSelector = -1; _windowOpen = true; break; @@ -1550,7 +1550,7 @@ void UserInterface::doTalkControl() { screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, "Exit"); else if (_endKeyActive) screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_FOREGROUND, true, "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"); else if (talk._moreTalkUp) @@ -1613,13 +1613,13 @@ void UserInterface::doTalkControl() { } if (events._released || _keyboardInput) { - if (((Common::Rect(99, CONTROLS_Y, 138, CONTROLS_Y + 10).contains(mousePos) && events._released) + if (((Common::Rect(99, CONTROLS_Y, 138, CONTROLS_Y + 10).contains(mousePos) && events._released) || _key == 'E') && _endKeyActive) { talk.freeTalkVars(); talk.pullSequence(); banishWindow(); _windowBounds.top = CONTROLS_Y1; - } else if (((Common::Rect(140, CONTROLS_Y, 179, CONTROLS_Y + 10).contains(mousePos) && events._released) + } else if (((Common::Rect(140, CONTROLS_Y, 179, CONTROLS_Y + 10).contains(mousePos) && events._released) || _key == 'U') && talk._moreTalkUp) { while (talk._statements[--talk._talkIndex]._talkMap == -1) ; @@ -1655,7 +1655,7 @@ void UserInterface::doTalkControl() { // Flag the response as having been used talk._talkHistory[talk._converseNum][_selector] = true; - + clearWindow(); screen.print(Common::Point(16, CONTROLS_Y + 12), TALK_FOREGROUND, "Sherlock Holmes"); talk.talkLine(_selector + 128, talk._statements[_selector]._talkMap, COMMAND_FOREGROUND, CONTROLS_Y + 21, true); @@ -1784,7 +1784,7 @@ void UserInterface::doTalkControl() { /** * Handles events when the Journal is active. * @remarks Whilst this would in theory be better in the Journal class, since it displays in - * the user interface, it uses so many internal UI fields, that it sort of made some sense + * the user interface, it uses so many internal UI fields, that it sort of made some sense * to put it in the UserInterface class. */ void UserInterface::journalControl() { @@ -1801,7 +1801,7 @@ void UserInterface::journalControl() { do { _key = -1; events.setButtonState(); - + // Handle keypresses if (events.kbHit()) { Common::KeyState keyState = events.getKey(); @@ -1859,7 +1859,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { if (!_invLookFlag) { // See if this look was called by a right button click or not if (!_lookHelp) { - // If it wasn't a right button click, then we need depress + // If it wasn't a right button click, then we need depress // the look button before we close the window. So save a copy of the // menu area, and draw the controls onto it Surface tempSurface((*_controls)[0]._frame.w, (*_controls)[0]._frame.h); @@ -1945,7 +1945,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { do { width += screen.charWidth(*msgP++); } while (width < 300 && *msgP); - + if (*msgP) --msgP; else @@ -2036,7 +2036,7 @@ void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { } else { // Gradually slide down the display of the window for (int idx = 1; idx <= bgSurface.h; idx += 2) { - screen._backBuffer->blitFrom(bgSurface, + screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h), Common::Rect(0, bgSurface.h - idx, bgSurface.w, bgSurface.h)); screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h, @@ -2047,7 +2047,7 @@ void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { } // Final display of the entire window - screen._backBuffer->blitFrom(bgSurface, Common::Point(0, + screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h), Common::Rect(0, 0, bgSurface.w, bgSurface.h)); screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h, bgSurface.w, bgSurface.h); @@ -2100,7 +2100,7 @@ void UserInterface::banishWindow(bool slideUp) { Common::Point(0, CONTROLS_Y), Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + idx)); - screen.slamArea(0, CONTROLS_Y + idx - 2, SHERLOCK_SCREEN_WIDTH, + screen.slamArea(0, CONTROLS_Y + idx - 2, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y - idx + 2); events.delay(10); } @@ -2162,7 +2162,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv _infoFlag = true; clearInfo(); _infoFlag = true; - + // Display error message _menuCounter = 30; screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "You can't do that to yourself."); @@ -2191,7 +2191,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv if (targetNum != -1) { // Found a target, so do the action const UseType &action = use[targetNum]; - + events.setCursor(WAIT); if (action._useFlag) @@ -2274,7 +2274,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] cAnimNum = 9; else cAnimNum = action._cAnimNum - 1; - + int dir = -1; if (action._cAnimNum != 99) { CAnim &anim = scene._cAnim[cAnimNum]; @@ -2299,7 +2299,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] bool printed = false; for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { - if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 + if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 && toupper(action._names[nameIdx][1]) == 'W') { if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), messages)) { if (!talk._talkToAbort) @@ -2367,7 +2367,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); // Set how long to show the message - _menuCounter = 30; + _menuCounter = 30; } } } -- cgit v1.2.3 From e3e4354f880d5f9354706b8f20d204960c48bb97 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 May 2015 10:21:46 +0200 Subject: SHERLOCK: Remove the use of ++ on boolean variables --- engines/sherlock/user_interface.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index f048e280a8..ce282aa2c2 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -428,7 +428,7 @@ void UserInterface::restoreButton(int num) { screen.slamArea(pt.x, pt.y, pt.x + frame.w, pt.y + frame.h); if (!_menuCounter) { - _infoFlag++; + _infoFlag = true; clearInfo(); } } @@ -515,7 +515,7 @@ void UserInterface::clearWindow() { void UserInterface::whileMenuCounter() { if (!(--_menuCounter) || _vm->_events->checkInput()) { _menuCounter = 0; - ++_infoFlag; + _infoFlag = true; clearInfo(); } } @@ -1259,7 +1259,7 @@ void UserInterface::doLookControl() { Screen &screen = *_vm->_screen; _key = _oldKey = -1; - _keyboardInput = _keycode != Common::KEYCODE_INVALID; + _keyboardInput = (_keycode != Common::KEYCODE_INVALID); if (events._released || events._rightReleased || _keyboardInput) { // Is an inventory object being looked at? @@ -1360,7 +1360,7 @@ void UserInterface::doMainControl() { // Check if the button being pointed to has changed if (_oldKey != _key && !_windowOpen) { // Clear the info line - _infoFlag++; + _infoFlag = true; clearInfo(); // If there was an old button selected, restore it @@ -2215,7 +2215,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv // Print "Done..." as an ending, unless flagged for leaving scene or otherwise flagged if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { - _infoFlag++; + _infoFlag = true; clearInfo(); screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); _menuCounter = 25; -- cgit v1.2.3 From 902b79116552b0605668f130e0695e4798ef87d5 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 9 May 2015 18:04:13 +0200 Subject: SHERLOCK: Make copyright headers consistent --- engines/sherlock/user_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ce282aa2c2..ec92848c26 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -8,12 +8,12 @@ * 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. -- cgit v1.2.3 From 1a485a44b8c265cb4e37e235659e1a4e7609d446 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 May 2015 12:08:45 -0400 Subject: SHERLOCK: Cleanup and fixes for Journal --- engines/sherlock/user_interface.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ec92848c26..674141f171 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1825,6 +1825,7 @@ void UserInterface::journalControl() { _windowOpen = false; _windowBounds.top = CONTROLS_Y1; _key = -1; + _menuMode = STD_MODE; // Reset the palette screen.setPalette(screen._cMap); -- cgit v1.2.3 From 6925b848d6bb8f93c6be3cc1d32780e729c6d242 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 May 2015 15:48:19 -0400 Subject: SHERLOCK: Fix getting fresh mouse positions in loop showing quit dialog --- engines/sherlock/user_interface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 674141f171..8b3ee426a4 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -936,6 +936,8 @@ void UserInterface::doEnvControl() { events.pollEventsAndWait(); events.setButtonState(); + mousePos = events.mousePos(); + if (events.kbHit()) { Common::KeyState keyState = events.getKey(); _key = toupper(keyState.keycode); -- cgit v1.2.3 From 7a46c84c0d02ec3fb5aa9d607519af8fbcd2715e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 May 2015 22:02:59 -0400 Subject: SHERLOCK: Beginnings of Rose Tattoo engine --- engines/sherlock/user_interface.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 41505b89fc..8e7254026b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -81,8 +81,13 @@ const char *const MUSE[] = { /*----------------------------------------------------------------*/ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { - _controls = new ImageFile("menu.all"); - _controlPanel = new ImageFile("controls.vgs"); + if (_vm->getGameID() == GType_SerratedScalpel) { + _controls = new ImageFile("menu.all"); + _controlPanel = new ImageFile("controls.vgs"); + } else { + _controls = nullptr; + _controlPanel = nullptr; + } _bgFound = 0; _oldBgFound = -1; _keycode = Common::KEYCODE_INVALID; -- cgit v1.2.3 From 72c9b9f56b99ca9c286de8618be4f473c0969983 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 May 2015 21:34:45 +0200 Subject: SHERLOCK: Implement sound priority --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 8b3ee426a4..d65bd9c01d 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1683,7 +1683,7 @@ void UserInterface::doTalkControl() { people.setTalking(0); if (!talk._statements[_selector]._voiceFile.empty() && sound._voices) { - sound.playSound(talk._statements[_selector]._voiceFile); + sound.playSound(talk._statements[_selector]._voiceFile, WAIT_RETURN_IMMEDIATELY); // Set voices as an indicator for waiting sound._voices = 2; -- cgit v1.2.3 From 44fbef5498070ee12fddb42c067d943e56d22f0e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 May 2015 21:01:57 -0400 Subject: SHERLOCK: Add missing setting of _oldSelector --- engines/sherlock/user_interface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index d65bd9c01d..41505b89fc 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1612,6 +1612,8 @@ void UserInterface::doTalkControl() { if (_selector != -1) talk.talkLine(_selector, talk._statements[_selector]._talkMap, TALK_FOREGROUND, talk._statements[_selector]._talkPos.top, true); + + _oldSelector = _selector; } if (events._released || _keyboardInput) { -- cgit v1.2.3 From 2a7019bd3d47c9e40b5e78ee83cc7bfb1c08bd1a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 18:33:23 -0400 Subject: SHERLOCK: Remove redundant _scriptCurrentIndex field --- engines/sherlock/user_interface.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 41505b89fc..e4230cae83 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1694,9 +1694,6 @@ void UserInterface::doTalkControl() { sound._speechOn = false; } - // Set the _scriptCurrentIndex so if the statement is irrupted, the entire - // reply will be shown when it's restarted - talk._scriptCurrentIndex = 0; talk.waitForMore(talk._statements[_selector]._statement.size()); if (talk._talkToAbort) return; -- cgit v1.2.3 From afa49212e8dab03a48ec50c900a942c2843bce07 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 May 2015 19:00:52 -0400 Subject: SHERLOCK: Remove space/Enter handling for keyboard cursor We don't implement the keyboard cursor movement anyway, and it was stopping Space and Enter from working when showing dialogs --- engines/sherlock/user_interface.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index e4230cae83..aa6bf2ba81 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -167,11 +167,6 @@ void UserInterface::handleInput() { _vm->quitGame(); events.pollEvents(); return; - } else if (keyState.keycode == Common::KEYCODE_SPACE || - keyState.keycode == Common::KEYCODE_RETURN) { - events._pressed = false; - events._oldButtons = 0; - _keycode = Common::KEYCODE_INVALID; } } -- cgit v1.2.3 From d3f1a76cc8336983d8bb36538fb8e6c520051935 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 May 2015 19:53:03 -0400 Subject: SHERLOCK: Default Files button to show GMM, with engine option to disable --- engines/sherlock/user_interface.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index aa6bf2ba81..85838f8a93 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1420,17 +1420,24 @@ void UserInterface::doMainControl() { break; case 'F': pushButton(10); - _menuMode = FILES_MODE; // Create a thumbnail of the current screen before the files dialog is shown, in case // the user saves the game saves.createThumbnail(); - // Display the dialog - saves.drawInterface(); - _selector = _oldSelector = -1; - _windowOpen = true; + + if (_vm->_showOriginalSavesDialog) { + // Show the original dialog + _menuMode = FILES_MODE; + saves.drawInterface(); + _windowOpen = true; + } else { + // Show the ScummVM GMM instead + _vm->_canLoadSave = true; + _vm->openMainMenuDialog(); + _vm->_canLoadSave = false; + } break; case 'S': pushButton(11); -- cgit v1.2.3 From d9a7d87b1908da6f249a1b16110ae3fd3cc9ed07 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 May 2015 19:46:29 -0400 Subject: SHERLOCK: Fix positioning of Quit Yes/No buttons --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 85838f8a93..1521421c15 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -919,7 +919,7 @@ void UserInterface::doEnvControl() { screen.print(Common::Point(0, CONTROLS_Y + 20), INV_FOREGROUND, "Are you sure you wish to Quit ?"); screen.vgaBar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + 10), BORDER_COLOR); - screen.makeButton(Common::Rect(112, CONTROLS_Y, 150, CONTROLS_Y + 10), 136 - screen.stringWidth("Yes") / 2, "Yes"); + screen.makeButton(Common::Rect(112, CONTROLS_Y, 160, CONTROLS_Y + 10), 136 - screen.stringWidth("Yes") / 2, "Yes"); screen.makeButton(Common::Rect(161, CONTROLS_Y, 209, CONTROLS_Y + 10), 184 - screen.stringWidth("No") / 2, "No"); screen.slamArea(112, CONTROLS_Y, 97, 10); -- cgit v1.2.3 From 40f7fff42977d01c8bac81d462580c2c8ec39dc3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 May 2015 08:09:14 -0400 Subject: SHERLOCK: Beginnings of UserInterface split for Scalpel vs Tattoo --- engines/sherlock/user_interface.cpp | 150 +++++++++++++++++++++++------------- 1 file changed, 97 insertions(+), 53 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 1ab8fe7294..efe6c8ef59 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -78,45 +78,53 @@ const char *const MUSE[] = { "Doors don't smoke" }; -/*----------------------------------------------------------------*/ + + +UserInterface *UserInterface::init(SherlockEngine *vm) { + if (vm->getGameID() == GType_SerratedScalpel) + return new ScalpelUserInterface(vm); + else + return new TattooUserInterface(vm); +} UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { - if (_vm->getGameID() == GType_SerratedScalpel) { - _controls = new ImageFile("menu.all"); - _controlPanel = new ImageFile("controls.vgs"); - } else { - _controls = nullptr; - _controlPanel = nullptr; - } - _bgFound = 0; - _oldBgFound = -1; - _keycode = Common::KEYCODE_INVALID; - _helpStyle = false; - _menuCounter = 0; _menuMode = STD_MODE; - _help = _oldHelp = 0; - _lookHelp = 0; + _menuCounter = 0; + _infoFlag = false; + _windowOpen = false; + _endKeyActive = true; + _invLookFlag = 0; + _windowStyle = 1; // Sliding windows + _helpStyle = false; + _lookScriptFlag = false; + _key = _oldKey = 0; + _selector = _oldSelector = -1; _temp = _oldTemp = 0; _temp1 = 0; - _invLookFlag = 0; - _windowOpen = false; + _lookHelp = 0; +} + +/*----------------------------------------------------------------*/ + +ScalpelUserInterface::ScalpelUserInterface(SherlockEngine *vm): UserInterface(vm) { + _controls = new ImageFile("menu.all"); + _controlPanel = new ImageFile("controls.vgs"); + _bgFound = 0; + _oldBgFound = -1; + _keycode = Common::KEYCODE_INVALID; + _help = _oldHelp = 0; _oldLook = false; _keyboardInput = false; _pause = false; _cNum = 0; - _selector = _oldSelector = -1; _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); - _windowStyle = 1; // Sliding windows _find = 0; _oldUse = 0; - _endKeyActive = true; - _lookScriptFlag = false; - _infoFlag = false; } -UserInterface::~UserInterface() { +ScalpelUserInterface::~ScalpelUserInterface() { delete _controls; delete _controlPanel; } @@ -124,7 +132,7 @@ UserInterface::~UserInterface() { /** * Resets the user interface */ -void UserInterface::reset() { +void ScalpelUserInterface::reset() { _oldKey = -1; _help = _oldHelp = -1; _oldTemp = _temp = -1; @@ -133,7 +141,7 @@ void UserInterface::reset() { /** * Draw the user interface onto the screen's back buffers */ -void UserInterface::drawInterface(int bufferNum) { +void ScalpelUserInterface::drawInterface(int bufferNum) { Screen &screen = *_vm->_screen; if (bufferNum & 1) @@ -147,7 +155,7 @@ void UserInterface::drawInterface(int bufferNum) { /** * Main input handler for the user interface */ -void UserInterface::handleInput() { +void ScalpelUserInterface::handleInput() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; People &people = *_vm->_people; @@ -405,7 +413,7 @@ void UserInterface::handleInput() { /** * Draws the image for a user interface button in the down/pressed state. */ -void UserInterface::depressButton(int num) { +void ScalpelUserInterface::depressButton(int num) { Screen &screen = *_vm->_screen; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); @@ -418,7 +426,7 @@ void UserInterface::depressButton(int num) { * Draws the image for the given user interface button in the up * (not selected) position */ -void UserInterface::restoreButton(int num) { +void ScalpelUserInterface::restoreButton(int num) { Screen &screen = *_vm->_screen; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); Graphics::Surface &frame = (*_controls)[num]._frame; @@ -437,7 +445,7 @@ void UserInterface::restoreButton(int num) { * If he mouse button is pressed, then calls depressButton to draw the button * as pressed; if not, it will show it as released with a call to "restoreButton". */ -void UserInterface::pushButton(int num) { +void ScalpelUserInterface::pushButton(int num) { Events &events = *_vm->_events; _oldKey = -1; @@ -459,7 +467,7 @@ void UserInterface::pushButton(int num) { * have already been drawn. This simply takes care of switching the mode around * accordingly */ -void UserInterface::toggleButton(int num) { +void ScalpelUserInterface::toggleButton(int num) { Screen &screen = *_vm->_screen; if (_menuMode != (num + 1)) { @@ -490,7 +498,7 @@ void UserInterface::toggleButton(int num) { /** * Clears the info line of the screen */ -void UserInterface::clearInfo() { +void ScalpelUserInterface::clearInfo() { if (_infoFlag) { _vm->_screen->vgaBar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 19, INFO_LINE + 10), INFO_BLACK); @@ -502,7 +510,7 @@ void UserInterface::clearInfo() { /** * Clear any active text window */ -void UserInterface::clearWindow() { +void ScalpelUserInterface::clearWindow() { if (_windowOpen) { _vm->_screen->vgaBar(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); @@ -512,7 +520,7 @@ void UserInterface::clearWindow() { /** * Handles counting down whilst checking for input, then clears the info line. */ -void UserInterface::whileMenuCounter() { +void ScalpelUserInterface::whileMenuCounter() { if (!(--_menuCounter) || _vm->_events->checkInput()) { _menuCounter = 0; _infoFlag = true; @@ -524,7 +532,7 @@ void UserInterface::whileMenuCounter() { * Creates a text window and uses it to display the in-depth description * of the highlighted object */ -void UserInterface::examine() { +void ScalpelUserInterface::examine() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; People &people = *_vm->_people; @@ -578,7 +586,7 @@ void UserInterface::examine() { /** * Print the name of an object in the scene */ -void UserInterface::lookScreen(const Common::Point &pt) { +void ScalpelUserInterface::lookScreen(const Common::Point &pt) { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; Scene &scene = *_vm->_scene; @@ -694,7 +702,7 @@ void UserInterface::lookScreen(const Common::Point &pt) { /** * Gets the item in the inventory the mouse is on and display's it's description */ -void UserInterface::lookInv() { +void ScalpelUserInterface::lookInv() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; Screen &screen = *_vm->_screen; @@ -722,7 +730,7 @@ void UserInterface::lookInv() { /** * Handles input when the file list window is being displayed */ -void UserInterface::doEnvControl() { +void ScalpelUserInterface::doEnvControl() { Events &events = *_vm->_events; SaveManager &saves = *_vm->_saves; Scene &scene = *_vm->_scene; @@ -1028,12 +1036,13 @@ void UserInterface::doEnvControl() { /** * Handle input whilst the inventory is active */ -void UserInterface::doInvControl() { +void ScalpelUserInterface::doInvControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; Talk &talk = *_vm->_talk; + UserInterface &ui = *_vm->_ui; int colors[8]; Common::Point mousePos = events.mousePos(); @@ -1197,7 +1206,7 @@ void UserInterface::doInvControl() { if ((mousePos.y < CONTROLS_Y1) && (inv._invMode == 1) && (_find >= 0) && (_find < 1000)) { if (!scene._bgShapes[_find]._examine.empty() && scene._bgShapes[_find]._examine[0] >= ' ') - inv.doInvJF(); + ui.doInvJF(); } else if (_selector != -1 || _find >= 0) { // Selector is the inventory object that was clicked on, or selected. // If it's -1, then no inventory item is highlighted yet. Otherwise, @@ -1205,7 +1214,7 @@ void UserInterface::doInvControl() { if (_selector != -1 && inv._invMode == INVMODE_LOOK && mousePos.y >(CONTROLS_Y1 + 11)) - inv.doInvJF(); + ui.doInvJF(); if (talk._talkToAbort) return; @@ -1255,7 +1264,7 @@ void UserInterface::doInvControl() { /** * Handles waiting whilst an object's description window is open. */ -void UserInterface::doLookControl() { +void ScalpelUserInterface::doLookControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; Screen &screen = *_vm->_screen; @@ -1319,7 +1328,7 @@ void UserInterface::doLookControl() { /** * Handles input until one of the user interface buttons/commands is selected */ -void UserInterface::doMainControl() { +void ScalpelUserInterface::doMainControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; SaveManager &saves = *_vm->_saves; @@ -1460,7 +1469,7 @@ void UserInterface::doMainControl() { /** * Handles the input for the MOVE, OPEN, and CLOSE commands */ -void UserInterface::doMiscControl(int allowed) { +void ScalpelUserInterface::doMiscControl(int allowed) { Events &events = *_vm->_events; Scene &scene = *_vm->_scene; Talk &talk = *_vm->_talk; @@ -1512,7 +1521,7 @@ void UserInterface::doMiscControl(int allowed) { /** * Handles input for picking up items */ -void UserInterface::doPickControl() { +void ScalpelUserInterface::doPickControl() { Events &events = *_vm->_events; Scene &scene = *_vm->_scene; Talk &talk = *_vm->_talk; @@ -1539,7 +1548,7 @@ void UserInterface::doPickControl() { * Handles input when in talk mode. It highlights the buttons and available statements, * and handles allowing the user to click on them */ -void UserInterface::doTalkControl() { +void ScalpelUserInterface::doTalkControl() { Events &events = *_vm->_events; Journal &journal = *_vm->_journal; People &people = *_vm->_people; @@ -1795,7 +1804,7 @@ void UserInterface::doTalkControl() { * the user interface, it uses so many internal UI fields, that it sort of made some sense * to put it in the UserInterface class. */ -void UserInterface::journalControl() { +void ScalpelUserInterface::journalControl() { Events &events = *_vm->_events; Journal &journal = *_vm->_journal; Scene &scene = *_vm->_scene; @@ -1846,7 +1855,7 @@ void UserInterface::journalControl() { /** * Print the description of an object */ -void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { +void ScalpelUserInterface::printObjectDesc(const Common::String &str, bool firstTime) { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; Screen &screen = *_vm->_screen; @@ -2017,14 +2026,14 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { /** * Print the previously selected object's decription */ -void UserInterface::printObjectDesc() { +void ScalpelUserInterface::printObjectDesc() { printObjectDesc(_cAnimStr, true); } /** * Displays a passed window by gradually scrolling it vertically on-screen */ -void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { +void ScalpelUserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; @@ -2067,7 +2076,7 @@ void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { /** * Slide the window stored in the back buffer onto the screen */ -void UserInterface::summonWindow(bool slideUp, int height) { +void ScalpelUserInterface::summonWindow(bool slideUp, int height) { Screen &screen = *_vm->_screen; // Extract the window that's been drawn on the back buffer @@ -2088,7 +2097,7 @@ void UserInterface::summonWindow(bool slideUp, int height) { * Close a currently open window * @param flag 0 = slide old window down, 1 = slide prior UI back up */ -void UserInterface::banishWindow(bool slideUp) { +void ScalpelUserInterface::banishWindow(bool slideUp) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; @@ -2157,7 +2166,7 @@ void UserInterface::banishWindow(bool slideUp) { /** * Checks to see whether a USE action is valid on the given object */ -void UserInterface::checkUseAction(const UseType *use, const Common::String &invName, +void ScalpelUserInterface::checkUseAction(const UseType *use, const Common::String &invName, const char *const messages[], int objNum, int giveMode) { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -2253,7 +2262,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv /** * Called for OPEN, CLOSE, and MOVE actions are being done */ -void UserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) { +void ScalpelUserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) { Events &events = *_vm->_events; People &people = *_vm->_people; Scene &scene = *_vm->_scene; @@ -2385,4 +2394,39 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] events.setCursor(ARROW); } +/** + * Support method for updating the screen + */ +void ScalpelUserInterface::doInvJF() { + Inventory &inv = *_vm->_inventory; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + + _invLookFlag = true; + inv.freeInv(); + + _infoFlag = true; + clearInfo(); + + screen._backBuffer2.blitFrom(screen._backBuffer1, Common::Point(0, CONTROLS_Y), + Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); + examine(); + + if (!talk._talkToAbort) { + screen._backBuffer2.blitFrom((*_controlPanel)[0]._frame, + Common::Point(0, CONTROLS_Y)); + inv.loadInv(); + } +} + +/*----------------------------------------------------------------*/ + +TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm) { + // +} + +void TattooUserInterface::handleInput() { + // TODO +} + } // End of namespace Sherlock -- cgit v1.2.3 From 5e351b6bf3988b33a6af952331039083c3b2aff8 Mon Sep 17 00:00:00 2001 From: sirlemonhead Date: Sun, 17 May 2015 20:41:42 +0100 Subject: SHERLOCK: Replace scumm_stricmp() with equalsIgnoreCase() --- engines/sherlock/user_interface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 1521421c15..d5ff828aee 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2177,17 +2177,17 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv int targetNum = -1; if (giveMode) { for (int idx = 0; idx < 4 && targetNum == -1; ++idx) { - if ((scumm_stricmp(use[idx]._target.c_str(), "*GIVE*") == 0 || scumm_stricmp(use[idx]._target.c_str(), "*GIVEP*") == 0) - && scumm_stricmp(use[idx]._names[0].c_str(), invName.c_str()) == 0) { + if ((use[idx]._target.equalsIgnoreCase("*GIVE*") || use[idx]._target.equalsIgnoreCase("*GIVEP*")) + && use[idx]._names[0].equalsIgnoreCase(invName)) { // Found a match targetNum = idx; - if (scumm_stricmp(use[idx]._target.c_str(), "*GIVE*") == 0) + if (use[idx]._target.equalsIgnoreCase("*GIVE*")) inv.deleteItemFromInventory(invName); } } } else { for (int idx = 0; idx < 4 && targetNum == -1; ++idx) { - if (scumm_stricmp(use[idx]._target.c_str(), invName.c_str()) == 0) + if (use[idx]._target.equalsIgnoreCase(invName)) targetNum = idx; } } -- cgit v1.2.3 From d82d476b277f80b69514fcb360ec47e9482e4a28 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 May 2015 20:57:27 +0200 Subject: SHERLOCK: Add code to make non-interactive demo completable --- engines/sherlock/user_interface.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index d5ff828aee..e2ad307aa4 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -81,8 +81,14 @@ const char *const MUSE[] = { /*----------------------------------------------------------------*/ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { - _controls = new ImageFile("menu.all"); - _controlPanel = new ImageFile("controls.vgs"); + if (_vm->_interactiveFl) { + _controls = new ImageFile("menu.all"); + _controlPanel = new ImageFile("controls.vgs"); + } else { + _controls = nullptr; + _controlPanel = nullptr; + } + _bgFound = 0; _oldBgFound = -1; _keycode = Common::KEYCODE_INVALID; -- cgit v1.2.3 From 59993fdc74afad7b210da7849f8ce25631153201 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 May 2015 19:15:17 -0400 Subject: SHERLOCK: Replace magic numbers with enums and constants --- engines/sherlock/user_interface.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index e2ad307aa4..ffcbddb920 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1156,7 +1156,7 @@ void UserInterface::doInvControl() { COMMAND_HIGHLIGHTED, "^^"); inv.freeGraphics(); inv.loadGraphics(); - inv.putInv(1); + inv.putInv(SLAM_DISPLAY); inv.invCommands(true); } else if (((found == 5 && events._released) || _key == Common::KEYCODE_MINUS || _key == Common::KEYCODE_KP_MINUS) && inv._invIndex > 0) { @@ -1164,7 +1164,7 @@ void UserInterface::doInvControl() { screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "^"); inv.freeGraphics(); inv.loadGraphics(); - inv.putInv(1); + inv.putInv(SLAM_DISPLAY); inv.invCommands(true); } else if (((found == 6 && events._released) || _key == Common::KEYCODE_PLUS || _key == Common::KEYCODE_KP_PLUS) && (inv._holdings - inv._invIndex) > 6) { @@ -1172,7 +1172,7 @@ void UserInterface::doInvControl() { screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); inv.freeGraphics(); inv.loadGraphics(); - inv.putInv(1); + inv.putInv(SLAM_DISPLAY); inv.invCommands(true); } else if (((found == 7 && events._released) || _key == '.') && (inv._holdings - inv._invIndex) > 6) { inv._invIndex += 6; @@ -1182,7 +1182,7 @@ void UserInterface::doInvControl() { screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); inv.freeGraphics(); inv.loadGraphics(); - inv.putInv(1); + inv.putInv(SLAM_DISPLAY); inv.invCommands(true); } else { // If something is being given, make sure it's to a person @@ -1226,7 +1226,7 @@ void UserInterface::doInvControl() { int temp = _selector; // Save the selector _selector = -1; - inv.putInv(1); + inv.putInv(SLAM_DISPLAY); _selector = temp; // Restore it temp = inv._invMode; inv._invMode = INVMODE_USE55; @@ -1300,7 +1300,7 @@ void UserInterface::doLookControl() { tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - inv.drawInventory(128); + inv.drawInventory(INVENTORY_DONT_DISPLAY); banishWindow(true); // Restore the ui @@ -1405,19 +1405,19 @@ void UserInterface::doMainControl() { pushButton(6); _selector = _oldSelector = -1; _menuMode = INV_MODE; - inv.drawInventory(1); + inv.drawInventory(PLAIN_INVENTORY); break; case 'U': pushButton(7); _selector = _oldSelector = -1; _menuMode = USE_MODE; - inv.drawInventory(2); + inv.drawInventory(USE_INVENTORY_MODE); break; case 'G': pushButton(8); _selector = _oldSelector = -1; _menuMode = GIVE_MODE; - inv.drawInventory(3); + inv.drawInventory(GIVE_INVENTORY_MODE); break; case 'J': pushButton(9); @@ -1904,7 +1904,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { // Reload the inventory graphics and draw the inventory inv.loadInv(); - inv.putInv(2); + inv.putInv(SLAM_SECONDARY_BUFFER); inv.freeInv(); banishWindow(1); @@ -2182,7 +2182,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv // Scan for target item int targetNum = -1; if (giveMode) { - for (int idx = 0; idx < 4 && targetNum == -1; ++idx) { + for (int idx = 0; idx < USE_COUNT && targetNum == -1; ++idx) { if ((use[idx]._target.equalsIgnoreCase("*GIVE*") || use[idx]._target.equalsIgnoreCase("*GIVEP*")) && use[idx]._names[0].equalsIgnoreCase(invName)) { // Found a match @@ -2192,7 +2192,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv } } } else { - for (int idx = 0; idx < 4 && targetNum == -1; ++idx) { + for (int idx = 0; idx < USE_COUNT && targetNum == -1; ++idx) { if (use[idx]._target.equalsIgnoreCase(invName)) targetNum = idx; } @@ -2216,7 +2216,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv if (!talk._talkToAbort) { Object &obj = scene._bgShapes[objNum]; - for (int idx = 0; idx < 4 && !talk._talkToAbort; ++idx) { + for (int idx = 0; idx < NAMES_COUNT && !talk._talkToAbort; ++idx) { if (obj.checkNameForCodes(action._names[idx], messages)) { if (!talk._talkToAbort) printed = true; @@ -2308,7 +2308,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] events.setCursor(WAIT); bool printed = false; - for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { + for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 && toupper(action._names[nameIdx][1]) == 'W') { if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), messages)) { @@ -2319,7 +2319,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] } bool doCAnim = true; - for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { + for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2) { char ch = toupper(action._names[nameIdx][1]); @@ -2349,7 +2349,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] people.walkToCoords(pt, dir); } - for (int nameIdx = 0; nameIdx < 4; ++nameIdx) { + for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 && toupper(action._names[nameIdx][1]) == 'F') { if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, messages)) { @@ -2363,7 +2363,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] scene.startCAnim(cAnimNum, action._cAnimSpeed); if (!talk._talkToAbort) { - for (int nameIdx = 0; nameIdx < 4 && !talk._talkToAbort; ++nameIdx) { + for (int nameIdx = 0; nameIdx < NAMES_COUNT && !talk._talkToAbort; ++nameIdx) { if (obj.checkNameForCodes(action._names[nameIdx], messages)) { if (!talk._talkToAbort) printed = true; -- cgit v1.2.3 From 8d426ca46435426c925007b08c933fdccdd75fa8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 May 2015 20:43:26 -0400 Subject: SHERLOCK: Added more of the game options to the Engine tab --- engines/sherlock/user_interface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ffcbddb920..1607c727eb 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -109,7 +109,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _selector = _oldSelector = -1; _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); - _windowStyle = 1; // Sliding windows + _slideWindows = true; _find = 0; _oldUse = 0; _endKeyActive = true; @@ -1999,7 +1999,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { } if (firstTime) { - if (!_windowStyle) { + if (!_slideWindows) { screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); } else { @@ -2094,10 +2094,10 @@ void UserInterface::banishWindow(bool slideUp) { Screen &screen = *_vm->_screen; if (_windowOpen) { - if (slideUp || !_windowStyle) { + if (slideUp || !_slideWindows) { // Slide window down // Only slide the window if the window style allows it - if (_windowStyle) { + if (_slideWindows) { for (int idx = 2; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y); idx += 2) { // Shift the window down by 2 lines byte *pSrc = (byte *)screen._backBuffer1.getBasePtr(0, CONTROLS_Y + idx - 2); -- cgit v1.2.3 From 485214a831582bab79634555175a79a317039613 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 00:03:54 -0400 Subject: SHERLOCK: Further addition of enums and method renames --- engines/sherlock/user_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 1607c727eb..ef1da3b29f 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1198,7 +1198,7 @@ void UserInterface::doInvControl() { if ((mousePos.y < CONTROLS_Y1) && (inv._invMode == 1) && (_find >= 0) && (_find < 1000)) { if (!scene._bgShapes[_find]._examine.empty() && scene._bgShapes[_find]._examine[0] >= ' ') - inv.doInvJF(); + inv.refreshInv(); } else if (_selector != -1 || _find >= 0) { // Selector is the inventory object that was clicked on, or selected. // If it's -1, then no inventory item is highlighted yet. Otherwise, @@ -1206,7 +1206,7 @@ void UserInterface::doInvControl() { if (_selector != -1 && inv._invMode == INVMODE_LOOK && mousePos.y >(CONTROLS_Y1 + 11)) - inv.doInvJF(); + inv.refreshInv(); if (talk._talkToAbort) return; -- cgit v1.2.3 From 1df183ffcb08a69ed414afd69284a0596fee4e82 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 07:37:55 -0400 Subject: SHERLOCK: Move method comments from cpp to headers --- engines/sherlock/user_interface.cpp | 94 ------------------------------------- 1 file changed, 94 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ef1da3b29f..12054bd7fb 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -122,18 +122,12 @@ UserInterface::~UserInterface() { delete _controlPanel; } -/** - * Resets the user interface - */ void UserInterface::reset() { _oldKey = -1; _help = _oldHelp = -1; _oldTemp = _temp = -1; } -/** - * Draw the user interface onto the screen's back buffers - */ void UserInterface::drawInterface(int bufferNum) { Screen &screen = *_vm->_screen; @@ -145,9 +139,6 @@ void UserInterface::drawInterface(int bufferNum) { screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK); } -/** - * Main input handler for the user interface - */ void UserInterface::handleInput() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -403,9 +394,6 @@ void UserInterface::handleInput() { } } -/** - * Draws the image for a user interface button in the down/pressed state. - */ void UserInterface::depressButton(int num) { Screen &screen = *_vm->_screen; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); @@ -415,10 +403,6 @@ void UserInterface::depressButton(int num) { screen.slamArea(pt.x, pt.y, pt.x + s.w, pt.y + s.h); } -/** - * Draws the image for the given user interface button in the up - * (not selected) position - */ void UserInterface::restoreButton(int num) { Screen &screen = *_vm->_screen; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); @@ -434,10 +418,6 @@ void UserInterface::restoreButton(int num) { } } -/** - * If he mouse button is pressed, then calls depressButton to draw the button - * as pressed; if not, it will show it as released with a call to "restoreButton". - */ void UserInterface::pushButton(int num) { Events &events = *_vm->_events; _oldKey = -1; @@ -455,11 +435,6 @@ void UserInterface::pushButton(int num) { restoreButton(num); } -/** - * By the time this method has been called, the graphics for the button change - * have already been drawn. This simply takes care of switching the mode around - * accordingly - */ void UserInterface::toggleButton(int num) { Screen &screen = *_vm->_screen; @@ -488,9 +463,6 @@ void UserInterface::toggleButton(int num) { } } -/** - * Clears the info line of the screen - */ void UserInterface::clearInfo() { if (_infoFlag) { _vm->_screen->vgaBar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 19, @@ -500,9 +472,6 @@ void UserInterface::clearInfo() { } } -/** - * Clear any active text window - */ void UserInterface::clearWindow() { if (_windowOpen) { _vm->_screen->vgaBar(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, @@ -510,9 +479,6 @@ void UserInterface::clearWindow() { } } -/** - * Handles counting down whilst checking for input, then clears the info line. - */ void UserInterface::whileMenuCounter() { if (!(--_menuCounter) || _vm->_events->checkInput()) { _menuCounter = 0; @@ -521,10 +487,6 @@ void UserInterface::whileMenuCounter() { } } -/** - * Creates a text window and uses it to display the in-depth description - * of the highlighted object - */ void UserInterface::examine() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -576,9 +538,6 @@ void UserInterface::examine() { } } -/** - * Print the name of an object in the scene - */ void UserInterface::lookScreen(const Common::Point &pt) { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -692,9 +651,6 @@ void UserInterface::lookScreen(const Common::Point &pt) { } } -/** - * Gets the item in the inventory the mouse is on and display's it's description - */ void UserInterface::lookInv() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -720,9 +676,6 @@ void UserInterface::lookInv() { } } -/** - * Handles input when the file list window is being displayed - */ void UserInterface::doEnvControl() { Events &events = *_vm->_events; SaveManager &saves = *_vm->_saves; @@ -1026,9 +979,6 @@ void UserInterface::doEnvControl() { } } -/** - * Handle input whilst the inventory is active - */ void UserInterface::doInvControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -1253,9 +1203,6 @@ void UserInterface::doInvControl() { } } -/** - * Handles waiting whilst an object's description window is open. - */ void UserInterface::doLookControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -1317,9 +1264,6 @@ void UserInterface::doLookControl() { } } -/** - * Handles input until one of the user interface buttons/commands is selected - */ void UserInterface::doMainControl() { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -1458,9 +1402,6 @@ void UserInterface::doMainControl() { } } -/** - * Handles the input for the MOVE, OPEN, and CLOSE commands - */ void UserInterface::doMiscControl(int allowed) { Events &events = *_vm->_events; Scene &scene = *_vm->_scene; @@ -1510,9 +1451,6 @@ void UserInterface::doMiscControl(int allowed) { } } -/** - * Handles input for picking up items - */ void UserInterface::doPickControl() { Events &events = *_vm->_events; Scene &scene = *_vm->_scene; @@ -1536,10 +1474,6 @@ void UserInterface::doPickControl() { } } -/** - * Handles input when in talk mode. It highlights the buttons and available statements, - * and handles allowing the user to click on them - */ void UserInterface::doTalkControl() { Events &events = *_vm->_events; Journal &journal = *_vm->_journal; @@ -1790,12 +1724,6 @@ void UserInterface::doTalkControl() { } } -/** - * Handles events when the Journal is active. - * @remarks Whilst this would in theory be better in the Journal class, since it displays in - * the user interface, it uses so many internal UI fields, that it sort of made some sense - * to put it in the UserInterface class. - */ void UserInterface::journalControl() { Events &events = *_vm->_events; Journal &journal = *_vm->_journal; @@ -1844,9 +1772,6 @@ void UserInterface::journalControl() { screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); } -/** -* Print the description of an object -*/ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; @@ -2015,16 +1940,10 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { } } -/** - * Print the previously selected object's decription - */ void UserInterface::printObjectDesc() { printObjectDesc(_cAnimStr, true); } -/** - * Displays a passed window by gradually scrolling it vertically on-screen - */ void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; @@ -2065,9 +1984,6 @@ void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { _windowOpen = true; } -/** - * Slide the window stored in the back buffer onto the screen - */ void UserInterface::summonWindow(bool slideUp, int height) { Screen &screen = *_vm->_screen; @@ -2085,10 +2001,6 @@ void UserInterface::summonWindow(bool slideUp, int height) { summonWindow(tempSurface, slideUp); } -/** - * Close a currently open window - * @param flag 0 = slide old window down, 1 = slide prior UI back up - */ void UserInterface::banishWindow(bool slideUp) { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; @@ -2155,9 +2067,6 @@ void UserInterface::banishWindow(bool slideUp) { _menuMode = STD_MODE; } -/** - * Checks to see whether a USE action is valid on the given object - */ void UserInterface::checkUseAction(const UseType *use, const Common::String &invName, const char *const messages[], int objNum, int giveMode) { Events &events = *_vm->_events; @@ -2251,9 +2160,6 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv events.setCursor(ARROW); } -/** - * Called for OPEN, CLOSE, and MOVE actions are being done - */ void UserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) { Events &events = *_vm->_events; People &people = *_vm->_people; -- cgit v1.2.3 From fa35249a240d7bdfe5f5b7eb9ae073126d5080c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 08:01:06 -0400 Subject: SHERLOCK: More syntactic fixes --- engines/sherlock/user_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 12054bd7fb..861c1c695d 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -783,7 +783,7 @@ void UserInterface::doEnvControl() { if (saves.checkGameOnScreen(_selector)) _oldSelector = _selector; - if (saves.getFilename(_selector)) { + if (saves.promptForFilename(_selector)) { saves.saveGame(_selector + 1, saves._savegames[_selector]); banishWindow(1); @@ -954,7 +954,7 @@ void UserInterface::doEnvControl() { if (saves.checkGameOnScreen(_selector)) _oldSelector = _selector; - if (saves.getFilename(_selector)) { + if (saves.promptForFilename(_selector)) { saves.saveGame(_selector + 1, saves._savegames[_selector]); banishWindow(); _windowBounds.top = CONTROLS_Y1; -- cgit v1.2.3 From 8ae0014bc25e42e519d5a6a31279ee22580aaba9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 09:10:35 -0400 Subject: SHERLOCK: Refactor Surface not to descend directly from Graphics::Surface --- engines/sherlock/user_interface.cpp | 39 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 861c1c695d..d36be4ed76 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -398,9 +398,9 @@ void UserInterface::depressButton(int num) { Screen &screen = *_vm->_screen; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); - Graphics::Surface &s = (*_controls)[num]._frame; - screen._backBuffer1.transBlitFrom(s, pt); - screen.slamArea(pt.x, pt.y, pt.x + s.w, pt.y + s.h); + ImageFrame &frame = (*_controls)[num]; + screen._backBuffer1.transBlitFrom(frame, pt); + screen.slamArea(pt.x, pt.y, pt.x + frame._width, pt.y + frame._height); } void UserInterface::restoreButton(int num) { @@ -451,10 +451,10 @@ void UserInterface::toggleButton(int num) { _keyboardInput = false; - Graphics::Surface &s = (*_controls)[num]._frame; + ImageFrame &frame = (*_controls)[num]; Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); - screen._backBuffer1.transBlitFrom(s, pt); - screen.slamArea(pt.x, pt.y, pt.x + s.w, pt.y + s.h); + screen._backBuffer1.transBlitFrom(frame, pt); + screen.slamArea(pt.x, pt.y, pt.x + frame._width, pt.y + frame._height); } } else { _menuMode = STD_MODE; @@ -1220,7 +1220,7 @@ void UserInterface::doLookControl() { } else if (!_lookHelp) { // Need to close the window and depress the Look button Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); - screen._backBuffer2.blitFrom((*_controls)[0]._frame, pt); + screen._backBuffer2.blitFrom((*_controls)[0], pt); banishWindow(true); _windowBounds.top = CONTROLS_Y1; @@ -1801,8 +1801,8 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), - Common::Rect(pt.x, pt.y, pt.x + tempSurface.w, pt.y + tempSurface.h)); - screen._backBuffer2.transBlitFrom((*_controls)[0]._frame, pt); + Common::Rect(pt.x, pt.y, pt.x + tempSurface.w(), pt.y + tempSurface.h())); + screen._backBuffer2.transBlitFrom((*_controls)[0], pt); banishWindow(1); events.setCursor(MAGNIFY); @@ -1954,9 +1954,9 @@ void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { if (slideUp) { // Gradually slide up the display of the window - for (int idx = 1; idx <= bgSurface.h; idx += 2) { + for (int idx = 1; idx <= bgSurface.h(); idx += 2) { screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), - Common::Rect(0, 0, bgSurface.w, idx)); + Common::Rect(0, 0, bgSurface.w(), idx)); screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); @@ -1964,22 +1964,21 @@ void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { } } else { // Gradually slide down the display of the window - for (int idx = 1; idx <= bgSurface.h; idx += 2) { + for (int idx = 1; idx <= bgSurface.h(); idx += 2) { screen._backBuffer->blitFrom(bgSurface, - Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h), - Common::Rect(0, bgSurface.h - idx, bgSurface.w, bgSurface.h)); - screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h, - SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - bgSurface.h + idx)); + Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h()), + Common::Rect(0, bgSurface.h() - idx, bgSurface.w(), bgSurface.h())); + screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h(), + SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - bgSurface.h() + idx)); events.delay(10); } } // Final display of the entire window - screen._backBuffer->blitFrom(bgSurface, Common::Point(0, - SHERLOCK_SCREEN_HEIGHT - bgSurface.h), - Common::Rect(0, 0, bgSurface.w, bgSurface.h)); - screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h, bgSurface.w, bgSurface.h); + screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h()), + Common::Rect(0, 0, bgSurface.w(), bgSurface.h())); + screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h(), bgSurface.w(), bgSurface.h()); _windowOpen = true; } -- cgit v1.2.3 From 033241eb434ff4916c140885a6cda84a593406d5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 09:19:42 -0400 Subject: SHERLOCK: Corrected incorrect method name in SaveManager --- engines/sherlock/user_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index d36be4ed76..7ac44ee99e 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -783,7 +783,7 @@ void UserInterface::doEnvControl() { if (saves.checkGameOnScreen(_selector)) _oldSelector = _selector; - if (saves.promptForFilename(_selector)) { + if (saves.promptForDescription(_selector)) { saves.saveGame(_selector + 1, saves._savegames[_selector]); banishWindow(1); @@ -954,7 +954,7 @@ void UserInterface::doEnvControl() { if (saves.checkGameOnScreen(_selector)) _oldSelector = _selector; - if (saves.promptForFilename(_selector)) { + if (saves.promptForDescription(_selector)) { saves.saveGame(_selector + 1, saves._savegames[_selector]); banishWindow(); _windowBounds.top = CONTROLS_Y1; -- cgit v1.2.3 From 6f9693102f99843501822f27431d839777fb43d5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 09:35:53 -0400 Subject: SHERLOCK: Further minor cleanups --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 7ac44ee99e..fbedbb9005 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -714,7 +714,7 @@ void UserInterface::doEnvControl() { // Handle selecting buttons, if any saves.highlightButtons(found); - if (found == 0 || found == 5) + if (found == 0 || found == ONSCREEN_FILES_COUNT) saves._envMode = SAVEMODE_NONE; } -- cgit v1.2.3 From 4849e008977d87b707d70c836c7abcd0c79eb9de Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 May 2015 19:06:44 +0200 Subject: SHERLOCK: Fix some issues pointed by eriktorbjorn --- engines/sherlock/user_interface.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index fbedbb9005..e1d6619ed7 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -523,7 +523,7 @@ void UserInterface::examine() { } if (_invLookFlag) { - // Dont close the inventory window when starting an examine display, since it's + // Don't close the inventory window when starting an examine display, since its // window will slide up to replace the inventory display _windowOpen = false; _menuMode = LOOK_MODE; @@ -690,13 +690,11 @@ void UserInterface::doEnvControl() { _keyboardInput = false; int found = saves.getHighlightedButton(); - if (events._pressed || events._released) - { + if (events._pressed || events._released) { events.clearKeyboard(); // Check for a filename entry being highlighted - if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10)) - { + if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10)) { int found1 = 0; for (_selector = 0; (_selector < 5) && !found1; ++_selector) if (mousePos.y > (CONTROLS_Y + 11 + _selector * 10) && mousePos.y < (CONTROLS_Y + 21 + _selector * 10)) @@ -828,7 +826,7 @@ void UserInterface::doEnvControl() { color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - 5) ? COMMAND_NULL : COMMAND_FOREGROUND; screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); - // Check for there are more pending U keys pressed + // Check whether there are more pending U keys pressed moreKeys = false; if (events.kbHit()) { Common::KeyState keyState = events.getKey(); @@ -864,7 +862,7 @@ void UserInterface::doEnvControl() { color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - 5) ? COMMAND_NULL : COMMAND_FOREGROUND; screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); - // Check for there are more pending D keys pressed + // Check whether there are more pending D keys pressed moreKeys = false; if (events.kbHit()) { Common::KeyState keyState; @@ -950,7 +948,7 @@ void UserInterface::doEnvControl() { if (saves._envMode == SAVEMODE_LOAD) { saves.loadGame(_selector + 1); } else if (saves._envMode == SAVEMODE_SAVE || _selector == MAX_SAVEGAME_SLOTS) { - // We're alreaady in save mode, or pointed to an empty save slot + // We're already in save mode, or pointing to an empty save slot if (saves.checkGameOnScreen(_selector)) _oldSelector = _selector; @@ -1007,7 +1005,7 @@ void UserInterface::doInvControl() { events.clearKeyboard(); if (found != -1) - // If a slot highlighted, set it's color + // If a slot highlighted, set its color colors[found] = COMMAND_HIGHLIGHTED; screen.buttonPrint(Common::Point(INVENTORY_POINTS[0][2], CONTROLS_Y1), colors[0], true, "Exit"); @@ -1135,7 +1133,7 @@ void UserInterface::doInvControl() { inv.putInv(SLAM_DISPLAY); inv.invCommands(true); } else { - // If something is being given, make sure it's to a person + // If something is being given, make sure it's being given to a person if (inv._invMode == 3) { if (_bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON) _find = _bgFound; -- cgit v1.2.3 From 85081b7702e7571a144ff57accd5ac9123f4123f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 May 2015 19:37:33 +0200 Subject: SHERLOCK: Systematically use InvMode values when it's appropriate --- engines/sherlock/user_interface.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index e1d6619ed7..943d3498b2 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -300,7 +300,7 @@ void UserInterface::handleInput() { case USE_MODE: case GIVE_MODE: case INV_MODE: - if (inv._invMode == 1 || inv._invMode == 2 || inv._invMode == 3) { + if (inv._invMode == INVMODE_LOOK || inv._invMode == INVMODE_USE || inv._invMode == INVMODE_GIVE) { if (pt.y > CONTROLS_Y) lookInv(); else @@ -568,10 +568,10 @@ void UserInterface::lookScreen(const Common::Point &pt) { if (!tempStr.empty() && tempStr[0] != ' ') { // If inventory is active and an item is selected for a Use or Give action if ((_menuMode == INV_MODE || _menuMode == USE_MODE || _menuMode == GIVE_MODE) && - (inv._invMode == 2 || inv._invMode == 3)) { + (inv._invMode == INVMODE_USE || inv._invMode == INVMODE_GIVE)) { int width1 = 0, width2 = 0; int x, width; - if (inv._invMode == 2) { + if (inv._invMode == INVMODE_USE) { // Using an object x = width = screen.stringWidth("Use "); @@ -1028,7 +1028,7 @@ void UserInterface::doInvControl() { } bool flag = false; - if (inv._invMode == 1 || inv._invMode == 2 || inv._invMode == 3) { + if (inv._invMode == INVMODE_LOOK || inv._invMode == INVMODE_USE || inv._invMode == INVMODE_GIVE) { Common::Rect r(15, CONTROLS_Y1 + 11, 314, SHERLOCK_SCREEN_HEIGHT - 2); if (r.contains(mousePos)) { _selector = (mousePos.x - 6) / 52 + inv._invIndex; @@ -1050,13 +1050,13 @@ void UserInterface::doInvControl() { if (_key == 'E' || _key == 'L' || _key == 'U' || _key == 'G' || _key == '-' || _key == '+') { - int temp = inv._invMode; + InvMode temp = inv._invMode; const char *chP = strchr(INVENTORY_COMMANDS, _key); inv._invMode = !chP ? INVMODE_INVALID : (InvMode)(chP - INVENTORY_COMMANDS); inv.invCommands(true); - inv._invMode = (InvMode)temp; + inv._invMode = temp; _keyboardInput = true; if (_key == 'E') inv._invMode = INVMODE_EXIT; @@ -1134,7 +1134,7 @@ void UserInterface::doInvControl() { inv.invCommands(true); } else { // If something is being given, make sure it's being given to a person - if (inv._invMode == 3) { + if (inv._invMode == INVMODE_GIVE) { if (_bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON) _find = _bgFound; else @@ -1143,7 +1143,7 @@ void UserInterface::doInvControl() { _find = _bgFound; } - if ((mousePos.y < CONTROLS_Y1) && (inv._invMode == 1) && (_find >= 0) && (_find < 1000)) { + if ((mousePos.y < CONTROLS_Y1) && (inv._invMode == INVMODE_LOOK) && (_find >= 0) && (_find < 1000)) { if (!scene._bgShapes[_find]._examine.empty() && scene._bgShapes[_find]._examine[0] >= ' ') inv.refreshInv(); @@ -1166,17 +1166,17 @@ void UserInterface::doInvControl() { // is being tried on an object in the scene without an inventory // object being highlighted first. - if ((inv._invMode == 2 || (_selector != -1 && inv._invMode == 3)) && _find >= 0) { + if ((inv._invMode == INVMODE_USE || (_selector != -1 && inv._invMode == INVMODE_GIVE)) && _find >= 0) { events._pressed = events._released = false; _infoFlag = true; clearInfo(); - int temp = _selector; // Save the selector + int tempSel = _selector; // Save the selector _selector = -1; inv.putInv(SLAM_DISPLAY); - _selector = temp; // Restore it - temp = inv._invMode; + _selector = tempSel; // Restore it + InvMode tempMode = inv._invMode; inv._invMode = INVMODE_USE55; inv.invCommands(true); @@ -1187,12 +1187,13 @@ void UserInterface::doInvControl() { inv.freeInv(); + bool giveFl = (tempMode >= INVMODE_GIVE); if (_selector >= 0) // Use/Give inv object with scene object - checkUseAction(&scene._bgShapes[_find]._use[0], inv[_selector]._name, MUSE, _find, temp - 2); + checkUseAction(&scene._bgShapes[_find]._use[0], inv[_selector]._name, MUSE, _find, giveFl); else // Now inv object has been highlighted - checkUseAction(&scene._bgShapes[_find]._use[0], "*SELF*", MUSE, _find, temp - 2); + checkUseAction(&scene._bgShapes[_find]._use[0], "*SELF*", MUSE, _find, giveFl); _selector = _oldSelector = -1; } @@ -2065,7 +2066,7 @@ void UserInterface::banishWindow(bool slideUp) { } void UserInterface::checkUseAction(const UseType *use, const Common::String &invName, - const char *const messages[], int objNum, int giveMode) { + const char *const messages[], int objNum, bool giveMode) { Events &events = *_vm->_events; Inventory &inv = *_vm->_inventory; Scene &scene = *_vm->_scene; -- cgit v1.2.3 From 456e0c584f2497b82b6be5f531f655b9681a11b8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 May 2015 20:07:24 +0200 Subject: SHERLOCK: Use a bit more MenuMode and SaveMode --- engines/sherlock/user_interface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 943d3498b2..c42829167b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -389,7 +389,7 @@ void UserInterface::handleInput() { doMainControl(); } - if (pt.y < CONTROLS_Y && events._pressed && _oldTemp != (_menuMode - 1) && _oldKey != -1) + if (pt.y < CONTROLS_Y && events._pressed && _oldTemp != (int)(_menuMode - 1) && _oldKey != -1) restoreButton(_oldTemp); } } @@ -438,7 +438,7 @@ void UserInterface::pushButton(int num) { void UserInterface::toggleButton(int num) { Screen &screen = *_vm->_screen; - if (_menuMode != (num + 1)) { + if (_menuMode != (MenuMode)(num + 1)) { _menuMode = (MenuMode)(num + 1); _oldKey = COMMANDS[num]; _oldTemp = num; @@ -700,7 +700,7 @@ void UserInterface::doEnvControl() { if (mousePos.y > (CONTROLS_Y + 11 + _selector * 10) && mousePos.y < (CONTROLS_Y + 21 + _selector * 10)) found1 = 1; - if (_selector + saves._savegameIndex - 1 < MAX_SAVEGAME_SLOTS + (saves._envMode != 1)) + if (_selector + saves._savegameIndex - 1 < MAX_SAVEGAME_SLOTS + (saves._envMode != SAVEMODE_LOAD)) _selector = _selector + saves._savegameIndex - 1; else _selector = -1; @@ -734,7 +734,7 @@ void UserInterface::doEnvControl() { } else if (_key >= '1' && _key <= '9') { _keyboardInput = true; _selector = _key - '1'; - if (_selector >= MAX_SAVEGAME_SLOTS + (saves._envMode == 1 ? 0 : 1)) + if (_selector >= MAX_SAVEGAME_SLOTS + (saves._envMode == SAVEMODE_LOAD ? 0 : 1)) _selector = -1; if (saves.checkGameOnScreen(_selector)) -- cgit v1.2.3 From de08eb071e37013627dd4de941a50b8e45441c71 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 19:11:57 -0400 Subject: SHERLOCK: Use more constants in doEnvControl --- engines/sherlock/user_interface.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index c42829167b..8121eee7bc 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -696,7 +696,7 @@ void UserInterface::doEnvControl() { // Check for a filename entry being highlighted if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10)) { int found1 = 0; - for (_selector = 0; (_selector < 5) && !found1; ++_selector) + for (_selector = 0; (_selector < ONSCREEN_FILES_COUNT) && !found1; ++_selector) if (mousePos.y > (CONTROLS_Y + 11 + _selector * 10) && mousePos.y < (CONTROLS_Y + 21 + _selector * 10)) found1 = 1; @@ -746,7 +746,7 @@ void UserInterface::doEnvControl() { } if (_selector != _oldSelector) { - if (_oldSelector != -1 && _oldSelector >= saves._savegameIndex && _oldSelector < (saves._savegameIndex + 5)) { + if (_oldSelector != -1 && _oldSelector >= saves._savegameIndex && _oldSelector < (saves._savegameIndex + ONSCREEN_FILES_COUNT)) { screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _oldSelector + 1); screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), @@ -810,9 +810,9 @@ void UserInterface::doEnvControl() { screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); - for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + 5); ++idx) { + for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT); ++idx) { color = INV_FOREGROUND; - if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + 5)) + if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT)) color = TALK_FOREGROUND; screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); @@ -823,7 +823,7 @@ void UserInterface::doEnvControl() { color = !saves._savegameIndex ? COMMAND_NULL : COMMAND_FOREGROUND; screen.buttonPrint(Common::Point(ENV_POINTS[3][2], CONTROLS_Y), color, true, "Up"); - color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - 5) ? COMMAND_NULL : COMMAND_FOREGROUND; + color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) ? COMMAND_NULL : COMMAND_FOREGROUND; screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); // Check whether there are more pending U keys pressed @@ -835,15 +835,15 @@ void UserInterface::doEnvControl() { moreKeys = _key == 'U'; } } while ((saves._savegameIndex) && moreKeys); - } else if (((found == 4 && events._released) || _key == 'D') && saves._savegameIndex < (MAX_SAVEGAME_SLOTS - 5)) { + } else if (((found == 4 && events._released) || _key == 'D') && saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT)) { bool moreKeys; do { saves._savegameIndex++; screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); - for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + 5); ++idx) { - if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + 5)) + for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT); ++idx) { + if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT)) color = TALK_FOREGROUND; else color = INV_FOREGROUND; @@ -859,7 +859,7 @@ void UserInterface::doEnvControl() { color = (!saves._savegameIndex) ? COMMAND_NULL : COMMAND_FOREGROUND; screen.buttonPrint(Common::Point(ENV_POINTS[3][2], CONTROLS_Y), color, true, "Up"); - color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - 5) ? COMMAND_NULL : COMMAND_FOREGROUND; + color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) ? COMMAND_NULL : COMMAND_FOREGROUND; screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); // Check whether there are more pending D keys pressed @@ -870,8 +870,8 @@ void UserInterface::doEnvControl() { moreKeys = _key == 'D'; } - } while (saves._savegameIndex < (MAX_SAVEGAME_SLOTS - 5) && moreKeys); - } else if ((found == 5 && events._released) || _key == 'Q') { + } while (saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) && moreKeys); + } else if ((found == ONSCREEN_FILES_COUNT && events._released) || _key == 'Q') { clearWindow(); screen.print(Common::Point(0, CONTROLS_Y + 20), INV_FOREGROUND, "Are you sure you wish to Quit ?"); screen.vgaBar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + 10), BORDER_COLOR); -- cgit v1.2.3 From fe8139b57168bbb85eb1d4bb0d2c62219ee6383d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 May 2015 07:13:18 +0200 Subject: SHERLOCK: Improve comment as suggested by LordHoto --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 8121eee7bc..ed6558c6dd 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -1159,7 +1159,7 @@ void UserInterface::doInvControl() { if (talk._talkToAbort) return; - // Now check for the Use and Give actions. If inv_mode is 3, + // Now check for the Use and Give actions. If inv_mode is INVMODE_GIVE, // that means GIVE is in effect, _selector is the object being // given, and _find is the target. // The same applies to USE, except if _selector is -1, then USE -- cgit v1.2.3 From 30133cef0e2a840325c1b46b106628c3cccd7d04 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 May 2015 08:28:12 -0400 Subject: SHERLOCK: Re-add GCC_PRINTF and fix resulting GCC warnings --- engines/sherlock/user_interface.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ed6558c6dd..940fcbca03 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -230,7 +230,7 @@ void UserInterface::handleInput() { if (_help != -1 && !scene._bgShapes[_bgFound]._description.empty() && scene._bgShapes[_bgFound]._description[0] != ' ') screen.print(Common::Point(0, INFO_LINE + 1), - INFO_FOREGROUND, scene._bgShapes[_bgFound]._description.c_str()); + INFO_FOREGROUND, "%s", scene._bgShapes[_bgFound]._description.c_str()); _oldBgFound = _bgFound; } @@ -603,14 +603,14 @@ void UserInterface::lookScreen(const Common::Point &pt) { if (_selector != -1) { screen.print(Common::Point(xStart + width, INFO_LINE + 1), - TALK_FOREGROUND, inv[_selector]._name.c_str()); + TALK_FOREGROUND, "%s", inv[_selector]._name.c_str()); screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), INFO_FOREGROUND, " on "); screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), - INFO_FOREGROUND, tempStr.c_str()); + INFO_FOREGROUND, "%s", tempStr.c_str()); } else { screen.print(Common::Point(xStart + width, INFO_LINE + 1), - INFO_FOREGROUND, tempStr.c_str()); + INFO_FOREGROUND, "%s", tempStr.c_str()); } } else if (temp >= 0 && temp < 1000 && _selector != -1 && scene._bgShapes[temp]._aType == PERSON) { @@ -632,14 +632,14 @@ void UserInterface::lookScreen(const Common::Point &pt) { screen.print(Common::Point(xStart, INFO_LINE + 1), INFO_FOREGROUND, "Give "); screen.print(Common::Point(xStart + width, INFO_LINE + 1), - TALK_FOREGROUND, inv[_selector]._name.c_str()); + TALK_FOREGROUND, "%s", inv[_selector]._name.c_str()); screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), INFO_FOREGROUND, " to "); screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), - INFO_FOREGROUND, tempStr.c_str()); + INFO_FOREGROUND, "%s", tempStr.c_str()); } } else { - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, tempStr.c_str()); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", tempStr.c_str()); } _infoFlag = true; @@ -664,7 +664,7 @@ void UserInterface::lookInv() { if (temp < inv._holdings) { clearInfo(); screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, - inv[temp]._description.c_str()); + "%s", inv[temp]._description.c_str()); _infoFlag = true; _oldLook = temp; } @@ -1896,7 +1896,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { // Print out the line Common::String line(lineStartP, msgP); screen.gPrint(Common::Point(16, CONTROLS_Y + 12 + lineNum * 9), - INV_FOREGROUND, line.c_str()); + INV_FOREGROUND, "%s", line.c_str()); if (!endOfStr) // Start next line at start of the nxet word after space @@ -2148,7 +2148,7 @@ void UserInterface::checkUseAction(const UseType *use, const Common::String &inv } else if (messages == nullptr) { screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "You can't do that."); } else { - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[0]); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[0]); } _infoFlag = true; @@ -2174,7 +2174,7 @@ void UserInterface::checkAction(ActionType &action, const char *const messages[] // Invalid action, to print error message _infoFlag = true; clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, messages[action._cAnimNum]); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[action._cAnimNum]); _infoFlag = true; // Set how long to show the message -- cgit v1.2.3 From e115da8f3dd4622cf0f89f55ce00af415eac251e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 May 2015 20:32:04 -0400 Subject: SHERLOCK: Standardised keypress fields as char type --- engines/sherlock/user_interface.cpp | 56 +++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 30 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 940fcbca03..92fc89305e 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -91,13 +91,13 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _bgFound = 0; _oldBgFound = -1; - _keycode = Common::KEYCODE_INVALID; + _keyPress = '\0'; _helpStyle = false; _menuCounter = 0; _menuMode = STD_MODE; _help = _oldHelp = 0; _lookHelp = 0; - _key = _oldKey = 0; + _key = _oldKey = '\0'; _temp = _oldTemp = 0; _temp1 = 0; _invLookFlag = 0; @@ -152,13 +152,13 @@ void UserInterface::handleInput() { Common::Point pt = events.mousePos(); _bgFound = scene.findBgShape(Common::Rect(pt.x, pt.y, pt.x + 1, pt.y + 1)); - _keycode = Common::KEYCODE_INVALID; + _keyPress = '\0'; // Check kbd and set the mouse released flag if Enter or space is pressed. // Otherwise, the pressed _key is stored for later use if (events.kbHit()) { Common::KeyState keyState = events.getKey(); - _keycode = keyState.ascii; + _keyPress = keyState.ascii; if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) { _vm->quitGame(); @@ -315,8 +315,7 @@ void UserInterface::handleInput() { // // Do input processing // - if (events._pressed || events._released || events._rightPressed || - _keycode != Common::KEYCODE_INVALID || _pause) { + if (events._pressed || events._released || events._rightPressed || _keyPress || _pause) { if (((events._released && (_helpStyle || _help == -1)) || (events._rightReleased && !_helpStyle)) && (pt.y <= CONTROLS_Y) && (_menuMode == STD_MODE)) { // The mouse was clicked in the playing area with no action buttons down. @@ -383,9 +382,8 @@ void UserInterface::handleInput() { // As long as there isn't an open window, do main input processing. // Windows are opened when in TALK, USE, INV, and GIVE modes if ((!_windowOpen && !_menuCounter && pt.y > CONTROLS_Y) || - _keycode != Common::KEYCODE_INVALID) { - if (events._pressed || events._released || _pause || - _keycode != Common::KEYCODE_INVALID) + _keyPress) { + if (events._pressed || events._released || _pause || _keyPress) doMainControl(); } @@ -716,8 +714,8 @@ void UserInterface::doEnvControl() { saves._envMode = SAVEMODE_NONE; } - if (_keycode) { - _key = toupper(_keycode); + if (_keyPress) { + _key = toupper(_keyPress); // Escape _key will close the dialog if (_key == Common::KEYCODE_ESCAPE) @@ -769,7 +767,7 @@ void UserInterface::doEnvControl() { _windowBounds.top = CONTROLS_Y1; events._pressed = events._released = _keyboardInput = false; - _keycode = Common::KEYCODE_INVALID; + _keyPress = '\0'; } else if ((found == 1 && events._released) || _key == 'L') { saves._envMode = SAVEMODE_LOAD; if (_selector != -1) { @@ -787,7 +785,7 @@ void UserInterface::doEnvControl() { banishWindow(1); _windowBounds.top = CONTROLS_Y1; _key = _oldKey = -1; - _keycode = Common::KEYCODE_INVALID; + _keyPress = '\0'; _keyboardInput = false; } else { if (!talk._talkToAbort) { @@ -903,11 +901,11 @@ void UserInterface::doEnvControl() { if (_key == Common::KEYCODE_ESCAPE) _key = 'N'; - if (_key == Common::KEYCODE_RETURN || _key == Common::KEYCODE_SPACE) { + if (_key == Common::KEYCODE_RETURN || _key == ' ') { events._pressed = false; events._released = true; events._oldButtons = 0; - _keycode = Common::KEYCODE_INVALID; + _keyPress = '\0'; } } @@ -957,7 +955,7 @@ void UserInterface::doEnvControl() { banishWindow(); _windowBounds.top = CONTROLS_Y1; _key = _oldKey = -1; - _keycode = Common::KEYCODE_INVALID; + _keyPress = '\0'; _keyboardInput = false; } else { if (!talk._talkToAbort) { @@ -1041,12 +1039,12 @@ void UserInterface::doInvControl() { _selector = -1; } - if (_keycode != Common::KEYCODE_INVALID) { - _key = toupper(_keycode); + if (_keyPress) { + _key = toupper(_keyPress); if (_key == Common::KEYCODE_ESCAPE) // Escape will also 'E'xit out of inventory display - _key = Common::KEYCODE_e; + _key = 'E'; if (_key == 'E' || _key == 'L' || _key == 'U' || _key == 'G' || _key == '-' || _key == '+') { @@ -1106,16 +1104,14 @@ void UserInterface::doInvControl() { inv.loadGraphics(); inv.putInv(SLAM_DISPLAY); inv.invCommands(true); - } else if (((found == 5 && events._released) || _key == Common::KEYCODE_MINUS - || _key == Common::KEYCODE_KP_MINUS) && inv._invIndex > 0) { + } else if (((found == 5 && events._released) || _key == '-') && inv._invIndex > 0) { --inv._invIndex; screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "^"); inv.freeGraphics(); inv.loadGraphics(); inv.putInv(SLAM_DISPLAY); inv.invCommands(true); - } else if (((found == 6 && events._released) || _key == Common::KEYCODE_PLUS - || _key == Common::KEYCODE_KP_PLUS) && (inv._holdings - inv._invIndex) > 6) { + } else if (((found == 6 && events._released) || _key == '+') && (inv._holdings - inv._invIndex) > 6) { ++inv._invIndex; screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); inv.freeGraphics(); @@ -1208,7 +1204,7 @@ void UserInterface::doLookControl() { Screen &screen = *_vm->_screen; _key = _oldKey = -1; - _keyboardInput = (_keycode != Common::KEYCODE_INVALID); + _keyboardInput = (_keyPress != '\0'); if (events._released || events._rightReleased || _keyboardInput) { // Is an inventory object being looked at? @@ -1281,12 +1277,12 @@ void UserInterface::doMainControl() { _key = COMMANDS[_temp]; } --_temp; - } else if (_keycode != Common::KEYCODE_INVALID) { + } else if (_keyPress) { // Keyboard control _keyboardInput = true; - if (_keycode >= Common::KEYCODE_a && _keycode <= Common::KEYCODE_z) { - const char *c = strchr(COMMANDS, _keycode); + if (_keyPress >= 'A' && _keyPress <= 'Z') { + const char *c = strchr(COMMANDS, _keyPress); _temp = !c ? 12 : c - COMMANDS; } else { _temp = 12; @@ -1515,8 +1511,8 @@ void UserInterface::doTalkControl() { _selector = -1; } - if (_keycode != Common::KEYCODE_INVALID) { - _key = toupper(_keycode); + if (_keyPress) { + _key = toupper(_keyPress); if (_key == Common::KEYCODE_ESCAPE) _key = 'E'; @@ -1757,7 +1753,7 @@ void UserInterface::journalControl() { // Finish up _infoFlag = _keyboardInput = false; - _keycode = Common::KEYCODE_INVALID; + _keyPress = '\0'; _windowOpen = false; _windowBounds.top = CONTROLS_Y1; _key = -1; -- cgit v1.2.3 From 6a8e3173555c7a34749bcf4b905dec20178bbf5f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 May 2015 21:02:58 -0400 Subject: SHERLOCK: Constants fixes in UserInterface --- engines/sherlock/user_interface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 92fc89305e..4781f4811b 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -682,6 +682,7 @@ void UserInterface::doEnvControl() { Talk &talk = *_vm->_talk; Common::Point mousePos = events.mousePos(); static const char ENV_COMMANDS[7] = "ELSUDQ"; + byte color; _key = _oldKey = -1; @@ -710,7 +711,7 @@ void UserInterface::doEnvControl() { // Handle selecting buttons, if any saves.highlightButtons(found); - if (found == 0 || found == ONSCREEN_FILES_COUNT) + if (found == 0 || found == 5) saves._envMode = SAVEMODE_NONE; } @@ -869,7 +870,7 @@ void UserInterface::doEnvControl() { moreKeys = _key == 'D'; } } while (saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) && moreKeys); - } else if ((found == ONSCREEN_FILES_COUNT && events._released) || _key == 'Q') { + } else if ((found == 5 && events._released) || _key == 'Q') { clearWindow(); screen.print(Common::Point(0, CONTROLS_Y + 20), INV_FOREGROUND, "Are you sure you wish to Quit ?"); screen.vgaBar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + 10), BORDER_COLOR); @@ -1867,7 +1868,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) { // Loop through displaying up to five lines bool endOfStr = false; const char *msgP = str.c_str(); - for (int lineNum = 0; lineNum < 5 && !endOfStr; ++lineNum) { + for (int lineNum = 0; lineNum < ONSCREEN_FILES_COUNT && !endOfStr; ++lineNum) { int width = 0; const char *lineStartP = msgP; -- cgit v1.2.3 From 46e85f389f4fb9f3d956c42e77345f79701d7a93 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 May 2015 21:15:33 -0400 Subject: SHERLOCK: Go to save mode when clicking empty save slot --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 4781f4811b..524ecf3d2f 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -946,7 +946,7 @@ void UserInterface::doEnvControl() { // Are we already in Load mode? if (saves._envMode == SAVEMODE_LOAD) { saves.loadGame(_selector + 1); - } else if (saves._envMode == SAVEMODE_SAVE || _selector == MAX_SAVEGAME_SLOTS) { + } else if (saves._envMode == SAVEMODE_SAVE || saves.isSlotEmpty(_selector)) { // We're already in save mode, or pointing to an empty save slot if (saves.checkGameOnScreen(_selector)) _oldSelector = _selector; -- cgit v1.2.3 From ef4d8be853cf681f3c58db6daec78209982e5f5a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 May 2015 23:15:33 -0400 Subject: SHERLOCK: Fix display of first RT scene background --- engines/sherlock/user_interface.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 7a6722a218..4f83e9151a 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2304,6 +2304,7 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm) void TattooUserInterface::handleInput() { // TODO + _vm->_events->pollEventsAndWait(); } } // End of namespace Sherlock -- cgit v1.2.3 From 0d4163c6e932bed2b85843f6ab3b5066d0353df6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 May 2015 20:26:40 -0400 Subject: SHERLOCK: Implemented initial background clearing of RT doBgAnim --- engines/sherlock/user_interface.cpp | 53 ++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 4f83e9151a..06ec62b6a2 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -82,9 +82,9 @@ const char *const MUSE[] = { UserInterface *UserInterface::init(SherlockEngine *vm) { if (vm->getGameID() == GType_SerratedScalpel) - return new ScalpelUserInterface(vm); + return new Scalpel::ScalpelUserInterface(vm); else - return new TattooUserInterface(vm); + return new Tattoo::TattooUserInterface(vm); } UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { @@ -108,6 +108,8 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { /*----------------------------------------------------------------*/ +namespace Scalpel { + ScalpelUserInterface::ScalpelUserInterface(SherlockEngine *vm): UserInterface(vm) { _controls = new ImageFile("menu.all"); _controlPanel = new ImageFile("controls.vgs"); @@ -2296,10 +2298,15 @@ void ScalpelUserInterface::checkAction(ActionType &action, const char *const mes events.setCursor(ARROW); } +} + /*----------------------------------------------------------------*/ +namespace Tattoo { + TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm) { - // + _menuBuffer = nullptr; + _invMenuBuffer = nullptr; } void TattooUserInterface::handleInput() { @@ -2307,4 +2314,44 @@ void TattooUserInterface::handleInput() { _vm->_events->pollEventsAndWait(); } +void TattooUserInterface::doBgAnimRestoreUI() { + TattooScene &scene = *((TattooScene *)_vm->_scene); + Screen &screen = *_vm->_screen; + + // If _oldMenuBounds was set, then either a new menu has been opened or the current menu has been closed. + // Either way, we need to restore the area where the menu was displayed + if (_oldMenuBounds.width() > 0) + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldMenuBounds.left, _oldMenuBounds.top), + _oldMenuBounds); + + if (_oldInvMenuBounds.width() > 0) + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldInvMenuBounds.left, _oldInvMenuBounds.top), + _oldInvMenuBounds); + + if (_menuBuffer != nullptr) + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_menuBounds.left, _menuBounds.top), _menuBounds); + if (_invMenuBuffer != nullptr) + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_invMenuBounds.left, _invMenuBounds.top), _invMenuBounds); + + // If there is a Text Tag being display, restore the area underneath it + if (_oldTagBounds.width() > 0) + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldTagBounds.left, _oldTagBounds.top), + _oldTagBounds); + + // If there is an Inventory being shown, restore the graphics underneath it + if (_oldInvGraphicBounds.width() > 0) + screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldInvGraphicBounds.left, _oldInvGraphicBounds.top), + _oldInvGraphicBounds); + + // If a canimation is active, restore the graphics underneath it + if (scene._activeCAnim._images != nullptr) + screen.restoreBackground(scene._activeCAnim._oldBounds); + + // If a canimation just ended, remove it's graphics from the backbuffer + if (scene._activeCAnim._removeBounds.width() > 0) + screen.restoreBackground(scene._activeCAnim._removeBounds); +} + +} // End of namespace Tattoo + } // End of namespace Sherlock -- cgit v1.2.3 From 45b4989b55a043a9d2f1806db375d9f91476ed89 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 May 2015 22:36:51 -0400 Subject: SHERLOCK: Implement RT scrolling code --- engines/sherlock/user_interface.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 06ec62b6a2..5858daffc5 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -2352,6 +2352,31 @@ void TattooUserInterface::doBgAnimRestoreUI() { screen.restoreBackground(scene._activeCAnim._removeBounds); } +void TattooUserInterface::doScroll() { + Screen &screen = *_vm->_screen; + int oldScroll = screen._currentScroll; + + // If we're already at the target scroll position, nothing needs to be done + if (screen._targetScroll == screen._currentScroll) + return; + + screen._flushScreen = true; + if (screen._targetScroll > screen._currentScroll) { + screen._currentScroll += screen._scrollSpeed; + if (screen._currentScroll > screen._targetScroll) + screen._currentScroll = screen._targetScroll; + } else if (screen._targetScroll < screen._currentScroll) { + screen._currentScroll -= screen._scrollSpeed; + if (screen._currentScroll < screen._targetScroll) + screen._currentScroll = screen._targetScroll; + } + + if (_menuBuffer != nullptr) + _menuBounds.translate(screen._currentScroll - oldScroll, 0); + if (_invMenuBuffer != nullptr) + _invMenuBounds.translate(screen._currentScroll - oldScroll, 0); +} + } // End of namespace Tattoo } // End of namespace Sherlock -- cgit v1.2.3 From f4902b516ec8486338b777354809171112671e5b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 May 2015 08:31:53 -0400 Subject: SHERLOCK: Moving split up classes into their own files --- engines/sherlock/user_interface.cpp | 2330 +---------------------------------- 1 file changed, 2 insertions(+), 2328 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 5858daffc5..9fff7cc999 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -22,64 +22,11 @@ #include "sherlock/user_interface.h" #include "sherlock/sherlock.h" -#include "sherlock/settings.h" +#include "sherlock/scalpel/scalpel_user_interface.h" +#include "sherlock/tattoo/tattoo_user_interface.h" namespace Sherlock { -// Main user interface menu control locations -const int MENU_POINTS[12][4] = { - { 13, 153, 72, 165 }, - { 13, 169, 72, 181 }, - { 13, 185, 72, 197 }, - { 88, 153, 152, 165 }, - { 88, 169, 152, 181 }, - { 88, 185, 152, 197 }, - { 165, 153, 232, 165 }, - { 165, 169, 232, 181 }, - { 165, 185, 233, 197 }, - { 249, 153, 305, 165 }, - { 249, 169, 305, 181 }, - { 249, 185, 305, 197 } -}; - -// Inventory control locations */ -const int INVENTORY_POINTS[8][3] = { - { 4, 50, 29 }, - { 52, 99, 77 }, - { 101, 140, 123 }, - { 142, 187, 166 }, - { 189, 219, 198 }, - { 221, 251, 234 }, - { 253, 283, 266 }, - { 285, 315, 294 } -}; - -const char COMMANDS[13] = "LMTPOCIUGJFS"; -const char INVENTORY_COMMANDS[9] = { "ELUG-+,." }; -const char *const PRESS_KEY_FOR_MORE = "Press any Key for More."; -const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue."; - -const char *const MOPEN[] = { - "This cannot be opened", "It is already open", "It is locked", "Wait for Watson", " ", "." -}; -const char *const MCLOSE[] = { - "This cannot be closed", "It is already closed", "The safe door is in the way" -}; -const char *const MMOVE[] = { - "This cannot be moved", "It is bolted to the floor", "It is too heavy", "The other crate is in the way" -}; -const char *const MPICK[] = { - "Nothing of interest here", "It is bolted down", "It is too big to carry", "It is too heavy", - "I think a girl would be more your type", "Those flowers belong to Penny", "She's far too young for you!", - "I think a girl would be more your type!", "Government property for official use only" -}; -const char *const MUSE[] = { - "You can't do that", "It had no effect", "You can't reach it", "OK, the door looks bigger! Happy?", - "Doors don't smoke" -}; - - - UserInterface *UserInterface::init(SherlockEngine *vm) { if (vm->getGameID() == GType_SerratedScalpel) return new Scalpel::ScalpelUserInterface(vm); @@ -106,2277 +53,4 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _lookHelp = 0; } -/*----------------------------------------------------------------*/ - -namespace Scalpel { - -ScalpelUserInterface::ScalpelUserInterface(SherlockEngine *vm): UserInterface(vm) { - _controls = new ImageFile("menu.all"); - _controlPanel = new ImageFile("controls.vgs"); - _keyPress = '\0'; - _lookHelp = 0; - _bgFound = 0; - _oldBgFound = -1; - _help = _oldHelp = 0; - _key = _oldKey = '\0'; - _temp = _oldTemp = 0; - _oldLook = 0; - _keyboardInput = false; - _pause = false; - _cNum = 0; - _find = 0; - _oldUse = 0; -} - -ScalpelUserInterface::~ScalpelUserInterface() { - delete _controls; - delete _controlPanel; -} - -void ScalpelUserInterface::reset() { - _oldKey = -1; - _help = _oldHelp = -1; - _oldTemp = _temp = -1; -} - -void ScalpelUserInterface::drawInterface(int bufferNum) { - Screen &screen = *_vm->_screen; - - if (bufferNum & 1) - screen._backBuffer1.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); - if (bufferNum & 2) - screen._backBuffer2.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y)); - if (bufferNum == 3) - screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK); -} - -void ScalpelUserInterface::handleInput() { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - People &people = *_vm->_people; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Talk &talk = *_vm->_talk; - - if (_menuCounter) - whileMenuCounter(); - - Common::Point pt = events.mousePos(); - _bgFound = scene.findBgShape(Common::Rect(pt.x, pt.y, pt.x + 1, pt.y + 1)); - _keyPress = '\0'; - - // Check kbd and set the mouse released flag if Enter or space is pressed. - // Otherwise, the pressed _key is stored for later use - if (events.kbHit()) { - Common::KeyState keyState = events.getKey(); - _keyPress = keyState.ascii; - - if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) { - _vm->quitGame(); - events.pollEvents(); - return; - } - } - - // Do button highlighting check - if (!talk._scriptMoreFlag) { // Don't if scripts are running - if (((events._rightPressed || events._rightReleased) && _helpStyle) || - (!_helpStyle && !_menuCounter)) { - // Handle any default commands if we're in STD_MODE - if (_menuMode == STD_MODE) { - if (pt.y < CONTROLS_Y && - (events._rightPressed || (!_helpStyle && !events._released)) && - (_bgFound != -1) && (_bgFound < 1000) && - (scene._bgShapes[_bgFound]._defaultCommand || - !scene._bgShapes[_bgFound]._description.empty())) { - // If there is no default command, so set it to Look - if (scene._bgShapes[_bgFound]._defaultCommand) - _help = scene._bgShapes[_bgFound]._defaultCommand - 1; - else - _help = 0; - - // Reset 'help' if it is an invalid command - if (_help > 5) - _help = -1; - } else if (pt.y < CONTROLS_Y && - ((events._rightReleased && _helpStyle) || (events._released && !_helpStyle)) && - (_bgFound != -1 && _bgFound < 1000) && - (scene._bgShapes[_bgFound]._defaultCommand || - !scene._bgShapes[_bgFound]._description.empty())) { - // If there is no default command, set it to Look - if (scene._bgShapes[_bgFound]._defaultCommand) - _menuMode = (MenuMode)scene._bgShapes[_bgFound]._defaultCommand; - else - _menuMode = LOOK_MODE; - events._released = true; - events._pressed = events._oldButtons = false; - _help = _oldHelp = -1; - - if (_menuMode == LOOK_MODE) { - // Set the flag to tell the game that this was a right-click - // call to look and should exit without the look button being pressed - _lookHelp = true; - } - } else { - _help = -1; - } - - // Check if highlighting a different button than last time - if (_help != _oldHelp) { - // If another button was highlighted previously, restore it - if (_oldHelp != -1) - restoreButton(_oldHelp); - - // If we're highlighting a new button, then draw it pressed - if (_help != -1) - depressButton(_help); - - _oldHelp = _help; - } - - if (_bgFound != _oldBgFound || _oldBgFound == -1) { - _infoFlag = true; - clearInfo(); - - if (_help != -1 && !scene._bgShapes[_bgFound]._description.empty() - && scene._bgShapes[_bgFound]._description[0] != ' ') - screen.print(Common::Point(0, INFO_LINE + 1), - INFO_FOREGROUND, "%s", scene._bgShapes[_bgFound]._description.c_str()); - - _oldBgFound = _bgFound; - } - } else { - // We're not in STD_MODE - // If there isn't a window open, then revert back to STD_MODE - if (!_windowOpen && events._rightReleased) { - // Restore all buttons - for (int idx = 0; idx < 12; ++idx) - restoreButton(idx); - - _menuMode = STD_MODE; - _key = _oldKey = -1; - _temp = _oldTemp = _lookHelp = _invLookFlag = 0; - events.clearEvents(); - } - } - } - } - - // Reset the old bgshape number if the mouse button is released, so that - // it can e re-highlighted when we come back here - if ((events._rightReleased && _helpStyle) || (events._released && !_helpStyle)) - _oldBgFound = -1; - - // Do routines that should be done before input processing - switch (_menuMode) { - case LOOK_MODE: - if (!_windowOpen) { - if (events._released && _bgFound >= 0 && _bgFound < 1000) { - if (!scene._bgShapes[_bgFound]._examine.empty()) - examine(); - } else { - lookScreen(pt); - } - } - break; - - case MOVE_MODE: - case OPEN_MODE: - case CLOSE_MODE: - case PICKUP_MODE: - lookScreen(pt); - break; - - case TALK_MODE: - if (!_windowOpen) { - bool personFound; - - if (_bgFound >= 1000) { - personFound = false; - if (!events._released) - lookScreen(pt); - } else { - personFound = _bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON; - } - - if (events._released && personFound) - talk.talk(_bgFound); - else if (personFound) - lookScreen(pt); - else if (_bgFound < 1000) - clearInfo(); - } - break; - - case USE_MODE: - case GIVE_MODE: - case INV_MODE: - if (inv._invMode == INVMODE_LOOK || inv._invMode == INVMODE_USE || inv._invMode == INVMODE_GIVE) { - if (pt.y > CONTROLS_Y) - lookInv(); - else - lookScreen(pt); - } - break; - - default: - break; - } - - // - // Do input processing - // - if (events._pressed || events._released || events._rightPressed || _keyPress || _pause) { - if (((events._released && (_helpStyle || _help == -1)) || (events._rightReleased && !_helpStyle)) && - (pt.y <= CONTROLS_Y) && (_menuMode == STD_MODE)) { - // The mouse was clicked in the playing area with no action buttons down. - // Check if the mouse was clicked in a script zone. If it was, - // then execute the script. Otherwise, walk to the given position - if (scene.checkForZones(pt, SCRIPT_ZONE) != 0 || - scene.checkForZones(pt, NOWALK_ZONE) != 0) { - // Mouse clicked in script zone - events._pressed = events._released = false; - } else { - people._walkDest = pt; - people._allowWalkAbort = false; - people.goAllTheWay(); - } - - if (_oldKey != -1) { - restoreButton(_oldTemp); - _oldKey = -1; - } - } - - // Handle action depending on selected mode - switch (_menuMode) { - case LOOK_MODE: - if (_windowOpen) - doLookControl(); - break; - - case MOVE_MODE: - doMiscControl(ALLOW_MOVE); - break; - - case TALK_MODE: - if (_windowOpen) - doTalkControl(); - break; - - case OPEN_MODE: - doMiscControl(ALLOW_OPEN); - break; - - case CLOSE_MODE: - doMiscControl(ALLOW_CLOSE); - break; - - case PICKUP_MODE: - doPickControl(); - break; - - case USE_MODE: - case GIVE_MODE: - case INV_MODE: - doInvControl(); - break; - - case FILES_MODE: - doEnvControl(); - break; - - default: - break; - } - - // As long as there isn't an open window, do main input processing. - // Windows are opened when in TALK, USE, INV, and GIVE modes - if ((!_windowOpen && !_menuCounter && pt.y > CONTROLS_Y) || - _keyPress) { - if (events._pressed || events._released || _pause || _keyPress) - doMainControl(); - } - - if (pt.y < CONTROLS_Y && events._pressed && _oldTemp != (int)(_menuMode - 1) && _oldKey != -1) - restoreButton(_oldTemp); - } -} - -void ScalpelUserInterface::depressButton(int num) { - Screen &screen = *_vm->_screen; - Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); - - ImageFrame &frame = (*_controls)[num]; - screen._backBuffer1.transBlitFrom(frame, pt); - screen.slamArea(pt.x, pt.y, pt.x + frame._width, pt.y + frame._height); -} - -void ScalpelUserInterface::restoreButton(int num) { - Screen &screen = *_vm->_screen; - Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); - Graphics::Surface &frame = (*_controls)[num]._frame; - - screen._backBuffer1.blitFrom(screen._backBuffer2, pt, - Common::Rect(pt.x, pt.y, pt.x + 90, pt.y + 19)); - screen.slamArea(pt.x, pt.y, pt.x + frame.w, pt.y + frame.h); - - if (!_menuCounter) { - _infoFlag = true; - clearInfo(); - } -} - -void ScalpelUserInterface::pushButton(int num) { - Events &events = *_vm->_events; - _oldKey = -1; - - if (!events._released) { - if (_oldHelp != -1) - restoreButton(_oldHelp); - if (_help != -1) - restoreButton(_help); - - depressButton(num); - events.wait(6); - } - - restoreButton(num); -} - -void ScalpelUserInterface::toggleButton(int num) { - Screen &screen = *_vm->_screen; - - if (_menuMode != (MenuMode)(num + 1)) { - _menuMode = (MenuMode)(num + 1); - _oldKey = COMMANDS[num]; - _oldTemp = num; - - if (_keyboardInput) { - if (_oldHelp != -1 && _oldHelp != num) - restoreButton(_oldHelp); - if (_help != -1 && _help != num) - restoreButton(_help); - - _keyboardInput = false; - - ImageFrame &frame = (*_controls)[num]; - Common::Point pt(MENU_POINTS[num][0], MENU_POINTS[num][1]); - screen._backBuffer1.transBlitFrom(frame, pt); - screen.slamArea(pt.x, pt.y, pt.x + frame._width, pt.y + frame._height); - } - } else { - _menuMode = STD_MODE; - _oldKey = -1; - restoreButton(num); - } -} - -void ScalpelUserInterface::clearInfo() { - if (_infoFlag) { - _vm->_screen->vgaBar(Common::Rect(16, INFO_LINE, SHERLOCK_SCREEN_WIDTH - 19, - INFO_LINE + 10), INFO_BLACK); - _infoFlag = false; - _oldLook = -1; - } -} - -void ScalpelUserInterface::clearWindow() { - if (_windowOpen) { - _vm->_screen->vgaBar(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, - SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); - } -} - -void ScalpelUserInterface::whileMenuCounter() { - if (!(--_menuCounter) || _vm->_events->checkInput()) { - _menuCounter = 0; - _infoFlag = true; - clearInfo(); - } -} - -void ScalpelUserInterface::examine() { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - People &people = *_vm->_people; - Scene &scene = *_vm->_scene; - Talk &talk = *_vm->_talk; - Common::Point pt = events.mousePos(); - - if (pt.y < (CONTROLS_Y + 9)) { - Object &obj = scene._bgShapes[_bgFound]; - - if (obj._lookcAnim != 0) { - int canimSpeed = ((obj._lookcAnim & 0xe0) >> 5) + 1; - scene._cAnimFramePause = obj._lookFrames; - _cAnimStr = obj._examine; - _cNum = (obj._lookcAnim & 0x1f) - 1; - - scene.startCAnim(_cNum, canimSpeed); - } else if (obj._lookPosition.y != 0) { - // Need to walk to the object to be examined - people.walkToCoords(Common::Point(obj._lookPosition.x, obj._lookPosition.y * 100), obj._lookFacing); - } - - if (!talk._talkToAbort) { - _cAnimStr = obj._examine; - if (obj._lookFlag) - _vm->setFlags(obj._lookFlag); - } - } else { - // Looking at an inventory item - _cAnimStr = inv[_selector]._examine; - if (inv[_selector]._lookFlag) - _vm->setFlags(inv[_selector]._lookFlag); - } - - if (_invLookFlag) { - // Don't close the inventory window when starting an examine display, since its - // window will slide up to replace the inventory display - _windowOpen = false; - _menuMode = LOOK_MODE; - } - - if (!talk._talkToAbort) { - if (!scene._cAnimFramePause) - printObjectDesc(_cAnimStr, true); - else - // description was already printed in startCAnimation - scene._cAnimFramePause = 0; - } -} - -void ScalpelUserInterface::lookScreen(const Common::Point &pt) { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Common::Point mousePos = events.mousePos(); - int temp; - Common::String tempStr; - - // Don't display anything for right button command - if ((events._rightPressed || events._rightPressed) && !events._pressed) - return; - - if (mousePos.y < CONTROLS_Y && (temp = _bgFound) != -1) { - if (temp != _oldLook) { - _infoFlag = true; - clearInfo(); - - if (temp < 1000) - tempStr = scene._bgShapes[temp]._description; - else - tempStr = scene._bgShapes[temp - 1000]._description; - - _infoFlag = true; - clearInfo(); - - // Only print description if there is one - if (!tempStr.empty() && tempStr[0] != ' ') { - // If inventory is active and an item is selected for a Use or Give action - if ((_menuMode == INV_MODE || _menuMode == USE_MODE || _menuMode == GIVE_MODE) && - (inv._invMode == INVMODE_USE || inv._invMode == INVMODE_GIVE)) { - int width1 = 0, width2 = 0; - int x, width; - if (inv._invMode == INVMODE_USE) { - // Using an object - x = width = screen.stringWidth("Use "); - - if (temp < 1000 && scene._bgShapes[temp]._aType != PERSON) - // It's not a person, so make it lowercase - tempStr.setChar(tolower(tempStr[0]), 0); - - x += screen.stringWidth(tempStr); - - // If we're using an inventory object, add in the width - // of the object name and the " on " - if (_selector != -1) { - width1 = screen.stringWidth(inv[_selector]._name); - x += width1; - width2 = screen.stringWidth(" on "); - x += width2; - } - - // If the line will be too long, keep cutting off characters - // until the string will fit - while (x > 280) { - x -= screen.charWidth(tempStr.lastChar()); - tempStr.deleteLastChar(); - } - - int xStart = (SHERLOCK_SCREEN_WIDTH - x) / 2; - screen.print(Common::Point(xStart, INFO_LINE + 1), - INFO_FOREGROUND, "Use "); - - if (_selector != -1) { - screen.print(Common::Point(xStart + width, INFO_LINE + 1), - TALK_FOREGROUND, "%s", inv[_selector]._name.c_str()); - screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), - INFO_FOREGROUND, " on "); - screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), - INFO_FOREGROUND, "%s", tempStr.c_str()); - } else { - screen.print(Common::Point(xStart + width, INFO_LINE + 1), - INFO_FOREGROUND, "%s", tempStr.c_str()); - } - } else if (temp >= 0 && temp < 1000 && _selector != -1 && - scene._bgShapes[temp]._aType == PERSON) { - // Giving an object to a person - width1 = screen.stringWidth(inv[_selector]._name); - x = width = screen.stringWidth("Give "); - x += width1; - width2 = screen.stringWidth(" to "); - x += width2; - x += screen.stringWidth(tempStr); - - // Ensure string will fit on-screen - while (x > 280) { - x -= screen.charWidth(tempStr.lastChar()); - tempStr.deleteLastChar(); - } - - int xStart = (SHERLOCK_SCREEN_WIDTH - x) / 2; - screen.print(Common::Point(xStart, INFO_LINE + 1), - INFO_FOREGROUND, "Give "); - screen.print(Common::Point(xStart + width, INFO_LINE + 1), - TALK_FOREGROUND, "%s", inv[_selector]._name.c_str()); - screen.print(Common::Point(xStart + width + width1, INFO_LINE + 1), - INFO_FOREGROUND, " to "); - screen.print(Common::Point(xStart + width + width1 + width2, INFO_LINE + 1), - INFO_FOREGROUND, "%s", tempStr.c_str()); - } - } else { - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", tempStr.c_str()); - } - - _infoFlag = true; - _oldLook = temp; - } - } - } else { - clearInfo(); - } -} - -void ScalpelUserInterface::lookInv() { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - Screen &screen = *_vm->_screen; - Common::Point mousePos = events.mousePos(); - - if (mousePos.x > 15 && mousePos.x < 314 && mousePos.y > (CONTROLS_Y1 + 11) - && mousePos.y < (SHERLOCK_SCREEN_HEIGHT - 2)) { - int temp = (mousePos.x - 6) / 52 + inv._invIndex; - if (temp < inv._holdings) { - if (temp < inv._holdings) { - clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, - "%s", inv[temp]._description.c_str()); - _infoFlag = true; - _oldLook = temp; - } - } else { - clearInfo(); - } - } else { - clearInfo(); - } -} - -void ScalpelUserInterface::doEnvControl() { - Events &events = *_vm->_events; - SaveManager &saves = *_vm->_saves; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Talk &talk = *_vm->_talk; - Common::Point mousePos = events.mousePos(); - static const char ENV_COMMANDS[7] = "ELSUDQ"; - - byte color; - - _key = _oldKey = -1; - _keyboardInput = false; - int found = saves.getHighlightedButton(); - - if (events._pressed || events._released) { - events.clearKeyboard(); - - // Check for a filename entry being highlighted - if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10)) { - int found1 = 0; - for (_selector = 0; (_selector < ONSCREEN_FILES_COUNT) && !found1; ++_selector) - if (mousePos.y > (CONTROLS_Y + 11 + _selector * 10) && mousePos.y < (CONTROLS_Y + 21 + _selector * 10)) - found1 = 1; - - if (_selector + saves._savegameIndex - 1 < MAX_SAVEGAME_SLOTS + (saves._envMode != SAVEMODE_LOAD)) - _selector = _selector + saves._savegameIndex - 1; - else - _selector = -1; - - if (!found1) - _selector = -1; - } - - // Handle selecting buttons, if any - saves.highlightButtons(found); - - if (found == 0 || found == 5) - saves._envMode = SAVEMODE_NONE; - } - - if (_keyPress) { - _key = toupper(_keyPress); - - // Escape _key will close the dialog - if (_key == Common::KEYCODE_ESCAPE) - _key = 'E'; - - if (_key == 'E' || _key == 'L' || _key == 'S' || _key == 'U' || _key == 'D' || _key == 'Q') { - const char *chP = strchr(ENV_COMMANDS, _key); - int btnIndex = !chP ? -1 : chP - ENV_COMMANDS; - saves.highlightButtons(btnIndex); - _keyboardInput = true; - - if (_key == 'E' || _key == 'Q') { - saves._envMode = SAVEMODE_NONE; - } else if (_key >= '1' && _key <= '9') { - _keyboardInput = true; - _selector = _key - '1'; - if (_selector >= MAX_SAVEGAME_SLOTS + (saves._envMode == SAVEMODE_LOAD ? 0 : 1)) - _selector = -1; - - if (saves.checkGameOnScreen(_selector)) - _oldSelector = _selector; - } else { - _selector = -1; - } - } - } - - if (_selector != _oldSelector) { - if (_oldSelector != -1 && _oldSelector >= saves._savegameIndex && _oldSelector < (saves._savegameIndex + ONSCREEN_FILES_COUNT)) { - screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, "%d.", _oldSelector + 1); - screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, "%s", saves._savegames[_oldSelector].c_str()); - } - - if (_selector != -1) { - screen.print(Common::Point(6, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), - TALK_FOREGROUND, "%d.", _selector + 1); - screen.print(Common::Point(24, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), - TALK_FOREGROUND, "%s", saves._savegames[_selector].c_str()); - } - - _oldSelector = _selector; - } - - if (events._released || _keyboardInput) { - if ((found == 0 && events._released) || _key == 'E') { - banishWindow(); - _windowBounds.top = CONTROLS_Y1; - - events._pressed = events._released = _keyboardInput = false; - _keyPress = '\0'; - } else if ((found == 1 && events._released) || _key == 'L') { - saves._envMode = SAVEMODE_LOAD; - if (_selector != -1) { - saves.loadGame(_selector + 1); - } - } else if ((found == 2 && events._released) || _key == 'S') { - saves._envMode = SAVEMODE_SAVE; - if (_selector != -1) { - if (saves.checkGameOnScreen(_selector)) - _oldSelector = _selector; - - if (saves.promptForDescription(_selector)) { - saves.saveGame(_selector + 1, saves._savegames[_selector]); - - banishWindow(1); - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = -1; - _keyPress = '\0'; - _keyboardInput = false; - } else { - if (!talk._talkToAbort) { - screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, - SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); - screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, - "%d.", _selector + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, - "%s", saves._savegames[_selector].c_str()); - - screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); - _selector = _oldSelector = -1; - } - } - } - } else if (((found == 3 && events._released) || _key == 'U') && saves._savegameIndex) { - bool moreKeys; - do { - saves._savegameIndex--; - screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, - SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); - - for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT); ++idx) { - color = INV_FOREGROUND; - if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT)) - color = TALK_FOREGROUND; - - screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%s", saves._savegames[idx].c_str()); - } - - screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); - - color = !saves._savegameIndex ? COMMAND_NULL : COMMAND_FOREGROUND; - screen.buttonPrint(Common::Point(ENV_POINTS[3][2], CONTROLS_Y), color, true, "Up"); - color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) ? COMMAND_NULL : COMMAND_FOREGROUND; - screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); - - // Check whether there are more pending U keys pressed - moreKeys = false; - if (events.kbHit()) { - Common::KeyState keyState = events.getKey(); - - _key = toupper(keyState.keycode); - moreKeys = _key == 'U'; - } - } while ((saves._savegameIndex) && moreKeys); - } else if (((found == 4 && events._released) || _key == 'D') && saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT)) { - bool moreKeys; - do { - saves._savegameIndex++; - screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, - SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); - - for (int idx = saves._savegameIndex; idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT); ++idx) { - if (idx == _selector && idx >= saves._savegameIndex && idx < (saves._savegameIndex + ONSCREEN_FILES_COUNT)) - color = TALK_FOREGROUND; - else - color = INV_FOREGROUND; - - screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, - "%d.", idx + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, - "%s", saves._savegames[idx].c_str()); - } - - screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); - - color = (!saves._savegameIndex) ? COMMAND_NULL : COMMAND_FOREGROUND; - screen.buttonPrint(Common::Point(ENV_POINTS[3][2], CONTROLS_Y), color, true, "Up"); - - color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) ? COMMAND_NULL : COMMAND_FOREGROUND; - screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, "Down"); - - // Check whether there are more pending D keys pressed - moreKeys = false; - if (events.kbHit()) { - Common::KeyState keyState; - _key = toupper(keyState.keycode); - - moreKeys = _key == 'D'; - } - } while (saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) && moreKeys); - } else if ((found == 5 && events._released) || _key == 'Q') { - clearWindow(); - screen.print(Common::Point(0, CONTROLS_Y + 20), INV_FOREGROUND, "Are you sure you wish to Quit ?"); - screen.vgaBar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + 10), BORDER_COLOR); - - screen.makeButton(Common::Rect(112, CONTROLS_Y, 160, CONTROLS_Y + 10), 136 - screen.stringWidth("Yes") / 2, "Yes"); - screen.makeButton(Common::Rect(161, CONTROLS_Y, 209, CONTROLS_Y + 10), 184 - screen.stringWidth("No") / 2, "No"); - screen.slamArea(112, CONTROLS_Y, 97, 10); - - do { - scene.doBgAnim(); - - if (talk._talkToAbort) - return; - - events.pollEventsAndWait(); - events.setButtonState(); - mousePos = events.mousePos(); - - if (events.kbHit()) { - Common::KeyState keyState = events.getKey(); - _key = toupper(keyState.keycode); - - if (_key == 'X' && (keyState.flags & Common::KBD_ALT) != 0) { - _vm->quitGame(); - events.pollEvents(); - return; - } - - if (_key == Common::KEYCODE_ESCAPE) - _key = 'N'; - - if (_key == Common::KEYCODE_RETURN || _key == ' ') { - events._pressed = false; - events._released = true; - events._oldButtons = 0; - _keyPress = '\0'; - } - } - - if (events._pressed || events._released) { - if (mousePos.x > 112 && mousePos.x < 159 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9)) - color = COMMAND_HIGHLIGHTED; - else - color = COMMAND_FOREGROUND; - screen.buttonPrint(Common::Point(136, CONTROLS_Y), color, true, "Yes"); - - if (mousePos.x > 161 && mousePos.x < 208 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9)) - color = COMMAND_HIGHLIGHTED; - else - color = COMMAND_FOREGROUND; - screen.buttonPrint(Common::Point(184, CONTROLS_Y), color, true, "No"); - } - - if (mousePos.x > 112 && mousePos.x < 159 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9) && events._released) - _key = 'Y'; - - if (mousePos.x > 161 && mousePos.x < 208 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9) && events._released) - _key = 'N'; - } while (!_vm->shouldQuit() && _key != 'Y' && _key != 'N'); - - if (_key == 'Y') { - _vm->quitGame(); - events.pollEvents(); - return; - } else { - screen.buttonPrint(Common::Point(184, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, "No"); - banishWindow(1); - _windowBounds.top = CONTROLS_Y1; - _key = -1; - } - } else { - if (_selector != -1) { - // Are we already in Load mode? - if (saves._envMode == SAVEMODE_LOAD) { - saves.loadGame(_selector + 1); - } else if (saves._envMode == SAVEMODE_SAVE || saves.isSlotEmpty(_selector)) { - // We're already in save mode, or pointing to an empty save slot - if (saves.checkGameOnScreen(_selector)) - _oldSelector = _selector; - - if (saves.promptForDescription(_selector)) { - saves.saveGame(_selector + 1, saves._savegames[_selector]); - banishWindow(); - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = -1; - _keyPress = '\0'; - _keyboardInput = false; - } else { - if (!talk._talkToAbort) { - screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, - 317, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); - screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), - INV_FOREGROUND, "%d.", _selector + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), - INV_FOREGROUND, "%s", saves._savegames[_selector].c_str()); - screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); - _selector = _oldSelector = -1; - } - } - } - } - } - } -} - -void ScalpelUserInterface::doInvControl() { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Talk &talk = *_vm->_talk; - int colors[8]; - Common::Point mousePos = events.mousePos(); - - _key = _oldKey = -1; - _keyboardInput = false; - - // Check whether any inventory slot is highlighted - int found = -1; - Common::fill(&colors[0], &colors[8], (int)COMMAND_FOREGROUND); - for (int idx = 0; idx < 8; ++idx) { - Common::Rect r(INVENTORY_POINTS[idx][0], CONTROLS_Y1, - INVENTORY_POINTS[idx][1], CONTROLS_Y1 + 10); - if (r.contains(mousePos)) { - found = idx; - break; - } - } - - if (events._pressed || events._released) { - events.clearKeyboard(); - - 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, "Exit"); - - if (found >= 0 && found <= 3) { - screen.buttonPrint(Common::Point(INVENTORY_POINTS[1][2], CONTROLS_Y1), colors[1], true, "Look"); - screen.buttonPrint(Common::Point(INVENTORY_POINTS[2][2], CONTROLS_Y1), colors[2], true, "Use"); - screen.buttonPrint(Common::Point(INVENTORY_POINTS[3][2], CONTROLS_Y1), colors[3], true, "Give"); - inv._invMode = (InvMode)found; - _selector = -1; - } - - if (inv._invIndex) { - screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), colors[4], "^^"); - screen.print(Common::Point(INVENTORY_POINTS[5][2], CONTROLS_Y1 + 1), colors[5], "^"); - } - - if ((inv._holdings - inv._invIndex) > 6) { - screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), colors[6], "_"); - screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), colors[7], "__"); - } - - bool flag = false; - if (inv._invMode == INVMODE_LOOK || inv._invMode == INVMODE_USE || inv._invMode == INVMODE_GIVE) { - Common::Rect r(15, CONTROLS_Y1 + 11, 314, SHERLOCK_SCREEN_HEIGHT - 2); - if (r.contains(mousePos)) { - _selector = (mousePos.x - 6) / 52 + inv._invIndex; - if (_selector < inv._holdings) - flag = true; - } - } - - if (!flag && mousePos.y >(CONTROLS_Y1 + 11)) - _selector = -1; - } - - if (_keyPress) { - _key = toupper(_keyPress); - - if (_key == Common::KEYCODE_ESCAPE) - // Escape will also 'E'xit out of inventory display - _key = 'E'; - - if (_key == 'E' || _key == 'L' || _key == 'U' || _key == 'G' - || _key == '-' || _key == '+') { - InvMode temp = inv._invMode; - - const char *chP = strchr(INVENTORY_COMMANDS, _key); - inv._invMode = !chP ? INVMODE_INVALID : (InvMode)(chP - INVENTORY_COMMANDS); - inv.invCommands(true); - - inv._invMode = temp; - _keyboardInput = true; - if (_key == 'E') - inv._invMode = INVMODE_EXIT; - _selector = -1; - } else { - _selector = -1; - } - } - - if (_selector != _oldSelector) { - if (_oldSelector != -1) { - // Un-highlight - if (_oldSelector >= inv._invIndex && _oldSelector < (inv._invIndex + 6)) - inv.highlight(_oldSelector, BUTTON_MIDDLE); - } - - if (_selector != -1) - inv.highlight(_selector, 235); - - _oldSelector = _selector; - } - - if (events._released || _keyboardInput) { - if ((found == 0 && events._released) || _key == 'E') { - inv.freeInv(); - _infoFlag = true; - clearInfo(); - banishWindow(false); - _key = -1; - events.clearEvents(); - events.setCursor(ARROW); - } else if ((found == 1 && events._released) || (_key == 'L')) { - inv._invMode = INVMODE_LOOK; - } else if ((found == 2 && events._released) || (_key == 'U')) { - inv._invMode = INVMODE_USE; - } else if ((found == 3 && events._released) || (_key == 'G')) { - inv._invMode = INVMODE_GIVE; - } else if (((found == 4 && events._released) || _key == ',') && inv._invIndex) { - if (inv._invIndex >= 6) - inv._invIndex -= 6; - else - inv._invIndex = 0; - - screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), - COMMAND_HIGHLIGHTED, "^^"); - inv.freeGraphics(); - inv.loadGraphics(); - inv.putInv(SLAM_DISPLAY); - inv.invCommands(true); - } else if (((found == 5 && events._released) || _key == '-') && inv._invIndex > 0) { - --inv._invIndex; - screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "^"); - inv.freeGraphics(); - inv.loadGraphics(); - inv.putInv(SLAM_DISPLAY); - inv.invCommands(true); - } else if (((found == 6 && events._released) || _key == '+') && (inv._holdings - inv._invIndex) > 6) { - ++inv._invIndex; - screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); - inv.freeGraphics(); - inv.loadGraphics(); - inv.putInv(SLAM_DISPLAY); - inv.invCommands(true); - } else if (((found == 7 && events._released) || _key == '.') && (inv._holdings - inv._invIndex) > 6) { - inv._invIndex += 6; - if ((inv._holdings - 6) < inv._invIndex) - inv._invIndex = inv._holdings - 6; - - screen.print(Common::Point(INVENTORY_POINTS[7][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_"); - inv.freeGraphics(); - inv.loadGraphics(); - inv.putInv(SLAM_DISPLAY); - inv.invCommands(true); - } else { - // If something is being given, make sure it's being given to a person - if (inv._invMode == INVMODE_GIVE) { - if (_bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON) - _find = _bgFound; - else - _find = -1; - } else { - _find = _bgFound; - } - - if ((mousePos.y < CONTROLS_Y1) && (inv._invMode == INVMODE_LOOK) && (_find >= 0) && (_find < 1000)) { - if (!scene._bgShapes[_find]._examine.empty() && - scene._bgShapes[_find]._examine[0] >= ' ') - inv.refreshInv(); - } else if (_selector != -1 || _find >= 0) { - // Selector is the inventory object that was clicked on, or selected. - // If it's -1, then no inventory item is highlighted yet. Otherwise, - // an object in the scene has been clicked. - - if (_selector != -1 && inv._invMode == INVMODE_LOOK - && mousePos.y >(CONTROLS_Y1 + 11)) - inv.refreshInv(); - - if (talk._talkToAbort) - return; - - // Now check for the Use and Give actions. If inv_mode is INVMODE_GIVE, - // that means GIVE is in effect, _selector is the object being - // given, and _find is the target. - // The same applies to USE, except if _selector is -1, then USE - // is being tried on an object in the scene without an inventory - // object being highlighted first. - - if ((inv._invMode == INVMODE_USE || (_selector != -1 && inv._invMode == INVMODE_GIVE)) && _find >= 0) { - events._pressed = events._released = false; - _infoFlag = true; - clearInfo(); - - int tempSel = _selector; // Save the selector - _selector = -1; - - inv.putInv(SLAM_DISPLAY); - _selector = tempSel; // Restore it - InvMode tempMode = inv._invMode; - inv._invMode = INVMODE_USE55; - inv.invCommands(true); - - _infoFlag = true; - clearInfo(); - banishWindow(false); - _key = -1; - - inv.freeInv(); - - bool giveFl = (tempMode >= INVMODE_GIVE); - if (_selector >= 0) - // Use/Give inv object with scene object - checkUseAction(&scene._bgShapes[_find]._use[0], inv[_selector]._name, MUSE, _find, giveFl); - else - // Now inv object has been highlighted - checkUseAction(&scene._bgShapes[_find]._use[0], "*SELF*", MUSE, _find, giveFl); - - _selector = _oldSelector = -1; - } - } - } - } -} - -void ScalpelUserInterface::doLookControl() { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - Screen &screen = *_vm->_screen; - - _key = _oldKey = -1; - _keyboardInput = (_keyPress != '\0'); - - if (events._released || events._rightReleased || _keyboardInput) { - // Is an inventory object being looked at? - if (!_invLookFlag) { - // Is there any remaining text to display? - if (!_descStr.empty()) { - printObjectDesc(_descStr, false); - } else if (!_lookHelp) { - // Need to close the window and depress the Look button - Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); - screen._backBuffer2.blitFrom((*_controls)[0], pt); - banishWindow(true); - - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = COMMANDS[LOOK_MODE - 1]; - _temp = _oldTemp = 0; - _menuMode = LOOK_MODE; - events.clearEvents(); - - // Restore UI - drawInterface(); - } else { - events.setCursor(ARROW); - banishWindow(true); - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = -1; - _temp = _oldTemp = 0; - _menuMode = STD_MODE; - events.clearEvents(); - } - } else { - // Looking at an inventory object - // Backup the user interface - Surface tempSurface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1); - tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), - Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - - inv.drawInventory(INVENTORY_DONT_DISPLAY); - banishWindow(true); - - // Restore the ui - screen._backBuffer2.blitFrom(tempSurface, Common::Point(0, CONTROLS_Y1)); - - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = COMMANDS[LOOK_MODE - 1]; - _temp = _oldTemp = 0; - events.clearEvents(); - _invLookFlag = false; - _menuMode = INV_MODE; - _windowOpen = true; - } - } -} - -void ScalpelUserInterface::doMainControl() { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - SaveManager &saves = *_vm->_saves; - Common::Point pt = events.mousePos(); - - if ((events._pressed || events._released) && pt.y > CONTROLS_Y) { - events.clearKeyboard(); - _key = -1; - - // Check whether the mouse is in any of the command areas - for (_temp = 0; (_temp < 12) && (_key == -1); ++_temp) { - Common::Rect r(MENU_POINTS[_temp][0], MENU_POINTS[_temp][1], - MENU_POINTS[_temp][2], MENU_POINTS[_temp][3]); - if (r.contains(pt)) - _key = COMMANDS[_temp]; - } - --_temp; - } else if (_keyPress) { - // Keyboard control - _keyboardInput = true; - - if (_keyPress >= 'A' && _keyPress <= 'Z') { - const char *c = strchr(COMMANDS, _keyPress); - _temp = !c ? 12 : c - COMMANDS; - } else { - _temp = 12; - } - - if (_temp == 12) - _key = -1; - - if (events._rightPressed) { - _temp = 12; - _key = -1; - } - } else if (!events._released) { - _key = -1; - } - - // Check if the button being pointed to has changed - if (_oldKey != _key && !_windowOpen) { - // Clear the info line - _infoFlag = true; - clearInfo(); - - // If there was an old button selected, restore it - if (_oldKey != -1) { - _menuMode = STD_MODE; - restoreButton(_oldTemp); - } - - // If a new button is being pointed to, highlight it - if (_key != -1 && _temp < 12 && !_keyboardInput) - depressButton(_temp); - - // Save the new button selection - _oldKey = _key; - _oldTemp = _temp; - } - - if (!events._pressed && !_windowOpen) { - switch (_key) { - case 'L': - toggleButton(0); - break; - case 'M': - toggleButton(1); - break; - case 'T': - toggleButton(2); - break; - case 'P': - toggleButton(3); - break; - case 'O': - toggleButton(4); - break; - case 'C': - toggleButton(5); - break; - case 'I': - pushButton(6); - _selector = _oldSelector = -1; - _menuMode = INV_MODE; - inv.drawInventory(PLAIN_INVENTORY); - break; - case 'U': - pushButton(7); - _selector = _oldSelector = -1; - _menuMode = USE_MODE; - inv.drawInventory(USE_INVENTORY_MODE); - break; - case 'G': - pushButton(8); - _selector = _oldSelector = -1; - _menuMode = GIVE_MODE; - inv.drawInventory(GIVE_INVENTORY_MODE); - break; - case 'J': - pushButton(9); - _menuMode = JOURNAL_MODE; - journalControl(); - break; - case 'F': - pushButton(10); - - // Create a thumbnail of the current screen before the files dialog is shown, in case - // the user saves the game - saves.createThumbnail(); - - _selector = _oldSelector = -1; - - if (_vm->_showOriginalSavesDialog) { - // Show the original dialog - _menuMode = FILES_MODE; - saves.drawInterface(); - _windowOpen = true; - } else { - // Show the ScummVM GMM instead - _vm->_canLoadSave = true; - _vm->openMainMenuDialog(); - _vm->_canLoadSave = false; - } - break; - case 'S': - pushButton(11); - _menuMode = SETUP_MODE; - Settings::show(_vm); - break; - default: - break; - } - - _help = _oldHelp = _oldBgFound = -1; - } -} - -void ScalpelUserInterface::doMiscControl(int allowed) { - Events &events = *_vm->_events; - Scene &scene = *_vm->_scene; - Talk &talk = *_vm->_talk; - - if (events._released) { - _temp = _bgFound; - if (_bgFound != -1) { - // Only allow pointing to objects, not people - if (_bgFound < 1000) { - events.clearEvents(); - Object &obj = scene._bgShapes[_bgFound]; - - switch (allowed) { - case ALLOW_OPEN: - checkAction(obj._aOpen, MOPEN, _temp); - if (_menuMode != TALK_MODE && !talk._talkToAbort) { - _menuMode = STD_MODE; - restoreButton(OPEN_MODE - 1); - _key = _oldKey = -1; - } - break; - - case ALLOW_CLOSE: - checkAction(obj._aClose, MCLOSE, _temp); - if (_menuMode != TALK_MODE && !talk._talkToAbort) { - _menuMode = STD_MODE; - restoreButton(CLOSE_MODE - 1); - _key = _oldKey = -1; - } - break; - - case ALLOW_MOVE: - checkAction(obj._aMove, MMOVE, _temp); - if (_menuMode != TALK_MODE && !talk._talkToAbort) { - _menuMode = STD_MODE; - restoreButton(MOVE_MODE - 1); - _key = _oldKey = -1; - } - break; - - default: - break; - } - } - } - } -} - -void ScalpelUserInterface::doPickControl() { - Events &events = *_vm->_events; - Scene &scene = *_vm->_scene; - Talk &talk = *_vm->_talk; - - if (events._released) { - if ((_temp = _bgFound) != -1) { - events.clearEvents(); - - // Don't allow characters to be picked up - if (_bgFound < 1000) { - scene._bgShapes[_bgFound].pickUpObject(MPICK); - - if (!talk._talkToAbort && _menuMode != TALK_MODE) { - _key = _oldKey = -1; - _menuMode = STD_MODE; - restoreButton(PICKUP_MODE - 1); - } - } - } - } -} - -void ScalpelUserInterface::doTalkControl() { - Events &events = *_vm->_events; - Journal &journal = *_vm->_journal; - People &people = *_vm->_people; - Screen &screen = *_vm->_screen; - Sound &sound = *_vm->_sound; - Talk &talk = *_vm->_talk; - Common::Point mousePos = events.mousePos(); - - _key = _oldKey = -1; - _keyboardInput = false; - - 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"); - else if (_endKeyActive) - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_FOREGROUND, true, "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"); - else if (talk._moreTalkUp) - screen.buttonPrint(Common::Point(159, CONTROLS_Y), COMMAND_FOREGROUND, true, "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"); - else if (talk._moreTalkDown) - screen.buttonPrint(Common::Point(200, CONTROLS_Y), COMMAND_FOREGROUND, true, "Down"); - - bool found = false; - for (_selector = talk._talkIndex; _selector < (int)talk._statements.size() && !found; ++_selector) { - if (mousePos.y > talk._statements[_selector]._talkPos.top && - mousePos.y < talk._statements[_selector]._talkPos.bottom) - found = true; - } - --_selector; - if (!found) - _selector = -1; - } - - if (_keyPress) { - _key = toupper(_keyPress); - if (_key == Common::KEYCODE_ESCAPE) - _key = 'E'; - - // Check for number press indicating reply line - if (_key >= '1' && _key <= ('1' + (int)talk._statements.size() - 1)) { - for (uint idx = 0; idx < talk._statements.size(); ++idx) { - if (talk._statements[idx]._talkMap == (_key - '1')) { - // Found the given statement - _selector = idx; - _key = -1; - _keyboardInput = true; - break; - } - } - } else if (_key == 'E' || _key == 'U' || _key == 'D') { - _keyboardInput = true; - } else { - _selector = -1; - } - } - - if (_selector != _oldSelector) { - // Remove highlighting from previous line, if any - if (_oldSelector != -1) { - if (!((talk._talkHistory[talk._converseNum][_oldSelector] >> (_oldSelector & 7)) & 1)) - talk.talkLine(_oldSelector, talk._statements[_oldSelector]._talkMap, INV_FOREGROUND, - talk._statements[_oldSelector]._talkPos.top, true); - else - talk.talkLine(_oldSelector, talk._statements[_oldSelector]._talkMap, TALK_NULL, - talk._statements[_oldSelector]._talkPos.top, true); - } - - // Add highlighting to new line, if any - if (_selector != -1) - talk.talkLine(_selector, talk._statements[_selector]._talkMap, TALK_FOREGROUND, - talk._statements[_selector]._talkPos.top, true); - - _oldSelector = _selector; - } - - if (events._released || _keyboardInput) { - if (((Common::Rect(99, CONTROLS_Y, 138, CONTROLS_Y + 10).contains(mousePos) && events._released) - || _key == 'E') && _endKeyActive) { - talk.freeTalkVars(); - talk.pullSequence(); - banishWindow(); - _windowBounds.top = CONTROLS_Y1; - } else if (((Common::Rect(140, CONTROLS_Y, 179, CONTROLS_Y + 10).contains(mousePos) && events._released) - || _key == 'U') && talk._moreTalkUp) { - while (talk._statements[--talk._talkIndex]._talkMap == -1) - ; - screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, - SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); - talk.displayTalk(false); - - screen.slamRect(Common::Rect(5, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH - 5, SHERLOCK_SCREEN_HEIGHT - 2)); - } else if (((Common::Rect(181, CONTROLS_Y, 220, CONTROLS_Y + 10).contains(mousePos) && events._released) - || _key == 'D') && talk._moreTalkDown) { - do { - ++talk._talkIndex; - } while (talk._talkIndex < (int)talk._statements.size() && talk._statements[talk._talkIndex]._talkMap == -1); - - screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, - SHERLOCK_SCREEN_HEIGHT - 1), INV_BACKGROUND); - talk.displayTalk(false); - - 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"); - - // If the reply is new, add it to the journal - if (!talk._talkHistory[talk._converseNum][_selector]) { - journal.record(talk._converseNum, _selector); - - // Add any Holmes point to Holmes' total, if any - if (talk._statements[_selector]._quotient) - people._holmesQuotient += talk._statements[_selector]._quotient; - } - - // Flag the response as having been used - talk._talkHistory[talk._converseNum][_selector] = true; - - clearWindow(); - screen.print(Common::Point(16, CONTROLS_Y + 12), TALK_FOREGROUND, "Sherlock Holmes"); - talk.talkLine(_selector + 128, talk._statements[_selector]._talkMap, COMMAND_FOREGROUND, CONTROLS_Y + 21, true); - - switch (talk._statements[_selector]._portraitSide & 3) { - case 0: - case 1: - people._portraitSide = 20; - break; - case 2: - people._portraitSide = 220; - break; - case 3: - people._portraitSide = 120; - break; - } - - // Check for flipping Holmes - if (talk._statements[_selector]._portraitSide & REVERSE_DIRECTION) - people._holmesFlip = true; - - talk._speaker = 0; - people.setTalking(0); - - if (!talk._statements[_selector]._voiceFile.empty() && sound._voices) { - sound.playSound(talk._statements[_selector]._voiceFile, WAIT_RETURN_IMMEDIATELY); - - // Set voices as an indicator for waiting - sound._voices = 2; - sound._speechOn = *sound._soundIsOn; - } else { - sound._speechOn = false; - } - - talk.waitForMore(talk._statements[_selector]._statement.size()); - if (talk._talkToAbort) - return; - - people.clearTalking(); - if (talk._talkToAbort) - return; - - while (!_vm->shouldQuit()) { - talk._scriptSelect = _selector; - talk._speaker = talk._talkTo; - talk.doScript(talk._statements[_selector]._reply); - - if (!talk._talkToAbort) { - if (!talk._talkStealth) - clearWindow(); - - if (!talk._statements[_selector]._modified.empty()) { - for (uint idx = 0; idx < talk._statements[_selector]._modified.size(); ++idx) { - _vm->setFlags(talk._statements[_selector]._modified[idx]); - } - - talk.setTalkMap(); - } - - // Check for another linked talk file - Common::String linkFilename = talk._statements[_selector]._linkFile; - if (!linkFilename.empty() && !talk._scriptMoreFlag) { - talk.freeTalkVars(); - talk.loadTalkFile(linkFilename); - - // Find the first new statement - int select = _selector = _oldSelector = -1; - for (uint idx = 0; idx < talk._statements.size() && select == -1; ++idx) { - if (!talk._statements[idx]._talkMap) - select = talk._talkIndex = idx; - } - - // See if the new statement is a stealth reply - talk._talkStealth = talk._statements[select]._statement.hasPrefix("^") ? 2 : 0; - - // Is the new talk file a standard file, reply first file, or a stealth file - if (!talk._statements[select]._statement.hasPrefix("*") && - !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"); - else - screen.buttonPrint(Common::Point(119, CONTROLS_Y), COMMAND_NULL, true, "Exit"); - - talk.displayTalk(true); - events.setCursor(ARROW); - break; - } else { - _selector = select; - - if (!talk._talkHistory[talk._converseNum][_selector]) - journal.record(talk._converseNum, _selector); - - talk._talkHistory[talk._converseNum][_selector] = true; - } - } else { - talk.freeTalkVars(); - talk.pullSequence(); - banishWindow(); - _windowBounds.top = CONTROLS_Y1; - break; - } - } else { - break; - } - } - - events._pressed = events._released = false; - events._oldButtons = 0; - talk._talkStealth = 0; - - // If a script was pushed onto the script stack, restore it - if (!talk._scriptStack.empty()) { - ScriptStackEntry stackEntry = talk._scriptStack.pop(); - talk._scriptName = stackEntry._name; - talk._scriptSaveIndex = stackEntry._currentIndex; - talk._scriptSelect = stackEntry._select; - } - } - } -} - -void ScalpelUserInterface::journalControl() { - Events &events = *_vm->_events; - Journal &journal = *_vm->_journal; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - bool doneFlag = false; - - // Draw the journal screen - journal.drawInterface(); - - // Handle journal events - do { - _key = -1; - events.setButtonState(); - - // Handle keypresses - if (events.kbHit()) { - Common::KeyState keyState = events.getKey(); - if (keyState.keycode == Common::KEYCODE_x && (keyState.flags & Common::KBD_ALT)) { - _vm->quitGame(); - return; - } else if (keyState.keycode == Common::KEYCODE_e || keyState.keycode == Common::KEYCODE_ESCAPE) { - doneFlag = true; - } else { - _key = toupper(keyState.keycode); - } - } - - if (!doneFlag) - doneFlag = journal.handleEvents(_key); - } while (!_vm->shouldQuit() && !doneFlag); - - // Finish up - _infoFlag = _keyboardInput = false; - _keyPress = '\0'; - _windowOpen = false; - _windowBounds.top = CONTROLS_Y1; - _key = -1; - _menuMode = STD_MODE; - - // Reset the palette - screen.setPalette(screen._cMap); - - screen._backBuffer1.blitFrom(screen._backBuffer2); - scene.updateBackground(); - screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); -} - -void ScalpelUserInterface::printObjectDesc(const Common::String &str, bool firstTime) { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - Screen &screen = *_vm->_screen; - Talk &talk = *_vm->_talk; - - if (str.hasPrefix("_")) { - _lookScriptFlag = true; - events.setCursor(MAGNIFY); - int savedSelector = _selector; - talk.talkTo(str.c_str() + 1); - _lookScriptFlag = false; - - if (talk._talkToAbort) { - events.setCursor(ARROW); - return; - } - - // Check if looking at an inventory object - if (!_invLookFlag) { - // See if this look was called by a right button click or not - if (!_lookHelp) { - // If it wasn't a right button click, then we need depress - // the look button before we close the window. So save a copy of the - // menu area, and draw the controls onto it - Surface tempSurface((*_controls)[0]._frame.w, (*_controls)[0]._frame.h); - Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]); - - tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0), - Common::Rect(pt.x, pt.y, pt.x + tempSurface.w(), pt.y + tempSurface.h())); - screen._backBuffer2.transBlitFrom((*_controls)[0], pt); - - banishWindow(1); - events.setCursor(MAGNIFY); - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = COMMANDS[LOOK_MODE - 1]; - _temp = _oldTemp = 0; - _menuMode = LOOK_MODE; - events.clearEvents(); - - screen._backBuffer2.blitFrom(tempSurface, pt); - } else { - events.setCursor(ARROW); - banishWindow(true); - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = -1; - _temp = _oldTemp = 0; - _menuMode = STD_MODE; - _lookHelp = 0; - events.clearEvents(); - } - } else { - // Looking at an inventory object - _selector = _oldSelector = savedSelector; - - // Reload the inventory graphics and draw the inventory - inv.loadInv(); - inv.putInv(SLAM_SECONDARY_BUFFER); - inv.freeInv(); - banishWindow(1); - - _windowBounds.top = CONTROLS_Y1; - _key = _oldKey = COMMANDS[INV_MODE - 1]; - _temp = _oldTemp = 0; - events.clearEvents(); - - _invLookFlag = 0; - _menuMode = INV_MODE; - _windowOpen = true; - } - - return; - } - - Surface &bb = *screen._backBuffer; - if (firstTime) { - // Only draw the border on the first call - _infoFlag = true; - clearInfo(); - - bb.fillRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, - CONTROLS_Y1 + 10), BORDER_COLOR); - bb.fillRect(Common::Rect(0, CONTROLS_Y + 10, 1, SHERLOCK_SCREEN_HEIGHT - 1), - BORDER_COLOR); - bb.fillRect(Common::Rect(SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y + 10, - SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); - bb.fillRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 1, SHERLOCK_SCREEN_WIDTH, - SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR); - } - - // Clear background - bb.fillRect(Common::Rect(2, CONTROLS_Y + 10, SHERLOCK_SCREEN_WIDTH - 2, - SHERLOCK_SCREEN_HEIGHT - 2), INV_BACKGROUND); - - _windowBounds.top = CONTROLS_Y; - events.clearEvents(); - - // Loop through displaying up to five lines - bool endOfStr = false; - const char *msgP = str.c_str(); - for (int lineNum = 0; lineNum < ONSCREEN_FILES_COUNT && !endOfStr; ++lineNum) { - int width = 0; - const char *lineStartP = msgP; - - // Determine how much can be displayed on the line - do { - width += screen.charWidth(*msgP++); - } while (width < 300 && *msgP); - - if (*msgP) - --msgP; - else - endOfStr = true; - - // If the line needs to be wrapped, scan backwards to find - // the end of the previous word as a splitting point - if (width >= 300) { - while (*msgP != ' ') - --msgP; - endOfStr = false; - } - - // Print out the line - Common::String line(lineStartP, msgP); - screen.gPrint(Common::Point(16, CONTROLS_Y + 12 + lineNum * 9), - INV_FOREGROUND, "%s", line.c_str()); - - if (!endOfStr) - // Start next line at start of the nxet word after space - ++msgP; - } - - // Handle display depending on whether all the message was shown - if (!endOfStr) { - screen.makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), - (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2, - PRESS_KEY_FOR_MORE); - screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - - screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2, CONTROLS_Y), - COMMAND_FOREGROUND, "P"); - _descStr = msgP; - } else { - screen.makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10), - (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, - PRESS_KEY_TO_CONTINUE); - screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH - - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, CONTROLS_Y), - COMMAND_FOREGROUND, "P"); - _descStr = ""; - } - - if (firstTime) { - if (!_slideWindows) { - screen.slamRect(Common::Rect(0, CONTROLS_Y, - SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - } else { - // Display the window - summonWindow(); - } - - _selector = _oldSelector = -1; - _windowOpen = true; - } else { - screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, - SHERLOCK_SCREEN_HEIGHT)); - } -} - -void ScalpelUserInterface::printObjectDesc() { - printObjectDesc(_cAnimStr, true); -} - -void ScalpelUserInterface::summonWindow(const Surface &bgSurface, bool slideUp) { - Events &events = *_vm->_events; - Screen &screen = *_vm->_screen; - - if (_windowOpen) - // A window is already open, so can't open another one - return; - - if (slideUp) { - // Gradually slide up the display of the window - for (int idx = 1; idx <= bgSurface.h(); idx += 2) { - screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx), - Common::Rect(0, 0, bgSurface.w(), idx)); - screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx, - SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - - events.delay(10); - } - } else { - // Gradually slide down the display of the window - for (int idx = 1; idx <= bgSurface.h(); idx += 2) { - screen._backBuffer->blitFrom(bgSurface, - Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h()), - Common::Rect(0, bgSurface.h() - idx, bgSurface.w(), bgSurface.h())); - screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h(), - SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - bgSurface.h() + idx)); - - events.delay(10); - } - } - - // Final display of the entire window - screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h()), - Common::Rect(0, 0, bgSurface.w(), bgSurface.h())); - screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h(), bgSurface.w(), bgSurface.h()); - - _windowOpen = true; -} - -void ScalpelUserInterface::summonWindow(bool slideUp, int height) { - Screen &screen = *_vm->_screen; - - // Extract the window that's been drawn on the back buffer - Surface tempSurface(SHERLOCK_SCREEN_WIDTH, - (SHERLOCK_SCREEN_HEIGHT - height)); - Common::Rect r(0, height, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); - tempSurface.blitFrom(screen._backBuffer1, Common::Point(0, 0), r); - - // Remove drawn window with original user interface - screen._backBuffer1.blitFrom(screen._backBuffer2, - Common::Point(0, height), r); - - // Display the window gradually on-screen - summonWindow(tempSurface, slideUp); -} - -void ScalpelUserInterface::banishWindow(bool slideUp) { - Events &events = *_vm->_events; - Screen &screen = *_vm->_screen; - - if (_windowOpen) { - if (slideUp || !_slideWindows) { - // Slide window down - // Only slide the window if the window style allows it - if (_slideWindows) { - for (int idx = 2; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y); idx += 2) { - // Shift the window down by 2 lines - byte *pSrc = (byte *)screen._backBuffer1.getBasePtr(0, CONTROLS_Y + idx - 2); - byte *pSrcEnd = (byte *)screen._backBuffer1.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - 2); - byte *pDest = (byte *)screen._backBuffer1.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT); - Common::copy_backward(pSrc, pSrcEnd, pDest); - - // Restore lines from the ui in the secondary back buffer - screen._backBuffer1.blitFrom(screen._backBuffer2, - Common::Point(0, CONTROLS_Y), - Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + idx)); - - screen.slamArea(0, CONTROLS_Y + idx - 2, SHERLOCK_SCREEN_WIDTH, - SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y - idx + 2); - events.delay(10); - } - - // Restore final two old lines - screen._backBuffer1.blitFrom(screen._backBuffer2, - Common::Point(0, SHERLOCK_SCREEN_HEIGHT - 2), - Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 2, - SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - 2, SHERLOCK_SCREEN_WIDTH, 2); - } else { - // Restore old area to completely erase window - screen._backBuffer1.blitFrom(screen._backBuffer2, - Common::Point(0, CONTROLS_Y), - Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - screen.slamRect(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, - SHERLOCK_SCREEN_HEIGHT)); - } - } else { - // Slide the original user interface up to cover the dialog - for (int idx = 1; idx < (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y1); idx += 2) { - byte *pSrc = (byte *)screen._backBuffer2.getBasePtr(0, CONTROLS_Y1); - byte *pSrcEnd = (byte *)screen._backBuffer2.getBasePtr(0, CONTROLS_Y1 + idx); - byte *pDest = (byte *)screen._backBuffer1.getBasePtr(0, SHERLOCK_SCREEN_HEIGHT - idx); - Common::copy(pSrc, pSrcEnd, pDest); - - screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - idx, SHERLOCK_SCREEN_WIDTH, - SHERLOCK_SCREEN_HEIGHT); - events.delay(10); - } - - // Show entire final area - screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(0, CONTROLS_Y1), - Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - screen.slamRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - } - - _infoFlag = false; - _windowOpen = false; - } - - _menuMode = STD_MODE; -} - -void ScalpelUserInterface::checkUseAction(const UseType *use, const Common::String &invName, - const char *const messages[], int objNum, bool giveMode) { - Events &events = *_vm->_events; - Inventory &inv = *_vm->_inventory; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Talk &talk = *_vm->_talk; - bool printed = messages == nullptr; - - if (objNum >= 1000) { - // Holmes was specified, so do nothing - _infoFlag = true; - clearInfo(); - _infoFlag = true; - - // Display error message - _menuCounter = 30; - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "You can't do that to yourself."); - return; - } - - // Scan for target item - int targetNum = -1; - if (giveMode) { - for (int idx = 0; idx < USE_COUNT && targetNum == -1; ++idx) { - if ((use[idx]._target.equalsIgnoreCase("*GIVE*") || use[idx]._target.equalsIgnoreCase("*GIVEP*")) - && use[idx]._names[0].equalsIgnoreCase(invName)) { - // Found a match - targetNum = idx; - if (use[idx]._target.equalsIgnoreCase("*GIVE*")) - inv.deleteItemFromInventory(invName); - } - } - } else { - for (int idx = 0; idx < USE_COUNT && targetNum == -1; ++idx) { - if (use[idx]._target.equalsIgnoreCase(invName)) - targetNum = idx; - } - } - - if (targetNum != -1) { - // Found a target, so do the action - const UseType &action = use[targetNum]; - - events.setCursor(WAIT); - - if (action._useFlag) - _vm->setFlags(action._useFlag); - - if (action._cAnimNum != 99) { - if (action._cAnimNum == 0) - scene.startCAnim(9, action._cAnimSpeed); - else - scene.startCAnim(action._cAnimNum - 1, action._cAnimSpeed); - } - - if (!talk._talkToAbort) { - Object &obj = scene._bgShapes[objNum]; - for (int idx = 0; idx < NAMES_COUNT && !talk._talkToAbort; ++idx) { - if (obj.checkNameForCodes(action._names[idx], messages)) { - if (!talk._talkToAbort) - printed = true; - } - } - - // Print "Done..." as an ending, unless flagged for leaving scene or otherwise flagged - if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { - _infoFlag = true; - clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); - _menuCounter = 25; - } - } - } else { - // Couldn't find target, so print error - _infoFlag = true; - clearInfo(); - - if (giveMode) { - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "No, thank you."); - } else if (messages == nullptr) { - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "You can't do that."); - } else { - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[0]); - } - - _infoFlag = true; - _menuCounter = 30; - } - - events.setCursor(ARROW); -} - -void ScalpelUserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) { - Events &events = *_vm->_events; - People &people = *_vm->_people; - Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Talk &talk = *_vm->_talk; - Common::Point pt(-1, -1); - - if (objNum >= 1000) - // Ignore actions done on characters - return; - - if (!action._cAnimSpeed) { - // Invalid action, to print error message - _infoFlag = true; - clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[action._cAnimNum]); - _infoFlag = true; - - // Set how long to show the message - _menuCounter = 30; - } else { - Object &obj = scene._bgShapes[objNum]; - - int cAnimNum; - if (action._cAnimNum == 0) - // Really a 10 - cAnimNum = 9; - else - cAnimNum = action._cAnimNum - 1; - - int dir = -1; - if (action._cAnimNum != 99) { - CAnim &anim = scene._cAnim[cAnimNum]; - - if (action._cAnimNum != 99) { - if (action._cAnimSpeed & REVERSE_DIRECTION) { - pt = anim._teleportPos; - dir = anim._teleportDir; - } else { - pt = anim._goto; - dir = anim._gotoDir; - } - } - } else { - pt = Common::Point(-1, -1); - dir = -1; - } - - // Has a value, so do action - // Show wait cursor whilst walking to object and doing action - events.setCursor(WAIT); - bool printed = false; - - for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { - if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 - && toupper(action._names[nameIdx][1]) == 'W') { - if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), messages)) { - if (!talk._talkToAbort) - printed = true; - } - } - } - - bool doCAnim = true; - for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { - if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2) { - char ch = toupper(action._names[nameIdx][1]); - - if (ch == 'T' || ch == 'B') { - printed = true; - if (pt.x != -1) - // Holmes needs to walk to object before the action is done - people.walkToCoords(pt, dir); - - if (!talk._talkToAbort) { - // Ensure Holmes is on the exact intended location - people[AL]._position = pt; - people[AL]._sequenceNumber = dir; - people.gotoStand(people[AL]); - - talk.talkTo(action._names[nameIdx].c_str() + 2); - if (ch == 'T') - doCAnim = false; - } - } - } - } - - if (doCAnim && !talk._talkToAbort) { - if (pt.x != -1) - // Holmes needs to walk to object before the action is done - people.walkToCoords(pt, dir); - } - - for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { - if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 - && toupper(action._names[nameIdx][1]) == 'F') { - if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, messages)) { - if (!talk._talkToAbort) - printed = true; - } - } - } - - if (doCAnim && !talk._talkToAbort && action._cAnimNum != 99) - scene.startCAnim(cAnimNum, action._cAnimSpeed); - - if (!talk._talkToAbort) { - for (int nameIdx = 0; nameIdx < NAMES_COUNT && !talk._talkToAbort; ++nameIdx) { - if (obj.checkNameForCodes(action._names[nameIdx], messages)) { - if (!talk._talkToAbort) - printed = true; - } - } - - // Unless we're leaving the scene, print a "Done" message unless the printed flag has been set - if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { - _infoFlag = true; - clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); - - // Set how long to show the message - _menuCounter = 30; - } - } - } - - // Reset cursor back to arrow - events.setCursor(ARROW); -} - -} - -/*----------------------------------------------------------------*/ - -namespace Tattoo { - -TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm) { - _menuBuffer = nullptr; - _invMenuBuffer = nullptr; -} - -void TattooUserInterface::handleInput() { - // TODO - _vm->_events->pollEventsAndWait(); -} - -void TattooUserInterface::doBgAnimRestoreUI() { - TattooScene &scene = *((TattooScene *)_vm->_scene); - Screen &screen = *_vm->_screen; - - // If _oldMenuBounds was set, then either a new menu has been opened or the current menu has been closed. - // Either way, we need to restore the area where the menu was displayed - if (_oldMenuBounds.width() > 0) - screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldMenuBounds.left, _oldMenuBounds.top), - _oldMenuBounds); - - if (_oldInvMenuBounds.width() > 0) - screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldInvMenuBounds.left, _oldInvMenuBounds.top), - _oldInvMenuBounds); - - if (_menuBuffer != nullptr) - screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_menuBounds.left, _menuBounds.top), _menuBounds); - if (_invMenuBuffer != nullptr) - screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_invMenuBounds.left, _invMenuBounds.top), _invMenuBounds); - - // If there is a Text Tag being display, restore the area underneath it - if (_oldTagBounds.width() > 0) - screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldTagBounds.left, _oldTagBounds.top), - _oldTagBounds); - - // If there is an Inventory being shown, restore the graphics underneath it - if (_oldInvGraphicBounds.width() > 0) - screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldInvGraphicBounds.left, _oldInvGraphicBounds.top), - _oldInvGraphicBounds); - - // If a canimation is active, restore the graphics underneath it - if (scene._activeCAnim._images != nullptr) - screen.restoreBackground(scene._activeCAnim._oldBounds); - - // If a canimation just ended, remove it's graphics from the backbuffer - if (scene._activeCAnim._removeBounds.width() > 0) - screen.restoreBackground(scene._activeCAnim._removeBounds); -} - -void TattooUserInterface::doScroll() { - Screen &screen = *_vm->_screen; - int oldScroll = screen._currentScroll; - - // If we're already at the target scroll position, nothing needs to be done - if (screen._targetScroll == screen._currentScroll) - return; - - screen._flushScreen = true; - if (screen._targetScroll > screen._currentScroll) { - screen._currentScroll += screen._scrollSpeed; - if (screen._currentScroll > screen._targetScroll) - screen._currentScroll = screen._targetScroll; - } else if (screen._targetScroll < screen._currentScroll) { - screen._currentScroll -= screen._scrollSpeed; - if (screen._currentScroll < screen._targetScroll) - screen._currentScroll = screen._targetScroll; - } - - if (_menuBuffer != nullptr) - _menuBounds.translate(screen._currentScroll - oldScroll, 0); - if (_invMenuBuffer != nullptr) - _invMenuBounds.translate(screen._currentScroll - oldScroll, 0); -} - -} // End of namespace Tattoo - } // End of namespace Sherlock -- cgit v1.2.3 From 7d2f15d8212f088950385cfc4ec91059b728c95c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Jun 2015 14:53:50 -0400 Subject: SHERLOCK: RT: Implemented doStandardControl --- engines/sherlock/user_interface.cpp | 134 ++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9fff7cc999..8ab26aca62 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -53,4 +53,138 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _lookHelp = 0; } + +void UserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) { + Events &events = *_vm->_events; + People &people = *_vm->_people; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + Point32 pt(-1, -1); + + if (objNum >= 1000) + // Ignore actions done on characters + return; + + if (!action._cAnimSpeed) { + // Invalid action, to print error message + _infoFlag = true; + clearInfo(); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[action._cAnimNum]); + _infoFlag = true; + + // Set how long to show the message + _menuCounter = 30; + } else { + Object &obj = scene._bgShapes[objNum]; + + int cAnimNum; + if (action._cAnimNum == 0) + // Really a 10 + cAnimNum = 9; + else + cAnimNum = action._cAnimNum - 1; + + int dir = -1; + if (action._cAnimNum != 99) { + CAnim &anim = scene._cAnim[cAnimNum]; + + if (action._cAnimNum != 99) { + if (action._cAnimSpeed & REVERSE_DIRECTION) { + pt = anim._teleport[0]; + dir = anim._teleport[0]._facing; + } else { + pt = anim._goto[0]; + dir = anim._goto[0]._facing; + } + } + } else { + pt = Point32(-1, -1); + dir = -1; + } + + // Has a value, so do action + // Show wait cursor whilst walking to object and doing action + events.setCursor(WAIT); + bool printed = false; + + for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { + if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 + && toupper(action._names[nameIdx][1]) == 'W') { + if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), messages)) { + if (!talk._talkToAbort) + printed = true; + } + } + } + + bool doCAnim = true; + for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { + if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2) { + char ch = toupper(action._names[nameIdx][1]); + + if (ch == 'T' || ch == 'B') { + printed = true; + if (pt.x != -1) + // Holmes needs to walk to object before the action is done + people[HOLMES].walkToCoords(pt, dir); + + if (!talk._talkToAbort) { + // Ensure Holmes is on the exact intended location + people[HOLMES]._position = pt; + people[HOLMES]._sequenceNumber = dir; + people[HOLMES].gotoStand(); + + talk.talkTo(action._names[nameIdx].c_str() + 2); + if (ch == 'T') + doCAnim = false; + } + } + } + } + + if (doCAnim && !talk._talkToAbort) { + if (pt.x != -1) + // Holmes needs to walk to object before the action is done + people[HOLMES].walkToCoords(pt, dir); + } + + for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { + if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 + && toupper(action._names[nameIdx][1]) == 'F') { + if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, messages)) { + if (!talk._talkToAbort) + printed = true; + } + } + } + + if (doCAnim && !talk._talkToAbort && action._cAnimNum != 99) + scene.startCAnim(cAnimNum, action._cAnimSpeed); + + if (!talk._talkToAbort) { + for (int nameIdx = 0; nameIdx < NAMES_COUNT && !talk._talkToAbort; ++nameIdx) { + if (obj.checkNameForCodes(action._names[nameIdx], messages)) { + if (!talk._talkToAbort) + printed = true; + } + } + + // Unless we're leaving the scene, print a "Done" message unless the printed flag has been set + if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { + _infoFlag = true; + clearInfo(); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); + + // Set how long to show the message + _menuCounter = 30; + } + } + } + + // Reset cursor back to arrow + events.setCursor(ARROW); +} + + } // End of namespace Sherlock -- cgit v1.2.3 From d314257968837f6c1e26a8465e91cc263017e4bf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Jun 2015 15:48:02 -0400 Subject: SHERLOCK: Simplify UseType to derive from ActionType --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 8ab26aca62..ba94d53aae 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -54,7 +54,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { } -void UserInterface::checkAction(ActionType &action, const char *const messages[], int objNum) { +void UserInterface::checkAction(ActionType &action, int objNum, const char *const messages[]) { Events &events = *_vm->_events; People &people = *_vm->_people; Scene &scene = *_vm->_scene; -- cgit v1.2.3 From 1b6a60f359eb20130f34a8f79bfe9e5d4ea25b5a Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 14 Jun 2015 17:52:11 +0200 Subject: SHERLOCK: action processing uses fixed text class action error messages are now localized too --- engines/sherlock/user_interface.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index ba94d53aae..af79b34561 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -54,8 +54,9 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { } -void UserInterface::checkAction(ActionType &action, int objNum, const char *const messages[]) { +void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionId fixedTextActionId) { Events &events = *_vm->_events; + FixedText &fixedText = *_vm->_fixedText; People &people = *_vm->_people; Scene &scene = *_vm->_scene; Screen &screen = *_vm->_screen; @@ -70,7 +71,8 @@ void UserInterface::checkAction(ActionType &action, int objNum, const char *cons // Invalid action, to print error message _infoFlag = true; clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", messages[action._cAnimNum]); + Common::String errorMessage = fixedText.getActionMessage(fixedTextActionId, action._cAnimNum); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, errorMessage.c_str()); _infoFlag = true; // Set how long to show the message @@ -111,7 +113,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, const char *cons for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 && toupper(action._names[nameIdx][1]) == 'W') { - if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), messages)) { + if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), fixedTextActionId)) { if (!talk._talkToAbort) printed = true; } @@ -152,7 +154,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, const char *cons for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 && toupper(action._names[nameIdx][1]) == 'F') { - if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, messages)) { + if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, fixedTextActionId)) { if (!talk._talkToAbort) printed = true; } @@ -164,7 +166,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, const char *cons if (!talk._talkToAbort) { for (int nameIdx = 0; nameIdx < NAMES_COUNT && !talk._talkToAbort; ++nameIdx) { - if (obj.checkNameForCodes(action._names[nameIdx], messages)) { + if (obj.checkNameForCodes(action._names[nameIdx], fixedTextActionId)) { if (!talk._talkToAbort) printed = true; } -- cgit v1.2.3 From cf07fb562dd59c16ae91db5f9c991b8bb114d866 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 15 Jun 2015 21:07:47 -0400 Subject: SHERLOCK: Use a string literal as the format string It's a gcc warning, but can lead to crashes should a string with a specifier in it be passed in and no arguments on the stack. --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index af79b34561..9e7d0df7c6 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -72,7 +72,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI _infoFlag = true; clearInfo(); Common::String errorMessage = fixedText.getActionMessage(fixedTextActionId, action._cAnimNum); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, errorMessage.c_str()); + screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", errorMessage.c_str()); _infoFlag = true; // Set how long to show the message -- cgit v1.2.3 From a96aad55592101810f71dd8813767ddbe2e76ece Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 17 Jun 2015 20:03:08 -0400 Subject: SHERLOCK: RT: Fix crash in second intro scene --- engines/sherlock/user_interface.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9e7d0df7c6..9e21be8928 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -46,6 +46,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); _lookScriptFlag = false; + _bgFound = _oldBgFound = -1; _key = _oldKey = '\0'; _selector = _oldSelector = -1; _temp = _oldTemp = 0; @@ -53,7 +54,6 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _lookHelp = 0; } - void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionId fixedTextActionId) { Events &events = *_vm->_events; FixedText &fixedText = *_vm->_fixedText; @@ -188,5 +188,11 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI events.setCursor(ARROW); } +void UserInterface::reset() { + _bgFound = _oldBgFound = -1; + _oldKey = -1; + _oldTemp = _temp = -1; +} + } // End of namespace Sherlock -- cgit v1.2.3 From 9bbeaa668a559be34638c579310d0e832a278c6d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 25 Jun 2015 21:36:26 -0400 Subject: SHERLOCK: RT: Set up new values for color constants --- engines/sherlock/user_interface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9e21be8928..539efdd6cc 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -21,8 +21,9 @@ */ #include "sherlock/user_interface.h" -#include "sherlock/sherlock.h" +#include "sherlock/scalpel/scalpel.h" #include "sherlock/scalpel/scalpel_user_interface.h" +#include "sherlock/tattoo/tattoo.h" #include "sherlock/tattoo/tattoo_user_interface.h" namespace Sherlock { @@ -72,7 +73,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI _infoFlag = true; clearInfo(); Common::String errorMessage = fixedText.getActionMessage(fixedTextActionId, action._cAnimNum); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "%s", errorMessage.c_str()); + screen.print(Common::Point(0, INFO_LINE + 1), COL_INFO_FOREGROUND, "%s", errorMessage.c_str()); _infoFlag = true; // Set how long to show the message @@ -176,7 +177,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { _infoFlag = true; clearInfo(); - screen.print(Common::Point(0, INFO_LINE + 1), INFO_FOREGROUND, "Done..."); + screen.print(Common::Point(0, INFO_LINE + 1), COL_INFO_FOREGROUND, "Done..."); // Set how long to show the message _menuCounter = 30; -- cgit v1.2.3 From 480003f48d0cb8fd0fa40cb8a3ebab8dc8597f8a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 2 Jul 2015 20:53:40 -0400 Subject: SHERLOCK: RT: Cleanup of Exit class and fix exiting scenes --- engines/sherlock/user_interface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 539efdd6cc..37bde6be6c 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -46,6 +46,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) { _helpStyle = false; _windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1, SHERLOCK_SCREEN_HEIGHT - 1); _lookScriptFlag = false; + _exitZone = -1; _bgFound = _oldBgFound = -1; _key = _oldKey = '\0'; @@ -193,6 +194,7 @@ void UserInterface::reset() { _bgFound = _oldBgFound = -1; _oldKey = -1; _oldTemp = _temp = -1; + _exitZone = -1; } -- cgit v1.2.3 From 903875f0fea005adf9e47be59c3480714775ab9c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 9 Jul 2015 19:24:07 -0400 Subject: SHERLOCK: RT: Fix for leaving inside Baker Street --- engines/sherlock/user_interface.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 37bde6be6c..9db29023c8 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -65,6 +65,10 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI Talk &talk = *_vm->_talk; Point32 pt(-1, -1); + if (action._useFlag) + // Automatically set the given flag + _vm->setFlags(action._useFlag); + if (objNum >= 1000) // Ignore actions done on characters return; -- cgit v1.2.3 From 6847da28b2469eb949cd342234cd525e8f1076c9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jul 2015 22:10:05 -0400 Subject: SHERLOCK: RT: Fix sitting down at lab table --- engines/sherlock/user_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9db29023c8..9df3f1dc24 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -179,7 +179,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI } // Unless we're leaving the scene, print a "Done" message unless the printed flag has been set - if (scene._goToScene != 1 && !printed && !talk._talkToAbort) { + if (IS_SERRATED_SCALPEL && scene._goToScene != 1 && !printed && !talk._talkToAbort) { _infoFlag = true; clearInfo(); screen.print(Common::Point(0, INFO_LINE + 1), COL_INFO_FOREGROUND, "Done..."); -- cgit v1.2.3 From 9350c342bb77ba93910bdc68d44a169e8ae320c5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Aug 2015 19:44:16 -0400 Subject: SHERLOCK: RT: Fix using items on NPCs --- engines/sherlock/user_interface.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'engines/sherlock/user_interface.cpp') diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index 9df3f1dc24..bb0667d66a 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -69,11 +69,11 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI // Automatically set the given flag _vm->setFlags(action._useFlag); - if (objNum >= 1000) + if (IS_SERRATED_SCALPEL && objNum >= 1000) // Ignore actions done on characters return; - if (!action._cAnimSpeed) { + if (IS_SERRATED_SCALPEL && !action._cAnimSpeed) { // Invalid action, to print error message _infoFlag = true; clearInfo(); @@ -84,7 +84,11 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI // Set how long to show the message _menuCounter = 30; } else { - Object &obj = scene._bgShapes[objNum]; + BaseObject *obj; + if (objNum >= 1000) + obj = &people[objNum - 1000]; + else + obj = &scene._bgShapes[objNum]; int cAnimNum; if (action._cAnimNum == 0) @@ -119,7 +123,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 && toupper(action._names[nameIdx][1]) == 'W') { - if (obj.checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), fixedTextActionId)) { + if (obj->checkNameForCodes(Common::String(action._names[nameIdx].c_str() + 2), fixedTextActionId)) { if (!talk._talkToAbort) printed = true; } @@ -160,7 +164,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI for (int nameIdx = 0; nameIdx < NAMES_COUNT; ++nameIdx) { if (action._names[nameIdx].hasPrefix("*") && action._names[nameIdx].size() >= 2 && toupper(action._names[nameIdx][1]) == 'F') { - if (obj.checkNameForCodes(action._names[nameIdx].c_str() + 2, fixedTextActionId)) { + if (obj->checkNameForCodes(action._names[nameIdx].c_str() + 2, fixedTextActionId)) { if (!talk._talkToAbort) printed = true; } @@ -172,7 +176,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI if (!talk._talkToAbort) { for (int nameIdx = 0; nameIdx < NAMES_COUNT && !talk._talkToAbort; ++nameIdx) { - if (obj.checkNameForCodes(action._names[nameIdx], fixedTextActionId)) { + if (obj->checkNameForCodes(action._names[nameIdx], fixedTextActionId)) { if (!talk._talkToAbort) printed = true; } -- cgit v1.2.3