revamp handling of wii sysconf. it's in Common lib so that plugins can (possibly) utilize it if they like

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4268 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2009-09-14 06:26:49 +00:00
parent a08c801256
commit aff34e6789
10 changed files with 508 additions and 337 deletions

View File

@ -26,6 +26,7 @@
#include "ConfigMain.h"
#include "PluginManager.h"
#include "ConfigManager.h"
#include "SysConf.h"
#include "Frame.h"
@ -98,21 +99,6 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
// Control refreshing of the ISOs list
bRefreshList = false;
// Load Wii SYSCONF
pStream = NULL;
pStream = fopen(WII_SYSCONF_FILE, "rb");
if (pStream != NULL)
{
fread(m_SYSCONF, 1, 0x4000, pStream);
fclose(pStream);
m_bSysconfOK = true;
}
else
{
PanicAlert("Could not read %s. Please recover the SYSCONF file to that location.", WII_SYSCONF_FILE);
m_bSysconfOK = false;
}
CreateGUIControls();
// Update selected ISO paths
@ -437,29 +423,27 @@ void CConfigMain::CreateGUIControls()
GamecubePage->SetSizer(sGamecube);
sGamecube->Layout();
// Wii page
sbWiimoteSettings = new wxStaticBoxSizer(wxVERTICAL, WiiPage, wxT("Wiimote Settings"));
arrayStringFor_WiiSensBarPos.Add(wxT("Bottom")); arrayStringFor_WiiSensBarPos.Add(wxT("Top"));
WiiSensBarPosText = new wxStaticText(WiiPage, ID_WII_BT_BAR_TEXT, wxT("Sensor Bar Position:"), wxDefaultPosition, wxDefaultSize);
WiiSensBarPos = new wxChoice(WiiPage, ID_WII_BT_BAR, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiSensBarPos, 0, wxDefaultValidator);
WiiSensBarPos->SetSelection(m_SYSCONF[BT_BAR]);
WiiSensBarPos->SetSelection(SConfig::GetInstance().m_SYSCONF->GetData<u8>("BT.BAR"));
sbWiiIPLSettings = new wxStaticBoxSizer(wxVERTICAL, WiiPage, wxT("IPL Settings"));
sbWiiIPLSettings = new wxStaticBoxSizer(wxVERTICAL, WiiPage, wxT("Misc Settings"));
WiiScreenSaver = new wxCheckBox(WiiPage, ID_WII_IPL_SSV, wxT("Enable Screen Saver (burn-in reduction)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
WiiScreenSaver->SetValue(m_SYSCONF[IPL_SSV]!=0);
WiiScreenSaver->SetValue(!!SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.SSV"));
WiiProgressiveScan = new wxCheckBox(WiiPage, ID_WII_IPL_PGS, wxT("Enable Progressive Scan"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
WiiProgressiveScan->SetValue(m_SYSCONF[IPL_PGS]!=0 || SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressiveScan);
WiiProgressiveScan->SetValue(!!SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.PGS"));
WiiEuRGB60 = new wxCheckBox(WiiPage, ID_WII_IPL_E60, wxT("Use EuRGB60 Mode (PAL6)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
WiiEuRGB60->SetValue(m_SYSCONF[IPL_E60]!=0);
WiiEuRGB60->SetValue(!!SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.E60"));
arrayStringFor_WiiAspectRatio.Add(wxT("4:3")); arrayStringFor_WiiAspectRatio.Add(wxT("16:9"));
WiiAspectRatioText = new wxStaticText(WiiPage, ID_WII_IPL_AR_TEXT, wxT("Aspect Ratio:"), wxDefaultPosition, wxDefaultSize);
WiiAspectRatio = new wxChoice(WiiPage, ID_WII_IPL_AR, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiAspectRatio, 0, wxDefaultValidator);
WiiAspectRatio->SetSelection(m_SYSCONF[IPL_AR]!=0 || SConfig::GetInstance().m_LocalCoreStartupParameter.bWidescreen);
WiiAspectRatio->SetSelection(SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR"));
WiiSystemLangText = new wxStaticText(WiiPage, ID_WII_IPL_LNG_TEXT, wxT("System Language:"), wxDefaultPosition, wxDefaultSize);
WiiSystemLang = new wxChoice(WiiPage, ID_WII_IPL_LNG, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiSystemLang, 0, wxDefaultValidator);
WiiSystemLang->SetSelection(m_SYSCONF[IPL_LNG]);
WiiSystemLang->SetSelection(SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.LNG"));
// Populate sbWiimoteSettings
sWii = new wxBoxSizer(wxVERTICAL);
@ -594,22 +578,8 @@ void CConfigMain::OnClose(wxCloseEvent& WXUNUSED (event))
{
EndModal((bRefreshList) ? wxID_OK : wxID_CLOSE);
// First check that we did successfully populate m_SYSCONF earlier, otherwise don't
// save anything, it will be a corrupted file
if(m_bSysconfOK)
{
// Save SYSCONF with the new settings
pStream = fopen(WII_SYSCONF_FILE, "wb");
if (pStream != NULL)
{
fwrite(m_SYSCONF, 1, 0x4000, pStream);
fclose(pStream);
}
else
{
PanicAlert("Could not write to %s", WII_SYSCONF_FILE);
}
}
// Sysconf saves when it gets deleted
//delete SConfig::GetInstance().m_SYSCONF;
// Save the config. Dolphin crashes to often to save the settings on closing only
SConfig::GetInstance().SaveSettings();
@ -820,25 +790,23 @@ void CConfigMain::WiiSettingsChanged(wxCommandEvent& event)
switch (event.GetId())
{
case ID_WII_BT_BAR: // Wiimote settings
m_SYSCONF[BT_BAR] = WiiSensBarPos->GetSelection();
SConfig::GetInstance().m_SYSCONF->SetData("BT.BAR", WiiSensBarPos->GetSelection());
break;
case ID_WII_IPL_AR: // IPL settings
m_SYSCONF[IPL_AR] = WiiAspectRatio->GetSelection();
SConfig::GetInstance().m_LocalCoreStartupParameter.bWidescreen = WiiAspectRatio->GetSelection() ? true : false;
case ID_WII_IPL_AR: // SYSCONF settings
SConfig::GetInstance().m_SYSCONF->SetData("IPL.AR", WiiAspectRatio->GetSelection());
break;
case ID_WII_IPL_SSV:
m_SYSCONF[IPL_SSV] = WiiScreenSaver->IsChecked();
SConfig::GetInstance().m_SYSCONF->SetData("IPL.SSV", WiiScreenSaver->IsChecked());
break;
case ID_WII_IPL_LNG:
m_SYSCONF[IPL_LNG] = WiiSystemLang->GetSelection();
SConfig::GetInstance().m_SYSCONF->SetData("IPL.LNG", WiiSystemLang->GetSelection());
break;
case ID_WII_IPL_PGS:
m_SYSCONF[IPL_PGS] = WiiProgressiveScan->IsChecked();
SConfig::GetInstance().m_LocalCoreStartupParameter.bProgressiveScan = WiiProgressiveScan->IsChecked();
SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", WiiProgressiveScan->IsChecked());
break;
case ID_WII_IPL_E60:
m_SYSCONF[IPL_E60] = WiiEuRGB60->IsChecked();
SConfig::GetInstance().m_SYSCONF->SetData("IPL.E60", WiiEuRGB60->IsChecked());
break;
}
}