aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cge/cge_main.cpp6
-rw-r--r--engines/cge/cge_main.h2
-rw-r--r--engines/cge/events.cpp78
-rw-r--r--engines/cge/events.h5
-rw-r--r--engines/cge/vmenu.cpp2
-rw-r--r--engines/cge/vmenu.h2
6 files changed, 52 insertions, 43 deletions
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 0fa2b0cb0c..0ee8f3ef0b 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -552,7 +552,7 @@ void WALK::reach(Sprite *spr, int mode) {
class SQUARE : public Sprite {
public:
SQUARE(CGEEngine *vm);
- void Touch(uint16 mask, int x, int y);
+ virtual void touch(uint16 mask, int x, int y);
private:
CGEEngine *_vm;
};
@@ -565,7 +565,7 @@ SQUARE::SQUARE(CGEEngine *vm)
}
-void SQUARE::Touch(uint16 mask, int x, int y) {
+void SQUARE::touch(uint16 mask, int x, int y) {
Sprite::touch(mask, x, y);
if (mask & L_UP) {
XZ(_x + x, _y + y).cell() = 0;
@@ -822,7 +822,7 @@ SYSTEM::SYSTEM(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
Tick();
}
-void SYSTEM::Touch(uint16 mask, int x, int y) {
+void SYSTEM::touch(uint16 mask, int x, int y) {
static int pp = 0;
FunTouch();
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index effded84cc..6920f7b2d3 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -122,7 +122,7 @@ public:
void SetPal();
void FunTouch();
- void Touch(uint16 mask, int x, int y);
+ virtual void touch(uint16 mask, int x, int y);
void Tick();
private:
CGEEngine *_vm;
diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp
index 92c356fa5f..932c922c49 100644
--- a/engines/cge/events.cpp
+++ b/engines/cge/events.cpp
@@ -247,18 +247,46 @@ void MOUSE::ClrEvt(Sprite *spr) {
EvtTail = EvtHead;
}
+/*----------------- EventManager interface -----------------*/
+
+EventManager::EventManager() {
+ _quitFlag = false;
+}
+
+void EventManager::poll() {
+ while (g_system->getEventManager()->pollEvent(_event)) {
+ switch (_event.type) {
+ case Common::EVENT_QUIT:
+ _quitFlag = true;
+ return;
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYUP:
+ _keyboard->NewKeyboard(_event);
+ handleEvents();
+ break;
+ case Common::EVENT_MOUSEMOVE:
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ // TODO: Handle mouse events
+ //_mouse->NewMouse(event);
+ handleEvents();
+ break;
+ }
+ }
+}
-void MOUSE::Tick(void) {
- step();
+void EventManager::handleEvents(void) {
while (EvtTail != EvtHead) {
CGEEvent e = Evt[EvtTail];
if (e._msk) {
- if (Hold && e._ptr != Hold)
- Hold->touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y);
+ if (_mouse->Hold && e._ptr != _mouse->Hold)
+ _mouse->Hold->touch(e._msk | ATTN, e._x - _mouse->Hold->_x, e._y - _mouse->Hold->_y);
// update mouse cursor position
if (e._msk & ROLL)
- gotoxy(e._x, e._y);
+ _mouse->gotoxy(e._x, e._y);
// activate current touched SPRITE
if (e._ptr) {
@@ -270,18 +298,18 @@ void MOUSE::Tick(void) {
Sys->touch(e._msk, e._x, e._y);
if (e._msk & L_DN) {
- Hold = e._ptr;
- if (Hold) {
- Hold->_flags._hold = true;
- hx = e._x - Hold->_x;
- hy = e._y - Hold->_y;
+ _mouse->Hold = e._ptr;
+ if (_mouse->Hold) {
+ _mouse->Hold->_flags._hold = true;
+ _mouse->hx = e._x - _mouse->Hold->_x;
+ _mouse->hy = e._y - _mouse->Hold->_y;
}
}
if (e._msk & L_UP) {
- if (Hold) {
- Hold->_flags._hold = false;
- Hold = NULL;
+ if (_mouse->Hold) {
+ _mouse->Hold->_flags._hold = false;
+ _mouse->Hold = NULL;
}
}
///Touched = e.Ptr;
@@ -292,28 +320,8 @@ void MOUSE::Tick(void) {
}
EvtTail = (EvtTail + 1) % EVT_MAX;
}
- if (Hold)
- Hold->gotoxy(_x - hx, _y - hy);
-}
-
-/*----------------- EventManager interface -----------------*/
-
-EventManager::EventManager() {
- _quitFlag = false;
-}
-
-void EventManager::poll() {
- while (g_system->getEventManager()->pollEvent(_event)) {
- switch (_event.type) {
- case Common::EVENT_QUIT:
- _quitFlag = true;
- return;
- case Common::EVENT_KEYDOWN:
- case Common::EVENT_KEYUP:
- _keyboard->NewKeyboard(_event);
- break;
- }
- }
+ if (_mouse->Hold)
+ _mouse->Hold->gotoxy(_mouse->_x - _mouse->hx, _mouse->_y - _mouse->hy);
}
} // End of namespace CGE
diff --git a/engines/cge/events.h b/engines/cge/events.h
index be003ea0d8..4ed74469f2 100644
--- a/engines/cge/events.h
+++ b/engines/cge/events.h
@@ -98,11 +98,11 @@ class MOUSE : public Sprite {
static MOUSE_FUN *OldMouseFun;
static MOUSE_FUN NewMouseFun;
static uint16 OldMouseMask;
- Sprite *Hold;
- int hx, hy;
//void SetFun (void);
//void ResetFun (void);
public:
+ Sprite *Hold;
+ int hx, hy;
bool Exist;
int Buttons;
Sprite *Busy;
@@ -122,6 +122,7 @@ private:
class EventManager {
private:
Common::Event _event;
+ void handleEvents();
public:
bool _quitFlag;
diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp
index 149af901e8..d999dfa760 100644
--- a/engines/cge/vmenu.cpp
+++ b/engines/cge/vmenu.cpp
@@ -125,7 +125,7 @@ VMENU::~VMENU(void) {
}
-void VMENU::Touch(uint16 mask, int x, int y) {
+void VMENU::touch(uint16 mask, int x, int y) {
uint16 h = FONT_HIG + TEXT_LS;
bool ok = false;
diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h
index 2bb3cef88d..c2fc096e83 100644
--- a/engines/cge/vmenu.h
+++ b/engines/cge/vmenu.h
@@ -59,7 +59,7 @@ public:
MENU_BAR *Bar;
VMENU(CGEEngine *vm, CHOICE *list, int x, int y);
~VMENU();
- void Touch(uint16 mask, int x, int y);
+ virtual void touch(uint16 mask, int x, int y);
private:
CGEEngine *_vm;
};