aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-04-28 09:59:35 +0200
committerEugene Sandulenko2016-04-28 09:59:35 +0200
commit137d6b97276b3bde1a1c13eecd8f0ebe580cb7d9 (patch)
treed90fb6323d29a5dbd8b78dd94ee0b6d2b9d21b65
parent97371135c624aa4e8a0441bd6310d7dfd204e280 (diff)
downloadscummvm-rg350-137d6b97276b3bde1a1c13eecd8f0ebe580cb7d9.tar.gz
scummvm-rg350-137d6b97276b3bde1a1c13eecd8f0ebe580cb7d9.tar.bz2
scummvm-rg350-137d6b97276b3bde1a1c13eecd8f0ebe580cb7d9.zip
WAGE: More Menu class decoupling from the engine
-rw-r--r--engines/wage/gui.cpp2
-rw-r--r--engines/wage/macwindowmanager.cpp4
-rw-r--r--engines/wage/macwindowmanager.h2
-rw-r--r--engines/wage/menu.cpp13
-rw-r--r--engines/wage/menu.h4
5 files changed, 14 insertions, 11 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 1feed364cd..a3705dd267 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -186,7 +186,7 @@ Gui::Gui(WageEngine *engine) {
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
- _menu = _wm.addMenu(this);
+ _menu = _wm.addMenu(_builtInFonts, this);
_sceneWindow = _wm.addWindow(false, false);
_sceneWindow->setCallback(sceneWindowCallback, this);
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index b204d1b526..1defdaa277 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -100,8 +100,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
return w;
}
-Menu *MacWindowManager::addMenu(Gui *g) {
- _menu = new Menu(_lastId, _screen->getBounds(), g);
+Menu *MacWindowManager::addMenu(bool builtInFonts, Gui *g) {
+ _menu = new Menu(_lastId, _screen->getBounds(), builtInFonts, g);
_windows.push_back(_menu);
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 91d426e9d9..95b1dffcb2 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -61,7 +61,7 @@ public:
void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
MacWindow *addWindow(bool scrollable, bool resizable);
- Menu *addMenu(Gui *gui);
+ Menu *addMenu(bool builtInFonts, 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 2b848584aa..17a7d68ac6 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -104,12 +104,13 @@ struct MenuData {
{ 0, NULL, 0, 0, false }
};
-Menu::Menu(int id, const Common::Rect &bounds, Gui *gui) : BaseMacWindow(id), _gui(gui) {
+Menu::Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui)
+ : BaseMacWindow(id), _gui(gui), _builtInFonts(builtInFonts) {
_font = getMenuFont();
_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
- MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
+ MenuItem *about = new MenuItem(_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
@@ -149,7 +150,7 @@ Menu::Menu(int id, const Common::Rect &bounds, Gui *gui) : BaseMacWindow(id), _g
_items[i]->bbox.left = x - kMenuLeftMargin;
_items[i]->bbox.top = y;
_items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
- _items[i]->bbox.bottom = y + _font->getFontHeight() + (_gui->_builtInFonts ? 3 : 2);
+ _items[i]->bbox.bottom = y + _font->getFontHeight() + (_builtInFonts ? 3 : 2);
}
calcMenuBounds(_items[i]);
@@ -298,7 +299,7 @@ const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {
*res = 0;
if (item->shortcut != 0)
- sprintf(res, "%s%c%c", prefix, (_gui->_builtInFonts ? '^' : '\x11'), item->shortcut);
+ sprintf(res, "%s%c%c", prefix, (_builtInFonts ? '^' : '\x11'), item->shortcut);
return res;
}
@@ -368,7 +369,7 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
renderSubmenu(it);
}
- _font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_gui->_builtInFonts ? 2 : 1), it->bbox.width(), color);
+ _font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_builtInFonts ? 2 : 1), it->bbox.width(), color);
}
g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
@@ -397,7 +398,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
int color = kColorBlack;
if (i == (uint)_activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
color = kColorWhite;
- Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
+ Common::Rect trect(r->left, y - (_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 40d52ea397..374c9ed1df 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -92,7 +92,7 @@ enum {
class Menu : public BaseMacWindow {
public:
- Menu(int id, const Common::Rect &bounds, Gui *gui);
+ Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui);
~Menu();
bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
@@ -141,6 +141,8 @@ private:
int _activeItem;
int _activeSubItem;
+
+ bool _builtInFonts;
};
} // End of namespace Wage