diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/module.mk | 1 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel_scene.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel_scene.h | 2 | ||||
-rw-r--r-- | engines/sherlock/scene.h | 2 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_scene.h | 2 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.cpp | 140 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.h | 22 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_base.cpp | 5 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_base.h | 8 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_text.cpp | 40 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_text.h | 47 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_tooltip.h | 1 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_verbs.h | 1 | ||||
-rw-r--r-- | engines/sherlock/user_interface.h | 5 |
14 files changed, 263 insertions, 16 deletions
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk index 414dabf429..cb1c32485b 100644 --- a/engines/sherlock/module.mk +++ b/engines/sherlock/module.mk @@ -22,6 +22,7 @@ MODULE_OBJS = \ tattoo/tattoo_talk.o \ tattoo/tattoo_user_interface.o \ tattoo/widget_base.o \ + tattoo/widget_text.o \ tattoo/widget_tooltip.o \ tattoo/widget_verbs.o \ animation.o \ diff --git a/engines/sherlock/scalpel/scalpel_scene.cpp b/engines/sherlock/scalpel/scalpel_scene.cpp index 1bda827260..bbe6674837 100644 --- a/engines/sherlock/scalpel/scalpel_scene.cpp +++ b/engines/sherlock/scalpel/scalpel_scene.cpp @@ -23,6 +23,7 @@ #include "sherlock/scalpel/scalpel_scene.h" #include "sherlock/scalpel/scalpel_map.h" #include "sherlock/scalpel/scalpel_people.h" +#include "sherlock/scalpel/scalpel_user_interface.h" #include "sherlock/scalpel/scalpel.h" #include "sherlock/events.h" #include "sherlock/people.h" @@ -490,7 +491,7 @@ int ScalpelScene::startCAnim(int cAnimNum, int playRate) { People &people = *_vm->_people; Resources &res = *_vm->_res; Talk &talk = *_vm->_talk; - UserInterface &ui = *_vm->_ui; + ScalpelUserInterface &ui = *(ScalpelUserInterface *)_vm->_ui; Point32 tpPos, walkPos; int tpDir, walkDir; int tFrames = 0; diff --git a/engines/sherlock/scalpel/scalpel_scene.h b/engines/sherlock/scalpel/scalpel_scene.h index f79892e4e6..77e86cf9cf 100644 --- a/engines/sherlock/scalpel/scalpel_scene.h +++ b/engines/sherlock/scalpel/scalpel_scene.h @@ -81,7 +81,7 @@ public: * @param playRate Play rate. 0 is invalid; 1=normal speed, 2=1/2 speed, etc. * A negative playRate can also be specified to play the animation in reverse */ - virtual int startCAnim(int cAnimNum, int playRate); + virtual int startCAnim(int cAnimNum, int playRate = 1); }; } // End of namespace Scalpel diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index 799433fd53..d4c88350cc 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -323,7 +323,7 @@ public: * @param playRate Play rate. 0 is invalid; 1=normal speed, 2=1/2 speed, etc. * A negative playRate can also be specified to play the animation in reverse */ - virtual int startCAnim(int cAnimNum, int playRate) = 0; + virtual int startCAnim(int cAnimNum, int playRate = 1) = 0; }; } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/tattoo_scene.h b/engines/sherlock/tattoo/tattoo_scene.h index 5561b77aa4..58a73ec557 100644 --- a/engines/sherlock/tattoo/tattoo_scene.h +++ b/engines/sherlock/tattoo/tattoo_scene.h @@ -140,7 +140,7 @@ public: * @param playRate Play rate. 0 is invalid; 1=normal speed, 2=1/2 speed, etc. * A negative playRate can also be specified to play the animation in reverse */ - virtual int startCAnim(int cAnimNum, int playRate); + virtual int startCAnim(int cAnimNum, int playRate = 1); }; } // End of namespace Tattoo diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp index 62781964bb..f1f2c2b1c3 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.cpp +++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp @@ -29,7 +29,7 @@ namespace Sherlock { namespace Tattoo { TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm), - _tooltipWidget(vm), _verbsWidget(vm) { + _tooltipWidget(vm), _verbsWidget(vm), _textWidget(vm) { _menuBuffer = nullptr; _invMenuBuffer = nullptr; _invGraphic = nullptr; @@ -44,6 +44,8 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm), _scriptZone = -1; _arrowZone = _oldArrowZone = -1; _activeObj = -1; + _cAnimFramePause = 0; + _widget = nullptr; } void TattooUserInterface::initScrollVars() { @@ -53,7 +55,134 @@ void TattooUserInterface::initScrollVars() { } void TattooUserInterface::lookAtObject() { - // TODO + Events &events = *_vm->_events; + People &people = *_vm->_people; + Scene &scene = *_vm->_scene; + Sound &sound = *_vm->_sound; + Talk &talk = *_vm->_talk; + Common::Point mousePos = events.mousePos(); + Common::String desc; + int cAnimSpeed = 0; + + if (_personFound) { + desc = people[_bgFound - 1000]._examine; + } else { + // Check if there is a Look animation + if (_bgShape->_lookcAnim != 0) { + cAnimSpeed = _bgShape->_lookcAnim & 0xe0; + cAnimSpeed >>= 5; + ++cAnimSpeed; + + _cAnimFramePause = _bgShape->_lookFrames; + desc = _bgShape->_examine; + + int cNum = (_bgShape->_lookcAnim & 0x1f) - 1; + scene.startCAnim(cNum); + } else if (_bgShape->_lookPosition.y != 0) { + // Need to walk to object before looking at it + people[HOLMES].walkToCoords(Common::Point(_bgShape->_lookPosition.x * FIXED_INT_MULTIPLIER, + _bgShape->_lookPosition.y * FIXED_INT_MULTIPLIER), _bgShape->_lookFacing); + } + + if (!talk._talkToAbort) { + desc = _bgShape->_examine; + + if (_bgShape->_lookFlag) + _vm->setFlags(_bgShape->_lookFlag); + + // Find the Sound File to Play if there is one + if (!desc.hasPrefix("_")) { + for (uint idx = 0; idx < scene._objSoundList.size(); ++idx) { + // Get the object name up to the equals + const char *p = strchr(scene._objSoundList[idx].c_str(), '='); + + // Form the name and remove any trailing spaces + Common::String name(scene._objSoundList[idx].c_str(), p); + while (name.hasSuffix(" ")) + name.deleteLastChar(); + + // See if this Object Sound List entry matches the object's name + if (_bgShape->_name.compareToIgnoreCase(name)) { + // Move forward to get the sound filename + while ((*p == ' ') || (*p == '=')) + ++p; + + // If it's not "NONE", play the Sound File + Common::String soundName(p); + if (soundName.compareToIgnoreCase("NONE")) { + soundName.toLowercase(); + if (!soundName.contains('.')) + soundName += ".wav"; + + sound.playSound(soundName, WAIT_RETURN_IMMEDIATELY); + } + + break; + } + } + } + } + } + + // Only show the desciption if the object has one, and if no talk file interrupted while walking to it + if (!talk._talkToAbort && !desc.empty()) { + if (_cAnimFramePause == 0) + printObjectDesc(desc, true); + else + // The description was already printed by an animation + _cAnimFramePause = 0; + } else if (desc.empty()) { + // There was no description to display, so reset back to STD_MODE + _menuMode = STD_MODE; + } +} + +void TattooUserInterface::printObjectDesc(const Common::String &str, bool firstTime) { + Events &events = *_vm->_events; + TattooScene &scene = *(TattooScene *)_vm->_scene; + Talk &talk = *_vm->_talk; + + if (str.hasPrefix("_")) { + // The passed string specifies a talk file + _lookScriptFlag = true; + events.setCursor(MAGNIFY); + int savedSelector = _selector; + + freeMenu(); + if (!_invLookFlag) + _windowOpen = false; + + talk.talkTo(str.c_str() + 1); + _lookScriptFlag = false; + + if (talk._talkToAbort) { + events.setCursor(ARROW); + return; + } + + // See if we're looking at an inventory item + if (_invLookFlag) { + _selector = _oldSelector = savedSelector; + doInventory(0); + _invLookFlag = false; + + } else { + // Nope + events.setCursor(ARROW); + _key = -1; + _menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; + events._pressed = events._released = events._rightReleased = false; + events._oldButtons = 0; + } + } else { + // Show text dialog + _textWidget.load(str); + + if (firstTime) + _selector = _oldSelector = -1; + + _drawMenu = _windowOpen = true; + } } void TattooUserInterface::doJournal() { @@ -479,6 +608,13 @@ void TattooUserInterface::doQuitMenu() { // TODO } +void TattooUserInterface::freeMenu() { + if (_widget != nullptr) { + _widget->banishWindow(); + _widget = nullptr; + } +} + } // End of namespace Tattoo } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h index e2732c5ae2..2adbb4066e 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.h +++ b/engines/sherlock/tattoo/tattoo_user_interface.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "sherlock/saveload.h" #include "sherlock/user_interface.h" +#include "sherlock/tattoo/widget_text.h" #include "sherlock/tattoo/widget_tooltip.h" #include "sherlock/tattoo/widget_verbs.h" @@ -49,8 +50,11 @@ private: SaveMode _fileMode; int _exitZone; int _scriptZone; + int _cAnimFramePause; WidgetTooltip _tooltipWidget; WidgetVerbs _verbsWidget; + WidgetText _textWidget; + WidgetBase *_widget; private: /** * Draws designated areas of the screen that are meant to be grayed out using grayscale colors @@ -118,6 +122,11 @@ private: * Handle displaying the quit menu */ void doQuitMenu(); + + /** + * Free any active menu + */ + void freeMenu(); public: Common::Point _currentScroll, _targetScroll; int _scrollSize, _scrollSpeed; @@ -130,6 +139,7 @@ public: Common::KeyState _keyState; public: TattooUserInterface(SherlockEngine *vm); + virtual ~TattooUserInterface() {} /** * Handles restoring any areas of the back buffer that were/are covered by UI elements @@ -147,12 +157,18 @@ public: void initScrollVars(); /** - * Display the long description for an object stored in it's _examine field, in a window that - * will be shown at the bottom of the screen + * Display the long description for an object in a window */ void lookAtObject(); /** + * Display the passed long description for an object. If the flag firstTime is set, + * the window will be opened to accomodate the text. Otherwise, the remaining text + * will be printed in an already open window + */ + void printObjectDesc(const Common::String &str, bool firstTime); + + /** * Handles displaying the journal */ void doJournal(); @@ -172,8 +188,6 @@ public: */ void pickUpObject(int objNum); public: - virtual ~TattooUserInterface() {} - /** * Main input handler for the user interface */ diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp index 0d46daca65..49ad4092cb 100644 --- a/engines/sherlock/tattoo/widget_base.cpp +++ b/engines/sherlock/tattoo/widget_base.cpp @@ -30,8 +30,13 @@ namespace Tattoo { WidgetBase::WidgetBase(SherlockEngine *vm) : _vm(vm) { } +void WidgetBase::summonWindow() { + +} + void WidgetBase::banishWindow() { // TODO + _surface.free(); } } // End of namespace Tattoo diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h index cf992b5571..2a9988bc49 100644 --- a/engines/sherlock/tattoo/widget_base.h +++ b/engines/sherlock/tattoo/widget_base.h @@ -41,11 +41,17 @@ protected: Surface _surface; public: WidgetBase(SherlockEngine *vm); + virtual ~WidgetBase() {} + + /** + * Summon the window + */ + virtual void summonWindow(); /** * Close a currently active menu */ - void banishWindow(); + virtual void banishWindow(); }; } // End of namespace Tattoo diff --git a/engines/sherlock/tattoo/widget_text.cpp b/engines/sherlock/tattoo/widget_text.cpp new file mode 100644 index 0000000000..928dbbf7cf --- /dev/null +++ b/engines/sherlock/tattoo/widget_text.cpp @@ -0,0 +1,40 @@ +/* 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/tattoo/widget_text.h" +#include "sherlock/tattoo/tattoo_user_interface.h" +#include "sherlock/tattoo/tattoo.h" + +namespace Sherlock { + +namespace Tattoo { + +WidgetText::WidgetText(SherlockEngine *vm) : WidgetBase(vm) { +} + +void WidgetText::load(const Common::String &str) { + // TODO +} + +} // End of namespace Tattoo + +} // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/widget_text.h b/engines/sherlock/tattoo/widget_text.h new file mode 100644 index 0000000000..9765e1bb6e --- /dev/null +++ b/engines/sherlock/tattoo/widget_text.h @@ -0,0 +1,47 @@ +/* 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. + * + */ + +#ifndef SHERLOCK_TATTOO_WIDGET_TEXT_H +#define SHERLOCK_TATTOO_WIDGET_TEXT_H + +#include "common/scummsys.h" +#include "sherlock/tattoo/widget_base.h" + +namespace Sherlock { + +class SherlockEngine; + +namespace Tattoo { + +class WidgetText: public WidgetBase { +public: + WidgetText(SherlockEngine *vm); + virtual ~WidgetText() {} + + void load(const Common::String &str); +}; + +} // End of namespace Tattoo + +} // End of namespace Sherlock + +#endif diff --git a/engines/sherlock/tattoo/widget_tooltip.h b/engines/sherlock/tattoo/widget_tooltip.h index 429628fc39..21c38e3792 100644 --- a/engines/sherlock/tattoo/widget_tooltip.h +++ b/engines/sherlock/tattoo/widget_tooltip.h @@ -36,6 +36,7 @@ namespace Tattoo { class WidgetTooltip: public WidgetBase { public: WidgetTooltip(SherlockEngine *vm); + virtual ~WidgetTooltip() {} /** * Handle updating the tooltip state diff --git a/engines/sherlock/tattoo/widget_verbs.h b/engines/sherlock/tattoo/widget_verbs.h index 318aeefcca..82b9325681 100644 --- a/engines/sherlock/tattoo/widget_verbs.h +++ b/engines/sherlock/tattoo/widget_verbs.h @@ -47,6 +47,7 @@ public: Common::StringArray _verbCommands; public: WidgetVerbs(SherlockEngine *vm); + virtual ~WidgetVerbs() {} /** * Turns on the menu with all the verbs that are available for the given object diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h index 1fc876e91a..3f37f1fa83 100644 --- a/engines/sherlock/user_interface.h +++ b/engines/sherlock/user_interface.h @@ -129,11 +129,6 @@ public: * Clear any active text window */ virtual void clearWindow() {} - - /** - * Print the previously selected object's decription - */ - virtual void printObjectDesc() {} }; } // End of namespace Sherlock |