wxgui: More bugfixes to configuration saving/loading.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxgui@1667 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-08-21 14:29:02 +00:00
parent 68188a1fe2
commit 307346e19e
11 changed files with 80 additions and 43 deletions

View File

@ -204,19 +204,20 @@ struct AppImageIds
class Pcsx2App : public wxApp
{
protected:
MainEmuFrame* m_MainFrame;
ConsoleLogFrame* m_ProgramLogBox;
ConsoleLogFrame* m_Ps2ConLogBox;
wxBitmap* m_Bitmap_Logo;
MainEmuFrame* m_MainFrame;
ConsoleLogFrame* m_ProgramLogBox;
ConsoleLogFrame* m_Ps2ConLogBox;
wxBitmap* m_Bitmap_Logo;
wxImageList m_ConfigImages;
bool m_ConfigImagesAreLoaded;
wxImageList m_ConfigImages;
bool m_ConfigImagesAreLoaded;
wxImageList* m_ToolbarImages; // dynamic (pointer) to allow for large/small redefinition.
AppImageIds m_ImageId;
wxImageList* m_ToolbarImages; // dynamic (pointer) to allow for large/small redefinition.
AppImageIds m_ImageId;
public:
Pcsx2App();
virtual ~Pcsx2App();
wxFrame* GetMainWindow() const;

View File

@ -376,8 +376,10 @@ AppConfig::AppConfig() :
}
// ------------------------------------------------------------------------
void AppConfig::LoadSaveUserMode( IniInterface& ini )
void AppConfig::LoadSaveUserMode( IniInterface& ini, const wxString& cwdhash )
{
IniScopedGroup path( ini, cwdhash );
// timestamping would be useful if we want to auto-purge unused entries after
// a period of time. Dunno if it's needed.
@ -598,6 +600,8 @@ void AppConfig::FilenameOptions::LoadSave( IniInterface& ini )
{
ini.Entry( g_PluginNames[i], Plugins[i], pc );
}
ini.Entry( L"BIOS", Bios, pc );
}
wxFileConfig* OpenFileConfig( const wxString& filename )

View File

@ -155,7 +155,7 @@ public:
void Load();
void Save();
void Apply();
void LoadSaveUserMode( IniInterface& ini );
void LoadSaveUserMode( IniInterface& ini, const wxString& cwdhash );
wxString GetDefaultDocumentsFolder();

View File

@ -121,12 +121,18 @@ Dialogs::BiosSelectorDialog::BiosSelectorDialog( wxWindow* parent ) :
wxDialogWithHelpers( parent, wxID_ANY, _("BIOS Selector"), false )
{
wxBoxSizer& bleh( *new wxBoxSizer( wxVERTICAL ) );
bleh.Add( new Panels::BiosSelectorPanel( *this, 500 ), SizerFlags::StdExpand() );
Panels::BaseSelectorPanel* selpan = new Panels::BiosSelectorPanel( *this, 500 );
bleh.Add( selpan, SizerFlags::StdExpand() );
AddOkCancel( bleh, false );
SetSizerAndFit( &bleh );
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BiosSelectorDialog::OnOk_Click ) );
Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler(BiosSelectorDialog::OnDoubleClicked) );
selpan->OnShown();
}
void Dialogs::BiosSelectorDialog::OnOk_Click( wxCommandEvent& evt )
@ -137,3 +143,13 @@ void Dialogs::BiosSelectorDialog::OnOk_Click( wxCommandEvent& evt )
evt.Skip();
}
}
void Dialogs::BiosSelectorDialog::OnDoubleClicked( wxCommandEvent& evt )
{
wxWindow* forwardButton = FindWindow( wxID_OK );
if( forwardButton == NULL ) return;
wxCommandEvent nextpg( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK );
nextpg.SetEventObject( forwardButton );
forwardButton->GetEventHandler()->ProcessEvent( nextpg );
}

View File

@ -53,5 +53,6 @@ namespace Dialogs
protected:
void OnOk_Click( wxCommandEvent& evt );
void OnDoubleClicked( wxCommandEvent& evt );
};
}

View File

@ -122,6 +122,8 @@ FirstTimeWizard::FirstTimeWizard( wxWindow* parent ) :
Connect( wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler( FirstTimeWizard::OnPageChanged ) );
Connect( wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler( FirstTimeWizard::OnPageChanging ) );
Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler(FirstTimeWizard::OnDoubleClicked) );
}
FirstTimeWizard::~FirstTimeWizard()
@ -129,6 +131,16 @@ FirstTimeWizard::~FirstTimeWizard()
g_ApplyState.DoCleanup();
}
void FirstTimeWizard::OnDoubleClicked( wxCommandEvent& evt )
{
wxWindow* forwardButton = FindWindow( wxID_FORWARD );
if( forwardButton == NULL ) return;
wxCommandEvent nextpg( wxEVT_COMMAND_BUTTON_CLICKED, wxID_FORWARD );
nextpg.SetEventObject( forwardButton );
forwardButton->GetEventHandler()->ProcessEvent( nextpg );
}
void FirstTimeWizard::OnPageChanging( wxWizardEvent& evt )
{
if( evt.GetPage() == NULL ) return; // safety valve!

View File

@ -57,6 +57,7 @@ public:
protected:
virtual void OnPageChanging( wxWizardEvent& evt );
virtual void OnPageChanged( wxWizardEvent& evt );
virtual void OnDoubleClicked( wxCommandEvent& evt );
};
namespace Dialogs

View File

