diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/inventory.cpp | 28 | ||||
-rw-r--r-- | engines/sherlock/inventory.h | 2 | ||||
-rw-r--r-- | engines/sherlock/settings.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/sherlock.cpp | 2 | ||||
-rw-r--r-- | engines/sherlock/talk.cpp | 8 | ||||
-rw-r--r-- | engines/sherlock/talk.h | 4 | ||||
-rw-r--r-- | engines/sherlock/user_interface.cpp | 150 | ||||
-rw-r--r-- | engines/sherlock/user_interface.h | 96 |
8 files changed, 173 insertions, 120 deletions
diff --git a/engines/sherlock/inventory.cpp b/engines/sherlock/inventory.cpp index 1997807d15..397575dfd9 100644 --- a/engines/sherlock/inventory.cpp +++ b/engines/sherlock/inventory.cpp @@ -274,7 +274,8 @@ void Inventory::drawInventory(int flag) { screen._backBuffer = &screen._backBuffer1; } - ui._oldUse = -1; + assert(IS_SERRATED_SCALPEL); + ((ScalpelUserInterface *)_vm->_ui)->_oldUse = -1; } /** @@ -356,31 +357,6 @@ void Inventory::highlight(int index, byte color) { } /** - * Support method for updating the screen - */ -void Inventory::doInvJF() { - Screen &screen = *_vm->_screen; - Talk &talk = *_vm->_talk; - UserInterface &ui = *_vm->_ui; - - ui._invLookFlag = true; - freeInv(); - - ui._infoFlag = true; - ui.clearInfo(); - - screen._backBuffer2.blitFrom(screen._backBuffer1, Common::Point(0, CONTROLS_Y), - Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - ui.examine(); - - if (!talk._talkToAbort) { - screen._backBuffer2.blitFrom((*ui._controlPanel)[0]._frame, - Common::Point(0, CONTROLS_Y)); - loadInv(); - } -} - -/** * Adds a shape from the scene to the player's inventory */ int Inventory::putNameInInventory(const Common::String &name) { diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h index eb5aebdd7c..5b9374d7a7 100644 --- a/engines/sherlock/inventory.h +++ b/engines/sherlock/inventory.h @@ -95,8 +95,6 @@ public: void highlight(int index, byte color); - void doInvJF(); - int putNameInInventory(const Common::String &name); int putItemInInventory(Object &obj); diff --git a/engines/sherlock/settings.cpp b/engines/sherlock/settings.cpp index ffa1f056de..73c99bfa82 100644 --- a/engines/sherlock/settings.cpp +++ b/engines/sherlock/settings.cpp @@ -223,9 +223,10 @@ void Settings::show(SherlockEngine *vm) { Screen &screen = *vm->_screen; Sound &sound = *vm->_sound; Talk &talk = *vm->_talk; - UserInterface &ui = *vm->_ui; + ScalpelUserInterface &ui = *(ScalpelUserInterface *)vm->_ui; bool updateConfig = false; + assert(vm->getGameID() == GType_SerratedScalpel); Settings settings(vm); settings.drawInteface(false); diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index eea3dcb867..80a4383bdf 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -89,7 +89,7 @@ void SherlockEngine::initialize() { _screen = new Screen(this); _sound = new Sound(this, _mixer); _talk = new Talk(this); - _ui = new UserInterface(this); + _ui = UserInterface::init(this); // Load game settings loadConfig(); diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index d656431823..c67b98b35e 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -193,9 +193,11 @@ void Talk::talkTo(const Common::String &filename) { while (!_sequenceStack.empty()) pullSequence(); - // Restore any pressed button - if (!ui._windowOpen && savedMode != STD_MODE) - ui.restoreButton(savedMode - 1); + if (IS_SERRATED_SCALPEL) { + // Restore any pressed button + if (!ui._windowOpen && savedMode != STD_MODE) + ((ScalpelUserInterface *)_vm->_ui)->restoreButton(savedMode - 1); + } // Clear the ui counter so that anything displayed on the info line // before the window was opened isn't cleared diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h index b1a735827c..5c87d793f3 100644 --- a/engines/sherlock/talk.h +++ b/engines/sherlock/talk.h @@ -120,10 +120,10 @@ struct TalkSequences { }; class SherlockEngine; -class UserInterface; +class ScalpelUserInterface; class Talk { - friend class UserInterface; + friend class ScalpelUserInterface; private: Common::Array<TalkSequences> STILL_SEQUENCES; Common::Array<TalkSequences> TALK_SEQUENCES; 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 diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h index 2ff60715e3..acbb0c0ed0 100644 --- a/engines/sherlock/user_interface.h +++ b/engines/sherlock/user_interface.h @@ -61,31 +61,64 @@ extern const char *const PRESS_KEY_TO_CONTINUE; class SherlockEngine; class Inventory; class Talk; -class UserInterface; class UserInterface { +protected: + SherlockEngine *_vm; + + UserInterface(SherlockEngine *vm); +public: + MenuMode _menuMode; + int _menuCounter; + bool _infoFlag; + bool _windowOpen; + bool _endKeyActive; + int _invLookFlag; + int _windowStyle; + bool _helpStyle; + Common::Rect _windowBounds; + bool _lookScriptFlag; + + // TODO: Not so sure these should be in the base class. May want to refactor them to SherlockEngine, or refactor + // various Scalpel dialogs to keep their own private state of key/selections + int _key, _oldKey; + int _selector, _oldSelector; + int _temp, _oldTemp; + int _temp1; + int _lookHelp; +public: + static UserInterface *init(SherlockEngine *vm); + + virtual void reset() {} + virtual void drawInterface(int bufferNum = 3) {} + virtual void handleInput() {} + + virtual void doInvJF() {} + virtual void summonWindow(const Surface &bgSurface, bool slideUp = true) {} + virtual void summonWindow(bool slideUp = true, int height = CONTROLS_Y) {} + virtual void banishWindow(bool slideUp = true) {} + virtual void clearInfo() {} + virtual void clearWindow() {} + + virtual void printObjectDesc() {} +}; + +class ScalpelUserInterface: public UserInterface { friend class Inventory; friend class Settings; friend class Talk; private: - SherlockEngine *_vm; ImageFile *_controlPanel; ImageFile *_controls; int _bgFound; int _oldBgFound; int _keycode; - int _lookHelp; int _help, _oldHelp; - int _key, _oldKey; - int _temp, _oldTemp; int _oldLook; bool _keyboardInput; bool _pause; int _cNum; - int _selector, _oldSelector; Common::String _cAnimStr; - bool _lookScriptFlag; - Common::Rect _windowBounds; Common::String _descStr; int _find; int _oldUse; @@ -114,39 +147,38 @@ private: void checkUseAction(const UseType *use, const Common::String &invName, const char *const messages[], int objNum, int giveMode); void checkAction(ActionType &action, const char *const messages[], int objNum); + + void printObjectDesc(const Common::String &str, bool firstTime); public: - MenuMode _menuMode; - int _menuCounter; - bool _infoFlag; - bool _windowOpen; - bool _endKeyActive; - int _invLookFlag; - int _temp1; - int _windowStyle; - bool _helpStyle; -public: - UserInterface(SherlockEngine *vm); - ~UserInterface(); + ScalpelUserInterface(SherlockEngine *vm); + ~ScalpelUserInterface(); - void reset(); + void whileMenuCounter(); - void drawInterface(int bufferNum = 3); + void restoreButton(int num); +public: + virtual void reset(); - void handleInput(); + virtual void handleInput(); - void clearInfo(); - void clearWindow(); + virtual void drawInterface(int bufferNum = 3); - void whileMenuCounter(); + virtual void doInvJF(); - void printObjectDesc(const Common::String &str, bool firstTime); - void printObjectDesc(); + virtual void summonWindow(const Surface &bgSurface, bool slideUp = true); + virtual void summonWindow(bool slideUp = true, int height = CONTROLS_Y); + virtual void banishWindow(bool slideUp = true); + virtual void clearInfo(); + virtual void clearWindow(); - void summonWindow(const Surface &bgSurface, bool slideUp = true); - void summonWindow(bool slideUp = true, int height = CONTROLS_Y); - void banishWindow(bool slideUp = true); + virtual void printObjectDesc(); +}; - void restoreButton(int num); +class TattooUserInterface : public UserInterface { +public: + TattooUserInterface(SherlockEngine *vm); +public: + virtual void handleInput(); }; } // End of namespace Sherlock |