diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp index 49ed17b069b..32d0494f027 100644 --- a/engines/lab/dispman.cpp +++ b/engines/lab/dispman.cpp @@ -37,6 +37,7 @@ #include "lab/eventman.h" #include "lab/music.h" #include "lab/image.h" +#include "lab/interface.h" #include "lab/resource.h" #include "lab/utils.h" @@ -216,7 +217,7 @@ int DisplayMan::longDrawMessage(Common::String str, bool isActionMessage) { if (str.empty()) return 0; - _vm->_event->attachButtonList(nullptr); + _vm->_interface->attachButtonList(nullptr); if (!_longWinInFront) { _longWinInFront = true; @@ -269,7 +270,7 @@ void DisplayMan::drawPanel() { if (!_vm->_alternate) { // The horizontal lines under the black one drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319), 4); - _vm->_event->drawButtonList(&_vm->_moveButtonList); + _vm->_interface->drawButtonList(&_vm->_moveButtonList); } else { if (_vm->getPlatform() != Common::kPlatformWindows) { // Vertical Black lines @@ -298,12 +299,12 @@ void DisplayMan::drawPanel() { drawVLine(_vm->_utils->vgaScaleX(232), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198), 4); } - _vm->_event->drawButtonList(&_vm->_invButtonList); + _vm->_interface->drawButtonList(&_vm->_invButtonList); } } void DisplayMan::setUpScreens() { - EventManager *e = _vm->_event; + Interface *i = _vm->_interface; ButtonList *moveButtonList = &_vm->_moveButtonList; ButtonList *invButtonList = &_vm->_invButtonList; Image **moveImages = _vm->_moveImages; @@ -313,8 +314,8 @@ void DisplayMan::setUpScreens() { // TODO: The CONTROL file is not present in the Amiga version Common::File *controlFile = _vm->_resource->openDataFile("P:Control"); - for (int i = 0; i < 20; i++) - _vm->_moveImages[i] = new Image(controlFile, _vm); + for (int j = 0; j < 20; j++) + _vm->_moveImages[j] = new Image(controlFile, _vm); delete controlFile; // Creates the buttons for the movement control panel @@ -322,16 +323,16 @@ void DisplayMan::setUpScreens() { // It's very convenient to have those shortcut, so I added them // for all versions. (Strangerke) uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2); - moveButtonList->push_back(e->createButton( 1, y, 0, Common::KEYCODE_t, moveImages[0], moveImages[1])); - moveButtonList->push_back(e->createButton( 33, y, 1, Common::KEYCODE_m, moveImages[2], moveImages[3])); - moveButtonList->push_back(e->createButton( 65, y, 2, Common::KEYCODE_o, moveImages[4], moveImages[5])); - moveButtonList->push_back(e->createButton( 97, y, 3, Common::KEYCODE_c, moveImages[6], moveImages[7])); - moveButtonList->push_back(e->createButton(129, y, 4, Common::KEYCODE_l, moveImages[8], moveImages[9])); - moveButtonList->push_back(e->createButton(161, y, 5, Common::KEYCODE_i, moveImages[12], moveImages[13])); - moveButtonList->push_back(e->createButton(193, y, 6, Common::KEYCODE_LEFT, moveImages[14], moveImages[15])); - moveButtonList->push_back(e->createButton(225, y, 7, Common::KEYCODE_UP, moveImages[16], moveImages[17])); - moveButtonList->push_back(e->createButton(257, y, 8, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19])); - moveButtonList->push_back(e->createButton(289, y, 9, Common::KEYCODE_p, moveImages[10], moveImages[11])); + moveButtonList->push_back(i->createButton( 1, y, 0, Common::KEYCODE_t, moveImages[0], moveImages[1])); + moveButtonList->push_back(i->createButton( 33, y, 1, Common::KEYCODE_m, moveImages[2], moveImages[3])); + moveButtonList->push_back(i->createButton( 65, y, 2, Common::KEYCODE_o, moveImages[4], moveImages[5])); + moveButtonList->push_back(i->createButton( 97, y, 3, Common::KEYCODE_c, moveImages[6], moveImages[7])); + moveButtonList->push_back(i->createButton(129, y, 4, Common::KEYCODE_l, moveImages[8], moveImages[9])); + moveButtonList->push_back(i->createButton(161, y, 5, Common::KEYCODE_i, moveImages[12], moveImages[13])); + moveButtonList->push_back(i->createButton(193, y, 6, Common::KEYCODE_LEFT, moveImages[14], moveImages[15])); + moveButtonList->push_back(i->createButton(225, y, 7, Common::KEYCODE_UP, moveImages[16], moveImages[17])); + moveButtonList->push_back(i->createButton(257, y, 8, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19])); + moveButtonList->push_back(i->createButton(289, y, 9, Common::KEYCODE_p, moveImages[10], moveImages[11])); // TODO: The INV file is not present in the Amiga version Common::File *invFile = _vm->_resource->openDataFile("P:Inv"); @@ -342,18 +343,18 @@ void DisplayMan::setUpScreens() { for (int imgIdx = 0; imgIdx < 6; imgIdx++) _vm->_invImages[imgIdx] = new Image(invFile, _vm); } - invButtonList->push_back(e->createButton( 24, y, 0, Common::KEYCODE_ESCAPE, invImages[0], invImages[1])); - invButtonList->push_back(e->createButton( 56, y, 1, Common::KEYCODE_g, invImages[2], invImages[3])); - invButtonList->push_back(e->createButton( 94, y, 2, Common::KEYCODE_u, invImages[4], invImages[5])); - invButtonList->push_back(e->createButton(126, y, 3, Common::KEYCODE_l, moveImages[8], moveImages[9])); - invButtonList->push_back(e->createButton(164, y, 4, Common::KEYCODE_LEFT, moveImages[14], moveImages[15])); - invButtonList->push_back(e->createButton(196, y, 5, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19])); + invButtonList->push_back(i->createButton( 24, y, 0, Common::KEYCODE_ESCAPE, invImages[0], invImages[1])); + invButtonList->push_back(i->createButton( 56, y, 1, Common::KEYCODE_g, invImages[2], invImages[3])); + invButtonList->push_back(i->createButton( 94, y, 2, Common::KEYCODE_u, invImages[4], invImages[5])); + invButtonList->push_back(i->createButton(126, y, 3, Common::KEYCODE_l, moveImages[8], moveImages[9])); + invButtonList->push_back(i->createButton(164, y, 4, Common::KEYCODE_LEFT, moveImages[14], moveImages[15])); + invButtonList->push_back(i->createButton(196, y, 5, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19])); // The windows version has 2 extra buttons for breadcrumb trail // CHECKME: the game is really hard to play without those, maybe we could add something to enable that. if (_vm->getPlatform() == Common::kPlatformWindows) { - invButtonList->push_back(e->createButton(234, y, 6, Common::KEYCODE_b, invImages[6], invImages[7])); - invButtonList->push_back(e->createButton(266, y, 7, Common::KEYCODE_f, invImages[8], invImages[9])); + invButtonList->push_back(i->createButton(234, y, 6, Common::KEYCODE_b, invImages[6], invImages[7])); + invButtonList->push_back(i->createButton(266, y, 7, Common::KEYCODE_f, invImages[8], invImages[9])); } delete invFile; diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index b0b7d38e199..a159fb463a3 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -37,6 +37,7 @@ #include "lab/dispman.h" #include "lab/eventman.h" #include "lab/image.h" +#include "lab/interface.h" #include "lab/intro.h" #include "lab/labsets.h" #include "lab/music.h" @@ -47,9 +48,6 @@ namespace Lab { -#define CRUMBSWIDTH 24 -#define CRUMBSHEIGHT 24 - enum SpecialLock { kLockCombination = 100, kLockTiles = 101, @@ -256,7 +254,7 @@ void LabEngine::handleMonitorCloseup() { _graphics->drawPanel(); _closeDataPtr = nullptr; - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); _graphics->screenUpdate(); } @@ -289,7 +287,7 @@ Common::String LabEngine::getInvName(uint16 curInv) { void LabEngine::interfaceOff() { if (!_interfaceOff) { - _event->attachButtonList(nullptr); + _interface->attachButtonList(nullptr); _event->mouseHide(); _interfaceOff = true; } @@ -302,11 +300,11 @@ void LabEngine::interfaceOn() { } if (_graphics->_longWinInFront) - _event->attachButtonList(nullptr); + _interface->attachButtonList(nullptr); else if (_alternate) - _event->attachButtonList(&_invButtonList); + _interface->attachButtonList(&_invButtonList); else - _event->attachButtonList(&_moveButtonList); + _interface->attachButtonList(&_moveButtonList); } bool LabEngine::doUse(uint16 curInv) { @@ -489,7 +487,7 @@ void LabEngine::mainGameLoop() { drawRoomMessage(curInv, _closeDataPtr); forceDraw = false; - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); _graphics->screenUpdate(); if (!_followingCrumbs) @@ -523,14 +521,14 @@ void LabEngine::mainGameLoop() { if (code == kButtonForward || code == kButtonLeft || code == kButtonRight) { gotMessage = true; - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); _graphics->screenUpdate(); if (!processEvent(kMessageButtonUp, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode)) break; } } - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); _graphics->screenUpdate(); } else { gotMessage = true; @@ -604,7 +602,7 @@ bool LabEngine::processEvent(MessageClass tmpClass, uint16 code, uint16 qualifie else performAction(actionMode, curPos, curInv); - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); _graphics->screenUpdate(); } else if (rightButtonClick) { eatMessages(); @@ -624,7 +622,7 @@ bool LabEngine::processEvent(MessageClass tmpClass, uint16 code, uint16 qualifie _graphics->drawPanel(); drawRoomMessage(curInv, _closeDataPtr); - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); _graphics->screenUpdate(); } @@ -637,7 +635,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 msgClass, uint16 &qualif _breadCrumbs[0]._crumbRoomNum = 0; _numCrumbs = 0; _droppingCrumbs = true; - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); _graphics->screenUpdate(); } else if (getPlatform() == Common::kPlatformWindows && (code == Common::KEYCODE_f || code == Common::KEYCODE_r)) { // Follow bread crumbs @@ -665,8 +663,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 msgClass, uint16 &qualif _breadCrumbs[0]._crumbRoomNum = 0; _droppingCrumbs = false; - // Need to hide indicator!!!! - mayShowCrumbIndicatorOff(); + _interface->mayShowCrumbIndicatorOff(); _graphics->screenUpdate(); } } @@ -729,7 +726,7 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi _anim->_doBlack = true; _closeDataPtr = nullptr; - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); } else { uint16 oldActionMode = actionMode; actionMode = buttonId; @@ -760,7 +757,7 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi _graphics->drawPanel(); drawRoomMessage(curInv, _closeDataPtr); - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); break; case kButtonLeft: @@ -779,7 +776,7 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi _anim->_doBlack = true; _direction = newDir; forceDraw = true; - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); } break; @@ -842,14 +839,14 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi } } - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); } break; case kButtonMap: doUse(kItemMap); - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); break; } @@ -939,7 +936,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI _breadCrumbs[0]._crumbRoomNum = 0; _numCrumbs = 0; _droppingCrumbs = true; - mayShowCrumbIndicator(); + _interface->mayShowCrumbIndicator(); break; case kButtonFollowCrumbs: @@ -964,8 +961,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI _breadCrumbs[0]._crumbRoomNum = 0; _droppingCrumbs = false; - // Need to hide indicator!!!! - mayShowCrumbIndicatorOff(); + _interface->mayShowCrumbIndicatorOff(); } } break; @@ -1130,85 +1126,4 @@ MainButton LabEngine::followCrumbs() { return moveDir; } - -void LabEngine::mayShowCrumbIndicator() { - static byte dropCrumbsImageData[CRUMBSWIDTH * CRUMBSHEIGHT] = { - 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, - 0, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 0, - 4, 7, 7, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 7, 7, 4, - 4, 7, 4, 4, 0, 0, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 7, 4, -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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 0, 0, 0, 4, 7, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 0, 0, 0, 4, 7, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 2, 2, 3, 0, 0, 4, 4, 7, 4, - 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 4, - 0, 0, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 0, - 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0 - }; - - if (getPlatform() != Common::kPlatformWindows) - return; - - if (_droppingCrumbs && _mainDisplay) { - static byte *imgData = new byte[CRUMBSWIDTH * CRUMBSHEIGHT]; - memcpy(imgData, dropCrumbsImageData, CRUMBSWIDTH * CRUMBSHEIGHT); - static Image dropCrumbsImage(CRUMBSWIDTH, CRUMBSHEIGHT, imgData, this); - - dropCrumbsImage.drawMaskImage(612, 4); - } -} - -void LabEngine::mayShowCrumbIndicatorOff() { - static byte dropCrumbsOffImageData[CRUMBSWIDTH * CRUMBSHEIGHT] = { - 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, - 0, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 0, - 4, 8, 8, 3, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 8, 8, 4, - 4, 8, 4, 4, 0, 0, 3, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 8, 4, - 4, 8, 4, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 3, 8, 3, 0, 0, 0, 0, 4, 8, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 8, 3, 0, 0, 0, 0, 4, 8, 4, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 8, 8, 8, 3, 0, 0, 4, 4, 8, 4, - 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 4, - 0, 0, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 0, - 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0 - }; - - if (getPlatform() != Common::kPlatformWindows) - return; - - if (_mainDisplay) { - static byte *imgData = new byte[CRUMBSWIDTH * CRUMBSHEIGHT]; - memcpy(imgData, dropCrumbsOffImageData, CRUMBSWIDTH * CRUMBSHEIGHT); - static Image dropCrumbsOffImage(CRUMBSWIDTH, CRUMBSHEIGHT, imgData, this); - - dropCrumbsOffImage.drawMaskImage(612, 4); - } -} - } // End of namespace Lab diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp index 60c56e003a0..0a603f7691a 100644 --- a/engines/lab/eventman.cpp +++ b/engines/lab/eventman.cpp @@ -37,6 +37,7 @@ #include "lab/dispman.h" #include "lab/eventman.h" #include "lab/image.h" +#include "lab/interface.h" namespace Lab { @@ -64,10 +65,7 @@ static const byte mouseData[] = { EventManager::EventManager(LabEngine *vm) : _vm(vm) { _leftClick = false; _rightClick = false; - - _lastButtonHit = nullptr; - _screenButtonList = nullptr; - _hitButton = nullptr; + _buttonHit = false; _mousePos = Common::Point(0, 0); _keyPressed = Common::KEYCODE_INVALID; } @@ -87,19 +85,6 @@ void EventManager::mouseHide() { CursorMan.showMouse(false); } -void EventManager::updateMouse() { - if (!_hitButton) - return; - - _hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y); - for (int i = 0; i < 3; i++) - _vm->waitTOF(); - _hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y); - - _hitButton = nullptr; - _vm->_graphics->screenUpdate(); -} - void EventManager::setMousePos(Common::Point pos) { if (_vm->_isHiRes) _vm->_system->warpMouse(pos.x, pos.y); @@ -109,16 +94,12 @@ void EventManager::setMousePos(Common::Point pos) { void EventManager::processInput() { Common::Event event; - Button *curButton = nullptr; while (_vm->_system->getEventManager()->pollEvent(event)) { switch (event.type) { case Common::EVENT_LBUTTONDOWN: - if (_screenButtonList) - curButton = checkButtonHit(_screenButtonList, _mousePos); - - if (curButton) - _lastButtonHit = curButton; + if (_vm->_interface->checkButtonHit(_mousePos)) + _buttonHit = true; else _leftClick = true; break; @@ -156,6 +137,51 @@ void EventManager::processInput() { } } +IntuiMessage *EventManager::getMsg() { + static IntuiMessage message; + + _vm->_interface->handlePressedButton(); + processInput(); + + if (_buttonHit) { + Button *lastButtonHit = _vm->_interface->checkButtonHit(_mousePos); + _buttonHit = false; + if (lastButtonHit) { + _vm->_interface->handlePressedButton(); + message._msgClass = kMessageButtonUp; + message._code = lastButtonHit->_buttonId; + message._qualifier = _keyPressed.flags; + + return &message; + } else + return nullptr; + } else if (_leftClick || _rightClick) { + message._msgClass = (_leftClick) ? kMessageLeftClick : kMessageRightClick; + message._qualifier = 0; + message._mouse = _mousePos; + _leftClick = _rightClick = false; + return &message; + } else if (_keyPressed.keycode != Common::KEYCODE_INVALID) { + Button *curButton = _vm->_interface->checkNumButtonHit(_keyPressed.keycode); + + if (curButton) { + message._msgClass = kMessageButtonUp; + message._code = curButton->_buttonId; + } else { + message._msgClass = kMessageRawKey; + message._code = _keyPressed.keycode; + } + + message._qualifier = _keyPressed.flags; + message._mouse = _mousePos; + + _keyPressed.keycode = Common::KEYCODE_INVALID; + + return &message; + } else + return nullptr; +} + Common::Point EventManager::updateAndGetMousePos() { processInput(); diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h index f26e2eba1c9..e4114edbadd 100644 --- a/engines/lab/eventman.h +++ b/engines/lab/eventman.h @@ -45,55 +45,20 @@ struct IntuiMessage { Common::Point _mouse; }; -struct Button { - uint16 _x, _y, _buttonId; - Common::KeyCode _keyEquiv; // the key which activates this button - bool _isEnabled; - Image *_image, *_altImage; -}; - -typedef Common::List