@ -129,15 +129,14 @@ void Panels::BiosSelectorPanel::Apply( AppConfig& conf )
)
);
}
wxFileName relative( (*m_BiosList)[(int)m_ComboBox.GetClientData(sel)] );
relative.MakeRelativeTo( g_Conf->Folders.Bios.ToString() );
conf.BaseFilenames.Bios = relative.GetFullPath();
conf.BaseFilenames.Bios = (*m_BiosList)[(int)m_ComboBox.GetClientData(sel)];
}
void Panels::BiosSelectorPanel::DoRefresh()
{
wxFileName right( g_Conf->FullpathToBios() );
right.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
right.MakeAbsolute();
for( size_t i=0; i<m_BiosList->GetCount(); ++i )
{
@ -146,7 +145,7 @@ void Panels::BiosSelectorPanel::DoRefresh()
int sel = m_ComboBox.Append( description, (void*)i );
wxFileName left( (*m_BiosList)[i] );
left.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
left.MakeAbsolute();
if( left == right )
m_ComboBox.SetSelection( sel );

View File

@ -352,7 +352,7 @@ namespace Panels
public:
BiosSelectorPanel( wxWindow& parent, int idealWidth );
virtual ~BiosSelectorPanel();
protected:
virtual void Apply( AppConfig& conf );
virtual void DoRefresh();

View File

@ -133,6 +133,7 @@ Panels::PluginSelectorPanel::StatusPanel::StatusPanel( wxWindow* parent ) :
s_main.Add( &m_gauge, wxSizerFlags().Expand().Border( wxLEFT | wxRIGHT, 32 ) );
s_main.Add( &m_label, SizerFlags::StdExpand() );
// The status bar only looks right if I use SetSizerAndFit() here.
SetSizerAndFit( &s_main );
}
@ -254,9 +255,7 @@ void Panels::PluginSelectorPanel::Apply( AppConfig& conf )
);
}
wxFileName relative( GetFilename((int)m_ComponentBoxes.Get(i).GetClientData(sel)) );
relative.MakeRelativeTo( conf.Folders.Plugins.ToString() );
conf.BaseFilenames.Plugins[tbl_PluginInfo[i].id] = relative.GetFullPath();
conf.BaseFilenames.Plugins[tbl_PluginInfo[i].id] = GetFilename((int)m_ComponentBoxes.Get(i).GetClientData(sel));
}
}
@ -272,7 +271,6 @@ void Panels::PluginSelectorPanel::DoRefresh()
m_ComponentBoxes.Hide();
m_StatusPanel.SetSize( m_ComponentBoxes.GetSize().GetWidth() - 8, wxDefaultCoord );
//m_StatusPanel.SetSizer( m_StatusPanel.GetSizer(), false );
m_StatusPanel.CentreOnParent();
m_StatusPanel.Show();
@ -360,8 +358,8 @@ void Panels::PluginSelectorPanel::OnProgress( wxCommandEvent& evt )
wxFileName left( (*m_FileList)[evtidx] );
wxFileName right( g_Conf->FullpathTo(tbl_PluginInfo[i].id) );
left.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
right.MakeRelativeTo( g_Conf->Folders.Plugins.ToString() );
left.MakeAbsolute();
right.MakeAbsolute();
if( left == right )
m_ComponentBoxes.Get(i).SetSelection( sel );

View File

@ -53,17 +53,6 @@ namespace Exception
};
}
Pcsx2App::Pcsx2App() :
m_ProgramLogBox( NULL )
, m_Ps2ConLogBox( NULL )
, m_ConfigImages( 32, 32 )
, m_ConfigImagesAreLoaded( false )
, m_ToolbarImages( NULL )
, m_Bitmap_Logo( NULL )
{
SetAppName( L"pcsx2" );
}
wxFrame* Pcsx2App::GetMainWindow() const { return m_MainFrame; }
#include "HashMap.h"
@ -100,7 +89,7 @@ void Pcsx2App::ReadUserModeSettings()
// Save user's new settings
IniSaver saver( *conf_usermode );
g_Conf->LoadSaveUserMode( saver );
g_Conf->LoadSaveUserMode( saver, groupname );
g_Conf->Save();
}
else
@ -110,7 +99,7 @@ void Pcsx2App::ReadUserModeSettings()
UseAdminMode = false;
IniLoader loader( *conf_usermode );
g_Conf->LoadSaveUserMode( loader );
g_Conf->LoadSaveUserMode( loader, groupname );
}
}
@ -152,13 +141,6 @@ bool Pcsx2App::OnCmdLineParsed(wxCmdLineParser& parser)
return true;
}
void Pcsx2App::CleanupMess()
{
safe_delete( g_RecentIsoList );
safe_delete( m_Bitmap_Logo );
safe_delete( g_Conf );
}
// ------------------------------------------------------------------------
bool Pcsx2App::OnInit()
{
@ -215,6 +197,13 @@ void Pcsx2App::OnMessageBox( wxCommandEvent& evt )
Msgbox::OnEvent( evt );
}
void Pcsx2App::CleanupMess()
{
safe_delete( g_RecentIsoList );
safe_delete( m_Bitmap_Logo );
safe_delete( g_Conf );
}
// Common exit handler which can be called from any event (though really it should
// be called only from CloseWindow handlers since that's the more appropriate way
// to handle window closures)
@ -232,6 +221,22 @@ int Pcsx2App::OnExit()
return wxApp::OnExit();
}
Pcsx2App::Pcsx2App() :
m_ProgramLogBox( NULL )
, m_Ps2ConLogBox( NULL )
, m_ConfigImages( 32, 32 )
, m_ConfigImagesAreLoaded( false )
, m_ToolbarImages( NULL )
, m_Bitmap_Logo( NULL )
{
SetAppName( L"pcsx2" );
}
Pcsx2App::~Pcsx2App()
{
CleanupMess();
}
#include <wx/zipstrm.h>
#include <wx/wfstream.h>