spu2-x: Some changes to how the ini file writing works in Linux. (still buggy)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3072 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-05-25 05:26:39 +00:00
parent 65facf6958
commit 94ae54d6c0
4 changed files with 48 additions and 43 deletions

View File

@ -19,63 +19,53 @@
#include <wx/fileconf.h>
wxConfigBase *oldConfig;
wxString path;
wxFileConfig *spuConfig;
wxString path(L"~/.pcsx2/inis/spu2-x.ini");
bool pathSet = false;
wxFileConfig *setIni(const wchar_t* Section)
void initIni()
{
spuConfig = new wxFileConfig(L"", L"", path, L"", wxCONFIG_USE_LOCAL_FILE);
}
void setIni(const wchar_t* Section)
{
wxConfig *tempConfig;
oldConfig = wxConfigBase::Get(false);
tempConfig = new wxFileConfig(L"", L"", path, L"", wxCONFIG_USE_LOCAL_FILE);
wxConfigBase::Set(tempConfig);
tempConfig->SetPath(L"/");
tempConfig->SetPath(Section);
return tempConfig;
}
void writeIni(wxFileConfig *tempConfig)
{
tempConfig->Flush();
if (oldConfig != NULL) wxConfigBase::Set(oldConfig);
delete tempConfig;
if (spuConfig == NULL) initIni();
spuConfig->SetPath(wxsFormat(L"/%s", Section));
}
void CfgSetSettingsDir(const char* dir)
{
path = wxString::FromAscii(dir) + L"spu2-x.ini";
FileLog("CfgSetSettingsDir(%s)\n", dir);
path = wxString::FromAscii(dir) + L"/spu2-x.ini";
pathSet = true;
initIni();
}
void CfgWriteBool(const wchar_t* Section, const wchar_t* Name, bool Value)
{
wxConfig *config = setIni(Section);
config->Write(Name, Value);
writeIni(config);
setIni(Section);
spuConfig->Write(Name, Value);
}
void CfgWriteInt(const wchar_t* Section, const wchar_t* Name, int Value)
{
wxConfig *config = setIni(Section);
config->Write(Name, Value);
writeIni(config);
setIni(Section);
spuConfig->Write(Name, Value);
}
void CfgWriteStr(const wchar_t* Section, const wchar_t* Name, const wstring& Data)
{
wxConfig *config = setIni(Section);
config->Write(Name, Data);
writeIni(config);
setIni(Section);
spuConfig->Write(Name, Data);
}
bool CfgReadBool(const wchar_t *Section,const wchar_t* Name, bool Default)
{
bool ret;
wxConfig *config = setIni(Section);
config->Read(Name, &ret, Default);
writeIni(config);
setIni(Section);
spuConfig->Read(Name, &ret, Default);
return ret;
}
@ -84,25 +74,22 @@ int CfgReadInt(const wchar_t* Section, const wchar_t* Name,int Default)
{
int ret;
wxConfig *config = setIni(Section);
config->Read(Name, &ret, Default);
writeIni(config);
setIni(Section);
spuConfig->Read(Name, &ret, Default);
return ret;
}
void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wchar_t* Data, int DataSize, const wchar_t* Default)
{
wxConfig *config = setIni(Section);
wcscpy(Data, config->Read(Name, Default));
writeIni(config);
setIni(Section);
wcscpy(Data, spuConfig->Read(Name, Default));
}
void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, int DataSize, const wchar_t* Default)
{
wxConfig *config = setIni(Section);
Data = config->Read(Name, Default);
writeIni(config);
setIni(Section);
Data = spuConfig->Read(Name, Default);
}
void CfgReadStr(const wchar_t* Section, const wchar_t* Name, wstring& Data, int DataSize, const wchar_t* Default)

View File

@ -54,6 +54,14 @@ bool asyncMixingEnabled = false;
void ReadSettings()
{
// For some reason this can be called before we know what ini file we're writing to.
// Lets not try to read it if that happens.
if (!pathSet)
{
FileLog("Read called without the path set.\n");
return;
}
Interpolation = CfgReadInt( L"MIXING",L"Interpolation", 1 );
EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false );
ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 );
@ -76,12 +84,19 @@ void ReadSettings()
Clampify( SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX );
WriteSettings();
spuConfig->Flush();
}
/*****************************************************************************/
void WriteSettings()
{
if (!pathSet)
{
FileLog("Write called without the path set.\n");
return;
}
CfgWriteInt(L"MIXING",L"Interpolation",Interpolation);
CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled);
CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost);

View File

@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <string>
#include <wx/fileconf.h>
extern bool DebugEnabled;
@ -109,5 +110,6 @@ void ReadSettings();
void WriteSettings();
void configure();
void AboutBox();
extern wxFileConfig *spuConfig;
extern bool pathSet;
#endif // CONFIG_H_INCLUDED

View File

@ -13,6 +13,7 @@
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add option="-DPCSX2_DEVBUILD" />
</Compiler>
<Linker>
<Add library="../../../../deps/debug/libsoundtouch-dbg.a" />