From: <man...@us...> - 2015-06-01 09:27:06
|
Revision: 5223 http://sourceforge.net/p/modplug/code/5223 Author: manxorist Date: 2015-06-01 09:27:00 +0000 (Mon, 01 Jun 2015) Log Message: ----------- [Ref] Clenaup first-run and previous settings version logic. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-05-31 21:34:07 UTC (rev 5222) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-01 09:27:00 UTC (rev 5223) @@ -824,19 +824,7 @@ // chose config directory mpt::PathString configPath = portableMode ? configPathApp : configPathGlobal; - // check if this is the first run - bool firstRun = true; - { - WCHAR tempVersion[MAX_PATH]; - MemsetZero(tempVersion); - GetPrivateProfileStringW(L"Version", L"Version", L"", tempVersion, CountOf(tempVersion), (configPathApp + MPT_PATHSTRING("mptrack.ini")).AsNative().c_str()); - if(!std::wstring(tempVersion).empty()) - { - firstRun = false; - } - } - // Update state. // store exe path @@ -1083,26 +1071,31 @@ m_dwTimeStarted = timeGetTime(); m_bInitialized = TRUE; - const bool firstRun = TrackerSettings::Instance().gcsPreviousVersion == 0; - if(CUpdateCheck::GetUpdateCheckPeriod() != 0 && !firstRun) - { - CUpdateCheck::DoUpdateCheck(true); - } - // Open settings if the previous execution was with an earlier version. - if(TrackerSettings::Instance().ShowSettingsOnNewVersion && !firstRun && TrackerSettings::Instance().gcsPreviousVersion < MptVersion::num) + if(TrackerSettings::Instance().FirstRun) { - StopSplashScreen(); - m_pMainWnd->PostMessage(WM_COMMAND, ID_VIEW_OPTIONS); - } - - if(firstRun) - { + // On high-DPI devices, automatically upscale pattern font FontSetting font = TrackerSettings::Instance().patternFont; font.size = Clamp(Util::GetDPIy(m_pMainWnd->m_hWnd) / 96 - 1, 0, 9); TrackerSettings::Instance().patternFont = font; new WelcomeDlg(m_pMainWnd); + + } else + { + + // Update check + if(CUpdateCheck::GetUpdateCheckPeriod() != 0) + { + CUpdateCheck::DoUpdateCheck(true); + } + + // Open settings if the previous execution was with an earlier version. + if(TrackerSettings::Instance().ShowSettingsOnNewVersion && (TrackerSettings::Instance().PreviousSettingsVersion < MptVersion::num)) + { + m_pMainWnd->PostMessage(WM_COMMAND, ID_VIEW_OPTIONS); + } + } EndWaitCursor(); @@ -1821,7 +1814,7 @@ // Version <= 1.19.03.00 had buggy handling of custom host information. If last open was from // such OpenMPT version, clear the related settings to get a clean start. - if(TrackerSettings::Instance().gcsPreviousVersion != 0 && TrackerSettings::Instance().gcsPreviousVersion < MAKE_VERSION_NUMERIC(1, 19, 03, 01) && buffer == "OpenMPT") + if(TrackerSettings::Instance().PreviousSettingsVersion < MAKE_VERSION_NUMERIC(1,19,03,01) && buffer == "OpenMPT") { theApp.GetSettings().Remove("VST Plugins", "HostProductString"); theApp.GetSettings().Remove("VST Plugins", "HostVendorString"); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-05-31 21:34:07 UTC (rev 5222) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-06-01 09:27:00 UTC (rev 5223) @@ -45,13 +45,19 @@ } -static MptVersion::VersionNum GetStoredVersion(const std::string &iniVersion) -//--------------------------------------------------------------------------- +static MptVersion::VersionNum GetPreviousSettingsVersion(const std::string &iniVersion) +//------------------------------------------------------------------------------------- { MptVersion::VersionNum result = 0; if(!iniVersion.empty()) { result = MptVersion::ToNum(iniVersion); + } else + { + // No version stored. + // This is the first run, thus set the previous version to our current + // version which will avoid running all settings upgrade code. + result = MptVersion::num; } return result; } @@ -129,8 +135,9 @@ //------------------------------------------------------- : conf(conf) // Version - , IniVersion(conf, "Version", "Version", "") - , gcsPreviousVersion(GetStoredVersion(IniVersion)) + , IniVersion(conf, "Version", "Version", std::string()) + , FirstRun(IniVersion.Get() == std::string()) + , PreviousSettingsVersion(GetPreviousSettingsVersion(IniVersion)) , gcsInstallGUID(conf, "Version", "InstallGUID", std::wstring()) // Display , m_ShowSplashScreen(conf, "Display", "ShowSplashScreen", true) @@ -384,7 +391,7 @@ // Fixups: // ------- - const MptVersion::VersionNum storedVersion = gcsPreviousVersion ? gcsPreviousVersion : MptVersion::num; + const MptVersion::VersionNum storedVersion = PreviousSettingsVersion; // Version if(gcsInstallGUID.Get().empty()) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2015-05-31 21:34:07 UTC (rev 5222) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2015-06-01 09:27:00 UTC (rev 5223) @@ -415,7 +415,9 @@ // Version Setting<std::string> IniVersion; - const MptVersion::VersionNum gcsPreviousVersion; + const bool FirstRun; + const MptVersion::VersionNum PreviousSettingsVersion; + const bool FirstRun; Setting<std::wstring> gcsInstallGUID; // Display This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |