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")); StartupLog(_T("Store options back"));
Options.SetInt(_T("Last Version"),GetSVNRevision()); 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(); Options.Save();
AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times")); AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times"));

View file

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

View file

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