From 8b0b9f11c69b698269b0b471c52e863cadb1752e Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Thu, 16 Apr 2020 00:09:39 +0100 Subject: [PATCH] OSYSTEM: Add kFeatureNoQuit to remove Quit buttons and replace Quit with RTL Some platforms should not allow quitting ScummVM. For example the Apple's HUG for iOS state that we should "Never quit an iOS applications programmatically". Adding the kFeatureNoQuit allows those backend that need it to remove the possibility to quit the application. --- backends/events/default/default-events.cpp | 4 ++++ common/system.h | 7 ++++++- engines/dialogs.cpp | 4 ++-- gui/launcher.cpp | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index ffadcd25094..e7ccbde3f3a 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -95,6 +95,10 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { event = _eventQueue.pop(); bool forwardEvent = true; + // If the backend has the kFeatureNoQuit, replace Quit event with RTL + if (event.type == Common::EVENT_QUIT && g_system->hasFeature(OSystem::kFeatureNoQuit)) + event.type = Common::EVENT_RTL; + switch (event.type) { case Common::EVENT_KEYDOWN: _modifierState = event.kbd.flags; diff --git a/common/system.h b/common/system.h index 9922e92aab3..bf96f8bb077 100644 --- a/common/system.h +++ b/common/system.h @@ -418,7 +418,12 @@ public: * Supports for using the native system file browser dialog * through the DialogManager. */ - kFeatureSystemBrowserDialog + kFeatureSystemBrowserDialog, + + /** + * For platforms that should not have a Quit button + */ + kFeatureNoQuit }; diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 07442c40d81..7f85bebe8b0 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -95,8 +95,8 @@ MainMenuDialog::MainMenuDialog(Engine *engine) _rtlButton = new GUI::ButtonWidget(this, "GlobalMenu.RTL", _c("~R~eturn to Launcher", "lowres"), 0, kRTLCmd); _rtlButton->setEnabled(_engine->hasFeature(Engine::kSupportsRTL)); - - new GUI::ButtonWidget(this, "GlobalMenu.Quit", _("~Q~uit"), 0, kQuitCmd); + if (!g_system->hasFeature(OSystem::kFeatureNoQuit)) + new GUI::ButtonWidget(this, "GlobalMenu.Quit", _("~Q~uit"), 0, kQuitCmd); _aboutDialog = new GUI::AboutDialog(); _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index ae07aeb89d3..d004bc52d1e 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -136,8 +136,8 @@ void LauncherDialog::build() { // Show ScummVM version new StaticTextWidget(this, "Launcher.Version", gScummVMFullVersion); #endif - - new ButtonWidget(this, "Launcher.QuitButton", _("~Q~uit"), _("Quit ScummVM"), kQuitCmd); + if (!g_system->hasFeature(OSystem::kFeatureNoQuit)) + new ButtonWidget(this, "Launcher.QuitButton", _("~Q~uit"), _("Quit ScummVM"), kQuitCmd); new ButtonWidget(this, "Launcher.AboutButton", _("A~b~out..."), _("About ScummVM"), kAboutCmd); new ButtonWidget(this, "Launcher.OptionsButton", _("~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd); _startButton =