diff options
author | Eugene Sandulenko | 2016-04-26 11:17:56 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-26 11:17:56 +0200 |
commit | fab749cbe6ab0155bf3db17d013ad593e009ab33 (patch) | |
tree | 4a1e8ec91cda4a341f964cedff3db64900ee77ea /engines | |
parent | 587f03fab972a250611f0b989faa5dc78ee57090 (diff) | |
download | scummvm-rg350-fab749cbe6ab0155bf3db17d013ad593e009ab33.tar.gz scummvm-rg350-fab749cbe6ab0155bf3db17d013ad593e009ab33.tar.bz2 scummvm-rg350-fab749cbe6ab0155bf3db17d013ad593e009ab33.zip |
WAGE: More abstraction to menu rendering
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/gui.cpp | 2 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.cpp | 4 | ||||
-rw-r--r-- | engines/wage/macwindowmanager.h | 2 | ||||
-rw-r--r-- | engines/wage/menu.cpp | 50 | ||||
-rw-r--r-- | engines/wage/menu.h | 5 |
5 files changed, 32 insertions, 31 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 1feed364cd..c49b1ff230 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(&_screen, this); _sceneWindow = _wm.addWindow(false, false); _sceneWindow->setCallback(sceneWindowCallback, this); diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index b143f90db4..cef7f0ab19 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, g); +Menu *MacWindowManager::addMenu(Graphics::ManagedSurface *screen, Gui *g) { + _menu = new Menu(_lastId, screen, g); _windows.push_back(_menu); diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index 91d426e9d9..04cb8d029b 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(Graphics::ManagedSurface *screen, 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 18b1f04024..03757f51c3 100644 --- a/engines/wage/menu.cpp +++ b/engines/wage/menu.cpp @@ -104,7 +104,7 @@ struct MenuData { { 0, NULL, 0, 0, false } }; -Menu::Menu(int id, Gui *gui) : BaseMacWindow(id), _gui(gui) { +Menu::Menu(int id, Graphics::ManagedSurface *screen, Gui *gui) : BaseMacWindow(id), _screen(screen), _gui(gui) { _font = getMenuFont(); MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple @@ -157,15 +157,15 @@ Menu::Menu(int id, Gui *gui) : BaseMacWindow(id), _gui(gui) { _bbox.left = 0; _bbox.top = 0; - _bbox.right = _gui->_screen.w - 1; + _bbox.right = _screen->w - 1; _bbox.bottom = kMenuHeight - 1; _menuActivated = false; _activeItem = -1; _activeSubItem = -1; - _screenCopy.create(_gui->_screen.w, _gui->_screen.h, Graphics::PixelFormat::createFormatCLUT8()); - _tempSurface.create(_gui->_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8()); + _screenCopy.create(_screen->w, _screen->h, Graphics::PixelFormat::createFormatCLUT8()); + _tempSurface.create(_screen->w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8()); } Menu::~Menu() { @@ -343,11 +343,11 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) { _contentIsDirty = true; - Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid); + Design::drawFilledRoundRect(g, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid); r.top = 7; - Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(g, r, kColorWhite, _gui->_patterns, kPatternSolid); r.top = kMenuHeight - 1; - Design::drawFilledRect(&_gui->_screen, r, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(g, r, kColorBlack, _gui->_patterns, kPatternSolid); for (uint i = 0; i < _items.size(); i++) { int color = kColorBlack; @@ -359,31 +359,31 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) { hbox.left -= 1; hbox.right += 2; - Design::drawFilledRect(&_gui->_screen, hbox, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(g, hbox, kColorBlack, _gui->_patterns, kPatternSolid); color = kColorWhite; if (!it->subitems.empty()) - renderSubmenu(it); + renderSubmenu(g, it); } - _font->drawString(&_gui->_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_gui->_builtInFonts ? 2 : 1), it->bbox.width(), color); + _font->drawString(g, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_gui->_builtInFonts ? 2 : 1), it->bbox.width(), color); } - g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight); + g_system->copyRectToScreen(g->getPixels(), g->pitch, 0, 0, g->w, kMenuHeight); return true; } -void Menu::renderSubmenu(MenuItem *menu) { +void Menu::renderSubmenu(Graphics::ManagedSurface *g, MenuItem *menu) { Common::Rect *r = &menu->subbbox; if (r->width() == 0 || r->height() == 0) return; - Design::drawFilledRect(&_gui->_screen, *r, kColorWhite, _gui->_patterns, kPatternSolid); - Design::drawRect(&_gui->_screen, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid); - Design::drawVLine(&_gui->_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid); - Design::drawHLine(&_gui->_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(g, *r, kColorWhite, _gui->_patterns, kPatternSolid); + Design::drawRect(g, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawVLine(g, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawHLine(g, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid); int x = r->left + kMenuDropdownPadding; int y = r->top + 1; @@ -397,11 +397,11 @@ void Menu::renderSubmenu(MenuItem *menu) { color = kColorWhite; Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight()); - Design::drawFilledRect(&_gui->_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(g, trect, kColorBlack, _gui->_patterns, kPatternSolid); } if (!text.empty()) { - Graphics::ManagedSurface *s = &_gui->_screen; + Graphics::ManagedSurface *s = g; int tx = x, ty = y; if (!menu->subitems[i]->enabled) { @@ -423,7 +423,7 @@ void Menu::renderSubmenu(MenuItem *menu) { // fake it here for (int ii = 0; ii < _tempSurface.h; ii++) { const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii); - byte *dst = (byte *)_gui->_screen.getBasePtr(x, y+ii); + byte *dst = (byte *)g->getBasePtr(x, y+ii); byte pat = _gui->_patterns[kPatternCheckers2 - 1][ii % 8]; for (int j = 0; j < r->width(); j++) { if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8)))) @@ -434,13 +434,13 @@ void Menu::renderSubmenu(MenuItem *menu) { } } } else { // Delimiter - Design::drawHLine(&_gui->_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes); + Design::drawHLine(g, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes); } y += kMenuDropdownItemHeight; } - g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3); + g_system->copyRectToScreen(g->getBasePtr(r->left, r->top), g->pitch, r->left, r->top, r->width() + 3, r->height() + 3); } bool Menu::processEvent(Common::Event &event) { @@ -486,8 +486,8 @@ bool Menu::mouseClick(int x, int y) { r.right += 3; r.bottom += 3; - _gui->_screen.copyRectToSurface(_screenCopy, r.left, r.top, r); - g_system->copyRectToScreen(_gui->_screen.getBasePtr(r.left, r.top), _gui->_screen.pitch, r.left, r.top, r.width() + 1, r.height() + 1); + _screen->copyRectToSurface(_screenCopy, r.left, r.top, r); + g_system->copyRectToScreen(_screen->getBasePtr(r.left, r.top), _screen->pitch, r.left, r.top, r.width() + 1, r.height() + 1); } _activeItem = i; @@ -503,12 +503,12 @@ bool Menu::mouseClick(int x, int y) { if (numSubItem != _activeSubItem) { _activeSubItem = numSubItem; - renderSubmenu(_items[_activeItem]); + renderSubmenu(_screen, _items[_activeItem]); } } else if (_menuActivated && _activeItem != -1) { _activeSubItem = -1; - renderSubmenu(_items[_activeItem]); + renderSubmenu(_screen, _items[_activeItem]); } return false; diff --git a/engines/wage/menu.h b/engines/wage/menu.h index fba59bbc0a..ed4bfa56e0 100644 --- a/engines/wage/menu.h +++ b/engines/wage/menu.h @@ -92,7 +92,7 @@ enum { class Menu : public BaseMacWindow { public: - Menu(int id, Gui *gui); + Menu(int id, Graphics::ManagedSurface *screen, Gui *gui); ~Menu(); bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false); @@ -110,6 +110,7 @@ public: private: Gui *_gui; + Graphics::ManagedSurface *_screen; Graphics::ManagedSurface _screenCopy; Graphics::ManagedSurface _tempSurface; @@ -118,7 +119,7 @@ private: const char *getAcceleratorString(MenuSubItem *item, const char *prefix); int calculateMenuWidth(MenuItem *menu); void calcMenuBounds(MenuItem *menu); - void renderSubmenu(MenuItem *menu); + void renderSubmenu(Graphics::ManagedSurface *g, MenuItem *menu); void createCommandsMenu(MenuItem *menu); void createWeaponsMenu(MenuItem *menu); void executeCommand(MenuSubItem *subitem); |