diff options
author | Zach Hilman <zachhilman@gmail.com> | 2019-09-21 22:46:53 -0400 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2019-09-21 22:46:57 -0400 |
commit | 60c2e9e675ce3618d1eedd9a73479c48eb9ba1dc (patch) | |
tree | 0d1b0e1efada203e609ce74cc93e53c17a36c468 /src/yuzu/main.cpp | |
parent | e58e3719d89bd8ce2c919ab154ec93a657807b3a (diff) |
qt: Prompt user for confirmation if exit lock is active
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f147044d99..328f599f15 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -22,6 +22,8 @@ #include "core/frontend/applets/general_frontend.h" #include "core/frontend/scope_acquire_window_context.h" #include "core/hle/service/acc/profile_manager.h" +#include "core/hle/service/am/applet_ae.h" +#include "core/hle/service/am/applet_oe.h" #include "core/hle/service/am/applets/applets.h" #include "core/hle/service/hid/controllers/npad.h" #include "core/hle/service/hid/hid.h" @@ -83,6 +85,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "core/file_sys/submission_package.h" #include "core/frontend/applets/software_keyboard.h" #include "core/hle/kernel/process.h" +#include "core/hle/service/am/am.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/nfp/nfp.h" #include "core/hle/service/sm/sm.h" @@ -1674,6 +1677,11 @@ void GMainWindow::OnStartGame() { } void GMainWindow::OnPauseGame() { + Core::System& system{Core::System::GetInstance()}; + if (system.GetExitLock() && !ConfirmForceLockedExit()) { + return; + } + emu_thread->SetRunning(false); ui.action_Start->setEnabled(true); @@ -1685,6 +1693,11 @@ void GMainWindow::OnPauseGame() { } void GMainWindow::OnStopGame() { + Core::System& system{Core::System::GetInstance()}; + if (system.GetExitLock() && !ConfirmForceLockedExit()) { + return; + } + ShutdownGame(); } @@ -2189,6 +2202,34 @@ bool GMainWindow::ConfirmChangeGame() { return answer != QMessageBox::No; } +bool GMainWindow::ConfirmForceLockedExit() { + if (emu_thread == nullptr) + return true; + + auto answer = + QMessageBox::question(this, tr("yuzu"), + tr("The currently running application has requested yuzu to not " + "exit.\n\nWould you like to bypass this and exit anyway?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); + return answer != QMessageBox::No; +} + +void GMainWindow::RequestGameExit() { + auto& sm{Core::System::GetInstance().ServiceManager()}; + auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE"); + auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE"); + bool has_signalled = false; + + if (applet_oe != nullptr) { + applet_oe->GetMessageQueue()->RequestExit(); + has_signalled = true; + } + + if (applet_ae != nullptr && !has_signalled) { + applet_ae->GetMessageQueue()->RequestExit(); + } +} + void GMainWindow::filterBarSetChecked(bool state) { ui.action_Show_Filter_Bar->setChecked(state); emit(OnToggleFilterBar()); |