[Scummvm-cvs-logs] SF.net SVN: scummvm: [24938] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Dec 27 23:51:16 CET 2006


Revision: 24938
          http://scummvm.svn.sourceforge.net/scummvm/?rev=24938&view=rev
Author:   fingolfin
Date:     2006-12-27 14:51:14 -0800 (Wed, 27 Dec 2006)

Log Message:
-----------
Added NewGui::getTopDialog method

Modified Paths:
--------------
    scummvm/trunk/gui/newgui.cpp
    scummvm/trunk/gui/newgui.h

Modified: scummvm/trunk/gui/newgui.cpp
===================================================================
--- scummvm/trunk/gui/newgui.cpp	2006-12-27 18:33:27 UTC (rev 24937)
+++ scummvm/trunk/gui/newgui.cpp	2006-12-27 22:51:14 UTC (rev 24938)
@@ -210,8 +210,14 @@
 	_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 @@
 			setupCursor();
 	}
 
-	while (!_dialogStack.empty() && activeDialog == _dialogStack.top()) {
+	while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
 		if (_needRedraw) {
 			redraw();
 			_needRedraw = false;
@@ -248,7 +254,7 @@
 		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 @@
 		}
 
 		// 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 @@
 }
 
 void NewGui::clearDragWidget() {
-	_dialogStack.top()->_dragWidget = 0;
+	if (!_dialogStack.empty())
+		_dialogStack.top()->_dragWidget = 0;
 }
 
 void NewGui::screenChange() {

Modified: scummvm/trunk/gui/newgui.h
===================================================================
--- scummvm/trunk/gui/newgui.h	2006-12-27 18:33:27 UTC (rev 24937)
+++ scummvm/trunk/gui/newgui.h	2006-12-27 22:51:14 UTC (rev 24938)
@@ -132,6 +132,8 @@
 
 	void setupCursor();
 	void animateCursor();
+	
+	Dialog *getTopDialog() const;
 };
 
 } // End of namespace GUI


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list