aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-04-25 19:02:25 +0200
committerEugene Sandulenko2016-04-25 19:02:25 +0200
commit3a9159c5a34c891b10ff6b44d6982eda717e48f7 (patch)
tree227679ee07ea22aa6334b9edf638bbdb45fb9b6a
parent35d5d93725a4a554b1f0ddc8009d9595c950476b (diff)
downloadscummvm-rg350-3a9159c5a34c891b10ff6b44d6982eda717e48f7.tar.gz
scummvm-rg350-3a9159c5a34c891b10ff6b44d6982eda717e48f7.tar.bz2
scummvm-rg350-3a9159c5a34c891b10ff6b44d6982eda717e48f7.zip
WAGE: Made Menu subclass of BaseMacWindow
-rw-r--r--engines/wage/gui-console.cpp2
-rw-r--r--engines/wage/gui.cpp10
-rw-r--r--engines/wage/macwindowmanager.cpp11
-rw-r--r--engines/wage/macwindowmanager.h2
-rw-r--r--engines/wage/menu.cpp10
-rw-r--r--engines/wage/menu.h14
6 files changed, 38 insertions, 11 deletions
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index ca1917b96d..e0373687bf 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -45,6 +45,7 @@
*
*/
+#include "common/events.h"
#include "common/timer.h"
#include "common/unzip.h"
#include "graphics/cursorman.h"
@@ -54,6 +55,7 @@
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
+#include "wage/macwindow.h"
#include "wage/menu.h"
#include "wage/gui.h"
#include "wage/world.h"
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 5aacb96eaa..8aaad70cd3 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -187,7 +187,7 @@ Gui::Gui(WageEngine *engine) {
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
- _menu = new Menu(this);
+ _menu = _wm.addMenu(this);
_sceneWindow = _wm.addWindow(false, false);
_sceneWindow->setCallback(sceneWindowCallback, this);
@@ -235,7 +235,7 @@ void Gui::draw() {
if (_menuDirty) {
_wm.setFullRefresh(true);
_wm.draw();
- _menu->render();
+ _menu->draw(&_screen);
}
_menuDirty = false;
@@ -264,7 +264,7 @@ void Gui::draw() {
_wm.draw();
if (_menuDirty)
- _menu->render();
+ _menu->draw(&_screen);
if (_cursorDirty && _cursorRect.left < _screen.w && _cursorRect.bottom < _screen.h) {
g_system->copyRectToScreen(_screen.getBasePtr(_cursorRect.left, _cursorRect.top), _screen.pitch,
@@ -487,7 +487,7 @@ void Gui::processMenuShortCut(byte flags, uint16 ascii) {
}
void Gui::mouseMove(int x, int y) {
- if (_menu->_menuActivated) {
+ if (_menu->hasAllFocus()) {
if (_menu->mouseMove(x, y))
_menuDirty = true;
@@ -526,7 +526,7 @@ bool Gui::processEvent(Common::Event &event) {
}
void Gui::mouseUp(int x, int y) {
- if (_menu->_menuActivated) {
+ if (_menu->hasAllFocus()) {
if (_menu->mouseRelease(x, y)) {
_sceneDirty = true;
_consoleDirty = true;
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index a86b16a8bb..de75555273 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -57,6 +57,7 @@
#include "wage/gui.h"
#include "wage/macwindow.h"
#include "wage/macwindowmanager.h"
+#include "wage/menu.h"
namespace Wage {
@@ -97,6 +98,16 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
return w;
}
+Menu *MacWindowManager::addMenu(Gui *g) {
+ Menu *m = new Menu(_lastId, g);
+
+ _windows.push_back(m);
+
+ _lastId++;
+
+ return m;
+}
+
void MacWindowManager::setActive(int id) {
if (_activeWindow == id)
return;
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 06b7689706..0d0ade03ab 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -51,6 +51,7 @@
namespace Wage {
class MacWindow;
+class Menu;
class MacWindowManager {
public:
@@ -60,6 +61,7 @@ public:
void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
MacWindow *addWindow(bool scrollable, bool resizable);
+ Menu *addMenu(Gui *gui);
void setActive(int id);
void setFullRefresh(bool redraw) { _fullRefresh = true; }
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 27cbf5e4f5..198bdf3d40 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -104,7 +104,7 @@ struct MenuData {
{ 0, NULL, 0, 0, false }
};
-Menu::Menu(Gui *gui) : _gui(gui) {
+Menu::Menu(int id, Gui *gui) : BaseMacWindow(id), _gui(gui) {
assert(_gui->_engine);
assert(_gui->_engine->_world);
@@ -338,7 +338,7 @@ void Menu::calcMenuBounds(MenuItem *menu) {
menu->subbbox.bottom = y2;
}
-void Menu::render() {
+bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
Common::Rect r(_bbox);
Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
@@ -368,6 +368,8 @@ void Menu::render() {
}
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
+
+ return true;
}
void Menu::renderSubmenu(MenuItem *menu) {
@@ -439,6 +441,10 @@ void Menu::renderSubmenu(MenuItem *menu) {
g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3);
}
+bool Menu::processEvent(Common::Event &event) {
+ return false;
+}
+
bool Menu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
if (!_menuActivated)
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 916ef6d50e..fed5c5c66c 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -90,12 +90,14 @@ enum {
kMenuActionCommand
};
-class Menu {
+class Menu : public BaseMacWindow {
public:
- Menu(Gui *gui);
+ Menu(int id, Gui *gui);
~Menu();
- void render();
+ bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
+ bool processEvent(Common::Event &event);
+
bool mouseClick(int x, int y);
bool mouseRelease(int x, int y);
bool mouseMove(int x, int y);
@@ -106,7 +108,9 @@ public:
void enableCommand(int menunum, int action, bool state);
void disableAllMenus();
- bool _menuActivated;
+ void setActive(bool active) { _menuActivated = active; }
+ bool hasAllFocus() { return _menuActivated; }
+
Common::Rect _bbox;
private:
@@ -130,6 +134,8 @@ private:
const Graphics::Font *_font;
+ bool _menuActivated;
+
int _activeItem;
int _activeSubItem;
};