mirror of https://github.com/PCSX2/pcsx2.git
pcsx2: Move AppOpenModalDialog
Also avoid sending a change page event if an empty string is passed and the dialog is already open.
This commit is contained in:
parent
ad784a56ec
commit
c17eacec04
|
@ -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<typename DialogType>
|
||||
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;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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<AppConfig> g_Conf;
|
||||
|
||||
template<typename DialogType>
|
||||
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()))
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue