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.
This commit is contained in:
Thierry Crozat 2020-04-16 00:09:39 +01:00
parent 3b6b881ad4
commit 8b0b9f11c6
4 changed files with 14 additions and 5 deletions

View file

@ -95,6 +95,10 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {
event = _eventQueue.pop(); event = _eventQueue.pop();
bool forwardEvent = true; 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) { switch (event.type) {
case Common::EVENT_KEYDOWN: case Common::EVENT_KEYDOWN:
_modifierState = event.kbd.flags; _modifierState = event.kbd.flags;

View file

@ -418,7 +418,12 @@ public:
* Supports for using the native system file browser dialog * Supports for using the native system file browser dialog
* through the DialogManager. * through the DialogManager.
*/ */
kFeatureSystemBrowserDialog kFeatureSystemBrowserDialog,
/**
* For platforms that should not have a Quit button
*/
kFeatureNoQuit
}; };

View file

@ -95,8 +95,8 @@ MainMenuDialog::MainMenuDialog(Engine *engine)
_rtlButton = new GUI::ButtonWidget(this, "GlobalMenu.RTL", _c("~R~eturn to Launcher", "lowres"), 0, kRTLCmd); _rtlButton = new GUI::ButtonWidget(this, "GlobalMenu.RTL", _c("~R~eturn to Launcher", "lowres"), 0, kRTLCmd);
_rtlButton->setEnabled(_engine->hasFeature(Engine::kSupportsRTL)); _rtlButton->setEnabled(_engine->hasFeature(Engine::kSupportsRTL));
if (!g_system->hasFeature(OSystem::kFeatureNoQuit))
new GUI::ButtonWidget(this, "GlobalMenu.Quit", _("~Q~uit"), 0, kQuitCmd); new GUI::ButtonWidget(this, "GlobalMenu.Quit", _("~Q~uit"), 0, kQuitCmd);
_aboutDialog = new GUI::AboutDialog(); _aboutDialog = new GUI::AboutDialog();
_loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false); _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);

View file

@ -136,8 +136,8 @@ void LauncherDialog::build() {
// Show ScummVM version // Show ScummVM version
new StaticTextWidget(this, "Launcher.Version", gScummVMFullVersion); new StaticTextWidget(this, "Launcher.Version", gScummVMFullVersion);
#endif #endif
if (!g_system->hasFeature(OSystem::kFeatureNoQuit))
new ButtonWidget(this, "Launcher.QuitButton", _("~Q~uit"), _("Quit ScummVM"), kQuitCmd); 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.AboutButton", _("A~b~out..."), _("About ScummVM"), kAboutCmd);
new ButtonWidget(this, "Launcher.OptionsButton", _("~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd); new ButtonWidget(this, "Launcher.OptionsButton", _("~O~ptions..."), _("Change global ScummVM options"), kOptionsCmd);
_startButton = _startButton =