aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-23 22:11:35 -0400
committerPaul Gilbert2014-03-23 22:11:35 -0400
commit0dfa60ae00428ad83c6b6d19963e2d7352707637 (patch)
treec8df4b5f456b01cde87285968a58a5783661500d /engines
parentce9a15f010d84c8596380eec5226ef22704022e5 (diff)
downloadscummvm-rg350-0dfa60ae00428ad83c6b6d19963e2d7352707637.tar.gz
scummvm-rg350-0dfa60ae00428ad83c6b6d19963e2d7352707637.tar.bz2
scummvm-rg350-0dfa60ae00428ad83c6b6d19963e2d7352707637.zip
MADS: Refactored out and fixed cursor changes for hotspots
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/scene.cpp61
-rw-r--r--engines/mads/scene.h5
2 files changed, 39 insertions, 27 deletions
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: