From 2b50e2a7c0d6ed250a4b58fa0fa1bf18c458d091 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 7 Jul 2002 21:46:53 +0000 Subject: added dialog nesting code (for now using std::stack, I will provide my own stack class later svn-id: r4483 --- newgui.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'newgui.cpp') 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) -- cgit v1.2.3