aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/entities.cpp16
-rw-r--r--engines/wage/entities.h2
-rw-r--r--engines/wage/gui.cpp13
-rw-r--r--engines/wage/gui.h2
-rw-r--r--engines/wage/macwindow.cpp26
5 files changed, 40 insertions, 19 deletions
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 49e2592949..d0a838f1e7 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -202,6 +202,22 @@ const char *Scene::getFontName() {
return "Unknown";
}
+Designed *Scene::lookUpEntity(int x, int y) {
+ for (ObjList::const_iterator it = _objs.end(); it != _objs.begin(); ) {
+ it--;
+ if ((*it)->_design->isPointOpaque(x, y))
+ return *it;
+ }
+
+ for (ChrList::const_iterator it = _chrs.end(); it != _chrs.begin(); ) {
+ it--;
+ if ((*it)->_design->isPointOpaque(x, y))
+ return *it;
+ }
+
+ return nullptr;
+}
+
Obj::Obj() : _currentOwner(NULL), _currentScene(NULL) {
_index = 0;
_namePlural = false;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index c393f15f01..9e706f0d58 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -322,6 +322,8 @@ public:
Scene(Common::String name, Common::SeekableReadStream *data);
~Scene();
+ Designed *lookUpEntity(int x, int y);
+
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index ffbd801f89..05af5667e6 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -315,7 +315,18 @@ void Gui::drawScene() {
_consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth);
}
-static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui) {
+static void sceneWindowCallback(WindowClick click, Common::Event &event, void *g) {
+ Gui *gui = (Gui *)g;
+
+ if (click == kBorderInner && event.type == Common::EVENT_LBUTTONUP) {
+ Designed *obj = gui->_scene->lookUpEntity(event.mouse.x - gui->_sceneWindow->getDimensions().left,
+ event.mouse.y - gui->_sceneWindow->getDimensions().top);
+
+ if (obj != nullptr)
+ gui->_engine->processTurn(NULL, obj);
+
+ return;
+ }
}
// Render console
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 99bfbd8fad..baf167a370 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -155,13 +155,13 @@ public:
bool _menuDirty;
+ Scene *_scene;
MacWindow *_sceneWindow;
MacWindow *_consoleWindow;
private:
Graphics::ManagedSurface _console;
Menu *_menu;
- Scene *_scene;
bool _sceneDirty;
bool _consoleDirty;
bool _bordersDirty;
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 682045b9c9..1b869fa222 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -267,6 +267,9 @@ void MacWindow::fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h
}
static WindowClick isInBorder(Common::Rect &rect, int x, int y) {
+ if (rect.contains(x, y))
+ return kBorderInner;
+
if (x >= rect.left - kBorderWidth && x < rect.left && y >= rect.top - kBorderWidth && y < rect.top)
return kBorderCloseButton;
@@ -294,15 +297,12 @@ bool MacWindow::processEvent(Common::Event &event) {
case Common::EVENT_LBUTTONDOWN:
mouseDown(event);
break;
- case Common::EVENT_LBUTTONUP:
- setHighlight(kBorderNone);
-#if 0
- {
- Designed *obj = mouseUp(event.mouse.x, event.mouse.y);
- if (obj != NULL)
- _engine->processTurn(NULL, obj);
+ case Common::EVENT_LBUTTONUP: {
+ setHighlight(kBorderNone);
+
+ WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
+ (*_callback)(click, event, _dataPtr);
}
-#endif
break;
default:
@@ -313,14 +313,6 @@ bool MacWindow::processEvent(Common::Event &event) {
}
void MacWindow::mouseDown(Common::Event &event) {
- if (_innerDims.contains(event.mouse.x, event.mouse.y)) {
- if (!_callback)
- return;
-
- (*_callback)(kBorderInner, event, _dataPtr);
- return;
- }
-
WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
if (click == kBorderNone)
@@ -328,7 +320,7 @@ void MacWindow::mouseDown(Common::Event &event) {
setHighlight(click);
- if (click == kBorderScrollUp || click == kBorderScrollDown) {
+ if (click == kBorderScrollUp || click == kBorderScrollDown || click == kBorderInner) {
if (!_callback)
return;