From 2cca520465dd8005aa3ee21b25961afbde227afd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 11:52:48 -0400 Subject: [PATCH] ACCESS: Add new support for mouse wheel for cycling through cursors --- engines/access/events.cpp | 16 ++++++++++++++++ engines/access/events.h | 2 ++ engines/access/room.cpp | 29 ++++++++++++++++++++++++++--- engines/access/room.h | 5 +++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 7366905b0c3b..0a754305b2d1 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -40,6 +40,8 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _frameCounter = 10; _priorFrameTime = 0; _leftButton = _rightButton = false; + _middleButton = false; + _wheelUp = _wheelDown = false; _mouseCol = _mouseRow = 0; _cursorExitFlag = false; } @@ -122,6 +124,8 @@ void EventsManager::pollEvents() { nextFrame(); } + _wheelUp = _wheelDown = false; + Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { switch (event.type) { @@ -158,6 +162,18 @@ void EventsManager::pollEvents() { case Common::EVENT_RBUTTONUP: _rightButton = false; return; + case Common::EVENT_MBUTTONDOWN: + _middleButton = true; + return; + case Common::EVENT_MBUTTONUP: + _middleButton = false; + return; + case Common::EVENT_WHEELUP: + _wheelUp = true; + return; + case Common::EVENT_WHEELDOWN: + _wheelDown = true; + return; default: break; } diff --git a/engines/access/events.h b/engines/access/events.h index 014ff239b92f..6b46086d9a65 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -55,6 +55,8 @@ class EventsManager { CursorType _cursorId; CursorType _normalMouse; bool _leftButton, _rightButton; + bool _middleButton; + bool _wheelUp, _wheelDown; Common::Point _mousePos; int _mouseCol, _mouseRow; bool _cursorExitFlag; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index d4e8886cac0d..a7b619c23848 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -79,7 +79,7 @@ void Room::doRoom() { _vm->_screen->fadeIn(); } - // Handle any events + // Poll for events _vm->_canSaveLoad = true; _vm->_events->pollEvents(); _vm->_canSaveLoad = false; @@ -408,7 +408,16 @@ void Room::doCommands() { if (_vm->_screen->_screenChangeFlag) { _vm->_screen->_screenChangeFlag = false; _vm->_events->_cursorExitFlag = true; - executeCommand(4); + executeCommand(7); + } + else if (_vm->_events->_wheelUp || _vm->_events->_wheelDown) { + // Handle scrolling mouse wheel + cycleCommand(_vm->_events->_wheelUp ? 1 : -1); + + } else if (_vm->_events->_middleButton) { + // Switch back to walking + handleCommand(7); + } else if (_vm->_events->_leftButton) { if (_vm->_events->_mouseRow >= 22) { // Mouse in user interface area @@ -431,6 +440,20 @@ void Room::doCommands() { } } +void Room::cycleCommand(int incr) { + int command = _selectCommand + incr; + if (command < -1) + command = 6; + else if (command == -1) + command = 7; + else if (command == 1) + command = (incr == 1) ? 2 : 0; + else if (command == 4) + command = (incr == 1) ? 5 : 3; + + handleCommand(command); +} + void Room::handleCommand(int commandId) { if (commandId == 1) --commandId; @@ -494,7 +517,7 @@ void Room::executeCommand(int commandId) { _vm->_scripts->executeScript(); } _vm->_boxSelect = true; - break; + return; case 8: events.setCursor(CURSOR_HELP); break; diff --git a/engines/access/room.h b/engines/access/room.h index 1d540840e3ac..321ace4fd10d 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -72,6 +72,11 @@ class Room: public Manager { int calcLR(int yp); int calcUD(int xp); + /** + * Cycles forwards or backwards through the list of commands + */ + void cycleCommand(int incr); + bool checkCode(int v1, int v2); protected: void loadRoomData(const byte *roomData);