Skip to content

Commit

Permalink
ACCESS: Add new support for mouse wheel for cycling through cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 30, 2014
1 parent 949033e commit 2cca520
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
16 changes: 16 additions & 0 deletions engines/access/events.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -122,6 +124,8 @@ void EventsManager::pollEvents() {
nextFrame();
}

_wheelUp = _wheelDown = false;

Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions engines/access/events.h
Expand Up @@ -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;
Expand Down
29 changes: 26 additions & 3 deletions engines/access/room.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -494,7 +517,7 @@ void Room::executeCommand(int commandId) {
_vm->_scripts->executeScript();
}
_vm->_boxSelect = true;
break;
return;
case 8:
events.setCursor(CURSOR_HELP);
break;
Expand Down
5 changes: 5 additions & 0 deletions engines/access/room.h
Expand Up @@ -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);
Expand Down

0 comments on commit 2cca520

Please sign in to comment.