diff options
-rw-r--r-- | engines/draci/game.cpp | 37 | ||||
-rw-r--r-- | engines/draci/mouse.cpp | 16 | ||||
-rw-r--r-- | engines/draci/mouse.h | 4 |
3 files changed, 38 insertions, 19 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index f771c564f0..73a5a34d9a 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -463,16 +463,11 @@ void Game::updateCursor() { if (_loopStatus == kStatusDialogue) return; + bool mouseChanged = false; + // If we are in inventory mode, we do a different kind of updating that handles // inventory items and return early if (_loopStatus == kStatusInventory && _loopSubstatus == kSubstatusOrdinary) { - - if (_currentItem == kNoItem) { - _vm->_mouse->setCursorType(kNormalCursor); - } else { - _vm->_mouse->loadItemCursor(_currentItem); - } - if (_itemUnderCursor != kNoItem) { const GameItem *item = &_items[_itemUnderCursor]; @@ -482,6 +477,14 @@ void Game::updateCursor() { } else { _vm->_mouse->loadItemCursor(_currentItem, true); } + mouseChanged = true; + } + } + if (!mouseChanged) { + if (_currentItem == kNoItem) { + _vm->_mouse->setCursorType(kNormalCursor); + } else { + _vm->_mouse->loadItemCursor(_currentItem); } } @@ -498,14 +501,6 @@ void Game::updateCursor() { _oldObjUnderCursor = _objUnderCursor; } - // Load the appropriate cursor (item image if an item is held or ordinary cursor - // if not) - if (_currentItem == kNoItem) { - _vm->_mouse->setCursorType(kNormalCursor); - } else { - _vm->_mouse->loadItemCursor(_currentItem); - } - // TODO: Handle main menu // If there is no game object under the cursor, try using the room itself @@ -516,6 +511,7 @@ void Game::updateCursor() { } else { _vm->_mouse->loadItemCursor(_currentItem, true); } + mouseChanged = true; } // If there *is* a game object under the cursor, update the cursor image } else { @@ -531,11 +527,22 @@ void Game::updateCursor() { } else { _vm->_mouse->loadItemCursor(_currentItem, true); } + mouseChanged = true; } // If the walking direction *is* set, the game object is a gate, so update // the cursor image to the appropriate arrow. } else { _vm->_mouse->setCursorType((CursorType)obj->_walkDir); + mouseChanged = true; + } + } + // Load the appropriate cursor (item image if an item is held or ordinary cursor + // if not) + if (!mouseChanged) { + if (_currentItem == kNoItem) { + _vm->_mouse->setCursorType(kNormalCursor); + } else { + _vm->_mouse->loadItemCursor(_currentItem); } } } diff --git a/engines/draci/mouse.cpp b/engines/draci/mouse.cpp index f5eb2bbf4d..ae80775898 100644 --- a/engines/draci/mouse.cpp +++ b/engines/draci/mouse.cpp @@ -34,7 +34,7 @@ Mouse::Mouse(DraciEngine *vm) { _y = 0; _lButton = false; _rButton = false; - _cursorType = kNormalCursor; + _cursorType = kUninitializedCursor; _vm = vm; } @@ -90,10 +90,13 @@ void Mouse::setPosition(uint16 x, uint16 y) { } void Mouse::setCursorType(CursorType cur) { + if (cur == getCursorType()) { + return; + } _cursorType = cur; const BAFile *f; - f = _vm->_iconsArchive->getFile(_cursorType); + f = _vm->_iconsArchive->getFile(cur); Sprite sp(f->_data, f->_length, 0, 0, true); CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours); @@ -102,8 +105,15 @@ void Mouse::setCursorType(CursorType cur) { } void Mouse::loadItemCursor(int itemID, bool highlighted) { + int archiveIndex = 2 * itemID + highlighted; + CursorType newCursor = static_cast<CursorType> (kItemCursor + archiveIndex); + if (newCursor == getCursorType()) { + return; + } + _cursorType = newCursor; + const BAFile *f; - f = _vm->_itemImagesArchive->getFile(2 * itemID + highlighted); + f = _vm->_itemImagesArchive->getFile(archiveIndex); Sprite sp(f->_data, f->_length, 0, 0, true); CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours); diff --git a/engines/draci/mouse.h b/engines/draci/mouse.h index 629a7634d5..1dcd988ff5 100644 --- a/engines/draci/mouse.h +++ b/engines/draci/mouse.h @@ -39,7 +39,9 @@ enum CursorType { kArrowCursor4, kDialogueCursor, kHighlightedCursor, - kMainMenuCursor + kMainMenuCursor, + kUninitializedCursor = 100, + kItemCursor // + the index in the BArchive }; class DraciEngine; |