From a34565727b6eba66cf20d32f3ec2ad073f29f9e1 Mon Sep 17 00:00:00 2001 From: flodavid Date: Tue, 25 Jul 2023 22:31:39 +0200 Subject: yuzu: Enable to use controller to close a game - Add General setting to choose if a confirm dialog is shown when stopping - Show the right confirm dialog if wanted - Reuse dialog window that ask to close the game - Add "L + Plus + Minus" default shortcut to Stop emulation - Create generic question dialog based on TAS dialog - It allows controller interaction on most dialogs --- src/yuzu/configuration/config.cpp | 2 +- src/yuzu/configuration/shared_translation.cpp | 1 + src/yuzu/main.cpp | 86 +++++++++++++++++---------- src/yuzu/main.h | 13 ++++ src/yuzu/uisettings.h | 5 ++ 5 files changed, 75 insertions(+), 32 deletions(-) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 1de093447..bc47d1688 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -129,7 +129,7 @@ const std::array Config::default_hotkeys{{ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load File")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load/Remove Amiibo")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F5"), QStringLiteral(""), Qt::WindowShortcut, false}}, + {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F5"), QStringLiteral("L+Plus+Minus"), Qt::WindowShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Record")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F7"), QStringLiteral(""), Qt::ApplicationShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Reset")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F6"), QStringLiteral(""), Qt::ApplicationShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Start/Stop")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F5"), QStringLiteral(""), Qt::ApplicationShortcut, false}}, diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index a4e8af1b4..9e65525ca 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -157,6 +157,7 @@ std::unique_ptr InitializeTranslations(QWidget* parent) { INSERT(UISettings, select_user_on_boot, "Prompt for user on game boot", ""); INSERT(UISettings, pause_when_in_background, "Pause emulation when in background", ""); INSERT(UISettings, confirm_before_closing, "Confirm exit while emulation is running", ""); + INSERT(UISettings, confirm_before_stopping, "Confirm stopping emulation", ""); INSERT(UISettings, hide_mouse, "Hide mouse on inactivity", ""); INSERT(UISettings, controller_applet_disabled, "Disable controller applet", ""); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5427758c1..26fa3e191 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -209,7 +209,7 @@ void GMainWindow::ShowTelemetryCallout() { tr("Anonymous " "data is collected to help improve yuzu. " "

Would you like to share your usage data with us?"); - if (QMessageBox::question(this, tr("Telemetry"), telemetry_message) != QMessageBox::Yes) { + if (!question(this, tr("Telemetry"), telemetry_message)) { Settings::values.enable_telemetry = false; system->ApplySettings(); } @@ -2418,9 +2418,8 @@ void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryT } }(); - if (QMessageBox::question(this, tr("Remove Entry"), entry_question, - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No) != QMessageBox::Yes) { + if (!question(this, tr("Remove Entry"), entry_question, QMessageBox::Yes | QMessageBox::No, + QMessageBox::No)) { return; } @@ -2519,8 +2518,8 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ } }(); - if (QMessageBox::question(this, tr("Remove File"), question, QMessageBox::Yes | QMessageBox::No, - QMessageBox::No) != QMessageBox::Yes) { + if (!GMainWindow::question(this, tr("Remove File"), question, + QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { return; } @@ -3426,8 +3425,25 @@ void GMainWindow::OnPauseContinueGame() { } void GMainWindow::OnStopGame() { - if (system->GetExitLocked() && !ConfirmForceLockedExit()) { - return; + // Open (or not) the right confirm dialog based on current setting and game exit lock + if (UISettings::values.confirm_before_stopping.GetValue() == UISettings::AskStopIndex::Always) { + if (system->GetExitLocked()) { + if (!ConfirmForceLockedExit()) { + return; + } + } else { + if (!ConfirmChangeGame()) { + return; + } + } + } else { + if (UISettings::values.confirm_before_stopping.GetValue() == + UISettings::AskStopIndex::Game && + system->GetExitLocked()) { + if (!ConfirmForceLockedExit()) { + return; + } + } } play_time_manager->Stop(); @@ -3817,22 +3833,11 @@ void GMainWindow::OnTasRecord() { const bool is_recording = input_subsystem->GetTas()->Record(); if (!is_recording) { is_tas_recording_dialog_active = true; - ControllerNavigation* controller_navigation = - new ControllerNavigation(system->HIDCore(), this); - // Use QMessageBox instead of question so we can link controller navigation - QMessageBox* box_dialog = new QMessageBox(); - box_dialog->setWindowTitle(tr("TAS Recording")); - box_dialog->setText(tr("Overwrite file of player 1?")); - box_dialog->setStandardButtons(QMessageBox::Yes | QMessageBox::No); - box_dialog->setDefaultButton(QMessageBox::Yes); - connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, - [box_dialog](Qt::Key key) { - QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); - QCoreApplication::postEvent(box_dialog, event); - }); - int res = box_dialog->exec(); - controller_navigation->UnloadController(); - input_subsystem->GetTas()->SaveRecording(res == QMessageBox::Yes); + + bool answer = question(this, tr("TAS Recording"), tr("Overwrite file of player 1?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + + input_subsystem->GetTas()->SaveRecording(answer); is_tas_recording_dialog_active = false; } OnTasStateChanged(); @@ -4073,6 +4078,27 @@ void GMainWindow::OnLoadAmiibo() { LoadAmiibo(filename); } +bool GMainWindow::question(QWidget* parent, const QString& title, const QString& text, + QMessageBox::StandardButtons buttons, + QMessageBox::StandardButton defaultButton) { + ControllerNavigation* controller_navigation = new ControllerNavigation(system->HIDCore(), this); + + QMessageBox* box_dialog = new QMessageBox(parent); + box_dialog->setWindowTitle(title); + box_dialog->setText(text); + box_dialog->setStandardButtons(buttons); + box_dialog->setDefaultButton(defaultButton); + connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, + [box_dialog](Qt::Key key) { + QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); + QCoreApplication::postEvent(box_dialog, event); + }); + int res = box_dialog->exec(); + + controller_navigation->UnloadController(); + return res == QMessageBox::Yes; +} + void GMainWindow::LoadAmiibo(const QString& filename) { auto* virtual_amiibo = input_subsystem->GetVirtualAmiibo(); const QString title = tr("Error loading Amiibo data"); @@ -4806,8 +4832,7 @@ bool GMainWindow::ConfirmClose() { return true; } const auto text = tr("Are you sure you want to close yuzu?"); - const auto answer = QMessageBox::question(this, tr("yuzu"), text); - return answer != QMessageBox::No; + return question(this, tr("yuzu"), text); } void GMainWindow::closeEvent(QCloseEvent* event) { @@ -4900,11 +4925,11 @@ bool GMainWindow::ConfirmChangeGame() { if (emu_thread == nullptr) return true; - const auto answer = QMessageBox::question( + // Use custom question to link controller navigation + return question( this, tr("yuzu"), tr("Are you sure you want to stop the emulation? Any unsaved progress will be lost."), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No); - return answer != QMessageBox::No; + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); } bool GMainWindow::ConfirmForceLockedExit() { @@ -4914,8 +4939,7 @@ bool GMainWindow::ConfirmForceLockedExit() { const auto text = tr("The currently running application has requested yuzu to not exit.\n\n" "Would you like to bypass this and exit anyway?"); - const auto answer = QMessageBox::question(this, tr("yuzu"), text); - return answer != QMessageBox::No; + return question(this, tr("yuzu"), text); } void GMainWindow::RequestGameExit() { diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 2346eb3bd..711c53a32 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -15,6 +16,7 @@ #include "input_common/drivers/tas_input.h" #include "yuzu/compatibility_list.h" #include "yuzu/hotkeys.h" +#include "yuzu/util/controller_navigation.h" #ifdef __unix__ #include @@ -431,6 +433,17 @@ private: const std::string& command, const std::string& arguments, const std::string& categories, const std::string& keywords); + /** + * Mimic the behavior of QMessageBox::question but link controller navigation to the dialog + * The only difference is that it returns a boolean. + * + * @returns true if buttons contains QMessageBox::Yes and the user clicks on the "Yes" button. + */ + bool question(QWidget* parent, const QString& title, const QString& text, + QMessageBox::StandardButtons buttons = + QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No), + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); + std::unique_ptr ui; std::unique_ptr system; diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 975008159..1216c4efa 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -56,6 +56,8 @@ enum class Theme { MidnightBlueColorful, }; +enum AskStopIndex : int { Always, Game, Never }; + using Themes = std::array, 6>; extern const Themes themes; @@ -94,6 +96,9 @@ struct Values { Setting confirm_before_closing{ linkage, true, "confirmClose", Category::UiGeneral, Settings::Specialization::Default, true, true}; + Setting confirm_before_stopping{ + linkage, true, "confirmStop", Category::UiGeneral, Settings::Specialization::Default, + true, true}; Setting first_start{linkage, true, "firstStart", Category::Ui}; Setting pause_when_in_background{linkage, false, -- cgit v1.2.3 From 6c246f2ac5ce2ede656bf0d2def3b32f87e620b3 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 26 Aug 2023 21:23:02 +0200 Subject: yuzu: Use new setting method for stop emulation --- src/common/settings.cpp | 5 +++++ src/common/settings.h | 5 +++++ src/common/settings_enums.h | 2 ++ src/yuzu/configuration/shared_translation.cpp | 9 ++++++++- src/yuzu/main.cpp | 8 +++++--- src/yuzu/uisettings.h | 16 +++++++++++----- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 3fde3cae6..98b43e49c 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -45,6 +45,7 @@ SWITCHABLE(CpuAccuracy, true); SWITCHABLE(FullscreenMode, true); SWITCHABLE(GpuAccuracy, true); SWITCHABLE(Language, true); +SWITCHABLE(MemoryLayout, true); SWITCHABLE(NvdecEmulation, false); SWITCHABLE(Region, true); SWITCHABLE(RendererBackend, true); @@ -61,6 +62,10 @@ SWITCHABLE(u32, false); SWITCHABLE(u8, false); SWITCHABLE(u8, true); +// Used in UISettings +// TODO see if we can move this to uisettings.cpp +SWITCHABLE(ConfirmStop, true); + #undef SETTING #undef SWITCHABLE #endif diff --git a/src/common/settings.h b/src/common/settings.h index 98ab0ec2e..236e33bee 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -67,6 +67,7 @@ SWITCHABLE(CpuAccuracy, true); SWITCHABLE(FullscreenMode, true); SWITCHABLE(GpuAccuracy, true); SWITCHABLE(Language, true); +SWITCHABLE(MemoryLayout, true); SWITCHABLE(NvdecEmulation, false); SWITCHABLE(Region, true); SWITCHABLE(RendererBackend, true); @@ -83,6 +84,10 @@ SWITCHABLE(u32, false); SWITCHABLE(u8, false); SWITCHABLE(u8, true); +// Used in UISettings +// TODO see if we can move this to uisettings.h +SWITCHABLE(ConfirmStop, true); + #undef SETTING #undef SWITCHABLE #endif diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 815cafe15..11429d7a8 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -133,6 +133,8 @@ ENUM(CpuAccuracy, Auto, Accurate, Unsafe, Paranoid); ENUM(MemoryLayout, Memory_4Gb, Memory_6Gb, Memory_8Gb); +ENUM(ConfirmStop, Ask_Always, Ask_Based_On_Game, Ask_Never); + ENUM(FullscreenMode, Borderless, Exclusive); ENUM(NvdecEmulation, Off, Cpu, Gpu); diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index 9e65525ca..3fe448f27 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -157,7 +157,7 @@ std::unique_ptr InitializeTranslations(QWidget* parent) { INSERT(UISettings, select_user_on_boot, "Prompt for user on game boot", ""); INSERT(UISettings, pause_when_in_background, "Pause emulation when in background", ""); INSERT(UISettings, confirm_before_closing, "Confirm exit while emulation is running", ""); - INSERT(UISettings, confirm_before_stopping, "Confirm stopping emulation", ""); + INSERT(UISettings, confirm_before_stopping, "Confirm before stopping emulation", ""); INSERT(UISettings, hide_mouse, "Hide mouse on inactivity", ""); INSERT(UISettings, controller_applet_disabled, "Disable controller applet", ""); @@ -384,6 +384,13 @@ std::unique_ptr ComboboxEnumeration(QWidget* parent) { translations->insert( {Settings::EnumMetadata::Index(), {PAIR(ConsoleMode, Docked, "Docked"), PAIR(ConsoleMode, Handheld, "Handheld")}}); + translations->insert( + {Settings::EnumMetadata::Index(), + { + PAIR(ConfirmStop, Ask_Always, "Always ask (Default)"), + PAIR(ConfirmStop, Ask_Based_On_Game, "Only if game specifies not to stop"), + PAIR(ConfirmStop, Ask_Never, "Never ask"), + }}); #undef PAIR #undef CTX_PAIR diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 26fa3e191..2727f9d06 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -3426,7 +3426,7 @@ void GMainWindow::OnPauseContinueGame() { void GMainWindow::OnStopGame() { // Open (or not) the right confirm dialog based on current setting and game exit lock - if (UISettings::values.confirm_before_stopping.GetValue() == UISettings::AskStopIndex::Always) { + if (UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Always) { if (system->GetExitLocked()) { if (!ConfirmForceLockedExit()) { return; @@ -3438,7 +3438,7 @@ void GMainWindow::OnStopGame() { } } else { if (UISettings::values.confirm_before_stopping.GetValue() == - UISettings::AskStopIndex::Game && + ConfirmStop::Ask_Based_On_Game && system->GetExitLocked()) { if (!ConfirmForceLockedExit()) { return; @@ -4081,13 +4081,15 @@ void GMainWindow::OnLoadAmiibo() { bool GMainWindow::question(QWidget* parent, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { - ControllerNavigation* controller_navigation = new ControllerNavigation(system->HIDCore(), this); QMessageBox* box_dialog = new QMessageBox(parent); box_dialog->setWindowTitle(title); box_dialog->setText(text); box_dialog->setStandardButtons(buttons); box_dialog->setDefaultButton(defaultButton); + + ControllerNavigation* controller_navigation = + new ControllerNavigation(system->HIDCore(), box_dialog); connect(controller_navigation, &ControllerNavigation::TriggerKeyboardEvent, [box_dialog](Qt::Key key) { QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier); diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 1216c4efa..b62ff620c 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -16,7 +16,9 @@ #include "common/settings_enums.h" using Settings::Category; +using Settings::ConfirmStop; using Settings::Setting; +using Settings::SwitchableSetting; #ifndef CANNOT_EXPLICITLY_INSTANTIATE namespace Settings { @@ -56,8 +58,6 @@ enum class Theme { MidnightBlueColorful, }; -enum AskStopIndex : int { Always, Game, Never }; - using Themes = std::array, 6>; extern const Themes themes; @@ -96,9 +96,15 @@ struct Values { Setting confirm_before_closing{ linkage, true, "confirmClose", Category::UiGeneral, Settings::Specialization::Default, true, true}; - Setting confirm_before_stopping{ - linkage, true, "confirmStop", Category::UiGeneral, Settings::Specialization::Default, - true, true}; + + SwitchableSetting confirm_before_stopping{linkage, + ConfirmStop::Ask_Always, + "confirmStop", + Category::UiGeneral, + Settings::Specialization::Default, + true, + true}; + Setting first_start{linkage, true, "firstStart", Category::Ui}; Setting pause_when_in_background{linkage, false, -- cgit v1.2.3 From 48b67fc4a01e5add97f28e317a8af2e7d3e429b6 Mon Sep 17 00:00:00 2001 From: flodavid Date: Thu, 12 Oct 2023 00:17:06 +0200 Subject: yuzu: Enable to use controller to restart a game - Show the right confirm dialog if wanted - Create generic method to ask close confirmation - Add "R + Plus + Minus" default shortcut to Restart emulation --- src/yuzu/configuration/config.cpp | 2 +- src/yuzu/main.cpp | 41 +++++++++++++++++++++++---------------- src/yuzu/main.h | 4 ++++ 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index bc47d1688..d5157c502 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -128,7 +128,7 @@ const std::array Config::default_hotkeys{{ {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Fullscreen")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F11"), QStringLiteral("Home+B"), Qt::WindowShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load File")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+O"), QStringLiteral(""), Qt::WidgetWithChildrenShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load/Remove Amiibo")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F2"), QStringLiteral("Home+A"), Qt::WidgetWithChildrenShortcut, false}}, - {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F6"), QStringLiteral(""), Qt::WindowShortcut, false}}, + {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F6"), QStringLiteral("R+Plus+Minus"), Qt::WindowShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("F5"), QStringLiteral("L+Plus+Minus"), Qt::WindowShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Record")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F7"), QStringLiteral(""), Qt::ApplicationShortcut, false}}, {QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Reset")), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")), {QStringLiteral("Ctrl+F6"), QStringLiteral(""), Qt::ApplicationShortcut, false}}, diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 2727f9d06..425f546f7 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -3400,10 +3400,13 @@ void GMainWindow::OnRestartGame() { if (!system->IsPoweredOn()) { return; } - // Make a copy since ShutdownGame edits game_path - const auto current_game = QString(current_game_path); - ShutdownGame(); - BootGame(current_game); + + if (ConfirmShutdownGame()) { + // Make a copy since ShutdownGame edits game_path + const auto current_game = QString(current_game_path); + ShutdownGame(); + BootGame(current_game); + } } void GMainWindow::OnPauseGame() { @@ -3425,15 +3428,27 @@ void GMainWindow::OnPauseContinueGame() { } void GMainWindow::OnStopGame() { - // Open (or not) the right confirm dialog based on current setting and game exit lock + if (ConfirmShutdownGame()) { + play_time_manager->Stop(); + // Update game list to show new play time + game_list->PopulateAsync(UISettings::values.game_dirs); + if (OnShutdownBegin()) { + OnShutdownBeginDialog(); + } else { + OnEmulationStopped(); + } + } +} + +bool GMainWindow::ConfirmShutdownGame() { if (UISettings::values.confirm_before_stopping.GetValue() == ConfirmStop::Ask_Always) { if (system->GetExitLocked()) { if (!ConfirmForceLockedExit()) { - return; + return false; } } else { if (!ConfirmChangeGame()) { - return; + return false; } } } else { @@ -3441,19 +3456,11 @@ void GMainWindow::OnStopGame() { ConfirmStop::Ask_Based_On_Game && system->GetExitLocked()) { if (!ConfirmForceLockedExit()) { - return; + return false; } } } - - play_time_manager->Stop(); - // Update game list to show new play time - game_list->PopulateAsync(UISettings::values.game_dirs); - if (OnShutdownBegin()) { - OnShutdownBeginDialog(); - } else { - OnEmulationStopped(); - } + return true; } void GMainWindow::OnLoadComplete() { diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 711c53a32..178eef294 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -426,6 +426,10 @@ private: bool CheckSystemArchiveDecryption(); bool CheckFirmwarePresence(); void ConfigureFilesystemProvider(const std::string& filepath); + /** + * Open (or not) the right confirm dialog based on current setting and game exit lock + */ + bool ConfirmShutdownGame(); QString GetTasStateDescription() const; bool CreateShortcut(const std::string& shortcut_path, const std::string& title, -- cgit v1.2.3 From d9456f0a11ad39a9f8176c1e6f16215ac6c9a76c Mon Sep 17 00:00:00 2001 From: F David Date: Thu, 12 Oct 2023 16:06:44 +0200 Subject: fix style --- src/yuzu/main.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 178eef294..270a40c5f 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -427,8 +427,9 @@ private: bool CheckFirmwarePresence(); void ConfigureFilesystemProvider(const std::string& filepath); /** - * Open (or not) the right confirm dialog based on current setting and game exit lock - */ + * Open (or not) the right confirm dialog based on current setting and game exit lock + * @returns true if the player confirmed or the settings do no require it + */ bool ConfirmShutdownGame(); QString GetTasStateDescription() const; -- cgit v1.2.3