diff options
author | Eugene Sandulenko | 2016-04-28 10:10:47 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-28 10:22:13 +0200 |
commit | bbd107825f7673788ea43b7093e7855daded553b (patch) | |
tree | 8dce078b07a8bf8c1d26cbb22897946ce81d3cce | |
parent | 137d6b97276b3bde1a1c13eecd8f0ebe580cb7d9 (diff) | |
download | scummvm-rg350-bbd107825f7673788ea43b7093e7855daded553b.tar.gz scummvm-rg350-bbd107825f7673788ea43b7093e7855daded553b.tar.bz2 scummvm-rg350-bbd107825f7673788ea43b7093e7855daded553b.zip |
WAGE: Decoupled Window class too
-rw-r--r-- | engines/wage/gui.cpp | 3 | ||||
-rw-r--r-- | engines/wage/macwindow.cpp | 16 | ||||
-rw-r--r-- | engines/wage/macwindow.h | 9 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.cpp | 8 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.h | 6 | ||||
-rw-r--r-- | engines/wage/menu.cpp | 16 | ||||
-rw-r--r-- | engines/wage/menu.h | 4 |
7 files changed, 33 insertions, 29 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index a3705dd267..92b936f3e5 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -183,10 +183,11 @@ Gui::Gui(WageEngine *engine) { _patterns.push_back(fillPatterns[i]); loadFonts(); + _wm.setBuiltInFonts(_builtInFonts); g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor"); - _menu = _wm.addMenu(_builtInFonts, this); + _menu = _wm.addMenu(this); _sceneWindow = _wm.addWindow(false, false); _sceneWindow->setCallback(sceneWindowCallback, this); diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index 36b27a3e56..199bbdc25d 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -54,7 +54,7 @@ namespace Wage { -BaseMacWindow::BaseMacWindow(int id) : _id(id) { +BaseMacWindow::BaseMacWindow(int id, MacWindowManager *wm) : _id(id), _wm(wm) { _callback = 0; _dataPtr = 0; @@ -63,8 +63,8 @@ BaseMacWindow::BaseMacWindow(int id) : _id(id) { _type = kWindowUnknown; } -MacWindow::MacWindow(int id, bool scrollable, bool resizable) : - BaseMacWindow(id), _scrollable(scrollable), _resizable(resizable) { +MacWindow::MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *wm) : + BaseMacWindow(id, wm), _scrollable(scrollable), _resizable(resizable) { _active = false; _borderIsDirty = true; @@ -149,10 +149,6 @@ const Graphics::Font *MacWindow::getTitleFont() { return ((WageEngine *)g_engine)->_gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont); } -bool MacWindow::builtInFonts() { - return ((WageEngine *)g_engine)->_gui->builtInFonts(); -} - #define ARROW_W 12 #define ARROW_H 6 const int arrowPixels[ARROW_H][ARROW_W] = { @@ -248,7 +244,7 @@ void MacWindow::drawBorder() { if (drawTitle) { const Graphics::Font *font = getTitleFont(); - int yOff = builtInFonts() ? 3 : 1; + int yOff = _wm->hasBuiltInFonts() ? 3 : 1; int w = font->getStringWidth(_title) + 10; int maxWidth = width - size * 2 - 7; @@ -329,7 +325,7 @@ bool MacWindow::processEvent(Common::Event &event) { _draggedX = event.mouse.x; _draggedY = event.mouse.y; - ((WageEngine *)g_engine)->_gui->_wm.setFullRefresh(true); + _wm->setFullRefresh(true); } if (_beingResized) { @@ -339,7 +335,7 @@ bool MacWindow::processEvent(Common::Event &event) { _draggedX = event.mouse.x; _draggedY = event.mouse.y; - ((WageEngine *)g_engine)->_gui->_wm.setFullRefresh(true); + _wm->setFullRefresh(true); (*_callback)(click, event, _dataPtr); } break; diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index 797e2f9c2a..4b2f71e82c 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -52,6 +52,8 @@ namespace Wage { +class MacWindowManager; + enum WindowType { kWindowUnknown, kWindowWindow, @@ -74,7 +76,7 @@ enum WindowClick { class BaseMacWindow { public: - BaseMacWindow(int id); + BaseMacWindow(int id, MacWindowManager *wm); virtual ~BaseMacWindow() {} const Common::Rect &getDimensions() { return _dims; } @@ -102,11 +104,13 @@ protected: bool (*_callback)(WindowClick, Common::Event &, void *); void *_dataPtr; + + MacWindowManager *_wm; }; class MacWindow : public BaseMacWindow { public: - MacWindow(int id, bool scrollable, bool resizable); + MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *wm); virtual ~MacWindow(); void move(int x, int y); void resize(int w, int h); @@ -127,7 +131,6 @@ private: void drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h); void fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color = kColorBlack); const Graphics::Font *getTitleFont(); - bool builtInFonts(); void updateInnerDims(); WindowClick isInBorder(int x, int y); diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 1defdaa277..b3cd15e448 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -78,6 +78,8 @@ MacWindowManager::MacWindowManager() { _fullRefresh = true; + _builtInFonts = true; + for (int i = 0; i < ARRAYSIZE(fillPatterns); i++) _patterns.push_back(fillPatterns[i]); } @@ -88,7 +90,7 @@ MacWindowManager::~MacWindowManager() { } MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) { - MacWindow *w = new MacWindow(_lastId, scrollable, resizable); + MacWindow *w = new MacWindow(_lastId, scrollable, resizable, this); _windows.push_back(w); _windowStack.push_back(w); @@ -100,8 +102,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) { return w; } -Menu *MacWindowManager::addMenu(bool builtInFonts, Gui *g) { - _menu = new Menu(_lastId, _screen->getBounds(), builtInFonts, g); +Menu *MacWindowManager::addMenu(Gui *g) { + _menu = new Menu(_lastId, _screen->getBounds(), this, g); _windows.push_back(_menu); diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index 95b1dffcb2..c99120f00b 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -59,9 +59,11 @@ public: ~MacWindowManager(); void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; } + void setBuiltInFonts(bool builtInFonts) { _builtInFonts = builtInFonts; } + bool hasBuiltInFonts() { return _builtInFonts; } MacWindow *addWindow(bool scrollable, bool resizable); - Menu *addMenu(bool builtInFonts, Gui *gui); + Menu *addMenu(Gui *gui); void setActive(int id); void setFullRefresh(bool redraw) { _fullRefresh = true; } @@ -89,6 +91,8 @@ private: Patterns _patterns; Menu *_menu; + + bool _builtInFonts; }; } // End of namespace Wage diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp index 17a7d68ac6..e21adaed20 100644 --- a/engines/wage/menu.cpp +++ b/engines/wage/menu.cpp @@ -104,13 +104,13 @@ struct MenuData { { 0, NULL, 0, 0, false } }; -Menu::Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui) - : BaseMacWindow(id), _gui(gui), _builtInFonts(builtInFonts) { +Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui) + : BaseMacWindow(id, wm), _gui(gui) { _font = getMenuFont(); _screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8()); - MenuItem *about = new MenuItem(_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple + MenuItem *about = new MenuItem(_wm->hasBuiltInFonts() ? "\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)); @@ -150,7 +150,7 @@ Menu::Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui) _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() + (_builtInFonts ? 3 : 2); + _items[i]->bbox.bottom = y + _font->getFontHeight() + (_wm->hasBuiltInFonts() ? 3 : 2); } calcMenuBounds(_items[i]); @@ -299,7 +299,7 @@ const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) { *res = 0; if (item->shortcut != 0) - sprintf(res, "%s%c%c", prefix, (_builtInFonts ? '^' : '\x11'), item->shortcut); + sprintf(res, "%s%c%c", prefix, (_wm->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut); return res; } @@ -369,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 + (_builtInFonts ? 2 : 1), it->bbox.width(), color); + _font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_wm->hasBuiltInFonts() ? 2 : 1), it->bbox.width(), color); } g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight); @@ -398,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 - (_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight()); + Common::Rect trect(r->left, y - (_wm->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight()); Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid); } @@ -535,7 +535,7 @@ bool Menu::mouseRelease(int x, int y) { _activeItem = -1; _activeSubItem = -1; - _gui->_wm.setFullRefresh(true); + _wm->setFullRefresh(true); return true; } diff --git a/engines/wage/menu.h b/engines/wage/menu.h index 374c9ed1df..7e8e9d966e 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, bool builtInFonts, Gui *gui); + Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui); ~Menu(); bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false); @@ -141,8 +141,6 @@ private: int _activeItem; int _activeSubItem; - - bool _builtInFonts; }; } // End of namespace Wage |