diff options
author | Paul Gilbert | 2014-03-22 18:26:41 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-03-22 18:26:41 -0400 |
commit | a7c4fc7e234f604923aae0d08e03c6b8268688f4 (patch) | |
tree | b077262902699d354dca91edd3ec592a0b8edd08 | |
parent | 83a8ec14717b8b3c8ec2dced8465905f8c1c233c (diff) | |
download | scummvm-rg350-a7c4fc7e234f604923aae0d08e03c6b8268688f4.tar.gz scummvm-rg350-a7c4fc7e234f604923aae0d08e03c6b8268688f4.tar.bz2 scummvm-rg350-a7c4fc7e234f604923aae0d08e03c6b8268688f4.zip |
MADS: In progress implementing ScreenObjects::elementHighlighted
-rw-r--r-- | engines/mads/scene.cpp | 3 | ||||
-rw-r--r-- | engines/mads/screen.cpp | 135 | ||||
-rw-r--r-- | engines/mads/screen.h | 6 | ||||
-rw-r--r-- | engines/mads/user_interface.cpp | 46 | ||||
-rw-r--r-- | engines/mads/user_interface.h | 7 |
5 files changed, 185 insertions, 12 deletions
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index e01720f788..e357f8b1ad 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -337,7 +337,8 @@ void Scene::doFrame() { CursorType cursorId = CURSOR_ARROW; if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && _vm->_game->_screenObjects._category == CAT_HOTSPOT) { - int idx = _vm->_game->_screenObjects._selectedObject - _vm->_game->_screenObjects._hotspotsIndex; + int idx = _vm->_game->_screenObjects._selectedObject - + _userInterface._categoryIndexes[CAT_HOTSPOT - 1]; assert(idx >= 0); if (idx >= (int)_hotspots.size()) { diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp index 3565c1ac79..dac61d5bf1 100644 --- a/engines/mads/screen.cpp +++ b/engines/mads/screen.cpp @@ -262,7 +262,6 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) { _newDescId = 0; _released = false; _uiCount = 0; - _hotspotsIndex = 0; _selectedObject = -1; _scrollerY = -1; _milliTime = 0; @@ -302,7 +301,7 @@ void ScreenObjects::check(bool scanFlag) { && scene._userInterface._category != CAT_NONE) { _released = true; if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) { - scene._userInterface.elementHighlighted(); + elementHighlighted(); } scene._action.checkActionAtMousePos(); @@ -314,7 +313,7 @@ void ScreenObjects::check(bool scanFlag) { if (!_vm->_events->_mouseButtons || _vm->_easyMouse) { if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) { - scene._userInterface.elementHighlighted(); + elementHighlighted(); } } @@ -448,6 +447,136 @@ void ScreenObjects::checkScroller() { _objectY = userInterface._objectY; } +void ScreenObjects::elementHighlighted() { + Scene &scene = _vm->_game->_scene; + UserInterface &userInterface = scene._userInterface; + Common::Array<int> &invList = _vm->_game->_objects._inventoryList; + MADSAction &action = scene._action; + int varA; + int topIndex; + int *var6; + int var4; + int index, indexEnd; + int var8 = 0; + int uiCount; + + switch (userInterface._category) { + case CAT_ACTION: + index = 10; + indexEnd = 9; + varA = 5; + topIndex = 0; + var6 = !_v7FECA ? &userInterface._v1A : &userInterface._selectedActionIndex; + + if (_v7FECA && userInterface._selectedItemVocabIdx >= 0) + userInterface.drawInventory(3, -1, &userInterface._selectedItemVocabIdx); + + var4 = _released && !_v7FECA ? 1 : 0; + break; + + case CAT_INV_LIST: + userInterface.scrollInventory(); + + index = MIN((int)invList.size() - userInterface._inventoryTopIndex, 5); + indexEnd = invList.size() - 1; + varA = 0; + topIndex = userInterface._inventoryTopIndex; + var6 = &userInterface._v1C; + var4 = (!_released || (_vm->_events->_mouseButtons && action._v83338 == 1)) ? 0 : 1; + break; + + case CAT_INV_VOCAB: + if (userInterface._selectedInvIndex >= 0) { + InventoryObject &invObject = _vm->_game->_objects.getItem( + userInterface._selectedInvIndex); + index = invObject._vocabCount; + indexEnd = index - 1; + } else { + index = 0; + } + + varA = 0; + topIndex = 0; + var6 = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._v1E; + + if (_v7FECA && userInterface._selectedActionIndex >= 0) + userInterface.drawInventory(1, -1, &userInterface._selectedActionIndex); + + var4 = _released && !_v7FECA ? 1 : 0; + break; + + case CAT_INV_ANIM: + index = 1; + indexEnd = invList.size() - 1; + varA = 0; + topIndex = userInterface._selectedInvIndex; + var6 = &var8; + var4 = -1; + break; + + case CAT_TALK_ENTRY: + uiCount = size() - _uiCount; + index = scene._hotspots.size(); + indexEnd = index - 1; + varA = 0; + topIndex = 0; + var6 = &var8; + var4 = -1; + break; + + default: + index = 0; + for (int idx = 0; idx < 5; ++idx) { + if (!userInterface._talkStrings[idx].empty()) + ++index; + } + + indexEnd = index - 1; + varA = 0; + topIndex = 0; + var6 = &userInterface._v1A; + var4 = -1; + break; + } + + int newIndex = -1; + int catIndex = userInterface._categoryIndexes[userInterface._category - 1]; + int newY = 0; + int var1E = 0; + + for (int idx = 0; idx < index & newIndex < 0; ++idx) { + warning("TODO"); + } + + if (newIndex == -1 && index > 0 && !var4) { + if (_vm->_events->currentPos().y <= newY) { + newIndex = 0; + if (varA && _vm->_events->currentPos().x >= var1E) + newIndex = varA; + } else { + newIndex = index - 1; + } + } + + if (newIndex >= 0) + newIndex = MIN(newIndex + topIndex, indexEnd); + + _vm->_game->_scene._highlightedHotspot = newIndex; + + if (_category == CAT_INV_LIST || _category == CAT_INV_ANIM) { + if (action._v83338 == 1 && newIndex >= 0 && _released && + (!_vm->_events->_mouseReleased || !_vm->_easyMouse)) + newIndex = -1; + } + + if (_released && !_vm->_game->_screenObjects._v7FECA && + (_vm->_events->_mouseReleased || !_vm->_easyMouse)) + newIndex = -1; + + if (_category != CAT_HOTSPOT && _category != CAT_INV_ANIM) + userInterface.drawInventory(_category, newIndex, var6); +} + /*------------------------------------------------------------------------*/ ScreenSurface::ScreenSurface() { diff --git a/engines/mads/screen.h b/engines/mads/screen.h index c8534a0906..1d1e6d34f0 100644 --- a/engines/mads/screen.h +++ b/engines/mads/screen.h @@ -158,7 +158,6 @@ public: int _currentDescId; bool _released; int _uiCount; - int _hotspotsIndex; uint32 _milliTime; bool _eventFlag; @@ -175,6 +174,11 @@ public: /** */ void check(bool scanFlag); + + /** + * Handle element being highlighted on the screen + */ + void elementHighlighted(); }; class ScreenSurface : public MSurface { diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index 4dba127d47..cae5c116d2 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -188,6 +188,8 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm), _uiSlots(vm) { _invSpritesIndex = -1; _invFrameNumber = 1; + _scrollMilli = 0; + _scrollFlag = false; _category = CAT_NONE; _inventoryTopIndex = 0; _objectY = 0; @@ -200,6 +202,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm), _v1E = -1; _dirtyAreas.resize(50); _inventoryChanged = false; + Common::fill(&_categoryIndexes[0], &_categoryIndexes[7], 0); // Map the user interface to the bottom of the game's screen surface byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT); @@ -272,10 +275,6 @@ void UserInterface::setup(int id) { scene._dynamicHotspots.refresh(); } -void UserInterface::elementHighlighted() { - warning("TODO: UserInterface::elementHighlighted"); -} - void UserInterface::drawTextElements() { if (_vm->_game->_screenObjects._v832EC) { drawTalkList(); @@ -415,6 +414,7 @@ void UserInterface::loadElements() { } // Set up actions + _categoryIndexes[CAT_ACTION - 1] = _vm->_game->_screenObjects.size() + 1; for (int idx = 0; idx < 10; ++idx) { getBounds(CAT_ACTION, idx, bounds); moveRect(bounds); @@ -423,6 +423,7 @@ void UserInterface::loadElements() { } // Set up inventory list + _categoryIndexes[CAT_INV_LIST - 1] = _vm->_game->_screenObjects.size() + 1; for (int idx = 0; idx < 5; ++idx) { getBounds(CAT_INV_LIST, idx, bounds); moveRect(bounds); @@ -431,6 +432,7 @@ void UserInterface::loadElements() { } // Set up the inventory vocab list + _categoryIndexes[CAT_INV_VOCAB - 1] = _vm->_game->_screenObjects.size() + 1; for (int idx = 0; idx < 5; ++idx) { getBounds(CAT_INV_VOCAB, idx, bounds); moveRect(bounds); @@ -439,12 +441,13 @@ void UserInterface::loadElements() { } // Set up the inventory item picture + _categoryIndexes[CAT_INV_ANIM - 1] = _vm->_game->_screenObjects.size() + 1; _vm->_game->_screenObjects.add(Common::Rect(160, 159, 231, 194), LAYER_GUI, CAT_INV_ANIM, 0); } if (!_vm->_game->_screenObjects._v832EC || _vm->_game->_screenObjects._v832EC == 2) { - _vm->_game->_screenObjects._hotspotsIndex = _vm->_game->_screenObjects.size(); + _categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size(); for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) { Hotspot &hs = scene._hotspots[hotspotIdx]; _vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx); @@ -453,6 +456,7 @@ void UserInterface::loadElements() { if (_vm->_game->_screenObjects._v832EC == 1) { // setup areas for talk entries + _categoryIndexes[CAT_TALK_ENTRY - 1] = _vm->_game->_screenObjects.size() + 1; for (int idx = 0; idx < 5; ++idx) { getBounds(CAT_TALK_ENTRY, idx, bounds); moveRect(bounds); @@ -644,4 +648,36 @@ void UserInterface::scrollerChanged() { warning("TODO: scrollerChanged"); } +void UserInterface::scrollInventory() { + Common::Array<int> &invList = _vm->_game->_objects._inventoryList; + + if (_vm->_events->_mouseButtons) { + int yp = _vm->_events->currentPos().y; + if (yp < MADS_SCENE_HEIGHT || yp == (MADS_SCREEN_HEIGHT - 1)) { + uint32 timeDiff = _scrollFlag ? 100 : 380; + uint32 currentMilli = g_system->getMillis(); + _vm->_game->_screenObjects._v8332A = -1; + + if (currentMilli >= (_scrollMilli + timeDiff)) { + _scrollMilli = currentMilli; + _scrollFlag = true; + + if (yp == (MADS_SCREEN_HEIGHT - 1)) { + if (_inventoryTopIndex < (invList.size() - 1)) { + ++_inventoryTopIndex; + _inventoryChanged = true; + } + } else { + if (_inventoryTopIndex > 0) { + --_inventoryTopIndex; + _inventoryChanged = true; + } + } + } + } + } + + _vm->_game->_screenObjects._v8332A = 0; +} + } // End of namespace MADS diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index 06f1e70975..abb4619cf5 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -79,6 +79,8 @@ private: MADSEngine *_vm; int _invSpritesIndex; int _invFrameNumber; + uint32 _scrollMilli; + bool _scrollFlag; /** * Loads the elements of the user interface @@ -143,6 +145,7 @@ public: int _v1C; int _v1E; bool _inventoryChanged; + int _categoryIndexes[8]; Common::StringArray _talkStrings; Common::Array<int> _talkIds; public: @@ -161,8 +164,6 @@ public: */ void setup(int id); - void elementHighlighted(); - void drawTextElements(); void setBounds(const Common::Rect &r); @@ -193,6 +194,8 @@ public: void drawInventory(int v1, int v2, int *v3); void scrollerChanged(); + + void scrollInventory(); }; } // End of namespace MADS |