From bdb294893c4be150532af7bfe13736f31c359586 Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 10 Feb 2012 23:28:11 +0000 Subject: [PATCH] Now skin is deactivated if the Rainmeter version is less than the AppVersion value. --- Library/MeterWindow.cpp | 50 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 87660218..7ef4b673 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2010,6 +2010,8 @@ void CMeterWindow::WriteConfig(INT setting) */ bool CMeterWindow::ReadSkin() { + WCHAR buffer[128]; + std::wstring iniFile = m_Rainmeter->GetSkinPath() + m_SkinName; iniFile += L'\\'; iniFile += m_SkinIniFile; @@ -2023,6 +2025,26 @@ bool CMeterWindow::ReadSkin() } m_Parser.Initialize(iniFile.c_str(), m_Rainmeter, this); + + // Check the version + UINT appVersion = m_Parser.ReadUInt(L"Rainmeter", L"AppVersion", 0); + if (appVersion > RAINMETER_VERSION) + { + if (appVersion % 1000 != 0) + { + _snwprintf_s(buffer, _TRUNCATE, L"%u.%u.%u", appVersion / 1000000, (appVersion / 1000) % 1000, appVersion % 1000); + } + else + { + _snwprintf_s(buffer, _TRUNCATE, L"%u.%u", appVersion / 1000000, (appVersion / 1000) % 1000); + } + + std::wstring text = GetFormattedString(ID_STR_NEWVERSIONREQUIRED, m_SkinName.c_str(), m_SkinIniFile.c_str(), buffer); + MessageBox(m_Window, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); + return false; + } + + // Initialize window variables SetWindowPositionVariables(m_ScreenX, m_ScreenY); SetWindowSizeVariables(0, 0); @@ -2035,24 +2057,6 @@ bool CMeterWindow::ReadSkin() } InitializeGroup(m_ConfigGroup); - // Check the version - int appVersion = m_Parser.ReadInt(L"Rainmeter", L"AppVersion", 0); - if (appVersion > RAINMETER_VERSION) - { - WCHAR buffer[128]; - if (appVersion % 1000 != 0) - { - _snwprintf_s(buffer, _TRUNCATE, L"%i.%i.%i", appVersion / 1000000, (appVersion / 1000) % 1000, appVersion % 1000); - } - else - { - _snwprintf_s(buffer, _TRUNCATE, L"%i.%i", appVersion / 1000000, (appVersion / 1000) % 1000); - } - - std::wstring text = GetFormattedString(ID_STR_NEWVERSIONREQUIRED, m_SkinName.c_str(), m_SkinIniFile.c_str(), buffer); - MessageBox(m_Window, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); - } - static const RECT defMargins = {0}; m_BackgroundMargins = m_Parser.ReadRECT(L"Rainmeter", L"BackgroundMargins", defMargins); m_DragMargins = m_Parser.ReadRECT(L"Rainmeter", L"DragMargins", defMargins); @@ -2115,9 +2119,8 @@ bool CMeterWindow::ReadSkin() // Here we are checking to see if there are more than one blur region // to be loaded. They will be named BlurRegion2, BlurRegion3, etc. - WCHAR tmpName[64]; - _snwprintf_s(tmpName, _TRUNCATE, L"BlurRegion%i", ++i); - blurRegion = m_Parser.ReadString(L"Rainmeter", tmpName, L"").c_str(); + _snwprintf_s(buffer, _TRUNCATE, L"BlurRegion%i", ++i); + blurRegion = m_Parser.ReadString(L"Rainmeter", buffer, L"").c_str(); } while (*blurRegion); } @@ -2175,9 +2178,8 @@ bool CMeterWindow::ReadSkin() // Here we are checking to see if there are more than one local font // to be loaded. They will be named LocalFont2, LocalFont3, etc. - WCHAR tmpName[64]; - _snwprintf_s(tmpName, _TRUNCATE, L"LocalFont%i", ++i); - localFont = m_Parser.ReadString(L"Rainmeter", tmpName, L"").c_str(); + _snwprintf_s(buffer, _TRUNCATE, L"LocalFont%i", ++i); + localFont = m_Parser.ReadString(L"Rainmeter", buffer, L"").c_str(); } while (*localFont); }