diff options
author | Max Horn | 2002-07-07 21:46:53 +0000 |
---|---|---|
committer | Max Horn | 2002-07-07 21:46:53 +0000 |
commit | 2b50e2a7c0d6ed250a4b58fa0fa1bf18c458d091 (patch) | |
tree | 21d2206732b1c818858a160a23d3dee8ae8762fd /newgui.cpp | |
parent | aec25305294920da84a7d0721a2fd4e7f2547c74 (diff) | |
download | scummvm-rg350-2b50e2a7c0d6ed250a4b58fa0fa1bf18c458d091.tar.gz scummvm-rg350-2b50e2a7c0d6ed250a4b58fa0fa1bf18c458d091.tar.bz2 scummvm-rg350-2b50e2a7c0d6ed250a4b58fa0fa1bf18c458d091.zip |
added dialog nesting code (for now using std::stack, I will provide my own stack class later
svn-id: r4483
Diffstat (limited to 'newgui.cpp')
-rw-r--r-- | newgui.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/newgui.cpp b/newgui.cpp index 66a75d28dc..f660673304 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -28,7 +28,7 @@ #define vline(x, y, y2, color) line(x, y, x, y2, color); -NewGui::NewGui(Scumm *s):_s(s), _active(false), _need_redraw(false), _activeDialog(0) +NewGui::NewGui(Scumm *s) : _s(s), _need_redraw(false) { _pauseDialog = new PauseDialog(this); _saveLoadDialog = new SaveLoadDialog(this); @@ -36,33 +36,31 @@ NewGui::NewGui(Scumm *s):_s(s), _active(false), _need_redraw(false), _activeDial void NewGui::pauseDialog() { - _active = true; - _activeDialog = _pauseDialog; - _need_redraw = true; + openDialog(_pauseDialog); } void NewGui::saveloadDialog() { - _active = true; - _activeDialog = _saveLoadDialog; - _need_redraw = true; + openDialog(_saveLoadDialog); } void NewGui::loop() { + Dialog *activeDialog = _dialogStack.top(); + if (_need_redraw) { - _activeDialog->draw(); + activeDialog->draw(); saveState(); _need_redraw = false; } _s->animateCursor(); _s->getKeyInput(0); if (_s->_mouseButStat & MBS_LEFT_CLICK) { - _activeDialog->handleClick(_s->mouse.x, _s->mouse.y, _s->_mouseButStat); + activeDialog->handleClick(_s->mouse.x, _s->mouse.y, _s->_mouseButStat); } else if (_s->_lastKeyHit) { - _activeDialog->handleKey(_s->_lastKeyHit, 0); + activeDialog->handleKey(_s->_lastKeyHit, 0); } else if (_old_mouse.x != _s->mouse.x || _old_mouse.y != _s->mouse.y) { - _activeDialog->handleMouseMoved(_s->mouse.x, _s->mouse.y, _s->_mouseButStat); + activeDialog->handleMouseMoved(_s->mouse.x, _s->mouse.y, _s->_mouseButStat); _old_mouse.x = _s->mouse.x; _old_mouse.y = _s->mouse.y; } @@ -109,6 +107,21 @@ void NewGui::restoreState() _s->pauseSounds(_old_soundsPaused); } +void NewGui::openDialog(Dialog *dialog) +{ + _dialogStack.push(dialog); + _need_redraw = true; +} + +void NewGui::closeTopDialog() +{ + _dialogStack.pop(); + if (_dialogStack.empty()) + restoreState(); + else + _dialogStack.top()->draw(); +} + #pragma mark - const char *NewGui::queryString(int stringno) |