From: <man...@us...> - 2013-11-04 18:22:42
|
Revision: 3074 http://sourceforge.net/p/modplug/code/3074 Author: manxorist Date: 2013-11-04 18:22:26 +0000 (Mon, 04 Nov 2013) Log Message: ----------- merge branch settings. Merge is done by hand without recording svn mergeinfo. 'svn diff https://svn.code.sf.net/p/modplug/code/trunk/OpenMPT@3041 https://svn.code.sf.net/p/modplug/code/branches/manx/settings@3041' is applied to a trunk checkout of r3041 which is then updated to HEAD and then commited (svn gets somehow confused when using svn merge): ........ [Ref] Add a new type-aware and caching settings framework. [Ref] Convert all raw ini file reading/writing to the new settings framework. [Ref] Speedup configuration setting handling by only writing dirty values when closing OpenMPT. [New] Add an advanced options panel (still needs a bunch of usability improvements). ........ [Ref] Load settings before constructing CMainFrame. ........ [Fix] Actually properly initialize plugin cache. ........ [Ref] Construct settings framework instances not until we know the pathnames. ........ [Imp] settings: Support multiple backends. [New] settings: Add (read-only) registry backend. [Ref] settings: Add registry backend fallback for old ini versions. ........ [Fix] settings: Add a SettingValue(const char*) overload, so that string literals do not get converted to bool values. ........ [Ref] settings: Split TrackerDirectories from TrackerSetttings (for now), to break circular dependencies between initializing paths and loading the settings. [Ref] settings: Remove global static TrackerSettings instance and construct it at the right moment (after instanciating the SettingsContainer). [Ref] settings: Move default initialisation of dynamic setting defaults into TrackerSettings constructor. ........ [Ref] settings: Convert version, install GUID and splash screen handling to Setting<T>. ........ [Ref] settings: Move LoadSettings() directly after construction of TrackerSettings. ........ [Ref] settings: Move loop song setting where it belongs. ........ [Imp] settings: Support differing key names between current ini file and old registry. ........ [Ref] settings: Convert "Display" section to Setting<T>. ........ [Ref] settings: Convert "MIDI Settings" to Setting<T>. [Ref] settings: Add CachedSetting<T> with weaker consistency semantics. ........ [Fix] settings: Correct VU meter key name (broken in r2715 ). ........ [Fix] settings: VuMeterUpdateInterval should be cached. [Ref] settings: Small tunings. ........ [Ref] settings: Convert "Misc" section to Setting<T>. ........ [Imp] settings: Update instances of CachedSetting<T> via change notification callbacks. [Ref] settings: Minor tunings. ........ [Ref] settings: Support uint8 settings. [Ref] settings: float settings could as well be doubles. [Ref] settings: Add Setting<T>::GetPath(). ........ [Ref] settings: Convert most of "Sound Settings" section to Setting<T>. ........ [Fix] settings: Fix rounding of FIR cutoff. ........ [Ref] settings: Add an explicit type for binary setting values. This makes proting old binary registry settings easier and avoids the need to re-implement the WIN32 ini file binary structure encoding. ........ [Ref] Do not get current output samplerate and sampleformat from global TrackerSeetings. Instead, pass around the current device settings directly from the SoundDevice callbacks. The device itself knows best what it is set up to. ........ [Ref] settings: Convert most of section "Pattern Editor" to Setting<T>. ........ [Ref] Small cleanup. ........ [Ref] settings: Convert section "Sample Editor" to Setting<T>. ........ [Ref] settings: Call LoadSettings() in TrackerSettings constructor. [Ref] settings: Make LoadBarState and SaveBarState symmetric. [Ref] settings: Destroy registry backend directly after importing old settings. ........ [Fix] settings: Call LoadSettings() in TrackerSettings constructor. ........ [Ref] settings: Convert "Effects" section to conf.Read() / conf.Write(). [Ref] settings: Move code around a bit. ........ [Fix] Avoid constructing CAutoSaver with uninitialized members. [Ref] settings: Convert "AutoSave" section to conf.Read() / conf.Write(). ........ [Ref] settings: Convert "Display"/Colors to conf.Read() / conf.Write() . ........ [Ref] settings: Convert old maximized window setting to Setting<T>. ........ [Ref] settings: Convert section "Paths" to conf.Read() / conf.Write() . [Ref] settings: Kill TrackerSettings::LoadRegistrySettings() . ........ [Ref] settings: Kill TrackerSettings::LoadINISettings() . ........ [Ref] settings: Do not store default values twice. [Ref] settings: Uninline ReadSetting(),WriteSetting(),RemoveSetting() functions. ........ [Fix] settings: VS2008 does not support std::map::at(), use find() as a work-around. ........ [Ref] settings: Simplify code. ........ [Ref] settings: Simplify code. ........ [Ref] settings: Make usage of SettingPath more readable at the usage site by using an explicit OldSettingPath helper structure when the old setting path differs. ........ [Ref] Avoid touching TrackerSettings in CMainFrame::DoNotification(). ........ [Fix] settings: Make testcases compile again. ........ [Imp] settings: Make settings framework handle unicode strings. [Mod] settings: Convert/force mptrack.ini into UTF16 encoding (this is backwards compatible because even ANSI versions of WIN32 ini file functions handle the converted file correctly). [Ref] Add an explicit string type mpt::PathString for path and filenames which is either std::wstring (on windows) or std::string (elsewhere) and provide explicit encoding conversion functions. ........ [Ref] settings: Small cleanups. ........ [Fix] VS2008 compile fix. ........ [Ref] settings: Make immediate-flush mode a runtime option. ........ [Ref] settings: Add missing operator %= . ........ [Mod] settings: Convert any ini file to unicode only on demand (i.e. if a non-ansi-representable string gets written). ........ [Ref] settings: Convert remaining UNREFERENCED_PARAMETER to MPT_UNREFERENCED_PARAMETER. ........ [Imp] settings: Add a warning message to advanceds settings tab. ........ [Fix] settings: Make advanced settings listbox not sorted. The data is already sorted and this confuses indexing. [Fix] settings: ReInit advanced settings tab when activated. ........ [Ref] settings: Remove #define MPT_SETTINGS_PANEL . ........ [Ref] settings: Inline TrackerSettings::LoadSettings() into constructor. [Ref] settings: Small related cleanups. ........ [Ref] sounddev: Move defaults solely into SoundDeviceSettings default constructor. ........ [Ref] sounddev: Move defaults solely into SoundDeviceSettings default constructor. ........ [Fix] settings: Fix uninitialized variable. [Fix] settings: Make !MPT_SETTINGS_CACHE compile again. ........ [Ref] settings: Un-inline unimported functions. [Fix] settings: Make !MPT_SETTINGS_CACHE always hold values locally instead of reading them on every access. ........ [Fix] settings: Do not write changes immediately if !MPT_SETTINGS_CACHE. ........ [Fix] Fix mismerge of r2904 in r2906 . ........ [Ref] settings: Cleanup. ........ [Ref] settings: Add some comments, documenting the general idea of Setting.h . ........ [Ref] settings: Move translation of ancient setting paths to a single function. ........ [Mod] settings: Remove support for importing registry based settings from older versions ( < "1.17.02.40"). [Fix] settings: Do not assume version 0 if settings file is missing. ........ [Ref] settings: Add copy contructor for Setting<T> which is useful syntax to use in some corner cases. [Ref] settings: Add SettingValue converters to/from float. ........ Revision Links: -------------- http://sourceforge.net/p/modplug/code/3041 http://sourceforge.net/p/modplug/code/2715 http://sourceforge.net/p/modplug/code/2904 http://sourceforge.net/p/modplug/code/2906 Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/AutoSaver.h trunk/OpenMPT/mptrack/Childfrm.cpp trunk/OpenMPT/mptrack/Ctrl_com.h trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_gen.h trunk/OpenMPT/mptrack/Ctrl_ins.h trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_pat.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/EffectVis.h trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Moptions.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/UpdateCheck.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/dlg_misc.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/test/test.cpp Added Paths: ----------- trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/Settings.h Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/common/misc_util.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -38,6 +38,18 @@ template<> inline std::string Stringify(const signed char& x) { return Stringify((signed int)x); } template<> inline std::string Stringify(const unsigned char& x) { return Stringify((unsigned int)x); } +template<class T> +inline std::wstring StringifyW(const T& x) +//---------------------------------------- +{ + std::wostringstream o; + if(!(o << x)) return L"FAILURE"; + else return o.str(); +} + +template<> inline std::wstring StringifyW(const signed char& x) { return StringifyW((signed int)x); } +template<> inline std::wstring StringifyW(const unsigned char& x) { return StringifyW((unsigned int)x); } + //Convert string to number. template<class T> inline T ConvertStrTo(const char *str) @@ -52,6 +64,13 @@ return static_cast<T>(atof(str)); } +template<class T> +inline T ConvertStrTo(const std::string &str) +//------------------------------------------- +{ + return ConvertStrTo<T>(str.c_str()); +} + #if MPT_COMPILER_MSVC #define cxx11_strtoll _strtoi64 #define cxx11_strtoull _strtoui64 @@ -59,14 +78,26 @@ #define cxx11_strtoll std::strtoll #define cxx11_strtoull std::strtoull #endif +template<> inline bool ConvertStrTo(const char *str) {return std::strtol(str, nullptr, 10) ? true : false;} +template<> inline signed char ConvertStrTo(const char *str) {return (signed char)std::strtol(str, nullptr, 10);} +template<> inline signed short ConvertStrTo(const char *str) {return (signed short)std::strtol(str, nullptr, 10);} template<> inline signed int ConvertStrTo(const char *str) {return (signed int)std::strtol(str, nullptr, 10);} template<> inline signed long ConvertStrTo(const char *str) {return std::strtol(str, nullptr, 10);} template<> inline signed long long ConvertStrTo(const char *str) {return cxx11_strtoll(str, nullptr, 10);} +template<> inline unsigned char ConvertStrTo(const char *str) {return (unsigned char)std::strtoul(str, nullptr, 10);} +template<> inline unsigned short ConvertStrTo(const char *str) {return (unsigned short)std::strtoul(str, nullptr, 10);} template<> inline unsigned int ConvertStrTo(const char *str) {return (unsigned int)std::strtoul(str, nullptr, 10);} template<> inline unsigned long ConvertStrTo(const char *str) {return std::strtoul(str, nullptr, 10);} template<> inline unsigned long long ConvertStrTo(const char *str) {return cxx11_strtoull(str, nullptr, 10);} +template<class T> +inline T ConvertStrTo(const std::wstring &str) +//-------------------------------------------- +{ + return ConvertStrTo<T>(mpt::String::Encode(str, mpt::CharsetLocale)); +} + // Memset given object to zero. template <class T> inline void MemsetZero(T &a) Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/common/mptString.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -160,5 +160,26 @@ } // namespace String +#if defined(WIN32) +typedef std::wstring PathString; +#define MPT_PATHSTRING(lit) L##lit +static inline std::string PathToLocale(const PathString &path) { return mpt::String::Encode(path, mpt::CharsetLocale); } +static inline std::string PathToUTF8(const PathString &path) { return mpt::String::Encode(path, mpt::CharsetUTF8); } +static inline std::wstring PathToWide(const PathString &path) { return path; } +static inline PathString LocaleToPath(const std::string &path) { return mpt::String::Decode(path, mpt::CharsetLocale); } +static inline PathString UTF8ToPath(const std::string &path) { return mpt::String::Decode(path, mpt::CharsetUTF8); } +static inline PathString WideToPath(const std::wstring &path) { return path; } +#else // !WIN32 +typedef std::string PathString; +#define MPT_PATHSTRING(lit) lit +static inline std::string PathToLocale(const PathString &path) { return path; } +static inline std::string PathToUTF8(const PathString &path) { return mpt::String::Convert(path, mpt::CharsetLocale, mpt::CharsetUTF8); } +static inline std::wstring PathToWide(const PathString &path) { return mpt::String::Decode(path, mpt::CharsetLocale); } +static inline PathString LocaleToPath(const std::string &path) { return path; } +static inline PathString UTF8ToPath(const std::string &path) { return mpt::String::Convert(path, mpt::CharsetUTF8, mpt::CharsetLocale); } +static inline PathString WideToPath(const std::wstring &path) { return mpt::String::Encode(path, mpt::CharsetLocale); } +#endif // WIN32 + + } // namespace mpt Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -28,10 +28,6 @@ // Construction/Destruction /////////////////////////// -CAutoSaver::CAutoSaver() : m_bSaveInProgress(false) -{ -} - CAutoSaver::CAutoSaver(bool enabled, int saveInterval, int backupHistory, bool useOriginalPath, CString path, CString fileNameTemplate) : m_bSaveInProgress(false) @@ -45,7 +41,7 @@ m_csFileNameTemplate = fileNameTemplate; } -CAutoSaver::~CAutoSaver(void) +CAutoSaver::~CAutoSaver() { } Modified: trunk/OpenMPT/mptrack/AutoSaver.h =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/AutoSaver.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -9,6 +9,7 @@ #pragma once + #include "resource.h" class CModDoc; @@ -17,10 +18,9 @@ { public: //Cons/Destr - CAutoSaver(void); - CAutoSaver(bool enabled, int saveInterval, int backupHistory, - bool useOriginalPath, CString path, CString fileNameTemplate); - ~CAutoSaver(void); + CAutoSaver(bool enabled=true, int saveInterval=10, int backupHistory=3, + bool useOriginalPath=true, CString path="", CString fileNameTemplate=""); + ~CAutoSaver(); //Work bool DoSave(DWORD curTime); @@ -28,6 +28,7 @@ //Member access void Enable(); void Disable(); + void SetEnabled(bool enabled) { if(enabled) Enable(); else Disable(); } bool IsEnabled(); void SetUseOriginalPath(bool useOrgPath); bool GetUseOriginalPath(); @@ -62,7 +63,6 @@ CString m_csFileNameTemplate; }; -#pragma once // CAutoSaverGUI dialog Modified: trunk/OpenMPT/mptrack/Childfrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/Childfrm.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Childfrm.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -92,7 +92,7 @@ { if ((--glMdiOpenCount) == 0) { - TrackerSettings::Instance().gbMdiMaximize = m_bMaxWhenClosed; + TrackerSettings::Instance().gbMdiMaximize = (m_bMaxWhenClosed != 0); } } @@ -245,7 +245,7 @@ CRect rect; m_bMaxWhenClosed = IsZoomed(); - if (bForce) TrackerSettings::Instance().gbMdiMaximize = m_bMaxWhenClosed; + if (bForce) TrackerSettings::Instance().gbMdiMaximize = (m_bMaxWhenClosed != 0); if (!IsIconic()) { CWnd *pWnd = m_wndSplitter.GetPane(0, 0); Modified: trunk/OpenMPT/mptrack/Ctrl_com.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_com.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_com.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -21,7 +21,7 @@ public: CCtrlComments(CModControlView &parent, CModDoc &document); - LONG* GetSplitPosRef() {return &TrackerSettings::Instance().glCommentsWindowHeight;} //rewbs.varWindowSize + Setting<LONG>* GetSplitPosRef() {return &TrackerSettings::Instance().glCommentsWindowHeight;} //rewbs.varWindowSize public: //{{AFX_DATA(CCtrlComments) Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -505,7 +505,7 @@ void CCtrlGeneral::OnLoopSongChanged() //------------------------------------ { - TrackerSettings::Instance().gbLoopSong = IsDlgButtonChecked(IDC_CHECK_LOOPSONG); + TrackerSettings::Instance().gbLoopSong = (IsDlgButtonChecked(IDC_CHECK_LOOPSONG) != 0); m_sndFile.SetRepeatCount((TrackerSettings::Instance().gbLoopSong) ? -1 : 0); } Modified: trunk/OpenMPT/mptrack/Ctrl_gen.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_gen.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -45,7 +45,7 @@ { public: CCtrlGeneral(CModControlView &parent, CModDoc &document); - LONG* GetSplitPosRef() {return &TrackerSettings::Instance().glGeneralWindowHeight;} //rewbs.varWindowSize + Setting<LONG>* GetSplitPosRef() {return &TrackerSettings::Instance().glGeneralWindowHeight;} //rewbs.varWindowSize private: void setAsDecibels(LPSTR stringToSet, double value, double valueAtZeroDB); Modified: trunk/OpenMPT/mptrack/Ctrl_ins.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_ins.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -128,7 +128,7 @@ BOOL OpenInstrument(CSoundFile &sndFile, INSTRUMENTINDEX nInstr); BOOL EditSample(UINT nSample); VOID UpdateFilterText(); - LONG* GetSplitPosRef() {return &TrackerSettings::Instance().glInstrumentWindowHeight;} //rewbs.varWindowSize + Setting<LONG>* GetSplitPosRef() {return &TrackerSettings::Instance().glInstrumentWindowHeight;} //rewbs.varWindowSize public: //{{AFX_VIRTUAL(CCtrlInstruments) Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -449,7 +449,7 @@ case CTRLMSG_SETRECORD: if (lParam >= 0) m_bRecord = (BOOL)(lParam); else m_bRecord = !m_bRecord; m_ToolBar.SetState(IDC_PATTERN_RECORD, ((m_bRecord) ? TBSTATE_CHECKED : 0)|TBSTATE_ENABLED); - TrackerSettings::Instance().gbPatternRecord = m_bRecord; + TrackerSettings::Instance().gbPatternRecord = (m_bRecord != 0); SendViewMessage(VIEWMSG_SETRECORD, m_bRecord); break; @@ -943,7 +943,7 @@ { UINT nState = m_ToolBar.GetState(IDC_PATTERN_RECORD); m_bRecord = ((nState & TBSTATE_CHECKED) != 0); - TrackerSettings::Instance().gbPatternRecord = m_bRecord; + TrackerSettings::Instance().gbPatternRecord = (m_bRecord != 0); SendViewMessage(VIEWMSG_SETRECORD, m_bRecord); SwitchToView(); } @@ -954,7 +954,7 @@ { UINT nState = m_ToolBar.GetState(ID_PATTERN_VUMETERS); m_bVUMeters = ((nState & TBSTATE_CHECKED) != 0); - TrackerSettings::Instance().gbPatternVUMeters = m_bVUMeters; + TrackerSettings::Instance().gbPatternVUMeters = (m_bVUMeters != 0); SendViewMessage(VIEWMSG_SETVUMETERS, m_bVUMeters); SwitchToView(); } @@ -965,7 +965,7 @@ { UINT nState = m_ToolBar.GetState(ID_VIEWPLUGNAMES); m_bPluginNames = ((nState & TBSTATE_CHECKED) != 0); - TrackerSettings::Instance().gbPatternPluginNames = m_bPluginNames; + TrackerSettings::Instance().gbPatternPluginNames = (m_bPluginNames != 0); SendViewMessage(VIEWMSG_SETPLUGINNAMES, m_bPluginNames); SwitchToView(); } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_pat.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -193,7 +193,7 @@ public: CCtrlPatterns(CModControlView &parent, CModDoc &document); - LONG* GetSplitPosRef() {return &TrackerSettings::Instance().glPatternWindowHeight;} //rewbs.varWindowSize + Setting<LONG>* GetSplitPosRef() {return &TrackerSettings::Instance().glPatternWindowHeight;} //rewbs.varWindowSize public: void SetCurrentPattern(PATTERNINDEX nPat); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -389,7 +389,7 @@ } SetCurrentSample((lParam > 0) ? ((SAMPLEINDEX)lParam) : m_nSample); - m_nFinetuneStep = (uint16)GetPrivateProfileInt("Sample Editor", "FinetuneStep", 25, theApp.GetConfigFileName()); + m_nFinetuneStep = (uint16)theApp.GetSettings().Read<int32>("Sample Editor", "FinetuneStep", 25); // Initial Update if (!m_bInitialized) UpdateView((m_nSample << HINT_SHIFT_SMP) | HINT_SAMPLEINFO | HINT_MODTYPE, NULL); @@ -1027,7 +1027,7 @@ mpt::String::SetNullTerminator(szFileName); SanitizeFilename(szFileName); - CString format = CMainFrame::GetPrivateProfileCString("Sample Editor", "DefaultFormat", defaultFLAC ? "flac" : "wav", theApp.GetConfigFileName()); + CString format = theApp.GetSettings().Read<CString>("Sample Editor", "DefaultFormat", defaultFLAC ? "flac" : "wav"); int filter = 1; if(!format.CompareNoCase("flac")) filter = 2; Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -69,7 +69,7 @@ bool SetCurrentSample(SAMPLEINDEX nSmp, LONG lZoom = -1, bool bUpdNum = true); bool OpenSample(LPCSTR lpszFileName); bool OpenSample(const CSoundFile &sndFile, SAMPLEINDEX nSample); - LONG* GetSplitPosRef() {return &TrackerSettings::Instance().glSampleWindowHeight;} //rewbs.varWindowSize + Setting<LONG>* GetSplitPosRef() {return &TrackerSettings::Instance().glSampleWindowHeight;} //rewbs.varWindowSize public: //{{AFX_VIRTUAL(CCtrlSamples) Modified: trunk/OpenMPT/mptrack/EffectVis.h =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/EffectVis.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -116,7 +116,7 @@ BOOL OpenEditor(CWnd *parent); VOID DoClose(); afx_msg void OnClose(); - LONG* GetSplitPosRef() {return NULL;} //rewbs.varWindowSize + Setting<LONG>* GetSplitPosRef() {return NULL;} //rewbs.varWindowSize CViewPattern *m_pViewPattern; Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Globals.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -68,7 +68,7 @@ void LockControls() { m_nLockCount++; } void UnlockControls() { PostMessage(WM_MOD_UNLOCKCONTROLS); } bool IsLocked() const { return (m_nLockCount > 0); } - virtual LONG* GetSplitPosRef() = 0; //rewbs.varWindowSize + virtual Setting<LONG>* GetSplitPosRef() = 0; //rewbs.varWindowSize protected: //{{AFX_VIRTUAL(CModControlDlg) Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -208,8 +208,6 @@ MemsetZero(g_csAudio); InitializeCriticalSection(&g_csAudio); - TrackerSettings::Instance().LoadSettings(); - m_InputHandler = new CInputHandler(this); //rewbs.customKeys //Loading static tunings here - probably not the best place to do that but anyway. @@ -244,14 +242,14 @@ // Fall back to default WaveOut device TrackerSettings::Instance().m_nWaveDevice = SoundDeviceID(); } - if(TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq == 0) + if(TrackerSettings::Instance().MixerSamplerate == 0) { - TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = MixerSettings().gdwMixingFreq; + TrackerSettings::Instance().MixerSamplerate = MixerSettings().gdwMixingFreq; #ifndef NO_ASIO // If no mixing rate is specified and we're using ASIO, get a mixing rate supported by the device. - if(TrackerSettings::Instance().m_nWaveDevice.GetType() == SNDDEV_ASIO) + if(TrackerSettings::Instance().GetSoundDeviceID().GetType() == SNDDEV_ASIO) { - TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = theApp.GetSoundDevicesManager()->GetDeviceCaps(TrackerSettings::Instance().m_nWaveDevice, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).currentSampleRate; + TrackerSettings::Instance().MixerSamplerate = theApp.GetSoundDevicesManager()->GetDeviceCaps(TrackerSettings::Instance().m_nWaveDevice, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).currentSampleRate; } #endif // NO_ASIO } @@ -462,8 +460,9 @@ // Save Settings RemoveControlBar(&m_wndStatusBar); // Remove statusbar so that its state won't get saved. + SaveBarState("Toolbars"); + AddControlBar(&m_wndStatusBar); // Restore statusbar to mainframe. TrackerSettings::Instance().SaveSettings(); - AddControlBar(&m_wndStatusBar); // Restore statusbar to mainframe. if(m_InputHandler && m_InputHandler->activeCommandSet) { @@ -475,79 +474,8 @@ } -bool CMainFrame::WritePrivateProfileBool(const CString section, const CString key, const bool value, const CString iniFile) -{ - CHAR valueBuffer[INIBUFFERSIZE]; - wsprintf(valueBuffer, "%li", value?1:0); - return (WritePrivateProfileString(section, key, valueBuffer, iniFile) != 0); -} -bool CMainFrame::GetPrivateProfileBool(const CString section, const CString key, const bool defaultValue, const CString iniFile) -{ - CHAR defaultValueBuffer[INIBUFFERSIZE]; - wsprintf(defaultValueBuffer, "%li", defaultValue?1:0); - - CHAR valueBuffer[INIBUFFERSIZE]; - GetPrivateProfileString(section, key, defaultValueBuffer, valueBuffer, INIBUFFERSIZE, iniFile); - - return atol(valueBuffer)?true:false; -} - - -bool CMainFrame::WritePrivateProfileLong(const CString section, const CString key, const long value, const CString iniFile) -{ - CHAR valueBuffer[INIBUFFERSIZE]; - wsprintf(valueBuffer, "%li", value); - return (WritePrivateProfileString(section, key, valueBuffer, iniFile) != 0); -} - - -long CMainFrame::GetPrivateProfileLong(const CString section, const CString key, const long defaultValue, const CString iniFile) -{ - CHAR defaultValueBuffer[INIBUFFERSIZE]; - wsprintf(defaultValueBuffer, "%li", defaultValue); - - CHAR valueBuffer[INIBUFFERSIZE]; - GetPrivateProfileString(section, key, defaultValueBuffer, valueBuffer, INIBUFFERSIZE, iniFile); - - return ConvertStrTo<long>(valueBuffer); -} - - -bool CMainFrame::WritePrivateProfileDWord(const CString section, const CString key, const DWORD value, const CString iniFile) -{ - CHAR valueBuffer[INIBUFFERSIZE]; - wsprintf(valueBuffer, "%lu", value); - return (WritePrivateProfileString(section, key, valueBuffer, iniFile) != 0); -} - -DWORD CMainFrame::GetPrivateProfileDWord(const CString section, const CString key, const DWORD defaultValue, const CString iniFile) -{ - CHAR defaultValueBuffer[INIBUFFERSIZE]; - wsprintf(defaultValueBuffer, "%lu", defaultValue); - - CHAR valueBuffer[INIBUFFERSIZE]; - GetPrivateProfileString(section, key, defaultValueBuffer, valueBuffer, INIBUFFERSIZE, iniFile); - return ConvertStrTo<uint32>(valueBuffer); -} - -bool CMainFrame::WritePrivateProfileCString(const CString section, const CString key, const CString value, const CString iniFile) -{ - return (WritePrivateProfileString(section, key, value, iniFile) != 0); -} - -CString CMainFrame::GetPrivateProfileCString(const CString section, const CString key, const CString defaultValue, const CString iniFile) -{ - CHAR defaultValueBuffer[INIBUFFERSIZE]; - strcpy(defaultValueBuffer, defaultValue); - CHAR valueBuffer[INIBUFFERSIZE]; - GetPrivateProfileString(section, key, defaultValueBuffer, valueBuffer, INIBUFFERSIZE, iniFile); - return valueBuffer; -} - - - LRESULT CALLBACK CMainFrame::KeyboardProc(int code, WPARAM wParam, LPARAM lParam) //------------------------------------------------------------------------------- { @@ -841,7 +769,7 @@ { return true; } - if(TrackerSettings::Instance().m_MixerSettings.IsValid()) + if(TrackerSettings::Instance().GetMixerSettings().IsValid()) { if(audioTryOpeningDevice()) { @@ -1031,7 +959,7 @@ notification.masterVU[1] = rVu; if(gnClipLeft) notification.masterVU[0] |= Notification::ClipVU; if(gnClipRight) notification.masterVU[1] |= Notification::ClipVU; - uint32 dwVuDecay = Util::muldiv(dwSamplesRead, 120000, TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq) + 1; + uint32 dwVuDecay = Util::muldiv(dwSamplesRead, 120000, m_pSndFile->m_MixerSettings.gdwMixingFreq) + 1; if (lVu >= dwVuDecay) gnLVuMeter = (lVu - dwVuDecay) << 11; else gnLVuMeter = 0; if (rVu >= dwVuDecay) gnRVuMeter = (rVu - dwVuDecay) << 11; else gnRVuMeter = 0; @@ -1060,7 +988,7 @@ #ifndef NO_EQ sndFile.SetEQGains(TrackerSettings::Instance().m_EqSettings.Gains, MAX_EQ_BANDS, TrackerSettings::Instance().m_EqSettings.Freqs, reset?TRUE:FALSE); #endif - sndFile.SetDspEffects(TrackerSettings::Instance().m_MixerSettings.DSPMask); + sndFile.SetDspEffects(TrackerSettings::Instance().MixerDSPMask); sndFile.InitPlayer(reset?TRUE:FALSE); } @@ -1070,11 +998,11 @@ { CriticalSection cs; if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_MUTECHNMODE) - TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_MUTECHNMODE; + TrackerSettings::Instance().MixerFlags |= SNDMIX_MUTECHNMODE; else - TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_MUTECHNMODE; - sndFile.SetMixerSettings(TrackerSettings::Instance().m_MixerSettings); - sndFile.SetResamplerSettings(TrackerSettings::Instance().m_ResamplerSettings); + TrackerSettings::Instance().MixerFlags &= ~SNDMIX_MUTECHNMODE; + sndFile.SetMixerSettings(TrackerSettings::Instance().GetMixerSettings()); + sndFile.SetResamplerSettings(TrackerSettings::Instance().GetResamplerSettings()); UpdateDspEffects(sndFile, false); // reset done in next line sndFile.InitPlayer(reset?TRUE:FALSE); } @@ -1202,8 +1130,8 @@ void CMainFrame::SetPreAmp(UINT n) //-------------------------------- { - TrackerSettings::Instance().m_MixerSettings.m_nPreAmp = n; - if (m_pSndFile) m_pSndFile->SetPreAmp(TrackerSettings::Instance().m_MixerSettings.m_nPreAmp); + TrackerSettings::Instance().MixerPreAmp = n; + if (m_pSndFile) m_pSndFile->SetPreAmp(TrackerSettings::Instance().MixerPreAmp); } @@ -1636,7 +1564,7 @@ //------------------------------------------------------------------------------------------------ { const bool isPlaying = IsPlaying(); - if((TrackerSettings::Instance().m_nWaveDevice != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings() != deviceSettings)) + if((TrackerSettings::Instance().GetSoundDeviceID() != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings() != deviceSettings)) { CModDoc *pActiveMod = NULL; if (isPlaying) @@ -1644,7 +1572,7 @@ if ((m_pSndFile) && (!m_pSndFile->IsPaused())) pActiveMod = GetModPlaying(); PauseMod(); } - TrackerSettings::Instance().m_nWaveDevice = deviceID; + TrackerSettings::Instance().SetSoundDeviceID(deviceID); TrackerSettings::Instance().SetSoundDeviceSettings(deviceSettings); { CriticalSection cs; @@ -1687,9 +1615,9 @@ //--------------------------------- { if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_MUTECHNMODE) - TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_MUTECHNMODE; + TrackerSettings::Instance().MixerFlags |= SNDMIX_MUTECHNMODE; else - TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_MUTECHNMODE; + TrackerSettings::Instance().MixerFlags &= ~SNDMIX_MUTECHNMODE; { CriticalSection cs; if(GetSoundFilePlaying()) UpdateAudioParameters(*GetSoundFilePlaying()); @@ -1823,6 +1751,9 @@ #endif CAutoSaverGUI autosavedlg(m_pAutoSaver); //rewbs.AutoSaver CUpdateSetupDlg updatedlg; +#if defined(MPT_SETTINGS_CACHE) + COptionsAdvanced advanced; +#endif // MPT_SETTINGS_CACHE dlg.AddPage(&general); dlg.AddPage(&sounddlg); dlg.AddPage(&playerdlg); @@ -1834,6 +1765,9 @@ dlg.AddPage(&mididlg); dlg.AddPage(&autosavedlg); dlg.AddPage(&updatedlg); +#if defined(MPT_SETTINGS_CACHE) + dlg.AddPage(&advanced); +#endif // MPT_SETTINGS_CACHE m_bOptionsLocked=true; //rewbs.customKeys m_SoundCardOptionsDialog = &sounddlg; dlg.DoModal(); @@ -2526,10 +2460,9 @@ { firstShow = false; WINDOWPLACEMENT wpl; - if (GetPrivateProfileStruct("Display", "WindowPlacement", &wpl, sizeof(WINDOWPLACEMENT), theApp.GetConfigFileName())) - { - SetWindowPlacement(&wpl); - } + GetWindowPlacement(&wpl); + wpl = theApp.GetSettings().Read<WINDOWPLACEMENT>("Display", "WindowPlacement", wpl); + SetWindowPlacement(&wpl); } } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -247,6 +247,14 @@ #include "TrackerSettings.h" struct MODPLUGDIB; +template<> inline SettingValue ToSettingValue(const WINDOWPLACEMENT &val) { + return SettingValue(EncodeBinarySetting<WINDOWPLACEMENT>(val), "WINDOWPLACEMENT"); +} +template<> inline WINDOWPLACEMENT FromSettingValue(const SettingValue &val) { + ASSERT(val.GetTypeTag() == "WINDOWPLACEMENT"); + return DecodeBinarySetting<WINDOWPLACEMENT>(val.as<std::vector<char> >()); +} + //====================================================================================== class CMainFrame: public CMDIFrameWnd, public ISoundSource, public ISoundMessageReceiver //====================================================================================== @@ -357,16 +365,6 @@ static CInputHandler *m_InputHandler; //rewbs.customKeys static CAutoSaver *m_pAutoSaver; //rewbs.customKeys - static bool WritePrivateProfileBool(const CString section, const CString key, const bool value, const CString iniFile); - static bool GetPrivateProfileBool(const CString section, const CString key, const bool defaultValue, const CString iniFile); - static bool WritePrivateProfileLong(const CString section, const CString key, const long value, const CString iniFile); - static long GetPrivateProfileLong(const CString section, const CString key, const long defaultValue, const CString iniFile); - static bool WritePrivateProfileDWord(const CString section, const CString key, const DWORD value, const CString iniFile); - static DWORD GetPrivateProfileDWord(const CString section, const CString key, const DWORD defaultValue, const CString iniFile); - static bool WritePrivateProfileCString(const CString section, const CString key, const CString value, const CString iniFile); - static CString GetPrivateProfileCString(const CString section, const CString key, const CString defaultValue, const CString iniFile); - - // Misc functions public: void SetUserText(LPCSTR lpszText); Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -738,7 +738,7 @@ } MixerSettings oldmixersettings = m_pSndFile->m_MixerSettings; - MixerSettings mixersettings = TrackerSettings::Instance().m_MixerSettings; + MixerSettings mixersettings = TrackerSettings::Instance().GetMixerSettings(); mixersettings.m_nMaxMixChannels = MAX_CHANNELS; // always use max mixing channels when rendering mixersettings.gdwMixingFreq = samplerate; mixersettings.gnChannels = channels; @@ -754,7 +754,7 @@ m_pSndFile->ResetChannels(); m_pSndFile->SetMixerSettings(mixersettings); - m_pSndFile->SetResamplerSettings(TrackerSettings::Instance().m_ResamplerSettings); + m_pSndFile->SetResamplerSettings(TrackerSettings::Instance().GetResamplerSettings()); m_pSndFile->InitPlayer(TRUE); if ((!m_dwFileLimit) || (m_dwFileLimit > 2047*1024)) m_dwFileLimit = 2047*1024; // 2GB m_dwFileLimit <<= 10; Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -15,6 +15,8 @@ #include "mainfrm.h" #include "moptions.h" #include "moddoc.h" +#include "Settings.h" +#include "dlg_misc.h" ////////////////////////////////////////////////////////////// @@ -492,11 +494,14 @@ // Ensure that all colours are reset (for outdated colour schemes) OnPresetMPT(); - for(int i = 0; i < MAX_MODCOLORS; i++) { - TCHAR sKeyName[16]; - wsprintf(sKeyName, "Color%02d", i); - CustomColors[i] = CMainFrame::GetPrivateProfileLong("Colors", sKeyName, CustomColors[i], files.first_file.c_str()); + IniFileSettingsContainer file(mpt::LocaleToPath(files.first_file)); + for(int i = 0; i < MAX_MODCOLORS; i++) + { + TCHAR sKeyName[16]; + wsprintf(sKeyName, "Color%02d", i); + CustomColors[i] = file.Read<int32>("Colors", sKeyName, CustomColors[i]); + } } OnPreviewChanged(); } @@ -507,13 +512,16 @@ FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "mptcolor", "", "OpenMPT Color Schemes|*.mptcolor||", theApp.GetConfigPath()); - if(files.abort) return; - - for(int i = 0; i < MAX_MODCOLORS; i++) + if(files.abort) + return; { - TCHAR sKeyName[16]; - wsprintf(sKeyName, "Color%02d", i); - CMainFrame::WritePrivateProfileLong("Colors", sKeyName, CustomColors[i], files.first_file.c_str()); + IniFileSettingsContainer file(mpt::LocaleToPath(files.first_file)); + for(int i = 0; i < MAX_MODCOLORS; i++) + { + TCHAR sKeyName[16]; + wsprintf(sKeyName, "Color%02d", i); + file.Write<int32>("Colors", sKeyName, CustomColors[i]); + } } } @@ -678,3 +686,91 @@ } SetDlgItemText(IDC_TEXT1, (pszDesc) ? pszDesc : ""); } + + + +#if defined(MPT_SETTINGS_CACHE) + +BEGIN_MESSAGE_MAP(COptionsAdvanced, CPropertyPage) + ON_LBN_DBLCLK(IDC_LIST4, OnOptionDblClick) +END_MESSAGE_MAP() + +void COptionsAdvanced::DoDataExchange(CDataExchange* pDX) +//------------------------------------------------------- +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CModTypeDlg) + DDX_Control(pDX, IDC_LIST4, m_List); + //}}AFX_DATA_MAP +} + + +static std::string FormatSetting(const SettingPath &path, const SettingValue &val) +//-------------------------------------------------------------------------------- +{ + return path.FormatAsString() + " = " + mpt::String::Encode(val.FormatAsString(), mpt::CharsetLocale); +} + + +BOOL COptionsAdvanced::OnInitDialog() +//----------------------------------- +{ + CPropertyPage::OnInitDialog(); + ReInit(); + return TRUE; +} + + +void COptionsAdvanced::ReInit() +//----------------------------- +{ + m_List.ResetContent(); + m_IndexToPath.clear(); + for(SettingsContainer::SettingsMap::const_iterator it = theApp.GetSettings().begin(); it != theApp.GetSettings().end(); ++it) + { + int index = m_List.AddString(FormatSetting(it->first, it->second).c_str()); + m_IndexToPath[index] = it->first; + } +} + + +void COptionsAdvanced::OnOK() +//--------------------------- +{ + CPropertyPage::OnOK(); +} + + +BOOL COptionsAdvanced::OnSetActive() +//---------------------------------- +{ + ReInit(); + CMainFrame::m_nLastOptionsPage = OPTIONS_PAGE_ADVANCED; + return CPropertyPage::OnSetActive(); +} + + +void COptionsAdvanced::OnOptionDblClick() +//--------------------------------------- +{ + const int index = m_List.GetCurSel(); + if(m_IndexToPath.find(index) == m_IndexToPath.end()) + { + return; + } + const SettingPath path = m_IndexToPath[index]; + SettingValue val = theApp.GetSettings().GetMap().find(path)->second; + CInputDlg inputDlg(this, path.FormatAsString().c_str(), mpt::String::Encode(val.FormatValueAsString(), mpt::CharsetLocale).c_str()); + if(inputDlg.DoModal() != IDOK) + { + return; + } + val.SetFromString(mpt::String::Decode(inputDlg.resultString.GetString(), mpt::CharsetLocale)); + theApp.GetSettings().Write(path, val); + m_List.DeleteString(index); + m_List.InsertString(index, FormatSetting(path, val).c_str()); + m_List.SetCurSel(index); + OnSettingsChanged(); +} + +#endif // MPT_SETTINGS_CACHE Modified: trunk/OpenMPT/mptrack/Moptions.h =================================================================== --- trunk/OpenMPT/mptrack/Moptions.h 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Moptions.h 2013-11-04 18:22:26 UTC (rev 3074) @@ -23,6 +23,7 @@ OPTIONS_PAGE_MIDI, OPTIONS_PAGE_AUTOSAVE, OPTIONS_PAGE_UPDATE, + OPTIONS_PAGE_ADVANCED, }; @@ -56,6 +57,35 @@ }; +#if defined(MPT_SETTINGS_CACHE) + +//========================================== +class COptionsAdvanced: public CPropertyPage +//========================================== +{ +protected: + CListBox m_List; + std::map<int, SettingPath> m_IndexToPath; + +public: + COptionsAdvanced():CPropertyPage(IDD_OPTIONS_ADVANCED) {} + +protected: + virtual BOOL OnInitDialog(); + virtual void OnOK(); + virtual BOOL OnSetActive(); + virtual void DoDataExchange(CDataExchange* pDX); + afx_msg void OnOptionDblClick(); + afx_msg void OnSettingsChanged() { SetModified(TRUE); } + + void ReInit(); + + DECLARE_MESSAGE_MAP(); +}; + +#endif // MPT_SETTINGS_CACHE + + //======================================== class COptionsColors: public CPropertyPage //======================================== Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -128,7 +128,7 @@ CHAR s[128]; - CheckDlgButton(IDC_CHECK2, (TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING) ? MF_CHECKED : MF_UNCHECKED); + CheckDlgButton(IDC_CHECK2, (TrackerSettings::Instance().MixerFlags & SNDMIX_SOFTPANNING) ? MF_CHECKED : MF_UNCHECKED); CheckDlgButton(IDC_CHECK4, m_Settings.ExclusiveMode ? MF_CHECKED : MF_UNCHECKED); CheckDlgButton(IDC_CHECK5, m_Settings.BoostThreadPriority ? MF_CHECKED : MF_UNCHECKED); @@ -142,7 +142,7 @@ { wsprintf(s, "%d (%s)", nCPUMix[n], szCPUNames[n]); m_CbnPolyphony.AddString(s); - if (TrackerSettings::Instance().m_MixerSettings.m_nMaxMixChannels == nCPUMix[n]) m_CbnPolyphony.SetCurSel(n); + if (TrackerSettings::Instance().MixerMaxChannels == nCPUMix[n]) m_CbnPolyphony.SetCurSel(n); } } // latency @@ -188,7 +188,7 @@ m_SliderStereoSep.SetPos(2); for (int n=0; n<=4; n++) { - if ((int)TrackerSettings::Instance().m_MixerSettings.m_nStereoSeparation <= (int)(32 << n)) + if ((int)TrackerSettings::Instance().MixerStereoSeparation <= (int)(32 << n)) { m_SliderStereoSep.SetPos(n); break; @@ -371,9 +371,9 @@ //--------------------------------------- { CHAR s[64]; - TrackerSettings::Instance().m_MixerSettings.m_nStereoSeparation = 32 << m_SliderStereoSep.GetPos(); + TrackerSettings::Instance().MixerStereoSeparation = 32 << m_SliderStereoSep.GetPos(); CMainFrame::GetMainFrame()->SetupPlayer(); - wsprintf(s, "%d%%", (TrackerSettings::Instance().m_MixerSettings.m_nStereoSeparation * 100) / 128); + wsprintf(s, "%d%%", (TrackerSettings::Instance().MixerStereoSeparation * 100) / 128); SetDlgItemText(IDC_TEXT1, s); } @@ -382,7 +382,7 @@ void COptionsSoundcard::SetPreAmpSliderPosition() //----------------------------------------------- { - int n = (TrackerSettings::Instance().m_MixerSettings.m_nPreAmp - 64) / 8; + int n = (TrackerSettings::Instance().MixerPreAmp - 64) / 8; if ((n < 0) || (n > 40)) n = 16; m_SliderPreAmp.SetPos(n); } @@ -468,7 +468,10 @@ void COptionsSoundcard::OnOK() //---------------------------- { - if(IsDlgButtonChecked(IDC_CHECK2)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_SOFTPANNING; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_SOFTPANNING; + if(IsDlgButtonChecked(IDC_CHECK2)) + TrackerSettings::Instance().MixerFlags = TrackerSettings::Instance().MixerFlags | SNDMIX_SOFTPANNING; + else + TrackerSettings::Instance().MixerFlags = TrackerSettings::Instance().MixerFlags & ~SNDMIX_SOFTPANNING; m_Settings.ExclusiveMode = IsDlgButtonChecked(IDC_CHECK4) ? true : false; m_Settings.BoostThreadPriority = IsDlgButtonChecked(IDC_CHECK5) ? true : false; // Mixing Freq @@ -494,7 +497,7 @@ int nmmx = m_CbnPolyphony.GetCurSel(); if ((nmmx >= 0) && (nmmx < CountOf(nCPUMix))) { - TrackerSettings::Instance().m_MixerSettings.m_nMaxMixChannels = nCPUMix[nmmx]; + TrackerSettings::Instance().MixerMaxChannels = nCPUMix[nmmx]; CMainFrame::GetMainFrame()->SetupPlayer(); } } @@ -606,7 +609,7 @@ DWORD dwQuality; CPropertyPage::OnInitDialog(); - dwQuality = TrackerSettings::Instance().m_MixerSettings.DSPMask; + dwQuality = TrackerSettings::Instance().MixerDSPMask; // Resampling type { m_CbnResampling.AddString("No Interpolation"); @@ -616,7 +619,7 @@ m_CbnResampling.AddString("Polyphase"); m_CbnResampling.AddString("XMMS-ModPlug"); //end rewbs.resamplerConf - m_CbnResampling.SetCurSel(TrackerSettings::Instance().m_ResamplerSettings.SrcMode); + m_CbnResampling.SetCurSel(TrackerSettings::Instance().ResamplerMode); } // Effects #ifndef NO_DSP @@ -704,10 +707,10 @@ OnResamplerChanged(); char s[16] = ""; - _ltoa(TrackerSettings::Instance().m_MixerSettings.glVolumeRampUpSamples, s, 10); + _ltoa(TrackerSettings::Instance().MixerVolumeRampUpSamples, s, 10); m_CEditRampUp.SetWindowText(s); - _ltoa(TrackerSettings::Instance().m_MixerSettings.glVolumeRampDownSamples, s, 10); + _ltoa(TrackerSettings::Instance().MixerVolumeRampDownSamples, s, 10); m_CEditRampDown.SetWindowText(s); //end rewbs.resamplerConf @@ -744,7 +747,7 @@ //rewbs.resamplerConf void COptionsPlayer::OnWFIRTypeChanged() { - TrackerSettings::Instance().m_ResamplerSettings.gbWFIRType = static_cast<BYTE>(m_CbnWFIRType.GetCurSel()); + TrackerSettings::Instance().ResamplerSubMode = static_cast<BYTE>(m_CbnWFIRType.GetCurSel()); OnSettingsChanged(); } @@ -761,7 +764,7 @@ m_CbnWFIRType.SetCurSel(0); m_CbnWFIRType.EnableWindow(FALSE); m_CEditWFIRCutoff.EnableWindow(TRUE); - wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff * 100))); + wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().ResamplerCutoffPercent))); break; case SRCMODE_FIRFILTER: m_CbnWFIRType.AddString("Hann"); @@ -772,10 +775,10 @@ m_CbnWFIRType.AddString("Blackman 4 Tap 92"); m_CbnWFIRType.AddString("Blackman 4 Tap 74"); m_CbnWFIRType.AddString("Kaiser 4 Tap"); - m_CbnWFIRType.SetCurSel(TrackerSettings::Instance().m_ResamplerSettings.gbWFIRType); + m_CbnWFIRType.SetCurSel(TrackerSettings::Instance().ResamplerSubMode); m_CbnWFIRType.EnableWindow(TRUE); m_CEditWFIRCutoff.EnableWindow(TRUE); - wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff*100))); + wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().ResamplerCutoffPercent))); break; default: m_CbnWFIRType.AddString("None"); @@ -865,23 +868,23 @@ m_CEditWFIRCutoff.GetWindowText(s); if(s != "") { - double newCutoff = atoi(s)/100.0; - Limit(newCutoff, 0.0, 1.0); - TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff = newCutoff; + int newCutoff = atoi(s); + Limit(newCutoff, 0, 100); + TrackerSettings::Instance().ResamplerCutoffPercent = newCutoff; } { CHAR s[64]; - wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff*100))); + wsprintf(s, "%d", TrackerSettings::Instance().ResamplerCutoffPercent.Get()); m_CEditWFIRCutoff.SetWindowText(s); } //TrackerSettings::Instance().m_ResamplerSettings.gbWFIRType set in OnWFIRTypeChange m_CEditRampUp.GetWindowText(s); - TrackerSettings::Instance().m_MixerSettings.glVolumeRampUpSamples = atol(s); + TrackerSettings::Instance().MixerVolumeRampUpSamples = atol(s); m_CEditRampDown.GetWindowText(s); - TrackerSettings::Instance().m_MixerSettings.glVolumeRampDownSamples = atol(s); - TrackerSettings::Instance().m_ResamplerSettings.SrcMode = (ResamplingMode)dwSrcMode; - TrackerSettings::Instance().m_MixerSettings.DSPMask = dwQuality; + TrackerSettings::Instance().MixerVolumeRampDownSamples = atol(s); + TrackerSettings::Instance().ResamplerMode = (ResamplingMode)dwSrcMode; + TrackerSettings::Instance().MixerDSPMask = dwQuality; CMainFrame::GetMainFrame()->SetupPlayer(); CPropertyPage::OnOK(); } @@ -1258,12 +1261,12 @@ static const struct { const char *text; - TrackerSettings::RecordAftertouchOptions option; + RecordAftertouchOptions option; } aftertouchOptions[] = { - { "Do not record Aftertouch", TrackerSettings::atDoNotRecord }, - { "Record as Volume Commands", TrackerSettings::atRecordAsVolume }, - { "Record as MIDI Macros", TrackerSettings::atRecordAsMacro }, + { "Do not record Aftertouch", atDoNotRecord }, + { "Record as Volume Commands", atRecordAsVolume }, + { "Record as MIDI Macros", atRecordAsMacro }, }; for(size_t i = 0; i < CountOf(aftertouchOptions); i++) @@ -1280,7 +1283,7 @@ SetDlgItemInt(IDC_EDIT3, TrackerSettings::Instance().midiVelocityAmp); m_SpinAmp.SetRange(1, 10000); - SetDlgItemText(IDC_EDIT4, TrackerSettings::Instance().IgnoredCCsToString().c_str()); + SetDlgItemText(IDC_EDIT4, IgnoredCCsToString(TrackerSettings::Instance().midiIgnoreCCs).c_str()); // Midi Import settings SetDlgItemInt(IDC_EDIT1, TrackerSettings::Instance().midiImportSpeed); @@ -1313,7 +1316,7 @@ if (n >= 0) m_nMidiDevice = combo->GetItemData(n); } - TrackerSettings::Instance().aftertouchBehaviour = static_cast<TrackerSettings::RecordAftertouchOptions>(m_ATBehaviour.GetItemData(m_ATBehaviour.GetCurSel())); + TrackerSettings::Instance().aftertouchBehaviour = static_cast<RecordAftertouchOptions>(m_ATBehaviour.GetItemData(m_ATBehaviour.GetCurSel())); TrackerSettings::Instance().midiImportSpeed = GetDlgItemInt(IDC_EDIT1); TrackerSettings::Instance().midiImportPatternLen = GetDlgItemInt(IDC_EDIT2); @@ -1321,7 +1324,7 @@ CString cc; GetDlgItemText(IDC_EDIT4, cc); - TrackerSettings::Instance().ParseIgnoredCCs(cc); + TrackerSettings::Instance().midiIgnoreCCs = StringToIgnoredCCs(cc.GetString()); if (pMainFrm) pMainFrm->SetupMidi(m_dwMidiSetup, m_nMidiDevice); CPropertyPage::OnOK(); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-04 17:35:11 UTC (rev 3073) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-04 18:22:26 UTC (rev 3074) @@ -26,6 +26,7 @@ #include "../common/StringFixer.h" #include "ExceptionHandler.h" #include "CloseMainDialog.h" +#include "AutoSaver.h" // rewbs.memLeak #define _CRTDBG_MAP_ALLOC @@ -305,23 +306,23 @@ BOOL CTrackApp::ImportMidiConfig(LPCSTR lpszConfigFile, BOOL bNoWarn) //------------------------------------------------------------------- { - TCHAR szFileName[_MAX_PATH], s[_MAX_PATH], szUltraSndPath[_MAX_PATH]; + if ((!lpszConfigFile) || (!lpszConfigFile[0])) return FALSE; - if ((!lpszConfigFile) || (!lpszConfigFile[0])) return FALSE; if (!glpMidiLibrary) { glpMidiLibrary = new MIDILIBSTRUCT; if (!glpMidiLibrary) return FALSE; MemsetZero(*glpMidiLibrary); } + if (CDLSBank::IsDLSBank(lpszConfigFile)) { ConfirmAnswer result = cnfYes; if (!bNoWarn) { result = Reporting::Confirm("You are about to replace the current MIDI library:\n" - "Do you want to replace only the missing instruments? (recommended)", - "Warning", true); + "Do you want to replace only the missing instruments? (recommended)", + "Warning", true); } if (result == cnfCancel) return FALSE; const bool bReplaceAll = (result == cnfNo); @@ -348,24 +349,41 @@ } return TRUE; } - GetPrivateProfileString(_T("Ultrasound"), _T("PatchDir"), _T(""), szUltraSndPath, CountOf(szUltraSndPath), lpszConfigFile); + + IniFileSettingsContainer file(mpt::LocaleToPath(lpszConfigFile)); + return ImportMidiConfig(file); +} + +BOOL CTrackApp::ImportMidiConfig(SettingsContainer &file) +//------------------------------------------------------- +{ + TCHAR szFileName[_MAX_PATH], s[_MAX_PATH], szUltraSndPath[_MAX_PATH]; + + if (!glpMidiLibrary) + { + glpMidiLibrary = new MIDILIBSTRUCT; + if (!glpMidiLibrary) return FALSE; + MemsetZero(*glpMidiLibrary); + } + + mpt::String::Copy(szUltraSndPath, file.Read<std::string>("Ultrasound", "PatchDir", "")); if (!strcmp(szUltraSndPath, _T(".\\"))) szUltraSndPath[0] = 0; if (!szUltraSndPath[0]) GetCurrentDirectory(CountOf(szUltraSndPath), szUltraSndPath); for (UINT iMidi=0; iMidi<256; iMidi++) { szFileName[0] = 0; wsprintf(s, (iMidi < 128) ? _T("Midi%d") : _T("Perc%d"), iMidi & 0x7f); - GetPrivateProfileString(_T("Midi Library"), s, _T(""), szFileName, CountOf(szFileName), lpszConfigFile); + mpt::String::Copy(szFileName, file.Read<std::string>("Midi Library", s, "")); // Check for ULTRASND.INI if (!szFileName[0]) { LPCSTR pszSection = (iMidi < 128) ? _T("Melodic Patches") : _T("Drum Patches"); wsprintf(s, _T("%d"), iMidi & 0x7f); - GetPrivateProfileString(pszSection, s, _T(""), szFileName, CountOf(szFileName), lpszConfigFile); + mpt::String::Copy(szFileName, file.Read<std::string>(pszSection, s, "")); if (!szFileName[0]) { pszSection = (iMidi < 128) ? _T("Melodic Bank 0") : _T("Drum Bank 0"); - GetPrivateProfileString(pszSection, s, "", szFileName, CountOf(szFileName), lpszConfigFile); + mpt::String::Copy(szFileName, file.Read<std::string>(pszSection, s, "")); } if (szFileName[0]) { @@ -398,9 +416,17 @@ BOOL CTrackApp::ExportMidiConfig(LPCSTR lpszConfigFile) //----------------------------------------------------- { + if ((!glpMidiLibrary) || (!lpszConfigFile) || (!lpszConfigFile[0])) return FALSE; + IniFileSettingsContainer file(mpt::LocaleToPath(lpszConfigFile)); + return ExportMidiConfig(file); +} + +BOOL CTrackApp::ExportMidiConfig(SettingsContainer &file) +//------------------------------------------------------- +{ TCHAR szFileName[_MAX_PATH], s[128]; - if ((!glpMidiLibrary) || (!lpszConfigFile) || (!lpszConfigFile[0])) return FALSE; + if (!glpMidiLibrary) return FALSE; for(size_t iMidi = 0; iMidi < 256; iMidi++) if (glpMidiLibrary->MidiMap[iMidi]) { if (iMidi < 128) @@ -414,7 +440,7 @@ { if(theApp.IsPortableMode()) theApp.AbsolutePathToRelative(szFileName); - if (!WritePrivateProfileString("Midi Library", s, szFileName, lpszConfigFile)) break; + file.Write<std::string>("Midi Library", s, szFileName); } } return TRUE; @@ -434,18 +460,18 @@ CHAR szFileName[MAX_PATH]; HKEY key; - CString storedVersion = CMainFrame::GetPrivateProfileCString("Version", "Version", "", theApp.GetConfigFileName()); + CString storedVersion = theApp.GetSettings().Read<CString>("Version", "Version", ""); //If version number stored in INI is 1.17.02.40 or later, load DLS from INI file. //Else load DLS from Registry if (storedVersion >= "1.17.02.40") { CHAR s[MAX_PATH]; - UINT numBanks = CMainFrame::GetPrivateProfileLong("DLS Banks", "NumBanks", 0, theApp.GetConfigFileName()); + UINT numBanks = theApp.GetSettings().Read<int32>("DLS Banks", "NumBanks", 0); for(size_t i = 0; i < numBanks; i++) { wsprintf(s, _T("Bank%d"), i + 1); TCHAR szPath[_MAX_PATH]; - GetPrivateProfileString("DLS Banks", s, "", szPath, INIBUFFERSIZE, theApp.GetConfigFileName()); + mpt::String::Copy(szPath, theApp.GetSettings().Read<std::string>("DLS Banks", s, "")); theApp.RelativePathToAbsolute(szPath); AddDLSBank(szPath); } @@ -531,11 +557,11 @@ } wsprintf(s, _T("Bank%d"), nBanks+1); - WritePrivateProfileString("DLS Banks", s, szPath, theApp.GetConfigFileName()); + theApp.GetSettings().Write<std::string>("DLS Banks", s, szPath); nBanks++; } - CMainFrame::WritePrivateProfileLong("DLS Banks", "NumBanks", nBanks, theApp.GetConfigFileName()); + theApp.GetSettings().Write<int32>("DLS Banks", "NumBanks", nBanks); return TRUE; } @@ -610,6 +636,10 @@ CTrackApp::CTrackApp() //-------------------- + : m_pSettingsIniFile(nullptr) + , m_pSettings(nullptr) + , m_pTrackerSettings(nullptr) + , m_pPluginCache(nullptr) { #if MPT_COMPILER_MSVC _CrtSetDebugFillThreshold(0); // Disable buffer filling in secure enhanced CRT functions. @@ -623,6 +653,7 @@ m_pSoundDevicesManager = nullptr; m_bInitialized = FALSE; m_szConfigFileName[0] = 0; + m_szPluginCacheFileName[0] = 0; } @@ -719,11 +750,11 @@ // Create tunings dir CString sTuningPath; sTuningPath.Format(TEXT("%stunings\\"), m_szConfigDirectory); - TrackerSettings::Instance().SetDefaultDirectory(sTuningPath, DIR_TUNING); + TrackerDirectories::Instance().SetDefaultDirectory(sTuningPath, DIR_TUNING); - if(PathIsDirectory(TrackerSettings::Instance().GetDefaultDirectory(DIR_TUNING)) == 0) + if(PathIsDirectory(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING)) == 0) { - CreateDirectory(TrackerSettings::Instance().GetDefaultDirectory(DIR_TUNING), 0); + CreateDirectory(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING), 0); } if(!bIsAppDir) @@ -763,8 +794,15 @@ TCHAR szTemplatePath[MAX_PATH]; _tcscpy(szTemplatePath, m_szConfigDirectory); _tcscat(szTemplatePath, _T("TemplateModules\\")); - TrackerSettings::Instance().SetDefaultDirectory(szTemplatePath, DIR_TEMPLATE_FILES_USER); + TrackerDirectories::Instance().SetDefaultDirectory(szTemplatePath, DIR_TEMPLATE_FILES_USER); + //Force use of custom ini file rather than windowsDir\executableName.ini + if(m_pszProfileName) + { + free((void *)m_pszProfileName); + } + m_pszProfileName = _tcsdup(m_szConfigFileName); + m_bPortableMode = bIsAppDir; } @@ -781,18 +819,10 @@ // Start loading BeginWaitCursor(); - MEMORYSTATUS gMemStatus; - MemsetZero(gMemStatus); - GlobalMemoryStatus(&gMemStatus); -#if 0 - Log("Physical: %lu\n", gMemStatus.dwTotalPhys); - Log("Page File: %lu\n", gMemStatus.dwTotalPageFile); - Log("Virtual: %lu\n", gMemStatus.dwTotalVirtual); + // Initialize Audio +#ifdef ENABLE_ASM + InitProcSupport(); #endif - // Allow allocations of at least 16MB - if (gMemStatus.dwTotalPhys < 16*1024*1024) gMemStatus.dwTotalPhys = 16*1024*1024; - TrackerSettings::Instance().m_nSampleUndoMaxBuffer = gMemStatus.dwTotalPhys / 10; // set sample und... [truncated message content] |