[Scummvm-cvs-logs] scummvm master -> 365f06d836e853b83f8d1a4d16e32cd1e66bf35e
sev-
sev at scummvm.org
Mon Apr 25 21:28:26 CEST 2016
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
35d5d93725 WAGE: Fix crash when cursor is off-screen
3a9159c5a3 WAGE: Made Menu subclass of BaseMacWindow
df6ee16631 WAGE: Moved menu rendering to WindowManager
98061bdc4c WAGE: Move menu event processing to WindowManager
365f06d836 WAGE: Cleanup
Commit: 35d5d93725a4a554b1f0ddc8009d9595c950476b
https://github.com/scummvm/scummvm/commit/35d5d93725a4a554b1f0ddc8009d9595c950476b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-25T18:38:24+02:00
Commit Message:
WAGE: Fix crash when cursor is off-screen
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2841013..5aacb96 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -266,7 +266,7 @@ void Gui::draw() {
if (_menuDirty)
_menu->render();
- if (_cursorDirty) {
+ 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());
Commit: 3a9159c5a34c891b10ff6b44d6982eda717e48f7
https://github.com/scummvm/scummvm/commit/3a9159c5a34c891b10ff6b44d6982eda717e48f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-25T19:02:25+02:00
Commit Message:
WAGE: Made Menu subclass of BaseMacWindow
Changed paths:
engines/wage/gui-console.cpp
engines/wage/gui.cpp
engines/wage/macwindowmanager.cpp
engines/wage/macwindowmanager.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index ca1917b..e037368 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -45,6 +45,7 @@
*
*/
+#include "common/events.h"
#include "common/timer.h"
#include "common/unzip.h"
#include "graphics/cursorman.h"
@@ -54,6 +55,7 @@
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
+#include "wage/macwindow.h"
#include "wage/menu.h"
#include "wage/gui.h"
#include "wage/world.h"
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 5aacb96..8aaad70 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -187,7 +187,7 @@ Gui::Gui(WageEngine *engine) {
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
- _menu = new Menu(this);
+ _menu = _wm.addMenu(this);
_sceneWindow = _wm.addWindow(false, false);
_sceneWindow->setCallback(sceneWindowCallback, this);
@@ -235,7 +235,7 @@ void Gui::draw() {
if (_menuDirty) {
_wm.setFullRefresh(true);
_wm.draw();
- _menu->render();
+ _menu->draw(&_screen);
}
_menuDirty = false;
@@ -264,7 +264,7 @@ void Gui::draw() {
_wm.draw();
if (_menuDirty)
- _menu->render();
+ _menu->draw(&_screen);
if (_cursorDirty && _cursorRect.left < _screen.w && _cursorRect.bottom < _screen.h) {
g_system->copyRectToScreen(_screen.getBasePtr(_cursorRect.left, _cursorRect.top), _screen.pitch,
@@ -487,7 +487,7 @@ void Gui::processMenuShortCut(byte flags, uint16 ascii) {
}
void Gui::mouseMove(int x, int y) {
- if (_menu->_menuActivated) {
+ if (_menu->hasAllFocus()) {
if (_menu->mouseMove(x, y))
_menuDirty = true;
@@ -526,7 +526,7 @@ bool Gui::processEvent(Common::Event &event) {
}
void Gui::mouseUp(int x, int y) {
- if (_menu->_menuActivated) {
+ if (_menu->hasAllFocus()) {
if (_menu->mouseRelease(x, y)) {
_sceneDirty = true;
_consoleDirty = true;
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index a86b16a..de75555 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -57,6 +57,7 @@
#include "wage/gui.h"
#include "wage/macwindow.h"
#include "wage/macwindowmanager.h"
+#include "wage/menu.h"
namespace Wage {
@@ -97,6 +98,16 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
return w;
}
+Menu *MacWindowManager::addMenu(Gui *g) {
+ Menu *m = new Menu(_lastId, g);
+
+ _windows.push_back(m);
+
+ _lastId++;
+
+ return m;
+}
+
void MacWindowManager::setActive(int id) {
if (_activeWindow == id)
return;
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 06b7689..0d0ade0 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -51,6 +51,7 @@
namespace Wage {
class MacWindow;
+class Menu;
class MacWindowManager {
public:
@@ -60,6 +61,7 @@ public:
void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
MacWindow *addWindow(bool scrollable, bool resizable);
+ 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 27cbf5e..198bdf3 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -104,7 +104,7 @@ struct MenuData {
{ 0, NULL, 0, 0, false }
};
-Menu::Menu(Gui *gui) : _gui(gui) {
+Menu::Menu(int id, Gui *gui) : BaseMacWindow(id), _gui(gui) {
assert(_gui->_engine);
assert(_gui->_engine->_world);
@@ -338,7 +338,7 @@ void Menu::calcMenuBounds(MenuItem *menu) {
menu->subbbox.bottom = y2;
}
-void Menu::render() {
+bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
Common::Rect r(_bbox);
Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
@@ -368,6 +368,8 @@ void Menu::render() {
}
g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
+
+ return true;
}
void Menu::renderSubmenu(MenuItem *menu) {
@@ -439,6 +441,10 @@ void Menu::renderSubmenu(MenuItem *menu) {
g_system->copyRectToScreen(_gui->_screen.getBasePtr(r->left, r->top), _gui->_screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3);
}
+bool Menu::processEvent(Common::Event &event) {
+ return false;
+}
+
bool Menu::mouseClick(int x, int y) {
if (_bbox.contains(x, y)) {
if (!_menuActivated)
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 916ef6d..fed5c5c 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -90,12 +90,14 @@ enum {
kMenuActionCommand
};
-class Menu {
+class Menu : public BaseMacWindow {
public:
- Menu(Gui *gui);
+ Menu(int id, Gui *gui);
~Menu();
- void render();
+ bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
+ bool processEvent(Common::Event &event);
+
bool mouseClick(int x, int y);
bool mouseRelease(int x, int y);
bool mouseMove(int x, int y);
@@ -106,7 +108,9 @@ public:
void enableCommand(int menunum, int action, bool state);
void disableAllMenus();
- bool _menuActivated;
+ void setActive(bool active) { _menuActivated = active; }
+ bool hasAllFocus() { return _menuActivated; }
+
Common::Rect _bbox;
private:
@@ -130,6 +134,8 @@ private:
const Graphics::Font *_font;
+ bool _menuActivated;
+
int _activeItem;
int _activeSubItem;
};
Commit: df6ee166311e47e77d2b50aee87e233412f6d23a
https://github.com/scummvm/scummvm/commit/df6ee166311e47e77d2b50aee87e233412f6d23a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-25T19:47:08+02:00
Commit Message:
WAGE: Moved menu rendering to WindowManager
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/macwindowmanager.cpp
engines/wage/macwindowmanager.h
engines/wage/menu.cpp
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 8aaad70..92002ff 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -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);
}
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 2feb259..bec308d 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -146,8 +146,6 @@ public:
Common::Rect _cursorRect;
bool _cursorOff;
- bool _menuDirty;
-
Scene *_scene;
MacWindowManager _wm;
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index de75555..f099342 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -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;
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 0d0ade0..91d426e 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -87,6 +87,8 @@ private:
bool _fullRefresh;
Patterns _patterns;
+
+ Menu *_menu;
};
} // End of namespace Wage
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 198bdf3..40dbbbb 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -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
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 278badd..be79b14 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -227,7 +227,6 @@ void WageEngine::gameOver() {
_gui->disableAllMenus();
_gui->enableNewGameMenus();
- _gui->_menuDirty = true;
}
bool WageEngine::saveDialog() {
Commit: 98061bdc4c802f9e025f4047bc7d24186365b75d
https://github.com/scummvm/scummvm/commit/98061bdc4c802f9e025f4047bc7d24186365b75d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-25T19:54:26+02:00
Commit Message:
WAGE: Move menu event processing to WindowManager
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/menu.cpp
engines/wage/menu.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 92002ff..6fcbbc3 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -474,15 +474,6 @@ void Gui::processMenuShortCut(byte flags, uint16 ascii) {
_menu->processMenuShortCut(flags, ascii);
}
-void Gui::mouseMove(int x, int y) {
- if (_menu->hasAllFocus()) {
- if (_menu->mouseMove(x, y))
- _menu->setDirty(true);
-
- return;
- }
-}
-
void Gui::pushArrowCursor() {
CursorMan.pushCursor(macCursorArrow, 11, 16, 1, 1, 3);
}
@@ -492,38 +483,7 @@ void Gui::popCursor() {
}
bool Gui::processEvent(Common::Event &event) {
- if (_wm.processEvent(event))
- return true;
-
- switch (event.type) {
- case Common::EVENT_MOUSEMOVE:
- mouseMove(event.mouse.x, event.mouse.y);
- break;
- case Common::EVENT_LBUTTONDOWN:
- mouseDown(event.mouse.x, event.mouse.y);
- break;
- case Common::EVENT_LBUTTONUP:
- mouseUp(event.mouse.x, event.mouse.y);
- break;
-
- default:
- return false;
- }
-
- return true;
-}
-
-void Gui::mouseUp(int x, int y) {
- if (_menu->hasAllFocus())
- _menu->mouseRelease(x, y);
-
- return;
-}
-
-void Gui::mouseDown(int x, int y) {
- if (_menu->mouseClick(x, y)) {
- _menu->setDirty(true);
- }
+ return _wm.processEvent(event);
}
int Gui::calcTextX(int x, int textLine) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index bec308d..cfc7a09 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -90,9 +90,7 @@ public:
void appendText(const char *str);
void clearOutput();
bool processEvent(Common::Event &event);
- void mouseMove(int x, int y);
- void mouseDown(int x, int y);
- void mouseUp(int x, int y);
+
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 40dbbbb..425f2d6 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -447,6 +447,13 @@ void Menu::renderSubmenu(MenuItem *menu) {
}
bool Menu::processEvent(Common::Event &event) {
+ if (event.type == Common::EVENT_LBUTTONDOWN)
+ return mouseClick(event.mouse.x, event.mouse.y);
+ else if (event.type == Common::EVENT_LBUTTONUP)
+ return mouseRelease(event.mouse.x, event.mouse.y);
+ else if (event.type == Common::EVENT_MOUSEMOVE)
+ return mouseMove(event.mouse.x, event.mouse.y);
+
return false;
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index fed5c5c..5118112 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -98,10 +98,6 @@ public:
bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
bool processEvent(Common::Event &event);
- bool mouseClick(int x, int y);
- bool mouseRelease(int x, int y);
- bool mouseMove(int x, int y);
-
void regenCommandsMenu();
void regenWeaponsMenu();
void processMenuShortCut(byte flags, uint16 ascii);
@@ -128,6 +124,10 @@ private:
void createWeaponsMenu(MenuItem *menu);
void executeCommand(MenuSubItem *subitem);
+ bool mouseClick(int x, int y);
+ bool mouseRelease(int x, int y);
+ bool mouseMove(int x, int y);
+
Common::Array<MenuItem *> _items;
MenuItem *_weapons;
MenuItem *_commands;
Commit: 365f06d836e853b83f8d1a4d16e32cd1e66bf35e
https://github.com/scummvm/scummvm/commit/365f06d836e853b83f8d1a4d16e32cd1e66bf35e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-25T20:01:21+02:00
Commit Message:
WAGE: Cleanup
Changed paths:
engines/wage/macwindowmanager.cpp
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index f099342..b143f90 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -127,6 +127,13 @@ void MacWindowManager::setActive(int id) {
_fullRefresh = true;
}
+void MacWindowManager::drawDesktop() {
+ Common::Rect r(_screen->getBounds());
+
+ Design::drawFilledRoundRect(_screen, r, kDesktopArc, kColorBlack, _patterns, kPatternCheckers);
+ g_system->copyRectToScreen(_screen->getPixels(), _screen->pitch, 0, 0, _screen->w, _screen->h);
+}
+
void MacWindowManager::draw() {
assert(_screen);
@@ -152,14 +159,8 @@ void MacWindowManager::draw() {
_fullRefresh = false;
}
-void MacWindowManager::drawDesktop() {
- Common::Rect r(_screen->getBounds());
-
- Design::drawFilledRoundRect(_screen, r, kDesktopArc, kColorBlack, _patterns, kPatternCheckers);
- g_system->copyRectToScreen(_screen->getPixels(), _screen->pitch, 0, 0, _screen->w, _screen->h);
-}
-
bool MacWindowManager::processEvent(Common::Event &event) {
+ // Menu gets events first fir shortcuts and menu bar
if (_menu && _menu->processEvent(event))
return true;
More information about the Scummvm-git-logs
mailing list