diff options
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/events.cpp | 6 | ||||
-rw-r--r-- | engines/mads/game.cpp | 11 | ||||
-rw-r--r-- | engines/mads/user_interface.cpp | 90 | ||||
-rw-r--r-- | engines/mads/user_interface.h | 7 |
4 files changed, 73 insertions, 41 deletions
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp index 586ef7cbf3..06c6055f01 100644 --- a/engines/mads/events.cpp +++ b/engines/mads/events.cpp @@ -162,6 +162,12 @@ void EventsManager::pollEvents() { return; case Common::EVENT_KEYUP: return; + case Common::EVENT_WHEELUP: + _pendingKeys.push(Common::KeyState(Common::KEYCODE_PAGEUP)); + return; + case Common::EVENT_WHEELDOWN: + _pendingKeys.push(Common::KeyState(Common::KEYCODE_PAGEDOWN)); + return; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: _mouseClicked = true; diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index 27691d3380..3b8b053fec 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -420,6 +420,7 @@ void Game::handleKeypress(const Common::KeyState &kbd) { } } + Scene &scene = _vm->_game->_scene; switch (kbd.keycode) { case Common::KEYCODE_F1: _vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU; @@ -430,6 +431,16 @@ void Game::handleKeypress(const Common::KeyState &kbd) { case Common::KEYCODE_F7: _vm->_dialogs->_pendingDialog = DIALOG_RESTORE; break; + case Common::KEYCODE_PAGEUP: + scene._userInterface._scrollbarStrokeType = SCROLLBAR_UP; + scene._userInterface.changeScrollBar(); + break; + case Common::KEYCODE_PAGEDOWN: + scene._userInterface._scrollbarStrokeType = SCROLLBAR_DOWN; + scene._userInterface.changeScrollBar(); + break; + + default: break; } diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index 822460d549..929390a073 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -495,7 +495,6 @@ void UserInterface::drawScroller() { void UserInterface::updateInventoryScroller() { ScreenObjects &screenObjects = _vm->_game->_screenObjects; - Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList; if (screenObjects._inputMode != kInputBuildingSentences) return; @@ -518,45 +517,8 @@ void UserInterface::updateInventoryScroller() { _scrollbarQuickly = _vm->_events->_vD2 < 1; _scrollbarMilliTime = currentMilli; - switch (_scrollbarStrokeType) { - case SCROLLBAR_UP: - // Scroll up - if (_inventoryTopIndex > 0 && inventoryList.size() > 0) { - --_inventoryTopIndex; - _inventoryChanged = true; - } - break; - - case SCROLLBAR_DOWN: - // Scroll down - if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) { - ++_inventoryTopIndex; - _inventoryChanged = true; - } - break; - - case SCROLLBAR_ELEVATOR: { - // 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) { - _inventoryChanged = newIndex != _inventoryTopIndex; - _inventoryTopIndex = newIndex; - } - break; - } - - default: - break; - } - - if (_inventoryChanged) { - int dummy; - updateSelection(CAT_INV_LIST, 0, &dummy); - } + // Change the scrollbar and visible inventory list + changeScrollBar(); } } } @@ -569,6 +531,54 @@ void UserInterface::updateInventoryScroller() { _scrollbarOldElevator = _scrollbarElevator; } +void UserInterface::changeScrollBar() { + Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList; + ScreenObjects &screenObjects = _vm->_game->_screenObjects; + + if (screenObjects._inputMode != kInputBuildingSentences) + return; + + switch (_scrollbarStrokeType) { + case SCROLLBAR_UP: + // Scroll up + if (_inventoryTopIndex > 0 && inventoryList.size() > 0) { + --_inventoryTopIndex; + _inventoryChanged = true; + } + break; + + case SCROLLBAR_DOWN: + // Scroll down + if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) { + ++_inventoryTopIndex; + _inventoryChanged = true; + } + break; + + case SCROLLBAR_ELEVATOR: { + // 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) { + _inventoryChanged = newIndex != _inventoryTopIndex; + _inventoryTopIndex = newIndex; + } + break; + } + + default: + break; + } + + if (_inventoryChanged) { + int dummy; + updateSelection(CAT_INV_LIST, 0, &dummy); + } +} + void UserInterface::scrollbarChanged() { Common::Rect r(73, 4, 73 + 9, 4 + 38); _uiSlots.add(r); diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index 89044c9bf1..71c6f64c2a 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -140,7 +140,6 @@ private: bool _scrollFlag; int _noSegmentsActive; int _someSegmentsActive; - ScrollbarActive _scrollbarStrokeType; /** * Loads the elements of the user interface @@ -216,6 +215,7 @@ public: bool _scrollbarQuickly; uint32 _scrollbarMilliTime; int _scrollbarElevator, _scrollbarOldElevator; + ScrollbarActive _scrollbarStrokeType; public: /** * Constructor @@ -275,6 +275,11 @@ public: void updateSelection(ScrCategory category, int newIndex, int *idx); + /** + * Updates the current top visible item of the scrollbar + */ + void changeScrollBar(); + void scrollerChanged(); void scrollInventory(); |