From 75a3f4a3ecde4837976481fd1b7ea56bef0d0e25 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 12 Mar 2010 23:02:24 +0000 Subject: Fix from LordHoto for bug #2859401: GUI: GMM crashes when running in 320x200 and 320x240 svn-id: r48248 --- gui/GuiManager.cpp | 4 ++++ gui/GuiManager.h | 4 ++++ gui/object.cpp | 16 ++++++++-------- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'gui') diff --git a/gui/GuiManager.cpp b/gui/GuiManager.cpp index 931c3078b3..3d02816196 100644 --- a/gui/GuiManager.cpp +++ b/gui/GuiManager.cpp @@ -54,6 +54,8 @@ GuiManager::GuiManager() : _redrawStatus(kRedrawDisabled), _system = g_system; _lastScreenChangeID = _system->getScreenChangeID(); + _width = _system->getOverlayWidth(); + _height = _system->getOverlayHeight(); // Clear the cursor memset(_cursor, 0xFF, sizeof(_cursor)); @@ -448,6 +450,8 @@ bool GuiManager::checkScreenChange() { void GuiManager::screenChange() { _lastScreenChangeID = _system->getScreenChangeID(); + _width = _system->getOverlayWidth(); + _height = _system->getOverlayHeight(); // reinit the whole theme _theme->refresh(); diff --git a/gui/GuiManager.h b/gui/GuiManager.h index a5e75484c3..892d1aa3ac 100644 --- a/gui/GuiManager.h +++ b/gui/GuiManager.h @@ -76,6 +76,9 @@ public: ThemeEval *xmlEval() { return _theme->getEvaluator(); } + int getWidth() const { return _width; } + int getHeight() const { return _height; } + const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); } int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); } int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); } @@ -104,6 +107,7 @@ protected: // bool _needRedraw; RedrawStatus _redrawStatus; int _lastScreenChangeID; + int _width, _height; DialogStack _dialogStack; bool _stateIsSaved; diff --git a/gui/object.cpp b/gui/object.cpp index f24ce0997e..aaa5a1a4b3 100644 --- a/gui/object.cpp +++ b/gui/object.cpp @@ -48,16 +48,16 @@ void GuiObject::reflowLayout() { if (_x < 0) error("Widget <%s> has x < 0 (%d)", _name.c_str(), _x); - if (_x >= g_system->getOverlayWidth()) - error("Widget <%s> has x > %d (%d)", _name.c_str(), g_system->getOverlayWidth(), _x); - if (_x + _w > g_system->getOverlayWidth()) - error("Widget <%s> has x + w > %d (%d)", _name.c_str(), g_system->getOverlayWidth(), _x + _w); + if (_x >= g_gui.getWidth()) + error("Widget <%s> has x > %d (%d)", _name.c_str(), g_gui.getWidth(), _x); + if (_x + _w > g_gui.getWidth()) + error("Widget <%s> has x + w > %d (%d)", _name.c_str(), g_gui.getWidth(), _x + _w); if (_y < 0) error("Widget <%s> has y < 0 (%d)", _name.c_str(), _y); - if (_y >= g_system->getOverlayHeight()) - error("Widget <%s> has y > %d (%d)", _name.c_str(), g_system->getOverlayHeight(), _y); - if (_y + _h > g_system->getOverlayHeight()) - error("Widget <%s> has y + h > %d (%d)", _name.c_str(), g_system->getOverlayHeight(), _y + _h); + if (_y >= g_gui.getHeight()) + error("Widget <%s> has y > %d (%d)", _name.c_str(), g_gui.getHeight(), _y); + if (_y + _h > g_gui.getHeight()) + error("Widget <%s> has y + h > %d (%d)", _name.c_str(), g_gui.getHeight(), _y + _h); } } -- cgit v1.2.3