aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorja Lorente2016-06-11 23:57:35 +0200
committerBorja Lorente2016-08-14 18:15:35 +0200
commit63e4fe8fc7d99d858f5302a7c3321e1d73296904 (patch)
tree1672c8ce20226a2d5e36d3f57942bf9dc24b9bc9
parentc09e74b6a736f1970f2c75411dba6e2cefe1e76b (diff)
downloadscummvm-rg350-63e4fe8fc7d99d858f5302a7c3321e1d73296904.tar.gz
scummvm-rg350-63e4fe8fc7d99d858f5302a7c3321e1d73296904.tar.bz2
scummvm-rg350-63e4fe8fc7d99d858f5302a7c3321e1d73296904.zip
MACVENTURE: Add command callback
-rw-r--r--engines/macventure/gui.cpp31
-rw-r--r--engines/macventure/gui.h7
2 files changed, 33 insertions, 5 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 6bb54d8b79..887f9c2b65 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -82,13 +82,15 @@ Gui::~Gui() {
}
void Gui::draw() {
- _wm.draw();
+
Common::List<CommandButton>::const_iterator it = _controlData->begin();
for (; it != _controlData->end(); ++it) {
CommandButton button = *it;
if (button.getData().refcon != kControlExitBox)
button.draw(*_controlsWindow->getSurface());
}
+
+ _wm.draw();
}
bool Gui::processEvent(Common::Event &event) {
@@ -133,6 +135,7 @@ void Gui::initWindows() {
_controlsWindow->setActive(false);
_controlsWindow->setCallback(controlsWindowCallback, this);
loadBorder(_controlsWindow, "border_command.bmp", false);
+ loadBorder(_controlsWindow, "border_command.bmp", true);
}
@@ -229,10 +232,16 @@ bool Gui::loadMenus() {
}
/* CALLBACKS */
-bool outConsoleWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui) {
+bool outConsoleWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
return true;
}
+bool controlsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
+ Gui *g = (Gui*)gui;
+
+ return g->processCommandEvents(click, event);
+}
+
void menuCommandsCallback(int action, Common::String &text, void *data) {
Gui *g = (Gui *)data;
@@ -289,4 +298,22 @@ void Gui::handleMenuAction(MenuAction action) {
}
}
+
+bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
+ if (event.type == Common::EVENT_LBUTTONUP) {
+ Common::Point position(
+ event.mouse.x - _controlsWindow->getDimensions().left,
+ event.mouse.y - _controlsWindow->getDimensions().top);
+ //debug("Click at: %d, %d", p)
+ Common::List<CommandButton>::const_iterator it = _controlData->begin();
+ for (; it != _controlData->end(); ++it) {
+ const CommandButton &data = *it;
+ if (data.isInsideBounds(position)) {
+ debug("Command active: %s", data.getData().title);
+ }
+ }
+ }
+ return false;
+}
+
} // End of namespace MacVenture
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index d63f7fcb18..c6446cec29 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -62,6 +62,7 @@ public:
void draw();
bool processEvent(Common::Event &event);
void handleMenuAction(MenuAction action);
+ bool processCommandEvents(WindowClick click, Common::Event &event);
private: // Attributes
@@ -96,7 +97,7 @@ public:
}
~CommandButton() {}
- void draw(Graphics::ManagedSurface &surface) {
+ void draw(Graphics::ManagedSurface &surface) const {
surface.fillRect(_data.bounds, kColorWhite);
@@ -115,11 +116,11 @@ public:
}
- bool isInsideBounds(Common::Point point) {
+ bool isInsideBounds(const Common::Point point) const {
return _data.bounds.contains(point);
}
- const ControlData& getData() {
+ const ControlData& getData() const {
return _data;
}