From 24d941b2bcee4462710131abf10205ac4cbaf656 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Thu, 21 Jun 2007 06:14:49 +0000 Subject: [PATCH] config.dat can optionally be stored on the same folder as aegisub.exe. Originally committed to SVN as r1280. --- aegisub/changelog.txt | 2 ++ aegisub/dialog_options.cpp | 21 ++++++++++++--------- aegisub/main.cpp | 7 ++++++- aegisub/options.cpp | 7 ++----- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index e6639f125..4418ae832 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -119,6 +119,8 @@ Please visit http://aegisub.net to download latest version o Fixed behavior of the Escape key in it. (AMZ) o Redesigned the interface and replaced the log window with a much better Scintilla control. (AMZ) o You can now collect multiple times without reopening the dialog. (AMZ) +- All user-specific files (configuration, style storages, etc) are now stored on Application Data\Aegisub in Windows. (AMZ) +- config.dat can optionally be stored on the same folder as aegisub.exe. (AMZ) - Added a much-needed options dialog with all the relevant config.dat options in it. (AMZ) - Various fixes to better handle paths/file names with non-ANSI characters on Windows (jfs/AMZ) - Misc. fixes for building on Linux (Azzy, equinox, jfs) diff --git a/aegisub/dialog_options.cpp b/aegisub/dialog_options.cpp index cbfbbf3db..ad5e19d1e 100644 --- a/aegisub/dialog_options.cpp +++ b/aegisub/dialog_options.cpp @@ -45,6 +45,7 @@ #include "options.h" #include #include +#include #include "frame_main.h" #include "standard_paths.h" #include "validators.h" @@ -97,15 +98,12 @@ DialogOptions::DialogOptions(wxWindow *parent) wxSizer *genMainSizer = new wxBoxSizer(wxVERTICAL); wxSizer *genSizer1 = new wxStaticBoxSizer(wxHORIZONTAL,generalPage,_("Startup")); wxSizer *genSizer4 = new wxFlexGridSizer(2,2,5,5); - wxCheckBox *box = new wxCheckBox(generalPage,-1,_("Show Splash Screen")); - Bind(box,_T("Show splash")); - genSizer4->Add(box,1,wxALL,0); - box = new wxCheckBox(generalPage,-1,_("Show Tip of the Day")); - Bind(box,_T("Tips enabled")); - genSizer4->Add(box,1,wxALL,0); - box = new wxCheckBox(generalPage,-1,_("Auto Check for Updates")); - Bind(box,_T("Auto check for updates")); - genSizer4->Add(box,1,wxALL,0); + + AddCheckBox(generalPage,genSizer4,_("Show Splash Screen"),_T("Show splash")); + AddCheckBox(generalPage,genSizer4,_("Show Tip of the Day"),_T("Tips enabled")); + AddCheckBox(generalPage,genSizer4,_("Auto Check for Updates"),_T("Auto check for updates")); + AddCheckBox(generalPage,genSizer4,_("Save config.dat locally"),_T("Local config")); + genSizer1->Add(genSizer4,1,wxEXPAND|wxALL,5); wxSizer *genSizer2 = new wxStaticBoxSizer(wxVERTICAL,generalPage,_("Limits for levels and recent files")); wxFlexGridSizer *genSizer3 = new wxFlexGridSizer(8,2,5,5); @@ -869,6 +867,11 @@ void DialogOptions::WriteToOptions(bool justApply) { } // Save options + if (Options.AsBool(_T("Local config"))) Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat"))); + else { + Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat"))); + wxRemoveFile(StandardPaths::DecodePath(_T("?data/config.dat"))); + } Options.Save(); // Need restart? diff --git a/aegisub/main.cpp b/aegisub/main.cpp index 155abc5b0..5287f9718 100644 --- a/aegisub/main.cpp +++ b/aegisub/main.cpp @@ -87,8 +87,13 @@ bool AegisubApp::OnInit() { #endif // Set config file - Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat"))); + Options.SetFile(StandardPaths::DecodePath(_T("?data/config.dat"))); Options.Load(); + if (!Options.AsBool(_T("Local config"))) { + Options.SetFile(StandardPaths::DecodePath(_T("?user/config.dat"))); + Options.Load(); + } + Options.Save(); AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times")); // Set hotkeys file diff --git a/aegisub/options.cpp b/aegisub/options.cpp index ba1249e49..ea5ce9c1b 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -80,6 +80,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) { SetModificationType(MOD_AUTOMATIC); SetBool(_T("Tips enabled"),true); SetBool(_T("Show splash"),true); + SetBool(_T("Local config"),false); SetInt(_T("Undo levels"),8); SetInt(_T("Recent timecodes max"),16); SetInt(_T("Recent keyframes max"),16); @@ -394,11 +395,10 @@ void OptionsManager::Load() { // Load defaults LoadDefaults(); - // Check if file exists (create if it doesn't) + // Check if file exists wxFileName path(filename); if (!path.FileExists()) { modified = true; - Save(); return; } @@ -426,9 +426,6 @@ void OptionsManager::Load() { } else SetText(key,value); } - - // Close - Save(); }