GRAPHICS: MACGUI: Handle EVENT_QUIT properly in MacDialog

This commit is contained in:
Avijeet 2022-08-05 23:13:20 +05:30 committed by Eugene Sandulenko
parent 1ad34487ee
commit 4f3dc247e4
3 changed files with 21 additions and 6 deletions

View File

@ -230,7 +230,10 @@ void WageEngine::gameOver() {
Graphics::MacDialog gameOverDialog(&_gui->_screen, _gui->_wm, 199, &gameOverMessage, 199, &buttons, 0);
gameOverDialog.run();
int button = gameOverDialog.run();
if (button == Graphics::kMacDialogQuitRequested)
_shouldQuit = true;
doClose();
@ -254,10 +257,11 @@ bool WageEngine::saveDialog() {
int button = save.run();
if (button == 2) // Cancel
if (button == Graphics::kMacDialogQuitRequested)
_shouldQuit = true;
else if (button == 2) // Cancel
return false;
if (button == 1)
else if (button == 1)
saveGame();
doClose();
@ -279,7 +283,10 @@ void WageEngine::aboutDialog() {
Graphics::MacDialog about(&_gui->_screen, _gui->_wm, 450, &aboutMessage, 400, &buttons, 0);
about.run();
int button = about.run();
if (button == Graphics::kMacDialogQuitRequested)
_shouldQuit = true;
}
void WageEngine::saveGame() {

View File

@ -150,6 +150,7 @@ void MacDialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
}
int MacDialog::run() {
bool shouldQuitEngine = false;
bool shouldQuit = false;
Common::Rect r(_bbox);
@ -162,7 +163,7 @@ int MacDialog::run() {
while (g_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
//_shouldQuit = true;
shouldQuitEngine = true;
shouldQuit = true;
break;
case Common::EVENT_MOUSEMOVE:
@ -200,6 +201,9 @@ int MacDialog::run() {
_wm->popCursor();
if (shouldQuitEngine)
return kMacDialogQuitRequested;
return _pressedButton;
}

View File

@ -58,6 +58,10 @@ class ManagedSurface;
class MacText;
class MacWindowManager;
enum {
kMacDialogQuitRequested = -2
};
struct MacDialogButton {
Common::String text;
Common::Rect bounds;