diff options
author | Filippos Karapetis | 2015-12-18 00:41:24 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:34:08 +0100 |
commit | b6bed0aed72bb45e88dd363a9a34a26ad9f03f6d (patch) | |
tree | 9398e2e586caaced26057aeb4fc221c6f50eb1e5 | |
parent | fdf09a63851cf51dc4c07a65e5fbc82c2d56512c (diff) | |
download | scummvm-rg350-b6bed0aed72bb45e88dd363a9a34a26ad9f03f6d.tar.gz scummvm-rg350-b6bed0aed72bb45e88dd363a9a34a26ad9f03f6d.tar.bz2 scummvm-rg350-b6bed0aed72bb45e88dd363a9a34a26ad9f03f6d.zip |
LAB: Simplify mouse button handling
-rw-r--r-- | engines/lab/engine.cpp | 28 | ||||
-rw-r--r-- | engines/lab/eventman.h | 18 | ||||
-rw-r--r-- | engines/lab/interface.cpp | 13 | ||||
-rw-r--r-- | engines/lab/intro.cpp | 13 | ||||
-rw-r--r-- | engines/lab/map.cpp | 14 | ||||
-rw-r--r-- | engines/lab/special.cpp | 12 |
6 files changed, 46 insertions, 52 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index c79197a35a..66d0f464ef 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -571,7 +571,7 @@ void LabEngine::mainGameLoop() { gotMessage = true; mayShowCrumbIndicator(); _graphics->screenUpdate(); - if (!fromCrumbs(BUTTONUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode)) + if (!fromCrumbs(kMessageButtonUp, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode)) break; } } @@ -586,7 +586,7 @@ void LabEngine::mainGameLoop() { curPos.y = curMsg->_mouseY; _followingCrumbs = false; - if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_buttonId, actionMode)) + if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_code, actionMode)) break; } } @@ -648,25 +648,25 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo if (g_engine->shouldQuit()) return false; - if ((msgClass == RAWKEY) && !_graphics->_longWinInFront) { + if ((msgClass == kMessageRawKey) && !_graphics->_longWinInFront) { if (!processKey(curMsg, msgClass, qualifier, curPos, curInv, forceDraw, code)) return false; } - leftButtonClick = (msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier); - rightButtonClick = (msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier); + leftButtonClick = (msgClass == kMessageLeftClick); + rightButtonClick = (msgClass == kMessageRightClick); if (_graphics->_longWinInFront) { - if ((msgClass == RAWKEY) || (leftButtonClick || rightButtonClick)) { + if ((msgClass == kMessageRawKey) || (leftButtonClick || rightButtonClick)) { _graphics->_longWinInFront = false; _graphics->_doNotDrawMessage = false; _graphics->drawPanel(); drawRoomMessage(curInv, _closeDataPtr); _graphics->screenUpdate(); } - } else if ((msgClass == BUTTONUP) && !_alternate) { + } else if ((msgClass == kMessageButtonUp) && !_alternate) { processMainButton(wrkClosePtr, curInv, lastInv, oldDirection, forceDraw, buttonId, actionMode); - } else if ((msgClass == BUTTONUP) && _alternate) { + } else if ((msgClass == kMessageButtonUp) && _alternate) { processAltButton(curInv, lastInv, buttonId, actionMode); } else if (leftButtonClick && _mainDisplay) { interfaceOff(); @@ -780,7 +780,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo mayShowCrumbIndicator(); _graphics->screenUpdate(); - } else if (msgClass == DELTAMOVE) { + } else if (msgClass == kMessageDeltaMove) { ViewData *vptr = getViewData(_roomNum, _direction); CloseDataPtr oldClosePtr = vptr->_closeUps; @@ -816,8 +816,8 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code) { if (code == Common::KEYCODE_RETURN) { // The return key - msgClass = MOUSEBUTTONS; - qualifier = IEQUALIFIER_LEFTBUTTON; + msgClass = kMessageLeftClick; + qualifier = 0; curPos = _event->getMousePos(); } else if ((getPlatform() == Common::kPlatformWindows) && (code == Common::KEYCODE_b)) { // Start bread crumbs @@ -877,20 +877,20 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali // Does music load and next animation frame when you've run out of messages _music->updateMusic(); _anim->diffNextFrame(); - } else if (curMsg->_msgClass == RAWKEY) { + } else if (curMsg->_msgClass == kMessageRawKey) { if ((curMsg->_code == Common::KEYCODE_y) || (curMsg->_code == Common::KEYCODE_q)) { _anim->stopDiff(); return false; } else if (curMsg->_code < 128) break; - } else if (curMsg->_msgClass == MOUSEBUTTONS) + } else if ((curMsg->_msgClass == kMessageLeftClick) || (curMsg->_msgClass == kMessageRightClick)) break; } forceDraw = true; interfaceOn(); } else if (code == Common::KEYCODE_TAB) - msgClass = DELTAMOVE; + msgClass = kMessageDeltaMove; else if (code == Common::KEYCODE_ESCAPE) _closeDataPtr = nullptr; diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h index d2c5782453..20b4ddc29d 100644 --- a/engines/lab/eventman.h +++ b/engines/lab/eventman.h @@ -38,15 +38,13 @@ namespace Lab { class LabEngine; class Image; -// Defines for the Class variable in IntuiMessage -#define MOUSEBUTTONS 0x00000008 -#define BUTTONUP 0x00000040 -#define RAWKEY 0x00000400 -#define DELTAMOVE 0x00100000 - -// Defines for the Qualifier variable in IntuiMessage -#define IEQUALIFIER_RIGHTBUTTON 0x2000 -#define IEQUALIFIER_LEFTBUTTON 0x4000 +enum MessageClasses { + kMessageLeftClick, + kMessageRightClick, + kMessageButtonUp, + kMessageRawKey, + kMessageDeltaMove +}; #define VKEY_UPARROW 273 #define VKEY_DNARROW 274 @@ -55,7 +53,7 @@ class Image; struct IntuiMessage { uint32 _msgClass; - uint16 _code, _qualifier, _mouseX, _mouseY, _buttonId; + uint16 _code, _qualifier, _mouseX, _mouseY; uint32 _seconds, _micros; }; diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp index afaec28db3..d14b2835e0 100644 --- a/engines/lab/interface.cpp +++ b/engines/lab/interface.cpp @@ -137,15 +137,14 @@ IntuiMessage *EventManager::getMsg() { if (_lastButtonHit) { updateMouse(); - message._msgClass = BUTTONUP; + message._msgClass = kMessageButtonUp; message._code = _lastButtonHit->_buttonId; - message._buttonId = _lastButtonHit->_buttonId; message._qualifier = _keyPressed.flags; _lastButtonHit = nullptr; return &message; } else if (_leftClick || _rightClick) { - message._qualifier = (_leftClick) ? IEQUALIFIER_LEFTBUTTON : IEQUALIFIER_RIGHTBUTTON; - message._msgClass = MOUSEBUTTONS; + message._msgClass = (_leftClick) ? kMessageLeftClick : kMessageRightClick; + message._qualifier = 0; message._mouseX = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x; message._mouseY = (uint16)_mousePos.y; _leftClick = _rightClick = false; @@ -154,10 +153,10 @@ IntuiMessage *EventManager::getMsg() { Button *curButton = checkNumButtonHit(_screenButtonList, message._code); if (curButton) { - message._msgClass = BUTTONUP; - message._code = message._buttonId = curButton->_buttonId; + message._msgClass = kMessageButtonUp; + message._code = curButton->_buttonId; } else - message._msgClass = RAWKEY; + message._msgClass = kMessageRawKey; message._qualifier = _keyPressed.flags; return &message; diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp index 45119f4a5d..e4c84dc768 100644 --- a/engines/lab/intro.cpp +++ b/engines/lab/intro.cpp @@ -61,8 +61,8 @@ void Intro::introEatMessages() { if (!msg) return; - if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & msg->_qualifier)) - || ((msg->_msgClass == RAWKEY) && (msg->_code == Common::KEYCODE_ESCAPE))) + if ((msg->_msgClass == kMessageRightClick) + || ((msg->_msgClass == kMessageRawKey) && (msg->_code == Common::KEYCODE_ESCAPE))) _quitIntro = true; } } @@ -151,11 +151,10 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { _vm->waitTOF(); } else { uint32 msgClass = msg->_msgClass; - uint16 qualifier = msg->_qualifier; uint16 code = msg->_code; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE))) { + if ((msgClass == kMessageRightClick) || + ((msgClass == kMessageRawKey) && (code == Common::KEYCODE_ESCAPE))) { _quitIntro = true; if (isScreen) @@ -163,8 +162,8 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { delete[] textBuffer; return; - } else if (msgClass == MOUSEBUTTONS) { - if (IEQUALIFIER_LEFTBUTTON & qualifier) { + } else if ((msgClass == kMessageLeftClick) || (msgClass == kMessageRightClick)) { + if (msgClass == kMessageLeftClick) { if (doneFl) { if (isScreen) _vm->_graphics->fade(false, 0); diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 0136bf4f36..81068ed53e 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -473,19 +473,17 @@ void LabEngine::processMap(uint16 curRoom) { } else { uint32 msgClass = msg->_msgClass; uint16 msgCode = msg->_code; - uint16 buttonId = msg->_buttonId; - uint16 qualifier = msg->_qualifier; uint16 mouseX = msg->_mouseX; uint16 mouseY = msg->_mouseY; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == Common::KEYCODE_ESCAPE))) + if ((msgClass == kMessageRightClick) || ((msgClass == kMessageRawKey) && (msgCode == Common::KEYCODE_ESCAPE))) return; - if (msgClass == BUTTONUP) { - if (buttonId == 0) { + if (msgClass == kMessageButtonUp) { + if (msgCode == 0) { // Quit menu button return; - } else if (buttonId == 1) { + } else if (msgCode == 1) { // Up arrow uint16 upperFloor = getUpperFloor(curFloor); if (upperFloor != kFloorNone) { @@ -494,7 +492,7 @@ void LabEngine::processMap(uint16 curRoom) { drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); } - } else if (buttonId == 2) { + } else if (msgCode == 2) { // Down arrow uint16 lowerFloor = getLowerFloor(curFloor); if (lowerFloor != kFloorNone) { @@ -504,7 +502,7 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->fade(true, 0); } } - } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { + } else if (msgClass == kMessageLeftClick) { if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277)) && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352)) && floorVisited(kFloorSurMaze)) { diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5ed0919e82..820455a433 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -277,10 +277,10 @@ void LabEngine::processJournal() { uint16 qualifier = msg->_qualifier; uint16 buttonId = msg->_code; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (buttonId == Common::KEYCODE_ESCAPE))) + if ((msgClass == kMessageRightClick) || + ((msgClass == kMessageRawKey) && (buttonId == Common::KEYCODE_ESCAPE))) return; - else if (msgClass == BUTTONUP) { + else if (msgClass == kMessageButtonUp) { if (buttonId == 0) { if (_journalPage >= 2) { _journalPage -= 2; @@ -443,10 +443,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera uint16 mouseY = msg->_mouseY; uint16 code = msg->_code; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE))) + if ((msgClass == kMessageRightClick) || + ((msgClass == kMessageRawKey) && (code == Common::KEYCODE_ESCAPE))) return; - else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { + else if (msgClass == kMessageLeftClick) { if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { if (mouseX <= _utils->vgaScaleX(31)) { return; |