From f767b6ccfb2640095523d2bc5f3d349f66282a0b Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 6 Sep 2020 06:01:06 +0100 Subject: [PATCH] GUI: Add exitLoop() method to GuiManager The idea is to allow backends to start a game even after the LauncherDialog has been created, and for that they need a way to close the existing GUI dialogs. --- gui/gui-manager.cpp | 5 +++++ gui/gui-manager.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 270c1765ba7..50eb8d2a7bf 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -449,6 +449,11 @@ void GuiManager::runLoop() { #endif } +void GuiManager::exitLoop() { + while (!_dialogStack.empty()) + getTopDialog()->close(); +} + #pragma mark - void GuiManager::saveState() { diff --git a/gui/gui-manager.h b/gui/gui-manager.h index a8e88a4be2a..3752dde49c5 100644 --- a/gui/gui-manager.h +++ b/gui/gui-manager.h @@ -75,6 +75,11 @@ public: // until no dialogs are active anymore. void runLoop(); + // If the GUI loop is running close all the dialogs causing the loop to finish. + // Typically you may want to use it after setting the ConfMan active domain to + // a game domain to cause the game to start. + void exitLoop(); + void processEvent(const Common::Event &event, Dialog *const activeDialog); Common::Keymap *getKeymap() const; void scheduleTopDialogRedraw();