Reverted r800/r801. Fixed r800 issue in a better way (thanks spx).

This commit is contained in:
Birunthan Mohanathas 2011-05-02 11:58:02 +00:00
parent 04a7a5692f
commit 6377db5724
2 changed files with 55 additions and 63 deletions

View File

@ -1725,7 +1725,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
if (!c_DummyLitestep) InitalizeLitestep(); if (!c_DummyLitestep) InitalizeLitestep();
bool bPortableInstallation = false; bool bDefaultIniLocation = false;
if (c_CmdLine.empty()) if (c_CmdLine.empty())
{ {
@ -1737,6 +1737,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
{ {
m_IniFile = L"%APPDATA%\\Rainmeter\\Rainmeter.ini"; m_IniFile = L"%APPDATA%\\Rainmeter\\Rainmeter.ini";
ExpandEnvironmentVariables(m_IniFile); ExpandEnvironmentVariables(m_IniFile);
bDefaultIniLocation = true;
// If the ini file doesn't exist in the %APPDATA% either, create a default Rainmeter.ini file. // If the ini file doesn't exist in the %APPDATA% either, create a default Rainmeter.ini file.
if (_waccess(m_IniFile.c_str(), 0) == -1) if (_waccess(m_IniFile.c_str(), 0) == -1)
@ -1744,10 +1745,6 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
CreateDefaultConfigFile(m_IniFile); CreateDefaultConfigFile(m_IniFile);
} }
} }
else
{
bPortableInstallation = true;
}
} }
else else
{ {
@ -1789,6 +1786,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
{ {
CreateDefaultConfigFile(m_IniFile); CreateDefaultConfigFile(m_IniFile);
} }
bDefaultIniLocation = true;
} }
// Set the log file location // Set the log file location
@ -1815,17 +1813,11 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
StartLogging(); StartLogging();
} }
m_PluginPath = m_AddonPath = m_Path; m_PluginPath = m_AddonPath = m_SkinPath = m_Path;
m_PluginPath += L"Plugins\\"; m_PluginPath += L"Plugins\\";
m_AddonPath += L"Addons\\"; m_AddonPath += L"Addons\\";
if (bPortableInstallation)
{
m_SkinPath = m_Path;
m_SkinPath += L"Skins\\"; m_SkinPath += L"Skins\\";
}
else
{
// Read the skin folder from the ini file // Read the skin folder from the ini file
tmpSzPath[0] = L'\0'; tmpSzPath[0] = L'\0';
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0) if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
@ -1842,7 +1834,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
} }
} }
} }
else else if (bDefaultIniLocation)
{ {
// If the skin path is not defined in the Rainmeter.ini file use My Documents/Rainmeter/Skins // If the skin path is not defined in the Rainmeter.ini file use My Documents/Rainmeter/Skins
tmpSzPath[0] = L'\0'; tmpSzPath[0] = L'\0';
@ -1878,9 +1870,9 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
{ {
Log(LOG_WARNING, L"Unable to get the My Documents location."); Log(LOG_WARNING, L"Unable to get the My Documents location.");
} }
}
}
WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), m_IniFile.c_str()); WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), m_IniFile.c_str());
}
delete [] tmpSzPath; delete [] tmpSzPath;
tmpSzPath = NULL; tmpSzPath = NULL;
@ -1946,7 +1938,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
} }
// Test that the Rainmeter.ini file is writable // Test that the Rainmeter.ini file is writable
TestSettingsFile(bPortableInstallation); TestSettingsFile(bDefaultIniLocation);
// If the skin folder is somewhere else than in the program path // If the skin folder is somewhere else than in the program path
if (_wcsnicmp(m_Path.c_str(), m_SkinPath.c_str(), m_Path.size()) != 0) if (_wcsnicmp(m_Path.c_str(), m_SkinPath.c_str(), m_Path.size()) != 0)
@ -4348,7 +4340,7 @@ void CRainmeter::SetDisableDragging(bool dragging)
WritePrivateProfileString(L"Rainmeter", L"DisableDragging", dragging ? L"1" : L"0", m_IniFile.c_str()); WritePrivateProfileString(L"Rainmeter", L"DisableDragging", dragging ? L"1" : L"0", m_IniFile.c_str());
} }
void CRainmeter::TestSettingsFile(bool bPortableInstallation) void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
{ {
WritePrivateProfileString(L"Rainmeter", L"WriteTest", L"TRUE", m_IniFile.c_str()); WritePrivateProfileString(L"Rainmeter", L"WriteTest", L"TRUE", m_IniFile.c_str());
WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); // FLUSH WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); // FLUSH
@ -4367,7 +4359,7 @@ void CRainmeter::TestSettingsFile(bool bPortableInstallation)
std::wstring error = L"The Rainmeter.ini file is not writable. This means that the\n" std::wstring error = L"The Rainmeter.ini file is not writable. This means that the\n"
L"application will not be able to save any settings permanently.\n\n"; L"application will not be able to save any settings permanently.\n\n";
if (bPortableInstallation) if (!bDefaultIniLocation)
{ {
std::wstring strTarget = L"%APPDATA%\\Rainmeter\\"; std::wstring strTarget = L"%APPDATA%\\Rainmeter\\";
ExpandEnvironmentVariables(strTarget); ExpandEnvironmentVariables(strTarget);

View File

@ -274,7 +274,7 @@ private:
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow); void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
void CreateDefaultConfigFile(const std::wstring& strFile); void CreateDefaultConfigFile(const std::wstring& strFile);
void SetLogging(bool logging); void SetLogging(bool logging);
void TestSettingsFile(bool bPortableInstallation); void TestSettingsFile(bool bDefaultIniLocation);
void CheckSkinVersions(); void CheckSkinVersions();
int CompareVersions(const std::wstring& strA, const std::wstring& strB); int CompareVersions(const std::wstring& strA, const std::wstring& strB);