aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2016-01-15 20:56:15 +0200
committerFilippos Karapetis2016-01-15 21:03:57 +0200
commitafa75b70475ca47daba11c8bfacc7e61592cc0c6 (patch)
tree97ff0984e7c99501a3ae4c26a7e10f1abd140bb0 /engines
parent71b665b617fe664f358c37110d13a7a611db4885 (diff)
downloadscummvm-rg350-afa75b70475ca47daba11c8bfacc7e61592cc0c6.tar.gz
scummvm-rg350-afa75b70475ca47daba11c8bfacc7e61592cc0c6.tar.bz2
scummvm-rg350-afa75b70475ca47daba11c8bfacc7e61592cc0c6.zip
LAB: Separate the interface from the event manager
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/dispman.cpp49
-rw-r--r--engines/lab/engine.cpp125
-rw-r--r--engines/lab/eventman.cpp72
-rw-r--r--engines/lab/eventman.h38
-rw-r--r--engines/lab/interface.cpp163
-rw-r--r--engines/lab/interface.h91
-rw-r--r--engines/lab/lab.cpp6
-rw-r--r--engines/lab/lab.h6
-rw-r--r--engines/lab/map.cpp21
-rw-r--r--engines/lab/special.cpp17
10 files changed, 327 insertions, 261 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 49ed17b069..32d0494f02 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 b0b7d38e19..a159fb463a 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,
- 4, 7, 4, 0, 0, 0, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 7, 4,
- 4, 7, 4, 0, 0, 3, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 4, 7, 4,
- 4, 7, 4, 0, 0, 0, 3, 3, 3, 4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, 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, 0, 3, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 8, 4,
- 4, 8, 4, 0, 0, 3, 8, 8, 8, 3, 0, 0, 0, 0, 0, 0, 0, 3, 8, 3, 0, 4, 8, 4,
- 4, 8, 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 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 60c56e003a..0a603f7691 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 f26e2eba1c..e4114edbad 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<Button *> ButtonList;
-
class EventManager {
private:
LabEngine *_vm;
bool _leftClick;
bool _rightClick;
+ bool _buttonHit;
- Button *_hitButton;
- Button *_lastButtonHit;
- ButtonList *_screenButtonList;
Common::Point _mousePos;
Common::KeyState _keyPressed;
-private:
- /**
- * Checks whether or not the cords fall within one of the buttons in a list
- * of buttons.
- */
- Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
-
- /**
- * Checks whether or not the coords fall within one of the buttons in a list
- * of buttons.
- */
- Button *checkNumButtonHit(ButtonList *buttonList, Common::KeyCode key);
-
public:
EventManager (LabEngine *vm);
- void attachButtonList(ButtonList *buttonList);
- Button *createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode key, Image *image, Image *altImage);
- void toggleButton(Button *button, uint16 penColor, bool enable);
-
- /**
- * Draws a button list to the screen.
- */
- void drawButtonList(ButtonList *buttonList);
- void freeButtonList(ButtonList *buttonList);
- Button *getButton(uint16 id);
-
IntuiMessage *getMsg();
/**
@@ -116,7 +81,6 @@ public:
* Moves the mouse to new co-ordinates.
*/
void setMousePos(Common::Point pos);
- void updateMouse();
Common::Point updateAndGetMousePos();
/**
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index b0a83a90bf..bac1155725 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -33,13 +33,21 @@
#include "lab/lab.h"
#include "lab/dispman.h"
-#include "lab/eventman.h"
+#include "lab/interface.h"
#include "lab/image.h"
#include "lab/utils.h"
namespace Lab {
-Button *EventManager::createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode key, Image *image, Image *altImage) {
+#define CRUMBSWIDTH 24
+#define CRUMBSHEIGHT 24
+
+Interface::Interface(LabEngine *vm) : _vm(vm) {
+ _screenButtonList = nullptr;
+ _hitButton = nullptr;
+}
+
+Button *Interface::createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode key, Image *image, Image *altImage) {
Button *button = new Button();
if (button) {
@@ -56,7 +64,7 @@ Button *EventManager::createButton(uint16 x, uint16 y, uint16 id, Common::KeyCod
return nullptr;
}
-void EventManager::freeButtonList(ButtonList *buttonList) {
+void Interface::freeButtonList(ButtonList *buttonList) {
for (ButtonList::iterator buttonIter = buttonList->begin(); buttonIter != buttonList->end(); ++buttonIter) {
Button *button = *buttonIter;
delete button->_image;
@@ -67,7 +75,7 @@ void EventManager::freeButtonList(ButtonList *buttonList) {
buttonList->clear();
}
-void EventManager::drawButtonList(ButtonList *buttonList) {
+void Interface::drawButtonList(ButtonList *buttonList) {
for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
toggleButton((*button), 1, true);
@@ -76,7 +84,7 @@ void EventManager::drawButtonList(ButtonList *buttonList) {
}
}
-void EventManager::toggleButton(Button *button, uint16 disabledPenColor, bool enable) {
+void Interface::toggleButton(Button *button, uint16 disabledPenColor, bool enable) {
if (!enable)
_vm->_graphics->checkerBoardEffect(disabledPenColor, button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
else
@@ -85,13 +93,13 @@ void EventManager::toggleButton(Button *button, uint16 disabledPenColor, bool en
button->_isEnabled = enable;
}
-Button *EventManager::checkNumButtonHit(ButtonList *buttonList, Common::KeyCode key) {
+Button *Interface::checkNumButtonHit(Common::KeyCode key) {
uint16 gkey = key - '0';
- if (!buttonList)
+ if (!_screenButtonList)
return nullptr;
- for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
+ for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
Button *button = *buttonItr;
if (!button->_isEnabled)
continue;
@@ -107,8 +115,11 @@ Button *EventManager::checkNumButtonHit(ButtonList *buttonList, Common::KeyCode
return nullptr;
}
-Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) {
- for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
+Button *Interface::checkButtonHit(Common::Point pos) {
+ if (!_screenButtonList)
+ return nullptr;
+
+ for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
Button *button = *buttonItr;
Common::Rect buttonRect(button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
@@ -121,14 +132,24 @@ Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos)
return nullptr;
}
-void EventManager::attachButtonList(ButtonList *buttonList) {
- if (_screenButtonList != buttonList)
- _lastButtonHit = nullptr;
+void Interface::handlePressedButton() {
+ 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 Interface::attachButtonList(ButtonList *buttonList) {
_screenButtonList = buttonList;
}
-Button *EventManager::getButton(uint16 id) {
+Button *Interface::getButton(uint16 id) {
for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
Button *button = *buttonItr;
if (button->_buttonId == id)
@@ -138,44 +159,84 @@ Button *EventManager::getButton(uint16 id) {
return nullptr;
}
-IntuiMessage *EventManager::getMsg() {
- static IntuiMessage message;
-
- updateMouse();
- processInput();
-
- if (_lastButtonHit) {
- updateMouse();
- message._msgClass = kMessageButtonUp;
- message._code = _lastButtonHit->_buttonId;
- message._qualifier = _keyPressed.flags;
- _lastButtonHit = nullptr;
- return &message;
- } 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 = checkNumButtonHit(_screenButtonList, _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;
+void Interface::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,
+ 4, 7, 4, 0, 0, 0, 3, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 7, 4,
+ 4, 7, 4, 0, 0, 3, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 3, 2, 3, 0, 4, 7, 4,
+ 4, 7, 4, 0, 0, 0, 3, 3, 3, 4, 4, 4, 4, 4, 4, 0, 0, 3, 2, 3, 0, 4, 7, 4,
+ 4, 7, 4, 0, 0, 0, 0, 0, 4, 7, 7, 7, 7, 7, 7, 4, 3, 2, 2, 2, 3, 4, 7, 4,
+ 4, 7, 4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 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 (_vm->getPlatform() != Common::kPlatformWindows)
+ return;
+
+ if (_vm->_droppingCrumbs && _vm->isMainDisplay()) {
+ static byte *imgData = new byte[CRUMBSWIDTH * CRUMBSHEIGHT];
+ memcpy(imgData, dropCrumbsImageData, CRUMBSWIDTH * CRUMBSHEIGHT);
+ static Image dropCrumbsImage(CRUMBSWIDTH, CRUMBSHEIGHT, imgData, _vm);
+
+ dropCrumbsImage.drawMaskImage(612, 4);
+ }
+}
- return &message;
- } else
- return nullptr;
+void Interface::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, 0, 3, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 8, 4,
+ 4, 8, 4, 0, 0, 3, 8, 8, 8, 3, 0, 0, 0, 0, 0, 0, 0, 3, 8, 3, 0, 4, 8, 4,
+ 4, 8, 4, 0, 0, 0, 3, 3, 3, 4, 4, 4, 4, 4, 4, 0, 0, 3, 8, 3, 0, 4, 8, 4,
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, 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 (_vm->getPlatform() != Common::kPlatformWindows)
+ return;
+
+ if (_vm->isMainDisplay()) {
+ static byte *imgData = new byte[CRUMBSWIDTH * CRUMBSHEIGHT];
+ memcpy(imgData, dropCrumbsOffImageData, CRUMBSWIDTH * CRUMBSHEIGHT);
+ static Image dropCrumbsOffImage(CRUMBSWIDTH, CRUMBSHEIGHT, imgData, _vm);
+
+ dropCrumbsOffImage.drawMaskImage(612, 4);
+ }
}
} // End of namespace Lab
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
new file mode 100644
index 0000000000..51478dd463
--- /dev/null
+++ b/engines/lab/interface.h
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_INTERFACE_H
+#define LAB_INTERFACE_H
+
+#include "common/events.h"
+
+namespace Lab {
+
+class LabEngine;
+class Image;
+
+struct Button {
+ uint16 _x, _y, _buttonId;
+ Common::KeyCode _keyEquiv; // the key which activates this button
+ bool _isEnabled;
+ Image *_image, *_altImage;
+};
+
+typedef Common::List<Button *> ButtonList;
+
+class Interface {
+private:
+ LabEngine *_vm;
+
+ Button *_hitButton;
+ ButtonList *_screenButtonList;
+
+public:
+ Interface(LabEngine *vm);
+
+ void attachButtonList(ButtonList *buttonList);
+ Button *createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode key, Image *image, Image *altImage);
+ void toggleButton(Button *button, uint16 penColor, bool enable);
+
+ /**
+ * Draws a button list to the screen.
+ */
+ void drawButtonList(ButtonList *buttonList);
+ void freeButtonList(ButtonList *buttonList);
+ Button *getButton(uint16 id);
+
+ /**
+ * Checks whether or not the coords fall within one of the buttons in a list
+ * of buttons.
+ */
+ Button *checkButtonHit(Common::Point pos);
+
+ /**
+ * Checks whether or not the coords fall within one of the buttons in a list
+ * of buttons.
+ */
+ Button *checkNumButtonHit(Common::KeyCode key);
+
+ void handlePressedButton();
+
+ void mayShowCrumbIndicator();
+ void mayShowCrumbIndicatorOff();
+};
+
+} // End of namespace Lab
+
+#endif // LAB_INTERFACE_H
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 4eb0e4db56..70b7f718ec 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -41,6 +41,7 @@
#include "lab/dispman.h"
#include "lab/eventman.h"
#include "lab/image.h"
+#include "lab/interface.h"
#include "lab/music.h"
#include "lab/processroom.h"
#include "lab/resource.h"
@@ -77,6 +78,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_maxRooms = 0;
_event = nullptr;
+ _interface = nullptr;
_resource = nullptr;
_music = nullptr;
_anim = nullptr;
@@ -145,6 +147,7 @@ LabEngine::~LabEngine() {
delete _conditions;
delete _roomsFound;
delete _event;
+ delete _interface;
delete _resource;
delete _music;
delete _anim;
@@ -161,6 +164,7 @@ Common::Error LabEngine::run() {
else
initGraphics(640, 480, true);
+ _interface = new Interface(this);
_event = new EventManager(this);
_resource = new Resource(this);
_music = new Music(this);
@@ -206,7 +210,7 @@ void LabEngine::waitTOF() {
void LabEngine::updateEvents() {
_event->processInput();
- _event->updateMouse();
+ _interface->handlePressedButton();
}
Common::Error LabEngine::loadGameState(int slot) {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 3951f45127..4a037efb2d 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -60,6 +60,7 @@ struct ViewData;
class Anim;
class DisplayMan;
class EventManager;
+class Interface;
class Image;
class Music;
class Resource;
@@ -187,6 +188,7 @@ public:
CrumbData _breadCrumbs[MAX_CRUMBS];
DisplayMan *_graphics;
EventManager *_event;
+ Interface *_interface;
ButtonList _invButtonList;
ButtonList _moveButtonList;
Image *_invImages[10];
@@ -232,6 +234,8 @@ public:
bool canLoadGameStateCurrently();
bool canSaveGameStateCurrently();
+ bool isMainDisplay() const { return _mainDisplay; }
+
private:
/**
* Checks whether all the conditions in a condition list are met.
@@ -434,8 +438,6 @@ private:
*/
void mainGameLoop();
void showLab2Teaser();
- void mayShowCrumbIndicator();
- void mayShowCrumbIndicatorOff();
/**
* Permanently flips the imagery of a button.
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 27e80d69b8..5c6bb07814 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -33,6 +33,7 @@
#include "lab/dispman.h"
#include "lab/eventman.h"
#include "lab/image.h"
+#include "lab/interface.h"
#include "lab/labsets.h"
#include "lab/music.h"
#include "lab/processroom.h"
@@ -75,9 +76,9 @@ void LabEngine::loadMapData() {
_imgPath = new Image(mapImages, this);
_imgBridge = new Image(mapImages, this);
- _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, Common::KEYCODE_ESCAPE, new Image(mapImages, this), new Image(mapImages, this))); // back
- _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, Common::KEYCODE_UP, new Image(mapImages, this), new Image(mapImages, this))); // up
- _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, Common::KEYCODE_DOWN, new Image(mapImages, this), new Image(mapImages, this))); // down
+ _mapButtonList.push_back(_interface->createButton( 8, _utils->vgaScaleY(105), 0, Common::KEYCODE_ESCAPE, new Image(mapImages, this), new Image(mapImages, this))); // back
+ _mapButtonList.push_back(_interface->createButton( 55, _utils->vgaScaleY(105), 1, Common::KEYCODE_UP, new Image(mapImages, this), new Image(mapImages, this))); // up
+ _mapButtonList.push_back(_interface->createButton(101, _utils->vgaScaleY(105), 2, Common::KEYCODE_DOWN, new Image(mapImages, this), new Image(mapImages, this))); // down
delete mapImages;
@@ -98,7 +99,7 @@ void LabEngine::loadMapData() {
}
void LabEngine::freeMapData() {
- _event->freeButtonList(&_mapButtonList);
+ _interface->freeButtonList(&_mapButtonList);
delete _imgMap;
delete _imgRoom;
@@ -330,7 +331,7 @@ uint16 LabEngine::getLowerFloor(uint16 floorNum) {
void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeIn) {
_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0);
_imgMap->drawImage(0, 0);
- _event->drawButtonList(&_mapButtonList);
+ _interface->drawButtonList(&_mapButtonList);
for (int i = 1; i <= _maxRooms; i++) {
if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
@@ -346,8 +347,8 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x)
drawRoomMap(curRoom, true);
- _event->toggleButton(_event->getButton(1), 12, (getUpperFloor(floorNum) != kFloorNone)); // up button
- _event->toggleButton(_event->getButton(2), 12, (getLowerFloor(floorNum) != kFloorNone)); // down button
+ _interface->toggleButton(_interface->getButton(1), 12, (getUpperFloor(floorNum) != kFloorNone)); // up button
+ _interface->toggleButton(_interface->getButton(2), 12, (getLowerFloor(floorNum) != kFloorNone)); // down button
// Labyrinth specific code
if (floorNum == kFloorLower) {
@@ -413,7 +414,7 @@ void LabEngine::processMap(uint16 curRoom) {
waitTOF();
_graphics->writeColorRegs(newcolor, 1, 1);
- _event->updateMouse();
+ _interface->handlePressedButton();
waitTOF();
place++;
@@ -538,13 +539,13 @@ void LabEngine::doMap() {
updateEvents();
loadMapData();
_graphics->blackAllScreen();
- _event->attachButtonList(&_mapButtonList);
+ _interface->attachButtonList(&_mapButtonList);
drawMap(_roomNum, _roomNum, _maps[_roomNum]._pageNumber, true);
_event->mouseShow();
_graphics->screenUpdate();
processMap(_roomNum);
_event->mouseHide();
- _event->attachButtonList(nullptr);
+ _interface->attachButtonList(nullptr);
_graphics->fade(false);
_graphics->blackAllScreen();
_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index b91ffb454e..9f9b993afa 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -34,6 +34,7 @@
#include "lab/dispman.h"
#include "lab/eventman.h"
#include "lab/image.h"
+#include "lab/interface.h"
#include "lab/labsets.h"
#include "lab/music.h"
#include "lab/processroom.h"
@@ -128,9 +129,9 @@ void LabEngine::loadJournalData() {
_journalTextTitle = _resource->getText("Lab:Rooms/jt");
Common::File *journalFile = _resource->openDataFile("P:JImage");
- _journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, Common::KEYCODE_LEFT, new Image(journalFile, this), new Image(journalFile, this))); // back
- _journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, Common::KEYCODE_RIGHT, new Image(journalFile, this), new Image(journalFile, this))); // forward
- _journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, Common::KEYCODE_ESCAPE, new Image(journalFile, this), new Image(journalFile, this))); // cancel
+ _journalButtonList.push_back(_interface->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, Common::KEYCODE_LEFT, new Image(journalFile, this), new Image(journalFile, this))); // back
+ _journalButtonList.push_back(_interface->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, Common::KEYCODE_RIGHT, new Image(journalFile, this), new Image(journalFile, this))); // forward
+ _journalButtonList.push_back(_interface->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, Common::KEYCODE_ESCAPE, new Image(journalFile, this), new Image(journalFile, this))); // cancel
delete journalFile;
_anim->_noPalChange = true;
@@ -206,8 +207,8 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
else
turnPage((wipenum == 1));
- _event->toggleButton(_event->getButton(0), 15, (_journalPage > 0)); // back button
- _event->toggleButton(_event->getButton(2), 15, (!_lastPage)); // forward button
+ _interface->toggleButton(_interface->getButton(0), 15, (_journalPage > 0)); // back button
+ _interface->toggleButton(_interface->getButton(2), 15, (!_lastPage)); // forward button
if (needFade)
_graphics->fade(true);
@@ -268,11 +269,11 @@ void LabEngine::doJournal() {
updateEvents();
loadJournalData();
- _event->attachButtonList(&_journalButtonList);
+ _interface->attachButtonList(&_journalButtonList);
drawJournal(0, true);
_event->mouseShow();
processJournal();
- _event->attachButtonList(nullptr);
+ _interface->attachButtonList(nullptr);
_graphics->fade(false);
_event->mouseHide();
@@ -280,7 +281,7 @@ void LabEngine::doJournal() {
_blankJournal = nullptr;
_journalBackImage->setData(nullptr, true);
- _event->freeButtonList(&_journalButtonList);
+ _interface->freeButtonList(&_journalButtonList);
_graphics->freeFont(&_journalFont);
_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0);