diff options
author | Paul Gilbert | 2014-03-22 12:02:17 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-03-22 12:02:17 -0400 |
commit | 7cdaa9648c0c49345460a0ab194a4ca97869e6bd (patch) | |
tree | 9b71e2955f2ba676ae7f5b723e7d4095e39f8dfd | |
parent | 4fec23ad1cc58911ceb88f259c7721a77224982d (diff) | |
download | scummvm-rg350-7cdaa9648c0c49345460a0ab194a4ca97869e6bd.tar.gz scummvm-rg350-7cdaa9648c0c49345460a0ab194a4ca97869e6bd.tar.bz2 scummvm-rg350-7cdaa9648c0c49345460a0ab194a4ca97869e6bd.zip |
MADS: Implemented ScreenObjects::checkScroller
-rw-r--r-- | engines/mads/events.cpp | 7 | ||||
-rw-r--r-- | engines/mads/events.h | 2 | ||||
-rw-r--r-- | engines/mads/screen.cpp | 94 | ||||
-rw-r--r-- | engines/mads/screen.h | 13 | ||||
-rw-r--r-- | engines/mads/user_interface.cpp | 8 | ||||
-rw-r--r-- | engines/mads/user_interface.h | 4 |
6 files changed, 118 insertions, 10 deletions
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp index 90393d665f..fe2a2532c5 100644 --- a/engines/mads/events.cpp +++ b/engines/mads/events.cpp @@ -41,9 +41,10 @@ EventsManager::EventsManager(MADSEngine *vm) { _mouseClicked = false; _mouseReleased = false; _mouseButtons = 0; + _vCC = 0; _vD2 = 0; _vD4 = 0; - _vD6 = 0; + _mouseMoved = false; _vD8 = 0; } @@ -100,6 +101,7 @@ void EventsManager::freeCursors() { void EventsManager::pollEvents() { checkForNextFrameCounter(); + _mouseMoved = false; Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { @@ -130,9 +132,12 @@ void EventsManager::pollEvents() { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONUP: _mouseClicked = false; + _mouseMoved = true; return; case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; + _currentPos = event.mouse; + _mouseMoved = true; break; default: break; diff --git a/engines/mads/events.h b/engines/mads/events.h index 17224227c6..219af20c2a 100644 --- a/engines/mads/events.h +++ b/engines/mads/events.h @@ -62,7 +62,7 @@ public: int _vCC; int _vD2; int _vD4; - int _vD6; + bool _mouseMoved; int _vD8; public: /** diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp index 975ec7720b..3565c1ac79 100644 --- a/engines/mads/screen.cpp +++ b/engines/mads/screen.cpp @@ -251,17 +251,22 @@ ScreenObject::ScreenObject() { /*------------------------------------------------------------------------*/ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) { + _objectY = -1; _v8333C = false; _v832EC = 0; _v7FECA = 0; _v7FED6 = 0; _v8332A = 0; _category = CAT_NONE; - _objectIndex = 0; + _newDescId = 0; + _newDescId = 0; _released = false; _uiCount = 0; _hotspotsIndex = 0; _selectedObject = -1; + _scrollerY = -1; + _milliTime = 0; + _eventFlag = false; } void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) { @@ -282,11 +287,13 @@ void ScreenObjects::check(bool scanFlag) { if (!_vm->_events->_mouseButtons || _v832EC) _v7FECA = false; - if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) { + if ((_vm->_events->_mouseMoved || _vm->_game->_scene._userInterface._scrollerY + || _v8332A || _v8333C) && scanFlag) { + _category = CAT_NONE; _selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI); if (_selectedObject > 0) { _category = (ScrCategory)((*this)[_selectedObject - 1]._category & 7); - _objectIndex = (*this)[_selectedObject - 1]._descId; + _newDescId = (*this)[_selectedObject - 1]._descId; } // Handling for easy mouse @@ -297,6 +304,8 @@ void ScreenObjects::check(bool scanFlag) { if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) { scene._userInterface.elementHighlighted(); } + + scene._action.checkActionAtMousePos(); } _released = _vm->_events->_mouseReleased; @@ -321,7 +330,7 @@ void ScreenObjects::check(bool scanFlag) { } if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY) - proc1(); + checkScroller(); if (_vm->_events->_mouseButtons || _vm->_easyMouse) scene._action.set(); @@ -362,8 +371,81 @@ int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) { return 0; } -void ScreenObjects::proc1() { - warning("TODO: ScreenObjects::proc1"); +void ScreenObjects::checkScroller() { + UserInterface &userInterface = _vm->_game->_scene._userInterface; + Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList; + + if (_v832EC) + return; + + userInterface._scrollerY = 0; + + if ((_category == CAT_INV_SCROLLER || (_scrollerY == 3 && _vm->_events->_vD4)) + && (_vm->_events->_vD4 || _vm->_easyMouse)) { + if ((_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4)) + && _category == CAT_INV_SCROLLER) { + _currentDescId = _newDescId; + } + } + + if (_newDescId == _currentDescId || _scrollerY == 3) { + _vm->_game->_scene._userInterface._scrollerY = _currentDescId; + uint32 currentMilli = g_system->getMillis(); + uint32 timeInc = _eventFlag ? 100 : 380; + + if (_vm->_events->_vD2 || (_milliTime + timeInc) <= currentMilli) { + _eventFlag = _vm->_events->_vD2 < 1; + _milliTime = currentMilli; + + switch (_currentDescId) { + case 1: + // Scroll up + if (userInterface._inventoryTopIndex > 0 && inventoryList.size() > 0) { + --userInterface._inventoryTopIndex; + userInterface._inventoryChanged = true; + } + break; + + case 2: + // Scroll down + if (userInterface._inventoryTopIndex < (int)inventoryList.size() && + inventoryList.size() > 0) { + ++userInterface._inventoryTopIndex; + userInterface._inventoryChanged = true; + } + break; + + case 3: { + // Inventory slider + int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17) + * inventoryList.size() / 10; + if (newIndex >= (int)inventoryList.size()) + newIndex = inventoryList.size() - 1; + + if (inventoryList.size() > 0) { + userInterface._inventoryChanged = newIndex != userInterface._inventoryTopIndex; + userInterface._inventoryTopIndex = newIndex; + } + break; + } + + default: + break; + } + + if (userInterface._inventoryChanged) { + int dummy; + userInterface.drawInventory(2, 0, &dummy); + } + } + } + + if (userInterface._scrollerY != _scrollerY || + userInterface._objectY != _objectY) + userInterface.scrollerChanged(); + + _scrollerY = userInterface._scrollerY; + _objectY = userInterface._objectY; } /*------------------------------------------------------------------------*/ diff --git a/engines/mads/screen.h b/engines/mads/screen.h index c1e51cb193..c8534a0906 100644 --- a/engines/mads/screen.h +++ b/engines/mads/screen.h @@ -136,10 +136,16 @@ public: class ScreenObjects : public Common::Array<ScreenObject> { private: MADSEngine *_vm; + int _objectY; + int _scrollerY; int scanBackwards(const Common::Point &pt, int layer); - void proc1(); + /** + * Checks for the mouse being on the user interface inventory scroller, + * and update the scroller and selected inventory object as necessary + */ + void checkScroller(); public: int _v832EC; int _v7FECA; @@ -148,10 +154,13 @@ public: int _v8333C; int _selectedObject; ScrCategory _category; - int _objectIndex; + int _newDescId; + int _currentDescId; bool _released; int _uiCount; int _hotspotsIndex; + uint32 _milliTime; + bool _eventFlag; /* * Constructor diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index baec13318e..4dba127d47 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -636,4 +636,12 @@ void UserInterface::selectObject(int invIndex) { warning("TODO: selectObject"); } +void UserInterface::drawInventory(int v1, int v2, int *v3) { + warning("TODO: drawInventory"); +} + +void UserInterface::scrollerChanged() { + warning("TODO: scrollerChanged"); +} + } // End of namespace MADS diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index cd3ac1dd27..06f1e70975 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -189,6 +189,10 @@ public: * @param invIndex Index in the inventory list of the item to select */ void selectObject(int invIndex); + + void drawInventory(int v1, int v2, int *v3); + + void scrollerChanged(); }; } // End of namespace MADS |