Added a system to "revoke" old option values and force defaults if the previous version of Aegisub was too old. Set this for several config options.

Originally committed to SVN as r1784.
This commit is contained in:
Rodrigo Braz Monteiro 2008-01-20 04:55:44 +00:00
parent 15ce07e803
commit 33117888f0
3 changed files with 63 additions and 36 deletions

View file

@ -64,6 +64,7 @@
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
#include "auto4_base.h" #include "auto4_base.h"
#endif #endif
#include "version.h"
/////////////////// ///////////////////
@ -130,6 +131,8 @@ bool AegisubApp::OnInit() {
wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat"))); wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat")));
} }
StartupLog(_T("Store options back")); StartupLog(_T("Store options back"));
Options.SetInt(_T("Last Version"),GetSVNRevision());
Options.LoadDefaults(); // 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;
lastVersion = -1;
} }
@ -78,6 +79,8 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
///// 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 (onlyDefaults) lastVersion = -1;
// General // General
SetModificationType(MOD_AUTOMATIC); SetModificationType(MOD_AUTOMATIC);
SetBool(_T("Tips enabled"),true); SetBool(_T("Tips enabled"),true);
@ -109,8 +112,10 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetBool(_T("Auto save on every change"),false); SetBool(_T("Auto save on every change"),false);
// Edit Box // Edit Box
SetText(_T("Dictionaries path"),_T("dictionaries")); // don't these require restart? SetModificationType(MOD_RESTART);
SetText(_T("Dictionaries path"),_T("dictionaries"));
SetText(_T("Spell Checker"),_T("hunspell")); SetText(_T("Spell Checker"),_T("hunspell"));
SetModificationType(MOD_AUTOMATIC);
SetBool(_T("Link time boxes commit"),true); SetBool(_T("Link time boxes commit"),true);
#ifdef WIN32 #ifdef WIN32
SetBool(_T("Insert mode on time boxes"),true); SetBool(_T("Insert mode on time boxes"),true);
@ -118,7 +123,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetBool(_T("Insert mode on time boxes"),false); SetBool(_T("Insert mode on time boxes"),false);
#endif #endif
SetModificationType(MOD_EDIT_BOX); SetModificationType(MOD_EDIT_BOX);
SetBool(_T("Call tips enabled"),false); SetBool(_T("Call tips enabled"),false,1700);
SetBool(_T("Syntax highlight enabled"),true); SetBool(_T("Syntax highlight enabled"),true);
// Edit box cosmetic // Edit box cosmetic
@ -144,25 +149,25 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetInt(_T("Video Check Script Res"), 0); SetInt(_T("Video Check Script Res"), 0);
SetInt(_T("Video Default Zoom"), 7); SetInt(_T("Video Default Zoom"), 7);
SetInt(_T("Video Fast Jump Step"), 10); SetInt(_T("Video Fast Jump Step"), 10);
SetText(_T("Video Screenshot Path"),_T("?video")); SetText(_T("Video Screenshot Path"),_T("?video"),1700);
SetModificationType(MOD_VIDEO); SetModificationType(MOD_VIDEO);
SetBool(_T("Show keyframes on video slider"),true); SetBool(_T("Show keyframes on video slider"),true);
SetBool(_T("Show overscan mask"),false); SetBool(_T("Show overscan mask"),false);
// Video Provider (Advanced) // Video Provider (Advanced)
SetModificationType(MOD_VIDEO_RELOAD); SetModificationType(MOD_VIDEO_RELOAD);
SetInt(_T("Avisynth MemoryMax"),64); SetInt(_T("Avisynth MemoryMax"),64,1700);
SetBool(_T("Threaded Video"),false); SetBool(_T("Threaded Video"),false,1700);
SetText(_T("Video Provider"),_T("Avisynth")); SetText(_T("Video Provider"),_T("Avisynth"),1700);
SetBool(_T("Allow Ancient Avisynth"),false); SetBool(_T("Allow Ancient Avisynth"),false,1700);
SetText(_T("Avisynth subs renderer"),_T("vsfilter")); SetText(_T("Avisynth subs renderer"),_T("vsfilter"),1700);
SetBool(_T("Avisynth render own subs"),true); SetBool(_T("Avisynth render own subs"),true,1700);
#ifdef __WINDOWS__ #ifdef __WINDOWS__
SetText(_T("Subtitles Provider"),_T("csri/vsfilter_textsub")); SetText(_T("Subtitles Provider"),_T("csri/vsfilter_textsub"),1700);
#else #else
SetText(_T("Subtitles Provider"),_T("csri/asa")); SetText(_T("Subtitles Provider"),_T("csri/asa"));
#endif #endif
SetBool(_T("Video Use Pixel Shaders"),false); SetBool(_T("Video Use Pixel Shaders"),false,1700);
// Audio Options // Audio Options
SetModificationType(MOD_AUTOMATIC); SetModificationType(MOD_AUTOMATIC);
@ -181,19 +186,19 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
// Audio Advanced // Audio Advanced
SetModificationType(MOD_AUDIO_RELOAD); SetModificationType(MOD_AUDIO_RELOAD);
SetInt(_T("Audio Cache"),1); SetInt(_T("Audio Cache"),1,1700);
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
SetText(_T("Audio Player"),_T("dsound")); SetText(_T("Audio Player"),_T("dsound"),1700);
#elif defined(__APPLE__) #elif defined(__APPLE__)
SetText(_T("Audio Player"), _T("openal")); SetText(_T("Audio Player"), _T("openal"));
#else #else
SetText(_T("Audio Player"),_T("portaudio")); // FIXME: should this be something else? perhaps alsa on linux and portaudio on everything else? SetText(_T("Audio Player"),_T("portaudio")); // FIXME: should this be something else? perhaps alsa on linux and portaudio on everything else?
#endif #endif
SetText(_T("Audio Provider"),_T("avisynth")); // TODO: proper default on non-windows SetText(_T("Audio Provider"),_T("avisynth"),1700); // TODO: proper default on non-windows
SetText(_T("Audio Downmixer"),_T("ConvertToMono")); SetText(_T("Audio Downmixer"),_T("ConvertToMono"),1700);
SetText(_T("Audio Alsa Device"), _T("plughw:0,0")); SetText(_T("Audio Alsa Device"), _T("plughw:0,0"));
SetText(_T("Audio HD Cache Location"),_T("default")); SetText(_T("Audio HD Cache Location"),_T("default"),1700);
SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp")); SetText(_T("Audio HD Cache Name"),_T("audio%02i.tmp"),1700);
// Technically these can do with just the spectrum object being re-created // Technically these can do with just the spectrum object being re-created
SetInt(_T("Audio Spectrum Cutoff"),0); SetInt(_T("Audio Spectrum Cutoff"),0);
SetInt(_T("Audio Spectrum Quality"),1); SetInt(_T("Audio Spectrum Quality"),1);
@ -202,9 +207,9 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
// Automation // Automation
// The path changes only take effect when a script is (re)loaded but Automatic should be good enough, it certainly doesn't warrart a restart // The path changes only take effect when a script is (re)loaded but Automatic should be good enough, it certainly doesn't warrart a restart
SetModificationType(MOD_AUTOMATIC); SetModificationType(MOD_AUTOMATIC);
SetText(_T("Automation Base Path"), _T("?data/automation/")); SetText(_T("Automation Base Path"), _T("?data/automation/"),1700);
SetText(_T("Automation Include Path"), _T("?user/automation/include/|?data/automation/include/")); SetText(_T("Automation Include Path"), _T("?user/automation/include/|?data/automation/include/"),1700);
SetText(_T("Automation Autoload Path"), _T("?user/automation/autoload/|?data/automation/autoload/")); SetText(_T("Automation Autoload Path"), _T("?user/automation/autoload/|?data/automation/autoload/"),1700);
SetInt(_T("Automation Trace Level"), 3); SetInt(_T("Automation Trace Level"), 3);
SetInt(_T("Automation Thread Priority"), 1); // "below normal" SetInt(_T("Automation Thread Priority"), 1); // "below normal"
SetInt(_T("Automation Autoreload Mode"), 1); // local only SetInt(_T("Automation Autoreload Mode"), 1); // local only
@ -268,8 +273,8 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetColour(_T("Audio Waveform Selected"),wxColour(255,255,255)); SetColour(_T("Audio Waveform Selected"),wxColour(255,255,255));
SetColour(_T("Audio Waveform Inactive"),wxColour(0,80,0)); SetColour(_T("Audio Waveform Inactive"),wxColour(0,80,0));
SetColour(_T("Audio Waveform"),wxColour(0,200,0)); SetColour(_T("Audio Waveform"),wxColour(0,200,0));
SetColour(_T("Audio Line boundary start"),wxColour(216,0,0)); SetColour(_T("Audio Line boundary start"),wxColour(216,0,0),1700);
SetColour(_T("Audio Line boundary end"),wxColour(230,125,0)); SetColour(_T("Audio Line boundary end"),wxColour(230,125,0),1700);
SetColour(_T("Audio Line boundary inactive line"),wxColour(128,128,128)); SetColour(_T("Audio Line boundary inactive line"),wxColour(128,128,128));
SetColour(_T("Audio Syllable boundaries"),wxColour(255,255,0)); SetColour(_T("Audio Syllable boundaries"),wxColour(255,255,0));
SetColour(_T("Audio Syllable text"),wxColour(255,0,0)); SetColour(_T("Audio Syllable text"),wxColour(255,0,0));
@ -279,7 +284,10 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
// Only defaults? // Only defaults?
if (onlyDefaults) return; if (onlyDefaults) {
lastVersion = -1;
return;
}
///// INTERNAL ////// ///// INTERNAL //////
@ -291,7 +299,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetInt(_T("Video Dummy Last Length"), 40000); SetInt(_T("Video Dummy Last Length"), 40000);
SetBool(_T("Video Dummy Pattern"), false); SetBool(_T("Video Dummy Pattern"), false);
SetInt(_T("Locale Code"),-1); SetInt(_T("Locale Code"),-1,1700);
SetBool(_T("Sync video with subs"),true); SetBool(_T("Sync video with subs"),true);
SetText(_T("Spell checker language"),_T("en_US")); SetText(_T("Spell checker language"),_T("en_US"));
SetText(_T("Thesaurus language"),_T("en_US")); SetText(_T("Thesaurus language"),_T("en_US"));
@ -310,7 +318,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetBool(_T("Shift Times Direction"),true); SetBool(_T("Shift Times Direction"),true);
SetInt(_T("Tips current"),0); SetInt(_T("Tips current"),0);
SetBool(_T("Show associations"),true); SetBool(_T("Show associations"),true,1700);
SetBool(_T("Maximized"),false); SetBool(_T("Maximized"),false);
SetBool(_T("Find Match Case"),false); SetBool(_T("Find Match Case"),false);
@ -360,7 +368,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetBool(_T("Select Match comments"),false); SetBool(_T("Select Match comments"),false);
SetText(_T("Color Picker Recent"), _T("&H000000& &H0000FF& &H00FFFF& &H00FF00& &HFFFF00& &HFF0000& &HFF00FF& &HFFFFFF&")); SetText(_T("Color Picker Recent"), _T("&H000000& &H0000FF& &H00FFFF& &H00FF00& &HFFFF00& &HFF0000& &HFF00FF& &HFFFFFF&"));
SetInt(_T("Color Picker Mode"), 4); SetInt(_T("Color Picker Mode"), 4, 1700);
SetText(_T("Last open subtitles path"),_T("")); SetText(_T("Last open subtitles path"),_T(""));
SetText(_T("Last open video path"),_T("")); SetText(_T("Last open video path"),_T(""));
@ -376,6 +384,8 @@ 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;
} }
@ -445,12 +455,21 @@ void OptionsManager::Load() {
} }
else SetText(key,value); else SetText(key,value);
} }
// Get last version
if (IsDefined(_T("Last Version"))) {
long temp;
AsText(_T("Last Version")).ToLong(&temp);
lastVersion = temp;
}
else lastVersion = 1; // This was implemented in 1784, assume that anything before that is 1.
} }
///////////// /////////////
// Write int // Write int
void OptionsManager::SetInt(wxString key,int param) { void OptionsManager::SetInt(wxString key,int param,int ifLastVersion) {
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;
modified = true; modified = true;
@ -459,7 +478,8 @@ void OptionsManager::SetInt(wxString key,int param) {
/////////////// ///////////////
// Write float // Write float
void OptionsManager::SetFloat(wxString key,double param) { void OptionsManager::SetFloat(wxString key,double param,int ifLastVersion) {
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;
modified = true; modified = true;
@ -468,7 +488,8 @@ void OptionsManager::SetFloat(wxString key,double param) {
//////////////// ////////////////
// Write string // Write string
void OptionsManager::SetText(wxString key,wxString param) { void OptionsManager::SetText(wxString key,wxString param,int ifLastVersion) {
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;
modified = true; modified = true;
@ -477,7 +498,8 @@ void OptionsManager::SetText(wxString key,wxString param) {
///////////////// /////////////////
// Write boolean // Write boolean
void OptionsManager::SetBool(wxString key,bool param) { void OptionsManager::SetBool(wxString key,bool param,int ifLastVersion) {
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;
modified = true; modified = true;
@ -486,7 +508,8 @@ void OptionsManager::SetBool(wxString key,bool param) {
//////////////// ////////////////
// Write colour // Write colour
void OptionsManager::SetColour(wxString key,wxColour param) { void OptionsManager::SetColour(wxString key,wxColour param,int ifLastVersion) {
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;
modified = true; modified = true;

View file

@ -68,6 +68,7 @@ private:
wxString filename; wxString filename;
std::map<wxString,VariableData> opt; std::map<wxString,VariableData> opt;
std::map<wxString,ModType> optType; std::map<wxString,ModType> optType;
int lastVersion;
void SetModificationType(ModType type); void SetModificationType(ModType type);
@ -83,11 +84,11 @@ public:
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); void SetInt(wxString key,int param,int ifLastVersion=0);
void SetFloat(wxString key,double param); void SetFloat(wxString key,double param,int ifLastVersion=0);
void SetBool(wxString key,bool param); void SetBool(wxString key,bool param,int ifLastVersion=0);
void SetText(wxString key,wxString param); void SetText(wxString key,wxString param,int ifLastVersion=0);
void SetColour(wxString key,wxColour param); void SetColour(wxString key,wxColour param,int ifLastVersion=0);
void ResetWith(wxString key,wxString param); void ResetWith(wxString key,wxString param);
bool IsDefined(wxString key); bool IsDefined(wxString key);