aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/design.cpp9
-rw-r--r--engines/wage/design.h1
-rw-r--r--engines/wage/gui.cpp53
-rw-r--r--engines/wage/gui.h4
-rw-r--r--engines/wage/wage.cpp8
5 files changed, 68 insertions, 7 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 555ab5edcc..3b44566495 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -169,6 +169,15 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, bool mask, in
}
}
+bool Design::isPointOpaque(int x, int y) {
+ if (_surface == NULL)
+ error("Surface is null");
+
+ byte pixel = ((byte *)_surface->getBasePtr(x, y))[0];
+
+ return pixel != kColorGreen;
+}
+
void drawPixel(int x, int y, int color, void *data) {
plotData *p = (plotData *)data;
diff --git a/engines/wage/design.h b/engines/wage/design.h
index f876d1b550..2a051f1791 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -68,6 +68,7 @@ public:
}
void paint(Graphics::Surface *canvas, Patterns &patterns, bool mask, int x, int y);
+ bool isPointOpaque(int x, int y);
static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType);
static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 631a2f7cab..789c350353 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -119,6 +119,7 @@ static const byte macCursorBeam[] = {
Gui::Gui() {
_scene = NULL;
_sceneDirty = true;
+ _bordersDirty = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
Patterns p;
@@ -126,6 +127,7 @@ Gui::Gui() {
_scrollPos = 0;
_builtInFonts = false;
+ _sceneIsActive = false;
g_system->getPaletteManager()->setPalette(palette, 0, 4);
@@ -177,8 +179,11 @@ void Gui::appendText(String &str) {
void Gui::draw() {
if (_scene != NULL && _sceneDirty) {
_scene->paint(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding);
- paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
- kWindowScene);
+
+ _sceneArea.left = 0 + kComponentsPadding + kBorderWidth;
+ _sceneArea.top = kMenuHeight + kComponentsPadding + kBorderWidth;
+ _sceneArea.setWidth(_scene->_design->getBounds()->width() - 2 * kBorderWidth);
+ _sceneArea.setHeight(_scene->_design->getBounds()->height() - 2 * kBorderWidth);
_sceneDirty = false;
}
@@ -191,7 +196,15 @@ void Gui::draw() {
int consoleY = kMenuHeight + kComponentsPadding;
renderConsole(&_screen, consoleX + kBorderWidth , consoleY + kBorderWidth, consoleW - 2 * kBorderWidth, consoleH - 2 * kBorderWidth);
- paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);
+
+ if (_bordersDirty) {
+ if (_scene)
+ paintBorder(&_screen, 0 + kComponentsPadding, kMenuHeight + kComponentsPadding, _scene->_design->getBounds()->width(), _scene->_design->getBounds()->height(),
+ kWindowScene);
+ paintBorder(&_screen, consoleX, consoleY, consoleW, consoleH, kWindowConsole);
+
+ _bordersDirty = false;
+ }
renderMenu();
@@ -227,16 +240,16 @@ void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height,
switch (windowType) {
case kWindowScene:
- active = false;
+ active = _sceneIsActive;
scrollable = false;
- closeable = false;
+ closeable = _sceneIsActive;
closeBoxPressed = false;
drawTitle = true;
break;
case kWindowConsole:
- active = true;
+ active = !_sceneIsActive;
scrollable = true;
- closeable = true;
+ closeable = !_sceneIsActive;
closeBoxPressed = false;
drawTitle = false;
break;
@@ -506,4 +519,30 @@ void Gui::renderMenu() {
}
}
+Designed *Gui::getClickTarget(int x, int y) {
+ if (_sceneArea.contains(x, y)) {
+ if (!_sceneIsActive) {
+ _sceneIsActive = true;
+ _bordersDirty = true;
+ }
+
+ for (Common::List<Obj *>::const_iterator it = _scene->_objs.begin(); it != _scene->_objs.end(); ++it) {
+ if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
+ return *it;
+ }
+
+ for (Common::List<Chr *>::const_iterator it = _scene->_chrs.begin(); it != _scene->_chrs.end(); ++it) {
+ if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
+ return *it;
+ }
+ } else if (_consoleTextArea.contains(x, y)) {
+ if (_sceneIsActive) {
+ _sceneIsActive = false;
+ _bordersDirty = true;
+ }
+ }
+
+ return NULL;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 9573f57e25..f5e1ef5c9b 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -68,6 +68,7 @@ public:
void setScene(Scene *scene);
void appendText(Common::String &str);
void mouseMove(int x, int y);
+ Designed *getClickTarget(int x, int y);
private:
void paintBorder(Graphics::Surface *g, int x, int y, int width, int height, WindowType windowType);
@@ -82,6 +83,7 @@ private:
Graphics::Surface _console;
Scene *_scene;
bool _sceneDirty;
+ bool _bordersDirty;
Common::StringArray _out;
Common::StringArray _lines;
@@ -90,6 +92,8 @@ private:
bool _builtInFonts;
Common::Rect _consoleTextArea;
+ Common::Rect _sceneArea;
+ bool _sceneIsActive;
bool _cursorIsArrow;
};
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 2ff0c66f86..bc0aff734a 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -144,6 +144,14 @@ void WageEngine::processEvents() {
case Common::EVENT_MOUSEMOVE:
_gui->mouseMove(event.mouse.x, event.mouse.y);
break;
+ case Common::EVENT_LBUTTONDOWN:
+ break;
+ case Common::EVENT_LBUTTONUP:
+ {
+ Designed *obj = _gui->getClickTarget(event.mouse.x, event.mouse.y);
+ if (obj != NULL)
+ debug(0, "Clicked: %s", obj->_name.c_str());
+ }
default:
break;
}