diff options
author | Eugene Sandulenko | 2016-04-26 19:35:27 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-26 19:35:27 +0200 |
commit | d26c12c49778be525f23746c774e53c3f61852c4 (patch) | |
tree | 1d2cc41d9fbf2629a281f1664c327de0da332c4a | |
parent | fab749cbe6ab0155bf3db17d013ad593e009ab33 (diff) | |
download | scummvm-rg350-d26c12c49778be525f23746c774e53c3f61852c4.tar.gz scummvm-rg350-d26c12c49778be525f23746c774e53c3f61852c4.tar.bz2 scummvm-rg350-d26c12c49778be525f23746c774e53c3f61852c4.zip |
WAGE: Reuse WM _screen for Menu
-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 | 52 | ||||
-rw-r--r-- | engines/wage/menu.h | 6 |
5 files changed, 34 insertions, 32 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index c49b1ff230..1feed364cd 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(&_screen, this); + _menu = _wm.addMenu(this); _sceneWindow = _wm.addWindow(false, false); _sceneWindow->setCallback(sceneWindowCallback, this); diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index cef7f0ab19..b204d1b526 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(Graphics::ManagedSurface *screen, Gui *g) { - _menu = new Menu(_lastId, screen, g); +Menu *MacWindowManager::addMenu(Gui *g) { + _menu = new Menu(_lastId, _screen->getBounds(), g); _windows.push_back(_menu); diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index 04cb8d029b..91d426e9d9 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(Graphics::ManagedSurface *screen, Gui *gui); + 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 03757f51c3..c19a19962a 100644 --- a/engines/wage/menu.cpp +++ b/engines/wage/menu.cpp @@ -104,9 +104,11 @@ struct MenuData { { 0, NULL, 0, 0, false } }; -Menu::Menu(int id, Graphics::ManagedSurface *screen, Gui *gui) : BaseMacWindow(id), _screen(screen), _gui(gui) { +Menu::Menu(int id, const Common::Rect &bounds, Gui *gui) : BaseMacWindow(id), _gui(gui) { _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 _items.push_back(about); _items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout)); @@ -157,15 +159,15 @@ Menu::Menu(int id, Graphics::ManagedSurface *screen, Gui *gui) : BaseMacWindow(i _bbox.left = 0; _bbox.top = 0; - _bbox.right = _screen->w - 1; + _bbox.right = _screen.w - 1; _bbox.bottom = kMenuHeight - 1; _menuActivated = false; _activeItem = -1; _activeSubItem = -1; - _screenCopy.create(_screen->w, _screen->h, Graphics::PixelFormat::createFormatCLUT8()); - _tempSurface.create(_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 +345,11 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) { _contentIsDirty = true; - Design::drawFilledRoundRect(g, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid); + Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid); r.top = 7; - Design::drawFilledRect(g, r, kColorWhite, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(&_screen, r, kColorWhite, _gui->_patterns, kPatternSolid); r.top = kMenuHeight - 1; - Design::drawFilledRect(g, r, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(&_screen, r, kColorBlack, _gui->_patterns, kPatternSolid); for (uint i = 0; i < _items.size(); i++) { int color = kColorBlack; @@ -359,31 +361,31 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) { hbox.left -= 1; hbox.right += 2; - Design::drawFilledRect(g, hbox, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(&_screen, hbox, kColorBlack, _gui->_patterns, kPatternSolid); color = kColorWhite; if (!it->subitems.empty()) - renderSubmenu(g, it); + renderSubmenu(it); } - _font->drawString(g, 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 + (_gui->_builtInFonts ? 2 : 1), it->bbox.width(), color); } - g_system->copyRectToScreen(g->getPixels(), g->pitch, 0, 0, g->w, kMenuHeight); + g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight); return true; } -void Menu::renderSubmenu(Graphics::ManagedSurface *g, MenuItem *menu) { +void Menu::renderSubmenu(MenuItem *menu) { Common::Rect *r = &menu->subbbox; if (r->width() == 0 || r->height() == 0) return; - 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); + Design::drawFilledRect(&_screen, *r, kColorWhite, _gui->_patterns, kPatternSolid); + Design::drawRect(&_screen, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawVLine(&_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawHLine(&_screen, 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 +399,11 @@ void Menu::renderSubmenu(Graphics::ManagedSurface *g, MenuItem *menu) { color = kColorWhite; Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight()); - Design::drawFilledRect(g, trect, kColorBlack, _gui->_patterns, kPatternSolid); + Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid); } if (!text.empty()) { - Graphics::ManagedSurface *s = g; + Graphics::ManagedSurface *s = &_screen; int tx = x, ty = y; if (!menu->subitems[i]->enabled) { @@ -423,7 +425,7 @@ void Menu::renderSubmenu(Graphics::ManagedSurface *g, 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 *)g->getBasePtr(x, y+ii); + byte *dst = (byte *)_screen.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 +436,13 @@ void Menu::renderSubmenu(Graphics::ManagedSurface *g, MenuItem *menu) { } } } else { // Delimiter - Design::drawHLine(g, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes); + Design::drawHLine(&_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes); } y += kMenuDropdownItemHeight; } - g_system->copyRectToScreen(g->getBasePtr(r->left, r->top), g->pitch, r->left, r->top, r->width() + 3, r->height() + 3); + g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3); } bool Menu::processEvent(Common::Event &event) { @@ -486,8 +488,8 @@ bool Menu::mouseClick(int x, int y) { r.right += 3; r.bottom += 3; - _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); + _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 +505,12 @@ bool Menu::mouseClick(int x, int y) { if (numSubItem != _activeSubItem) { _activeSubItem = numSubItem; - renderSubmenu(_screen, _items[_activeItem]); + renderSubmenu(_items[_activeItem]); } } else if (_menuActivated && _activeItem != -1) { _activeSubItem = -1; - renderSubmenu(_screen, _items[_activeItem]); + renderSubmenu(_items[_activeItem]); } return false; diff --git a/engines/wage/menu.h b/engines/wage/menu.h index ed4bfa56e0..40d52ea397 100644 --- a/engines/wage/menu.h +++ b/engines/wage/menu.h @@ -92,7 +92,7 @@ enum { class Menu : public BaseMacWindow { public: - Menu(int id, Graphics::ManagedSurface *screen, Gui *gui); + Menu(int id, const Common::Rect &bounds, Gui *gui); ~Menu(); bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false); @@ -110,7 +110,7 @@ public: private: Gui *_gui; - Graphics::ManagedSurface *_screen; + Graphics::ManagedSurface _screen; Graphics::ManagedSurface _screenCopy; Graphics::ManagedSurface _tempSurface; @@ -119,7 +119,7 @@ private: const char *getAcceleratorString(MenuSubItem *item, const char *prefix); int calculateMenuWidth(MenuItem *menu); void calcMenuBounds(MenuItem *menu); - void renderSubmenu(Graphics::ManagedSurface *g, MenuItem *menu); + void renderSubmenu(MenuItem *menu); void createCommandsMenu(MenuItem *menu); void createWeaponsMenu(MenuItem *menu); void executeCommand(MenuSubItem *subitem); |