diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/dialog.cpp | 12 | ||||
-rw-r--r-- | gui/dialog.h | 11 | ||||
-rw-r--r-- | gui/newgui.cpp | 43 | ||||
-rw-r--r-- | gui/newgui.h | 2 |
4 files changed, 44 insertions, 24 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp index ec386f90f2..09f76edb1c 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -50,6 +50,18 @@ Dialog::~Dialog() _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; diff --git a/gui/dialog.h b/gui/dialog.h index 509ae6d385..7d7224c480 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -49,7 +49,13 @@ public: _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 @@ public: 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); diff --git a/gui/newgui.cpp b/gui/newgui.cpp index aed586fe04..61f50e2b72 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -82,7 +82,7 @@ static byte guifont[] = { // 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 @@ NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false void NewGui::runLoop() { - if (!isActive()) - return; - - Dialog *activeDialog; - int i; - OSystem::Event event; + Dialog *activeDialog = _dialogStack.top(); + bool didSaveState = false; - saveState(); - - _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 @@ void NewGui::runLoop() // 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 @@ void NewGui::runLoop() _system->delay_msecs(10); } - restoreState(); + if (didSaveState) + restoreState(); } #pragma mark - @@ -209,6 +205,13 @@ void NewGui::saveState() // _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 @@ void NewGui::restoreState() _screen = 0; } - _system->update_screen(); + _system->update_screen(); + + _stateIsSaved = false; } void NewGui::openDialog(Dialog *dialog) diff --git a/gui/newgui.h b/gui/newgui.h index bd97bcaaf0..957c63c1fa 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -81,6 +81,8 @@ protected: bool _needRedraw; DialogStack _dialogStack; + bool _stateIsSaved; + // for continuous events (keyDown) int _currentKeyDown, _currentKeyDownFlags; uint32 _keyRepeatTime; |