diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 01498a4f3f..6e6763b8c4 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -38,6 +38,7 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE( pxEvt_LoadPluginsComplete, -1 ) DECLARE_EVENT_TYPE( pxEvt_LogicalVsync, -1 ) DECLARE_EVENT_TYPE( pxEvt_ThreadTaskTimeout_SysExec, -1 ) + DECLARE_EVENT_TYPE( pxEvt_SetSettingsPage, -1 ) END_DECLARE_EVENT_TYPES() // This is used when the GS plugin is handling its own window. Messages from the PAD @@ -690,6 +691,42 @@ wxWindow* AppOpenDialog( wxWindow* parent=NULL ) return window; } +// -------------------------------------------------------------------------------------- +// AppOpenModalDialog +// -------------------------------------------------------------------------------------- +// Returns the ID of the button used to close the dialog. +// +template +int AppOpenModalDialog(wxString panel_name, wxWindow* parent = NULL) +{ + if (wxWindow* window = wxFindWindowByName(L"Dialog:" + DialogType::GetNameStatic())) + { + window->SetFocus(); + if (wxDialog* dialog = wxDynamicCast(window, wxDialog)) + { + // Switch to the requested panel. + if (panel_name != wxEmptyString) { + wxCommandEvent evt(pxEvt_SetSettingsPage); + evt.SetString(panel_name); + dialog->GetEventHandler()->ProcessEvent(evt); + } + + // It's legal to call ShowModal on a non-modal dialog, therefore making + // it modal in nature for the needs of whatever other thread of action wants + // to block against it: + if (!dialog->IsModal()) + { + int result = dialog->ShowModal(); + dialog->Destroy(); + return result; + } + } + pxFailDev("Can only show wxDialog class windows as modal!"); + return wxID_CANCEL; + } else + return DialogType(parent).ShowModal(); +} + extern pxDoAssertFnType AppDoAssert; // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 478fdf231c..b3e2c94402 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -14,6 +14,7 @@ */ #include "PrecompiledHeader.h" +#include "App.h" #include "MainFrame.h" #include "GSFrame.h" #include "GS.h" @@ -59,36 +60,6 @@ DEFINE_EVENT_TYPE( pxEvt_ThreadTaskTimeout_SysExec ); ScopedPtr g_Conf; -template -int AppOpenModalDialog( wxString panel_name, wxWindow* parent=NULL ) -{ - if( wxWindow* window = wxFindWindowByName( L"Dialog:" + DialogType::GetNameStatic() ) ) - { - window->SetFocus(); - if( wxDialog* dialog = wxDynamicCast( window, wxDialog ) ) - { - // Switch to the requested panel. - wxCommandEvent evt(pxEvt_SetSettingsPage); - evt.SetString(panel_name); - dialog->GetEventHandler()->ProcessEvent(evt); - - // It's legal to call ShowModal on a non-modal dialog, therefore making - // it modal in nature for the needs of whatever other thread of action wants - // to block against it: - if( !dialog->IsModal() ) - { - int result = dialog->ShowModal(); - dialog->Destroy(); - return result; - } - } - pxFailDev( "Can only show wxDialog class windows as modal!" ); - return wxID_CANCEL; - } - else - return DialogType( parent ).ShowModal(); -} - static bool HandlePluginError( BaseException& ex ) { if (!pxDialogExists(L"Dialog:" + Dialogs::ComponentsConfigDialog::GetNameStatic())) diff --git a/pcsx2/gui/Dialogs/ConfigurationDialog.h b/pcsx2/gui/Dialogs/ConfigurationDialog.h index 478733ce2e..4db685607a 100644 --- a/pcsx2/gui/Dialogs/ConfigurationDialog.h +++ b/pcsx2/gui/Dialogs/ConfigurationDialog.h @@ -30,7 +30,6 @@ namespace Panels } BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EVENT_TYPE( pxEvt_SetSettingsPage, -1 ) DECLARE_EVENT_TYPE( pxEvt_SomethingChanged, -1 ); END_DECLARE_EVENT_TYPES()