ACCESS: Add new support for mouse wheel for cycling through cursors

This commit is contained in:
Paul Gilbert 2014-08-30 11:52:48 -04:00
parent 949033ea92
commit 2cca520465
4 changed files with 49 additions and 3 deletions

View File

@ -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;
}

View File

@ -55,6 +55,8 @@ public:
CursorType _cursorId;
CursorType _normalMouse;
bool _leftButton, _rightButton;
bool _middleButton;
bool _wheelUp, _wheelDown;
Common::Point _mousePos;
int _mouseCol, _mouseRow;
bool _cursorExitFlag;

View File

@ -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;

View File

@ -72,6 +72,11 @@ private:
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);