diff options
author | flodavid <fl.david.53@gmail.com> | 2023-10-12 00:17:06 +0200 |
---|---|---|
committer | flodavid <fl.david.53@gmail.com> | 2023-10-12 01:53:54 +0200 |
commit | 48b67fc4a01e5add97f28e317a8af2e7d3e429b6 (patch) | |
tree | 99578c9bf4ccf38b62485d27ea88b128e3da3c2c /src/yuzu/main.cpp | |
parent | 6c246f2ac5ce2ede656bf0d2def3b32f87e620b3 (diff) |
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
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
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() { |