diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index ad9330d6e4..1018b702b9 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -446,11 +446,15 @@ public: void DispatchUiSettingsEvent( IniInterface& ini ); void DispatchVmSettingsEvent( IniInterface& ini ); + bool HasGUI() { return m_UseGUI; }; + bool ExitPromptWithNoGUI() { return m_NoGuiExitPrompt; }; + // ---------------------------------------------------------------------------- protected: int m_PendingSaves; bool m_ScheduledTermination; bool m_UseGUI; + bool m_NoGuiExitPrompt; Threading::Mutex m_mtx_Resources; Threading::Mutex m_mtx_LoadingGameDB; diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index cb42733844..2d7cc243d8 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -222,6 +222,8 @@ void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser ) parser.AddSwitch( wxEmptyString,L"windowed", _("use windowed GS mode") ); parser.AddSwitch( wxEmptyString,L"nogui", _("disables display of the gui while running games") ); + parser.AddSwitch( wxEmptyString,L"noguiprompt", _("when nogui - prompt before exiting on suspend") ); + parser.AddOption( wxEmptyString,L"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING ); parser.AddSwitch( wxEmptyString,L"nodisc", _("boots an empty dvd tray; use to enter the PS2 system menu") ); parser.AddSwitch( wxEmptyString,L"usecd", _("boots from the CDVD plugin (overrides IsoFile parameter)") ); @@ -319,6 +321,7 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser ) //wxApp::OnCmdLineParsed( parser ); m_UseGUI = !parser.Found(L"nogui"); + m_NoGuiExitPrompt = parser.Found(L"noguiprompt"); // by default no prompt for exit with nogui. if( !ParseOverrides(parser) ) return false; diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 4266d136a3..8e81e02d11 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -943,7 +943,8 @@ void Pcsx2App::OnGsFrameClosed( wxWindowID id ) if( !m_UseGUI ) { - // [TODO] : Prompt user before exiting, k thx. :) + // The user is prompted before suspending (at Sys_Suspend() ), because + // right now there's no way to resume from suspend without GUI. PrepForExit(); } } diff --git a/pcsx2/gui/GlobalCommands.cpp b/pcsx2/gui/GlobalCommands.cpp index c409eab612..7f264f18af 100644 --- a/pcsx2/gui/GlobalCommands.cpp +++ b/pcsx2/gui/GlobalCommands.cpp @@ -281,6 +281,37 @@ namespace Implementations void Sys_Suspend() { + GSFrame* gsframe = wxGetApp().GetGsFramePtr(); + if (gsframe && !wxGetApp().HasGUI() && g_Conf->GSWindow.CloseOnEsc) { + // When we run with --nogui, PCSX2 only knows to exit when the gs window closes. + // However, by default suspend just hides the gs window, so PCSX2 will not exit + // and there will also be no way to exit it even if no windows are left. + // If the gs window is not set to close on suspend, then the user can still + // close it with the X button, which PCSX2 will recognize and exit. + // So if we're set to close on esc and nogui: + // If the user didn't specify --noguiprompt - exit immediately. + // else prompt to either exit or abort the suspend. + if (!wxGetApp().ExitPromptWithNoGUI() // the user specified to exit immediately + || (wxOK == wxMessageBox(_("Exit PCSX2?"), + L"PCSX2", + wxICON_WARNING | wxOK | wxCANCEL))) + { + // Pcsx2App knows to exit if no gui and the GS window closes. + gsframe->Close(); + return; + } + else + { + // aborting suspend request + // TODO: It's likely that if we were full screen before showing the + // prompt then we're now not in full screen anymore. It would have + // been ideal to restore full screen, but the full screen flow is complex + // and specifically gsframe->IsFullScreen() is always false when we enter + // this function - even if we were full screen before displaying the prompt. + return; + } + } + CoreThread.Suspend(); sMainFrame.SetFocus(); }