WAGE: Moved menu rendering to WindowManager

This commit is contained in:
Eugene Sandulenko
2016-04-25 19:47:08 +02:00
parent 3a9159c5a3
commit df6ee16631
6 changed files with 31 additions and 31 deletions
+6 -25
View File
@@ -150,7 +150,6 @@ Gui::Gui(WageEngine *engine) {
_scene = NULL;
_sceneDirty = true;
_consoleDirty = true;
_menuDirty = true;
_cursorDirty = false;
_consoleFullRedraw = true;
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
@@ -200,7 +199,6 @@ Gui::~Gui() {
_screen.free();
_console.free();
g_system->getTimerManager()->removeTimerProc(&cursorTimerHandler);
delete _menu;
}
void Gui::undrawCursor() {
@@ -232,13 +230,7 @@ const Graphics::Font *Gui::getTitleFont() {
void Gui::draw() {
if (_engine->_isGameOver) {
if (_menuDirty) {
_wm.setFullRefresh(true);
_wm.draw();
_menu->draw(&_screen);
}
_menuDirty = false;
_wm.draw();
return;
}
@@ -263,9 +255,6 @@ void Gui::draw() {
_wm.draw();
if (_menuDirty)
_menu->draw(&_screen);
if (_cursorDirty && _cursorRect.left < _screen.w && _cursorRect.bottom < _screen.h) {
g_system->copyRectToScreen(_screen.getBasePtr(_cursorRect.left, _cursorRect.top), _screen.pitch,
_cursorRect.left, _cursorRect.top, _cursorRect.width(), _cursorRect.height());
@@ -275,7 +264,6 @@ void Gui::draw() {
_sceneDirty = false;
_consoleDirty = false;
_menuDirty = false;
_consoleFullRedraw = false;
}
@@ -288,7 +276,7 @@ void Gui::drawScene() {
_sceneDirty = true;
_consoleDirty = true;
_menuDirty = true;
_menu->setDirty(true);
_consoleFullRedraw = true;
}
@@ -489,7 +477,7 @@ void Gui::processMenuShortCut(byte flags, uint16 ascii) {
void Gui::mouseMove(int x, int y) {
if (_menu->hasAllFocus()) {
if (_menu->mouseMove(x, y))
_menuDirty = true;
_menu->setDirty(true);
return;
}
@@ -526,22 +514,15 @@ bool Gui::processEvent(Common::Event &event) {
}
void Gui::mouseUp(int x, int y) {
if (_menu->hasAllFocus()) {
if (_menu->mouseRelease(x, y)) {
_sceneDirty = true;
_consoleDirty = true;
_menuDirty = true;
}
return;
}
if (_menu->hasAllFocus())
_menu->mouseRelease(x, y);
return;
}
void Gui::mouseDown(int x, int y) {
if (_menu->mouseClick(x, y)) {
_menuDirty = true;
_menu->setDirty(true);
}
}
-2
View File
@@ -146,8 +146,6 @@ public:
Common::Rect _cursorRect;
bool _cursorOff;
bool _menuDirty;
Scene *_scene;
MacWindowManager _wm;
+12 -3
View File
@@ -74,6 +74,8 @@ MacWindowManager::MacWindowManager() {
_lastId = 0;
_activeWindow = -1;
_menu = 0;
_fullRefresh = true;
for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
@@ -99,13 +101,13 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
}
Menu *MacWindowManager::addMenu(Gui *g) {
Menu *m = new Menu(_lastId, g);
_menu = new Menu(_lastId, g);
_windows.push_back(m);
_windows.push_back(_menu);
_lastId++;
return m;
return _menu;
}
void MacWindowManager::setActive(int id) {
@@ -143,6 +145,10 @@ void MacWindowManager::draw() {
}
}
// Menu is drawn on top of everything and always
if (_menu)
_menu->draw(_screen, _fullRefresh);
_fullRefresh = false;
}
@@ -154,6 +160,9 @@ void MacWindowManager::drawDesktop() {
}
bool MacWindowManager::processEvent(Common::Event &event) {
if (_menu && _menu->processEvent(event))
return true;
if (event.type != Common::EVENT_MOUSEMOVE && event.type != Common::EVENT_LBUTTONDOWN &&
event.type != Common::EVENT_LBUTTONUP)
return false;
+2
View File
@@ -87,6 +87,8 @@ private:
bool _fullRefresh;
Patterns _patterns;
Menu *_menu;
};
} // End of namespace Wage
+11
View File
@@ -341,6 +341,11 @@ void Menu::calcMenuBounds(MenuItem *menu) {
bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
Common::Rect r(_bbox);
if (!_contentIsDirty)
return false;
_contentIsDirty = true;
Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
r.top = 7;
Design::drawFilledRect(&_gui->_screen, r, kColorWhite, _gui->_patterns, kPatternSolid);
@@ -506,6 +511,8 @@ bool Menu::mouseRelease(int x, int y) {
_activeItem = -1;
_activeSubItem = -1;
_gui->_wm.setFullRefresh(true);
return true;
}
@@ -566,12 +573,16 @@ void Menu::enableCommand(int menunum, int action, bool state) {
for (uint i = 0; i < _items[menunum]->subitems.size(); i++)
if (_items[menunum]->subitems[i]->action == action)
_items[menunum]->subitems[i]->enabled = state;
_contentIsDirty = true;
}
void Menu::disableAllMenus() {
for (uint i = 1; i < _items.size(); i++) // Leave About menu on
for (uint j = 0; j < _items[i]->subitems.size(); j++)
_items[i]->subitems[j]->enabled = false;
_contentIsDirty = true;
}
} // End of namespace Wage
-1
View File
@@ -227,7 +227,6 @@ void WageEngine::gameOver() {
_gui->disableAllMenus();
_gui->enableNewGameMenus();
_gui->_menuDirty = true;
}
bool WageEngine::saveDialog() {