Fix from LordHoto for bug #2859401: GUI: GMM crashes when running in 320x200 and 320x240

svn-id: r48248
This commit is contained in:
Max Horn 2010-03-12 23:02:24 +00:00
parent 79662919c6
commit 75a3f4a3ec
3 changed files with 16 additions and 8 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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);
}
}