diff options
author | Paul Gilbert | 2015-03-23 21:52:20 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-03-23 21:52:20 -0400 |
commit | 73de00b72f002c09c173226e85b0f96f35551d10 (patch) | |
tree | da46fad2255d0258988ed3dc272ea81ee524c7e6 /engines/sherlock | |
parent | 73085bf57034adc2dbf5994ce2c6930b416eee7d (diff) | |
download | scummvm-rg350-73de00b72f002c09c173226e85b0f96f35551d10.tar.gz scummvm-rg350-73de00b72f002c09c173226e85b0f96f35551d10.tar.bz2 scummvm-rg350-73de00b72f002c09c173226e85b0f96f35551d10.zip |
SHERLOCK: Implemented UserInterface::handleInput
Diffstat (limited to 'engines/sherlock')
-rw-r--r-- | engines/sherlock/people.cpp | 4 | ||||
-rw-r--r-- | engines/sherlock/people.h | 4 | ||||
-rw-r--r-- | engines/sherlock/scene.cpp | 22 | ||||
-rw-r--r-- | engines/sherlock/scene.h | 2 | ||||
-rw-r--r-- | engines/sherlock/sherlock.cpp | 2 | ||||
-rw-r--r-- | engines/sherlock/talk.cpp | 4 | ||||
-rw-r--r-- | engines/sherlock/talk.h | 2 | ||||
-rw-r--r-- | engines/sherlock/user_interface.cpp | 185 | ||||
-rw-r--r-- | engines/sherlock/user_interface.h | 16 |
9 files changed, 237 insertions, 4 deletions
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp index 91689e296c..8a8dcb5245 100644 --- a/engines/sherlock/people.cpp +++ b/engines/sherlock/people.cpp @@ -311,4 +311,8 @@ void People::walkToCoords(const Common::Point &destPos, int destDir) { warning("TODO: walkToCoords"); } +void People::goAllTheWay() { + // TODO +} + } // End of namespace Sherlock diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h index de84675e66..8d1953ee20 100644 --- a/engines/sherlock/people.h +++ b/engines/sherlock/people.h @@ -59,7 +59,6 @@ private: Sprite &_player; bool _walkLoaded; int _oldWalkSequence; - bool _allowWalkAbort; public: Common::Point _walkDest; Common::Stack<Common::Point> _walkTo; @@ -67,6 +66,7 @@ public: bool _portraitLoaded; Object _portrait; bool _clearingThePortrait; + bool _allowWalkAbort; public: People(SherlockEngine *vm); ~People(); @@ -86,6 +86,8 @@ public: void gotoStand(Sprite &sprite); void walkToCoords(const Common::Point &destPos, int destDir); + + void goAllTheWay(); }; } // End of namespace Sherlock diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index 6e09693807..95e8355957 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -1427,5 +1427,27 @@ int Scene::findBgShape(const Common::Rect &r) { return -1; } +/** + * Checks to see if the given position in the scene belongs to a given zone type. + * If it is, the zone is activated and used just like a TAKL zone or aFLAG_SET zone. + */ +int Scene::checkForZones(const Common::Point &pt, int zoneType) { + int matches = 0; + + for (uint idx = 0; idx < _bgShapes.size(); ++idx) { + Object &o = _bgShapes[idx]; + if ((o._aType == zoneType && o._type != INVALID) && o._type != HIDDEN) { + Common::Rect r = o._type == NO_SHAPE ? o.getNoShapeBounds() : o.getNewBounds(); + + if (r.contains(pt)) { + ++matches; + o.setFlagsAndToggles(); + _vm->_talk->talkTo(o._use[0]._target); + } + } + } + + return matches; +} } // End of namespace Sherlock diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index 785ed63106..1a9fe7b02c 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -177,6 +177,8 @@ public: void clearInfo(); int findBgShape(const Common::Rect &r); + + int checkForZones(const Common::Point &pt, int zoneType); }; } // End of namespace Sherlock diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index eea40f33a6..a9de32972f 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -138,8 +138,6 @@ void SherlockEngine::sceneLoop() { * Handle all player input */ void SherlockEngine::handleInput() { - bool personFound; - _events->pollEventsAndWait(); // See if a key or mouse button is pressed diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index 4c10b7b7ef..ff71d37a2f 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -34,6 +34,10 @@ void Talk::talkTo(const Common::String &name) { // TODO } +void Talk::talk(int objNum) { + // TODO +} + /** * Clear loaded talk data */ diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h index fc73994cc6..9359b77e87 100644 --- a/engines/sherlock/talk.h +++ b/engines/sherlock/talk.h @@ -51,6 +51,8 @@ public: void talkTo(const Common::String &name); + void talk(int objNum); + void freeTalkVars(); }; 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 diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h index 4a98a5be89..d312ff919c 100644 --- a/engines/sherlock/user_interface.h +++ b/engines/sherlock/user_interface.h @@ -62,6 +62,8 @@ private: ImageFile *_controls; int _oldLook; bool _keyboardInput; + int _invMode; + bool _pause; private: void depressButton(int num); @@ -70,6 +72,20 @@ private: void pushButton(int num); void toggleButton(int num); + + void examine(); + + void lookScreen(const Common::Point &pt); + + void lookInv(); + + void doEnvControl(); + void doInvControl(); + void doLookControl(); + void doMainControl(); + void doMiscControl(int allowed); + void doPickControl(); + void doTalkControl(); public: MenuMode _menuMode; int _menuCounter; |