Fixed a major bug related to config. Also, 1800 get.

Originally committed to SVN as r1800.
This commit is contained in:
Rodrigo Braz Monteiro 2008-01-20 23:57:03 +00:00
parent 23dc318406
commit 251d6f3a21
3 changed files with 128 additions and 107 deletions

View file

@ -132,7 +132,7 @@ bool AegisubApp::OnInit() {
}
StartupLog(_T("Store options back"));
Options.SetInt(_T("Last Version"),GetSVNRevision());
Options.LoadDefaults(); // Override options based on version number
Options.LoadDefaults(false,true); // Override options based on version number
Options.Save();
AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times"));

View file

@ -54,6 +54,7 @@
// Constructor
OptionsManager::OptionsManager() {
modified = false;
overriding = false;
lastVersion = -1;
}
@ -75,10 +76,11 @@ void OptionsManager::Clear() {
///////////////////////
// Load default values
void OptionsManager::LoadDefaults(bool onlyDefaults) {
void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) {
///// PUBLIC //////
// Here go the options that can be edited by the options menu
if (doOverride) overriding = true;
if (onlyDefaults) lastVersion = -1;
// General
@ -284,11 +286,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
// Only defaults?
if (onlyDefaults) {
lastVersion = -1;
return;
}
if (!onlyDefaults) {
///// INTERNAL //////
// Options that are set by the program itself
@ -384,8 +382,10 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
previewText += 0x8a9e; // kanji "speak"
SetText(_T("Style editor preview text"),previewText);
SetColour(_T("Style editor preview background"),wxColour(125,153,176));
}
lastVersion = -1;
overriding = false;
}
@ -469,6 +469,10 @@ void OptionsManager::Load() {
/////////////
// Write int
void OptionsManager::SetInt(wxString key,int param,int ifLastVersion) {
if (ifLastVersion == -1) {
if (overriding) ifLastVersion = 0;
else ifLastVersion = 0x7FFFFFFF;
}
if (lastVersion >= ifLastVersion) return;
opt[key.Lower()].SetInt(param);
if (curModType != MOD_OFF) optType[key.Lower()] = curModType;
@ -479,6 +483,10 @@ void OptionsManager::SetInt(wxString key,int param,int ifLastVersion) {
///////////////
// Write float
void OptionsManager::SetFloat(wxString key,double param,int ifLastVersion) {
if (ifLastVersion == -1) {
if (overriding) ifLastVersion = 0;
else ifLastVersion = 0x7FFFFFFF;
}
if (lastVersion >= ifLastVersion) return;
opt[key.Lower()].SetFloat(param);
if (curModType != MOD_OFF) optType[key.Lower()] = curModType;
@ -489,6 +497,10 @@ void OptionsManager::SetFloat(wxString key,double param,int ifLastVersion) {
////////////////
// Write string
void OptionsManager::SetText(wxString key,wxString param,int ifLastVersion) {
if (ifLastVersion == -1) {
if (overriding) ifLastVersion = 0;
else ifLastVersion = 0x7FFFFFFF;
}
if (lastVersion >= ifLastVersion) return;
opt[key.Lower()].SetText(param);
if (curModType != MOD_OFF) optType[key.Lower()] = curModType;
@ -499,6 +511,10 @@ void OptionsManager::SetText(wxString key,wxString param,int ifLastVersion) {
/////////////////
// Write boolean
void OptionsManager::SetBool(wxString key,bool param,int ifLastVersion) {
if (ifLastVersion == -1) {
if (overriding) ifLastVersion = 0;
else ifLastVersion = 0x7FFFFFFF;
}
if (lastVersion >= ifLastVersion) return;
opt[key.Lower()].SetBool(param);
if (curModType != MOD_OFF) optType[key.Lower()] = curModType;
@ -509,6 +525,10 @@ void OptionsManager::SetBool(wxString key,bool param,int ifLastVersion) {
////////////////
// Write colour
void OptionsManager::SetColour(wxString key,wxColour param,int ifLastVersion) {
if (ifLastVersion == -1) {
if (overriding) ifLastVersion = 0;
else ifLastVersion = 0x7FFFFFFF;
}
if (lastVersion >= ifLastVersion) return;
opt[key.Lower()].SetColour(param);
if (curModType != MOD_OFF) optType[key.Lower()] = curModType;

View file

@ -65,6 +65,7 @@ class OptionsManager {
private:
ModType curModType;
bool modified;
bool overriding;
wxString filename;
std::map<wxString,VariableData> opt;
std::map<wxString,ModType> optType;
@ -80,15 +81,15 @@ public:
void SetFile(wxString file);
void Save();
void Load();
void LoadDefaults(bool onlyDefaults=false);
void LoadDefaults(bool onlyDefaults=false,bool versionOverride=false);
void AddToRecentList (wxString entry,wxString list);
wxArrayString GetRecentList (wxString list);
void SetInt(wxString key,int param,int ifLastVersion=0);
void SetFloat(wxString key,double param,int ifLastVersion=0);
void SetBool(wxString key,bool param,int ifLastVersion=0);
void SetText(wxString key,wxString param,int ifLastVersion=0);
void SetColour(wxString key,wxColour param,int ifLastVersion=0);
void SetInt(wxString key,int param,int ifLastVersion=-1);
void SetFloat(wxString key,double param,int ifLastVersion=-1);
void SetBool(wxString key,bool param,int ifLastVersion=-1);
void SetText(wxString key,wxString param,int ifLastVersion=-1);
void SetColour(wxString key,wxColour param,int ifLastVersion=-1);
void ResetWith(wxString key,wxString param);
bool IsDefined(wxString key);