From f0458042f212e10155e4206312e46ce0beb7c06f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 Apr 2014 22:27:11 -0400 Subject: MADS: In progress cleanup of checkActionAtMousePos --- engines/mads/action.cpp | 43 ++++++++++++++++++++++--------------------- engines/mads/action.h | 9 +++++++-- engines/mads/scene.cpp | 1 - engines/mads/scene.h | 1 - engines/mads/screen.cpp | 4 ++-- engines/mads/screen.h | 2 +- 6 files changed, 32 insertions(+), 28 deletions(-) (limited to 'engines/mads') diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp index 35e989bf98..7a95e64e04 100644 --- a/engines/mads/action.cpp +++ b/engines/mads/action.cpp @@ -50,18 +50,19 @@ void MADSAction::clear() { _actionMode = ACTIONMODE_NONE; _actionMode2 = ACTIONMODE2_0; _v86F42 = 0; - _v86F4E = 0; + _recentCommandSource = 0; _articleNumber = 0; _lookFlag = false; _v86F4A = 0; _selectedRow = -1; _hotspotId = -1; _v86F3A = -1; - _v86F4C = -1; + _recentCommand = -1; _action._verbId = VERB_NONE; _action._objectNameId = -1; _action._indirectObjectId = -1; _textChanged = true; + _pickedWord = 0; } void MADSAction::appendVocab(int vocabId, bool capitalise) { @@ -355,9 +356,9 @@ void MADSAction::checkActionAtMousePos() { ScreenObjects &screenObjects = _vm->_game->_screenObjects; if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) && - _interAwaiting != 1 && scene._highlightedHotspot >= 0) { - if (_v86F4E == userInterface._category || _v86F4C != scene._highlightedHotspot || - (_interAwaiting != 2 && _interAwaiting != 3)) + _interAwaiting != AWAITING_COMMAND && _pickedWord >= 0) { + if (_recentCommandSource == userInterface._category || _recentCommand != _pickedWord || + (_interAwaiting != AWAITING_THIS && _interAwaiting != 3)) clear(); else if (_selectedRow != 0 || userInterface._category != CAT_COMMAND) scene._lookFlag = false; @@ -408,7 +409,7 @@ void MADSAction::checkActionAtMousePos() { switch (userInterface._category) { case CAT_COMMAND: _actionMode = ACTIONMODE_VERB; - _selectedRow = scene._highlightedHotspot; + _selectedRow = _pickedWord; if (_selectedRow >= 0) { _flags1 = scene._verbList[_selectedRow]._action1; _flags2 = scene._verbList[_selectedRow]._action2; @@ -417,7 +418,7 @@ void MADSAction::checkActionAtMousePos() { case CAT_INV_VOCAB: _actionMode = ACTIONMODE_OBJECT; - _selectedRow = scene._highlightedHotspot; + _selectedRow = _pickedWord; if (_selectedRow < 0) { _hotspotId = -1; _actionMode2 = ACTIONMODE2_0; @@ -439,12 +440,12 @@ void MADSAction::checkActionAtMousePos() { _selectedRow = -1; _actionMode = ACTIONMODE_NONE; _actionMode2 = ACTIONMODE2_4; - _hotspotId = scene._highlightedHotspot; + _hotspotId = _pickedWord; break; case CAT_TALK_ENTRY: _actionMode = ACTIONMODE_TALK; - _selectedRow = scene._highlightedHotspot; + _selectedRow = _pickedWord; break; default: @@ -460,7 +461,7 @@ void MADSAction::checkActionAtMousePos() { case CAT_INV_ANIM: // TODO: We may not need a separate ActionMode2 enum _actionMode2 = (ActionMode2)userInterface._category; - _hotspotId = scene._highlightedHotspot; + _hotspotId = _pickedWord; break; default: break; @@ -473,7 +474,7 @@ void MADSAction::checkActionAtMousePos() { case CAT_HOTSPOT: case CAT_INV_ANIM: _v86F42 = userInterface._category; - _v86F3A = scene._highlightedHotspot; + _v86F3A = _pickedWord; break; default: break; @@ -492,8 +493,8 @@ void MADSAction::leftClick() { bool abortFlag = false; if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) && - _interAwaiting != 1 && scene._highlightedHotspot >= 0 && - _v86F4E == userInterface._category && _v86F4C == scene._highlightedHotspot && + _interAwaiting != 1 && _pickedWord >= 0 && + _recentCommandSource == userInterface._category && _recentCommand == _pickedWord && (_interAwaiting == 2 || userInterface._category == CAT_INV_VOCAB)) { abortFlag = true; if (_selectedRow == 0 && userInterface._category == CAT_COMMAND) { @@ -519,16 +520,16 @@ void MADSAction::leftClick() { _selectedAction = -1; } else { - _v86F4C = _selectedRow; - _v86F4E = _actionMode; + _recentCommand = _selectedRow; + _recentCommandSource = _actionMode; _interAwaiting = AWAITING_THIS; } } break; case CAT_INV_LIST: - if (scene._highlightedHotspot >= 0) { - userInterface.selectObject(scene._highlightedHotspot); + if (_pickedWord >= 0) { + userInterface.selectObject(_pickedWord); } break; @@ -548,14 +549,14 @@ void MADSAction::leftClick() { _selectedAction = -1; } - _v86F4C = _selectedRow; - _v86F4E = _actionMode; + _recentCommand = _selectedRow; + _recentCommandSource = _actionMode; } break; case CAT_HOTSPOT: - _v86F4C = -1; - _v86F4E = 0; + _recentCommand = -1; + _recentCommandSource = 0; if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT) { scene._customDest = _vm->_events->currentPos() + scene._posAdjust; diff --git a/engines/mads/action.h b/engines/mads/action.h index e7a33230a4..45886c1bca 100644 --- a/engines/mads/action.h +++ b/engines/mads/action.h @@ -105,12 +105,13 @@ public: // Unknown fields int16 _v86F3A; int16 _v86F42; - int16 _v86F4E; + int16 _recentCommandSource; bool _v86F4A; - int16 _v86F4C; + int16 _recentCommand; InterAwaiting _interAwaiting; bool _inProgress; int _v8453A; + int _pickedWord; public: MADSAction(MADSEngine *vm); @@ -123,6 +124,10 @@ public: void checkAction(); bool isAction(int verbId, int objectNameId = 0, int indirectObjectId = 0); + /** + * Check the result of the current action on the sentence + * with the provision that the action is not yet complete. + */ void checkActionAtMousePos(); /** diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index d37834ab55..97a131a665 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -49,7 +49,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _frameStartTime = 0; _layer = LAYER_GUI; _lookFlag = false; - _highlightedHotspot = 0; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); diff --git a/engines/mads/scene.h b/engines/mads/scene.h index 1b0c9c9388..4e3829b838 100644 --- a/engines/mads/scene.h +++ b/engines/mads/scene.h @@ -124,7 +124,6 @@ public: uint32 _frameStartTime; Layer _layer; bool _lookFlag; - int _highlightedHotspot; Common::Point _customDest; /** diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp index ca7235a14c..f00146e1e2 100644 --- a/engines/mads/screen.cpp +++ b/engines/mads/screen.cpp @@ -350,7 +350,7 @@ void ScreenObjects::check(bool scanFlag) { for (uint idx = 0; idx < uiSlots.size(); ++idx) { UISlot &slot = uiSlots[idx]; - if (slot._flags != IMG_REFRESH && slot._flags > -20 + if (slot._flags != IMG_REFRESH && slot._flags > IMG_UPDATE_ONLY && slot._segmentId != IMG_SPINNING_OBJECT) slot._flags = IMG_ERASE; } @@ -598,7 +598,7 @@ void ScreenObjects::elementHighlighted() { if (newIndex >= 0) newIndex = MIN(newIndex + topIndex, indexEnd); - _vm->_game->_scene._highlightedHotspot = newIndex; + action._pickedWord = newIndex; if (_category == CAT_INV_LIST || _category == CAT_INV_ANIM) { if (action._interAwaiting == 1 && newIndex >= 0 && _released && diff --git a/engines/mads/screen.h b/engines/mads/screen.h index d292a7a7d7..e6e0f285c7 100644 --- a/engines/mads/screen.h +++ b/engines/mads/screen.h @@ -178,7 +178,7 @@ public: void check(bool scanFlag); /** - * Handle element being highlighted on the screen + * Handle an element being highlighted on the screen, and make it active. */ void elementHighlighted(); -- cgit v1.2.3