aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2015-12-02 00:55:29 +0100
committerWillem Jan Palenstijn2015-12-23 21:33:46 +0100
commit66bf8885585975ae860c8c3d175b960b6a7e9590 (patch)
tree3390e00906e95541fe193cc941f1524dc55c33d0
parent53d92be11f8ffb65f73d81874df9340f9f99a215 (diff)
downloadscummvm-rg350-66bf8885585975ae860c8c3d175b960b6a7e9590.tar.gz
scummvm-rg350-66bf8885585975ae860c8c3d175b960b6a7e9590.tar.bz2
scummvm-rg350-66bf8885585975ae860c8c3d175b960b6a7e9590.zip
LAB: Rework and renaming in the Event class
-rw-r--r--engines/lab/interface.cpp3
-rw-r--r--engines/lab/mouse.cpp88
-rw-r--r--engines/lab/mouse.h14
3 files changed, 56 insertions, 49 deletions
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index fc7ba1e633..21b5764cc2 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -164,7 +164,6 @@ static bool keyPress(uint16 *KeyCode) {
}
IntuiMessage IMessage;
-extern Gadget *ScreenGadgetList;
IntuiMessage *LabEngine::getMsg() {
Gadget *curgad;
@@ -190,7 +189,7 @@ IntuiMessage *LabEngine::getMsg() {
IMessage.msgClass = MOUSEBUTTONS;
return &IMessage;
} else if (keyPress(&IMessage.code)) { /* Keyboard key */
- curgad = checkNumGadgetHit(ScreenGadgetList, IMessage.code);
+ curgad = checkNumGadgetHit(_event->_screenGadgetList, IMessage.code);
if (curgad) {
IMessage.msgClass = GADGETUP;
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 4bd6c7f8d8..879bd08b68 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -35,13 +35,6 @@
namespace Lab {
-static bool LeftClick = false;
-static bool RightClick = false;
-
-static bool MouseHidden = true;
-static int32 NumHidden = 1;
-static Gadget *LastGadgetHit = NULL;
-Gadget *ScreenGadgetList = NULL;
static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
@@ -67,30 +60,30 @@ static Gadget *hitgad = NULL;
/* Checks whether or not the cords fall within one of the gadgets in a list */
/* of gadgets. */
/*****************************************************************************/
-Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
- while (gadlist != NULL) {
- if ((pos.x >= gadlist->x) && (pos.y >= gadlist->y) &&
- (pos.x <= (gadlist->x + gadlist->Im->Width)) &&
- (pos.y <= (gadlist->y + gadlist->Im->Height)) &&
- !(GADGETOFF & gadlist->GadgetFlags)) {
+Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
+ while (gadgetList != NULL) {
+ if ((pos.x >= gadgetList->x) && (pos.y >= gadgetList->y) &&
+ (pos.x <= (gadgetList->x + gadgetList->Im->Width)) &&
+ (pos.y <= (gadgetList->y + gadgetList->Im->Height)) &&
+ !(GADGETOFF & gadgetList->GadgetFlags)) {
if (_vm->_isHiRes) {
- hitgad = gadlist;
+ hitgad = gadgetList;
} else {
mouseHide();
- gadlist->ImAlt->drawImage(gadlist->x, gadlist->y);
+ gadgetList->ImAlt->drawImage(gadgetList->x, gadgetList->y);
mouseShow();
for (uint16 i = 0; i < 3; i++)
_vm->waitTOF();
mouseHide();
- gadlist->Im->drawImage(gadlist->x, gadlist->y);
+ gadgetList->Im->drawImage(gadgetList->x, gadgetList->y);
mouseShow();
}
- return gadlist;
+ return gadgetList;
} else {
- gadlist = gadlist->NextGadget;
+ gadgetList = gadgetList->NextGadget;
}
}
@@ -99,39 +92,46 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
-void EventManager::attachGadgetList(Gadget *GadList) {
- if (ScreenGadgetList != GadList)
- LastGadgetHit = NULL;
+void EventManager::attachGadgetList(Gadget *gadgetList) {
+ if (_screenGadgetList != gadgetList)
+ _lastGadgetHit = nullptr;
- ScreenGadgetList = GadList;
+ _screenGadgetList = gadgetList;
}
EventManager::EventManager(LabEngine *vm) : _vm(vm) {
+ _leftClick = false;
+ _rightClick = false;
+
+ _mouseHidden = true;
+ _numHidden = 1;
+ _lastGadgetHit = nullptr;
+ _screenGadgetList = nullptr;
}
void EventManager::mouseHandler(int flag, Common::Point pos) {
- if (NumHidden >= 2)
+ if (_numHidden >= 2)
return;
if (flag & 0x02) { /* Left mouse button click */
Gadget *tmp = NULL;
- if (ScreenGadgetList)
- tmp = checkGadgetHit(ScreenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
+ if (_screenGadgetList)
+ tmp = checkGadgetHit(_screenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
if (tmp)
- LastGadgetHit = tmp;
+ _lastGadgetHit = tmp;
else
- LeftClick = true;
+ _leftClick = true;
}
if (flag & 0x08) /* Right mouse button click */
- RightClick = true;
+ _rightClick = true;
}
void EventManager::updateMouse() {
bool doUpdateDisplay = false;
- if (!MouseHidden)
+ if (!_mouseHidden)
doUpdateDisplay = true;
if (hitgad) {
@@ -169,12 +169,12 @@ void EventManager::initMouse() {
/* Shows the mouse. */
/*****************************************************************************/
void EventManager::mouseShow() {
- if (NumHidden)
- NumHidden--;
+ if (_numHidden)
+ _numHidden--;
- if ((NumHidden == 0) && MouseHidden) {
+ if ((_numHidden == 0) && _mouseHidden) {
_vm->processInput();
- MouseHidden = false;
+ _mouseHidden = false;
}
g_system->showMouse(true);
@@ -184,10 +184,10 @@ void EventManager::mouseShow() {
/* Hides the mouse. */
/*****************************************************************************/
void EventManager::mouseHide() {
- NumHidden++;
+ _numHidden++;
- if (NumHidden && !MouseHidden) {
- MouseHidden = true;
+ if (_numHidden && !_mouseHidden) {
+ _mouseHidden = true;
g_system->showMouse(false);
}
@@ -214,7 +214,7 @@ void EventManager::setMousePos(Common::Point pos) {
else
g_system->warpMouse(pos.x * 2, pos.y);
- if (!MouseHidden)
+ if (!_mouseHidden)
_vm->processInput();
}
@@ -226,17 +226,17 @@ void EventManager::setMousePos(Common::Point pos) {
/*****************************************************************************/
bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
if (leftbutton) {
- if (LeftClick) {
+ if (_leftClick) {
*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
*y = (uint16)_vm->_mousePos.y;
- LeftClick = false;
+ _leftClick = false;
return true;
}
} else {
- if (RightClick) {
+ if (_rightClick) {
*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
*y = (uint16)_vm->_mousePos.y;
- RightClick = false;
+ _rightClick = false;
return true;
}
}
@@ -245,10 +245,10 @@ bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
}
Gadget *EventManager::mouseGadget() {
- Gadget *Temp = LastGadgetHit;
+ Gadget *temp = _lastGadgetHit;
- LastGadgetHit = nullptr;
- return Temp;
+ _lastGadgetHit = nullptr;
+ return temp;
}
} // End of namespace Lab
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 4bccb17805..0ff7d605f0 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -42,20 +42,28 @@ class LabEngine;
class EventManager {
private:
LabEngine *_vm;
+ bool _leftClick;
+ bool _rightClick;
+
+ bool _mouseHidden;
+ int32 _numHidden;
+ Gadget *_lastGadgetHit;
public:
EventManager (LabEngine *vm);
- Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos);
+ Gadget *_screenGadgetList;
+
+ Gadget *checkGadgetHit(Gadget *gadgetList, Common::Point pos);
void initMouse();
void updateMouse();
void mouseShow();
void mouseHide();
Common::Point getMousePos();
void setMousePos(Common::Point pos);
- bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
+ bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
Gadget *mouseGadget();
- void attachGadgetList(Gadget *GadList);
+ void attachGadgetList(Gadget *gadgetList);
void mouseHandler(int flag, Common::Point pos);
};