diff options
author | Eugene Sandulenko | 2016-04-19 10:37:53 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-19 10:37:53 +0200 |
commit | fd7bf64131a0f1ecc5f3b4039c481fff52eb6efa (patch) | |
tree | 092ffce1e890a20636a17eeb934f3bfea4d32f40 /engines/wage | |
parent | 609dd56b136db3e0bdfc7906bdc386403e4a1192 (diff) | |
download | scummvm-rg350-fd7bf64131a0f1ecc5f3b4039c481fff52eb6efa.tar.gz scummvm-rg350-fd7bf64131a0f1ecc5f3b4039c481fff52eb6efa.tar.bz2 scummvm-rg350-fd7bf64131a0f1ecc5f3b4039c481fff52eb6efa.zip |
WAGE: Switched event processing to generic code
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/gui.cpp | 30 | ||||
-rw-r--r-- | engines/wage/gui.h | 2 | ||||
-rw-r--r-- | engines/wage/macwindow.cpp | 26 | ||||
-rw-r--r-- | engines/wage/macwindow.h | 4 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.cpp | 17 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.h | 2 | ||||
-rw-r--r-- | engines/wage/wage.cpp | 16 |
7 files changed, 73 insertions, 24 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 8833f7f63d..5bb342fcab 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -55,10 +55,10 @@ #include "wage/wage.h" #include "wage/design.h" #include "wage/entities.h" +#include "wage/gui.h" #include "wage/macwindow.h" #include "wage/macwindowmanager.h" #include "wage/menu.h" -#include "wage/gui.h" #include "wage/world.h" namespace Wage { @@ -540,6 +540,32 @@ void Gui::popCursor() { CursorMan.popCursor(); } +bool Gui::processEvent(Common::Event &event) { + if (_wm.processEvent(event)) + return true; + + switch (event.type) { + case Common::EVENT_MOUSEMOVE: + mouseMove(event.mouse.x, event.mouse.y); + break; + case Common::EVENT_LBUTTONDOWN: + mouseDown(event.mouse.x, event.mouse.y); + break; + case Common::EVENT_LBUTTONUP: + { + Designed *obj = mouseUp(event.mouse.x, event.mouse.y); + if (obj != NULL) + _engine->processTurn(NULL, obj); + } + break; + + default: + return false; + } + + return true; +} + static int isInBorder(Common::Rect &rect, int x, int y) { if (x >= rect.left - kBorderWidth && x < rect.left && y >= rect.top - kBorderWidth && y < rect.top) return kBorderCloseButton; @@ -645,8 +671,6 @@ Designed *Gui::mouseUp(int x, int y) { void Gui::mouseDown(int x, int y) { int borderClick; - _wm.mouseDown(x, y); - if (_menu->mouseClick(x, y)) { _menuDirty = true; } else if (_consoleTextArea.contains(x, y)) { diff --git a/engines/wage/gui.h b/engines/wage/gui.h index dc3a593bda..c731c94425 100644 --- a/engines/wage/gui.h +++ b/engines/wage/gui.h @@ -52,6 +52,7 @@ #include "graphics/font.h" #include "graphics/fontman.h" #include "graphics/managed_surface.h" +#include "common/events.h" #include "common/rect.h" #include "wage/macwindow.h" @@ -89,6 +90,7 @@ public: void draw(); void appendText(const char *str); void clearOutput(); + bool processEvent(Common::Event &event); void mouseMove(int x, int y); void mouseDown(int x, int y); Designed *mouseUp(int x, int y); diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index 490ab9e886..eac552245f 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -46,6 +46,7 @@ */ #include "graphics/primitives.h" +#include "common/events.h" #include "wage/wage.h" #include "wage/gui.h" @@ -264,6 +265,31 @@ static WindowClick isInBorder(Common::Rect &rect, int x, int y) { return kBorderNone; } +bool MacWindow::processEvent(Common::Event &event) { + switch (event.type) { + case Common::EVENT_MOUSEMOVE: + //mouseMove(event.mouse.x, event.mouse.y); + break; + case Common::EVENT_LBUTTONDOWN: + mouseDown(event.mouse.x, event.mouse.y); + break; + case Common::EVENT_LBUTTONUP: +#if 0 + { + Designed *obj = mouseUp(event.mouse.x, event.mouse.y); + if (obj != NULL) + _engine->processTurn(NULL, obj); + } +#endif + break; + + default: + return false; + } + + return true; +} + void MacWindow::mouseDown(int x, int y) { if (_innerDims.contains(x, y)) { // (*callback)(x - _dims.left, y - dims.top); diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index 73984b0f34..fb2974a72f 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -85,7 +85,7 @@ public: void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; } void setDirty(bool dirty) { _contentIsDirty = dirty; } int getId() { return _id; } - void mouseDown(int x, int y); + bool processEvent(Common::Event &event); private: void drawBorder(); @@ -94,6 +94,8 @@ private: const Graphics::Font *getTitleFont(); bool builtInFonts(); + void mouseDown(int x, int y); + private: Graphics::ManagedSurface _surface; Graphics::ManagedSurface _borderSurface; diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 08c8a4df3a..1bf7b54190 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -45,8 +45,9 @@ * */ -#include "common/list.h" #include "common/array.h" +#include "common/events.h" +#include "common/list.h" #include "common/system.h" #include "graphics/managed_surface.h" @@ -115,16 +116,20 @@ void MacWindowManager::draw() { _fullRefresh = false; } -bool MacWindowManager::mouseDown(int x, int y) { +bool MacWindowManager::processEvent(Common::Event &event) { + if (event.type != Common::EVENT_MOUSEMOVE && event.type != Common::EVENT_LBUTTONDOWN && + event.type != Common::EVENT_LBUTTONUP) + return false; + for (Common::List<MacWindow *>::const_iterator it = _windowStack.end(); it != _windowStack.begin();) { it--; MacWindow *w = *it; - if (w->getDimensions().contains(x, y)) { - setActive(w->getId()); - w->mouseDown(x, y); + if (w->getDimensions().contains(event.mouse.x, event.mouse.y)) { + if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP) + setActive(w->getId()); - return true; + return w->processEvent(event); } } diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index adb086df8a..d074564f54 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -66,7 +66,7 @@ public: void draw(); - bool mouseDown(int x, int y); + bool processEvent(Common::Event &event); MacWindow *getWindow(int id) { return _windows[id]; } diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index 3a52aed1c4..73794f7afd 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -148,24 +148,14 @@ void WageEngine::processEvents() { Common::Event event; while (_eventMan->pollEvent(event)) { + if (_gui->processEvent(event)) + continue; + switch (event.type) { case Common::EVENT_QUIT: if (saveDialog()) _shouldQuit = true; break; - case Common::EVENT_MOUSEMOVE: - _gui->mouseMove(event.mouse.x, event.mouse.y); - break; - case Common::EVENT_LBUTTONDOWN: - _gui->mouseDown(event.mouse.x, event.mouse.y); - break; - case Common::EVENT_LBUTTONUP: - { - Designed *obj = _gui->mouseUp(event.mouse.x, event.mouse.y); - if (obj != NULL) - processTurn(NULL, obj); - } - break; case Common::EVENT_KEYDOWN: switch (event.kbd.keycode) { case Common::KEYCODE_BACKSPACE: |