aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2006-12-27 22:51:14 +0000
committerMax Horn2006-12-27 22:51:14 +0000
commitf01f4eea980924df60b8301eda02fb4acbb71c94 (patch)
treeeaccd9ecb58b6ddad6e1b3e0ae5e7acbc5df6512
parent4e52f4438f9ced523441e7bda2e168ac77688a2e (diff)
downloadscummvm-rg350-f01f4eea980924df60b8301eda02fb4acbb71c94.tar.gz
scummvm-rg350-f01f4eea980924df60b8301eda02fb4acbb71c94.tar.bz2
scummvm-rg350-f01f4eea980924df60b8301eda02fb4acbb71c94.zip
Added NewGui::getTopDialog method
svn-id: r24938
-rw-r--r--gui/newgui.cpp17
-rw-r--r--gui/newgui.h2
2 files changed, 14 insertions, 5 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 420d27e3e1..a7770df365 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -210,8 +210,14 @@ void NewGui::redraw() {
_theme->drawAll();
}
+Dialog *NewGui::getTopDialog() const {
+ if (_dialogStack.empty())
+ return 0;
+ return _dialogStack.top();
+}
+
void NewGui::runLoop() {
- Dialog *activeDialog = _dialogStack.top();
+ Dialog *activeDialog = getTopDialog();
bool didSaveState = false;
int button;
@@ -228,7 +234,7 @@ void NewGui::runLoop() {
setupCursor();
}
- while (!_dialogStack.empty() && activeDialog == _dialogStack.top()) {
+ while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
if (_needRedraw) {
redraw();
_needRedraw = false;
@@ -248,7 +254,7 @@ void NewGui::runLoop() {
uint32 time = _system->getMillis();
while (_system->pollEvent(event)) {
- if (activeDialog != _dialogStack.top() && event.type != OSystem::EVENT_QUIT && event.type != OSystem::EVENT_SCREEN_CHANGED)
+ if (activeDialog != getTopDialog() && event.type != OSystem::EVENT_QUIT && event.type != OSystem::EVENT_SCREEN_CHANGED)
continue;
Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y);
@@ -325,7 +331,7 @@ void NewGui::runLoop() {
}
// check if event should be sent again (keydown)
- if (_currentKeyDown.keycode != 0 && activeDialog == _dialogStack.top()) {
+ if (_currentKeyDown.keycode != 0 && activeDialog == getTopDialog()) {
if (_keyRepeatTime < time) {
// fire event
activeDialog->handleKeyDown(_currentKeyDown.ascii, _currentKeyDown.keycode, _currentKeyDown.flags);
@@ -440,7 +446,8 @@ WidgetSize NewGui::getWidgetSize() {
}
void NewGui::clearDragWidget() {
- _dialogStack.top()->_dragWidget = 0;
+ if (!_dialogStack.empty())
+ _dialogStack.top()->_dragWidget = 0;
}
void NewGui::screenChange() {
diff --git a/gui/newgui.h b/gui/newgui.h
index 4ee91c26c6..9cf6902e8a 100644
--- a/gui/newgui.h
+++ b/gui/newgui.h
@@ -132,6 +132,8 @@ protected:
void setupCursor();
void animateCursor();
+
+ Dialog *getTopDialog() const;
};
} // End of namespace GUI