[Scummvm-cvs-logs] CVS: scummvm/gui dialog.cpp,1.18,1.19 dialog.h,1.8,1.9 newgui.cpp,1.20,1.21 newgui.h,1.13,1.14
Max Horn
fingolfin at users.sourceforge.net
Wed Oct 16 10:38:05 CEST 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv30527/gui
Modified Files:
dialog.cpp dialog.h newgui.cpp newgui.h
Log Message:
dialogs now can be run 'modal'
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dialog.cpp 13 Oct 2002 11:51:48 -0000 1.18
+++ dialog.cpp 16 Oct 2002 17:37:29 -0000 1.19
@@ -50,6 +50,18 @@
_firstWidget = 0;
}
+int Dialog::runModal()
+{
+ // Open up
+ open();
+
+ // Start processing events
+ _gui->runLoop();
+
+ // FIXME - for now always return 0....
+ return 0;
+}
+
void Dialog::open()
{
Widget *w = _firstWidget;
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dialog.h 12 Oct 2002 00:26:24 -0000 1.8
+++ dialog.h 16 Oct 2002 17:37:29 -0000 1.9
@@ -49,7 +49,13 @@
_mouseWidget(0), _focusedWidget(0), _visible(false)
{}
virtual ~Dialog();
+
+ virtual int runModal();
+
+ NewGui *getGui() { return _gui; }
+ bool isVisible() const { return _visible; }
+protected:
virtual void open();
virtual void close();
@@ -63,11 +69,6 @@
virtual void handleMouseMoved(int x, int y, int button);
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
- NewGui *getGui() { return _gui; }
-
- bool isVisible() const { return _visible; }
-
-protected:
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
Widget* addButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey);
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- newgui.cpp 30 Sep 2002 12:56:59 -0000 1.20
+++ newgui.cpp 16 Oct 2002 17:37:29 -0000 1.21
@@ -82,7 +82,7 @@
// Constructor
NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false),
- _currentKeyDown(0), _cursorAnimateCounter(0), _cursorAnimateTimer(0)
+ _stateIsSaved(false), _currentKeyDown(0), _cursorAnimateCounter(0), _cursorAnimateTimer(0)
{
// Setup some default GUI colors.
// TODO - either use nicer values, or maybe make this configurable?
@@ -98,23 +98,18 @@
void NewGui::runLoop()
{
- if (!isActive())
- return;
-
- Dialog *activeDialog;
- int i;
- OSystem::Event event;
-
- saveState();
+ Dialog *activeDialog = _dialogStack.top();
+ bool didSaveState = false;
- _currentKeyDown = 0;
+ if (activeDialog == 0)
+ return;
- _lastClick.x = _lastClick.y = 0;
- _lastClick.time = 0;
- _lastClick.count = 0;
+ if (!_stateIsSaved) {
+ saveState();
+ didSaveState = true;
+ }
- while (isActive()) {
- activeDialog = _dialogStack.top();
+ while (activeDialog == _dialogStack.top()) {
activeDialog->handleTickle();
@@ -123,15 +118,15 @@
// This is necessary to get the blending right.
_system->clear_overlay();
_system->grab_overlay(_screen, _screenPitch);
- for (i = 0; i < _dialogStack.size(); i++)
+ for (int i = 0; i < _dialogStack.size(); i++)
_dialogStack[i]->draw();
_needRedraw = false;
}
animateCursor();
-
_system->update_screen();
+ OSystem::Event event;
uint32 time = _system->get_msecs();
while (_system->poll_event(&event)) {
@@ -192,7 +187,8 @@
_system->delay_msecs(10);
}
- restoreState();
+ if (didSaveState)
+ restoreState();
}
#pragma mark -
@@ -209,6 +205,13 @@
// _screen = new int16[_system->get_width() * _system->get_height()];
// _screenPitch = _system->get_width();
_system->grab_overlay(_screen, _screenPitch);
+
+ _currentKeyDown = 0;
+ _lastClick.x = _lastClick.y = 0;
+ _lastClick.time = 0;
+ _lastClick.count = 0;
+
+ _stateIsSaved = true;
}
void NewGui::restoreState()
@@ -221,7 +224,9 @@
_screen = 0;
}
- _system->update_screen();
+ _system->update_screen();
+
+ _stateIsSaved = false;
}
void NewGui::openDialog(Dialog *dialog)
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- newgui.h 30 Sep 2002 12:56:59 -0000 1.13
+++ newgui.h 16 Oct 2002 17:37:29 -0000 1.14
@@ -81,6 +81,8 @@
bool _needRedraw;
DialogStack _dialogStack;
+ bool _stateIsSaved;
+
// for continuous events (keyDown)
int _currentKeyDown, _currentKeyDownFlags;
uint32 _keyRepeatTime;
More information about the Scummvm-git-logs
mailing list