From 0dfa60ae00428ad83c6b6d19963e2d7352707637 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Mar 2014 22:11:35 -0400 Subject: MADS: Refactored out and fixed cursor changes for hotspots --- engines/mads/scene.cpp | 61 ++++++++++++++++++++++++++++---------------------- engines/mads/scene.h | 5 +++++ 2 files changed, 39 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 8360c1e396..1b3143f60e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -340,33 +340,7 @@ void Scene::doFrame() { player.nextFrame(); // Cursor update code - CursorType cursorId = CURSOR_ARROW; - if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && - _vm->_game->_screenObjects._category == CAT_HOTSPOT) { - int idx = _vm->_game->_screenObjects._selectedObject - - _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; - assert(idx >= 0); - - if (idx >= (int)_hotspots.size()) { - idx -= _hotspots.size(); - _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; - } else { - _vm->_events->_newCursorId = _hotspots[idx]._cursor; - } - - cursorId = _vm->_events->_newCursorId == CURSOR_NONE ? - CURSOR_ARROW : _vm->_events->_newCursorId; - } - - if (!player._stepEnabled) - cursorId = CURSOR_WAIT; - if (cursorId >= _vm->_events->_cursorSprites->getCount()) - cursorId = (CursorType)_vm->_events->_cursorSprites->getCount(); - _vm->_events->_newCursorId = cursorId; - - if (cursorId != _vm->_events->_cursorId) { - _vm->_events->setCursor(cursorId); - } + updateCursor(); if (!_vm->_game->_abortTimers) { // Handle any active sequences @@ -562,6 +536,39 @@ void Scene::loadAnimation(const Common::String &resName, int abortTimers) { _activeAnimation->startAnimation(abortTimers); } +void Scene::updateCursor() { + Player &player = _vm->_game->_player; + + CursorType cursorId = CURSOR_ARROW; + if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && + _vm->_game->_screenObjects._category == CAT_HOTSPOT) { + int idx = _vm->_game->_screenObjects._selectedObject - + _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; + assert(idx >= 0); + + if (idx >= (int)_hotspots.size()) { + idx -= _hotspots.size(); + _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; + } else { + idx = _hotspots.size() - idx - 1; + _vm->_events->_newCursorId = _hotspots[idx]._cursor; + } + + cursorId = _vm->_events->_newCursorId == CURSOR_NONE ? + CURSOR_ARROW : _vm->_events->_newCursorId; + } + + if (!player._stepEnabled) + cursorId = CURSOR_WAIT; + if (cursorId >= _vm->_events->_cursorSprites->getCount()) + cursorId = (CursorType)_vm->_events->_cursorSprites->getCount(); + _vm->_events->_newCursorId = cursorId; + + if (cursorId != _vm->_events->_cursorId) { + _vm->_events->setCursor(cursorId); + } +} + void Scene::free() { warning("TODO: Scene::free"); } diff --git a/engines/mads/scene.h b/engines/mads/scene.h index f7d0e56a78..e2eec23477 100644 --- a/engines/mads/scene.h +++ b/engines/mads/scene.h @@ -70,6 +70,11 @@ private: void doSceneStep(); void checkKeyboard(); + + /** + * Checks for a highlighted hotspot, and updates the cursor accordingly + */ + void updateCursor(); protected: MADSEngine *_vm; public: -- cgit v1.2.3