dialogs now can be run 'modal'
svn-id: r5168
This commit is contained in:
parent
c0a42d5450
commit
d5bcb63f82
7 changed files with 47 additions and 29 deletions
|
@ -136,8 +136,7 @@ static void launcherDialog(GameDetector &detector, OSystem *system)
|
||||||
g_system = system;
|
g_system = system;
|
||||||
|
|
||||||
Dialog *dlg = new LauncherDialog(g_gui, detector);
|
Dialog *dlg = new LauncherDialog(g_gui, detector);
|
||||||
dlg->open();
|
dlg->runModal();
|
||||||
g_gui->runLoop();
|
|
||||||
delete dlg;
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,18 @@ Dialog::~Dialog()
|
||||||
_firstWidget = 0;
|
_firstWidget = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Dialog::runModal()
|
||||||
|
{
|
||||||
|
// Open up
|
||||||
|
open();
|
||||||
|
|
||||||
|
// Start processing events
|
||||||
|
_gui->runLoop();
|
||||||
|
|
||||||
|
// FIXME - for now always return 0....
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Dialog::open()
|
void Dialog::open()
|
||||||
{
|
{
|
||||||
Widget *w = _firstWidget;
|
Widget *w = _firstWidget;
|
||||||
|
|
11
gui/dialog.h
11
gui/dialog.h
|
@ -49,7 +49,13 @@ public:
|
||||||
_mouseWidget(0), _focusedWidget(0), _visible(false)
|
_mouseWidget(0), _focusedWidget(0), _visible(false)
|
||||||
{}
|
{}
|
||||||
virtual ~Dialog();
|
virtual ~Dialog();
|
||||||
|
|
||||||
|
virtual int runModal();
|
||||||
|
|
||||||
|
NewGui *getGui() { return _gui; }
|
||||||
|
bool isVisible() const { return _visible; }
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual void open();
|
virtual void open();
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
|
||||||
|
@ -63,11 +69,6 @@ public:
|
||||||
virtual void handleMouseMoved(int x, int y, int button);
|
virtual void handleMouseMoved(int x, int y, int button);
|
||||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
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* 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);
|
Widget* addButton(int x, int y, const ScummVM::String &label, uint32 cmd, char hotkey);
|
||||||
|
|
|
@ -82,7 +82,7 @@ static byte guifont[] = {
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false),
|
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.
|
// Setup some default GUI colors.
|
||||||
// TODO - either use nicer values, or maybe make this configurable?
|
// 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()
|
void NewGui::runLoop()
|
||||||
{
|
{
|
||||||
if (!isActive())
|
Dialog *activeDialog = _dialogStack.top();
|
||||||
|
bool didSaveState = false;
|
||||||
|
|
||||||
|
if (activeDialog == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Dialog *activeDialog;
|
if (!_stateIsSaved) {
|
||||||
int i;
|
saveState();
|
||||||
OSystem::Event event;
|
didSaveState = true;
|
||||||
|
}
|
||||||
|
|
||||||
saveState();
|
while (activeDialog == _dialogStack.top()) {
|
||||||
|
|
||||||
_currentKeyDown = 0;
|
|
||||||
|
|
||||||
_lastClick.x = _lastClick.y = 0;
|
|
||||||
_lastClick.time = 0;
|
|
||||||
_lastClick.count = 0;
|
|
||||||
|
|
||||||
while (isActive()) {
|
|
||||||
activeDialog = _dialogStack.top();
|
|
||||||
|
|
||||||
activeDialog->handleTickle();
|
activeDialog->handleTickle();
|
||||||
|
|
||||||
|
@ -123,15 +118,15 @@ void NewGui::runLoop()
|
||||||
// This is necessary to get the blending right.
|
// This is necessary to get the blending right.
|
||||||
_system->clear_overlay();
|
_system->clear_overlay();
|
||||||
_system->grab_overlay(_screen, _screenPitch);
|
_system->grab_overlay(_screen, _screenPitch);
|
||||||
for (i = 0; i < _dialogStack.size(); i++)
|
for (int i = 0; i < _dialogStack.size(); i++)
|
||||||
_dialogStack[i]->draw();
|
_dialogStack[i]->draw();
|
||||||
_needRedraw = false;
|
_needRedraw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
animateCursor();
|
animateCursor();
|
||||||
|
|
||||||
_system->update_screen();
|
_system->update_screen();
|
||||||
|
|
||||||
|
OSystem::Event event;
|
||||||
uint32 time = _system->get_msecs();
|
uint32 time = _system->get_msecs();
|
||||||
|
|
||||||
while (_system->poll_event(&event)) {
|
while (_system->poll_event(&event)) {
|
||||||
|
@ -192,7 +187,8 @@ void NewGui::runLoop()
|
||||||
_system->delay_msecs(10);
|
_system->delay_msecs(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreState();
|
if (didSaveState)
|
||||||
|
restoreState();
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
@ -209,6 +205,13 @@ void NewGui::saveState()
|
||||||
// _screen = new int16[_system->get_width() * _system->get_height()];
|
// _screen = new int16[_system->get_width() * _system->get_height()];
|
||||||
// _screenPitch = _system->get_width();
|
// _screenPitch = _system->get_width();
|
||||||
_system->grab_overlay(_screen, _screenPitch);
|
_system->grab_overlay(_screen, _screenPitch);
|
||||||
|
|
||||||
|
_currentKeyDown = 0;
|
||||||
|
_lastClick.x = _lastClick.y = 0;
|
||||||
|
_lastClick.time = 0;
|
||||||
|
_lastClick.count = 0;
|
||||||
|
|
||||||
|
_stateIsSaved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGui::restoreState()
|
void NewGui::restoreState()
|
||||||
|
@ -221,7 +224,9 @@ void NewGui::restoreState()
|
||||||
_screen = 0;
|
_screen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_system->update_screen();
|
_system->update_screen();
|
||||||
|
|
||||||
|
_stateIsSaved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGui::openDialog(Dialog *dialog)
|
void NewGui::openDialog(Dialog *dialog)
|
||||||
|
|
|
@ -81,6 +81,8 @@ protected:
|
||||||
bool _needRedraw;
|
bool _needRedraw;
|
||||||
DialogStack _dialogStack;
|
DialogStack _dialogStack;
|
||||||
|
|
||||||
|
bool _stateIsSaved;
|
||||||
|
|
||||||
// for continuous events (keyDown)
|
// for continuous events (keyDown)
|
||||||
int _currentKeyDown, _currentKeyDownFlags;
|
int _currentKeyDown, _currentKeyDownFlags;
|
||||||
uint32 _keyRepeatTime;
|
uint32 _keyRepeatTime;
|
||||||
|
|
|
@ -468,7 +468,7 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
|
||||||
// TODO
|
// TODO
|
||||||
break;
|
break;
|
||||||
case kAboutCmd:
|
case kAboutCmd:
|
||||||
_aboutDialog->open();
|
_aboutDialog->runModal();
|
||||||
break;
|
break;
|
||||||
case kMasterVolumeChanged:
|
case kMasterVolumeChanged:
|
||||||
_soundVolumeMaster = masterVolumeSlider->getValue();
|
_soundVolumeMaster = masterVolumeSlider->getValue();
|
||||||
|
|
|
@ -952,8 +952,7 @@ void Scumm::runDialog(Dialog *dialog)
|
||||||
_sound->pauseSounds(true);
|
_sound->pauseSounds(true);
|
||||||
|
|
||||||
// Open & run the dialog
|
// Open & run the dialog
|
||||||
dialog->open();
|
dialog->runModal();
|
||||||
_newgui->runLoop();
|
|
||||||
|
|
||||||
// Restore old cursor
|
// Restore old cursor
|
||||||
updateCursor();
|
updateCursor();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue