mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Reverted r800/r801. Fixed r800 issue in a better way (thanks spx).
This commit is contained in:
parent
04a7a5692f
commit
6377db5724
@ -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,72 +1813,66 @@ 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\\";
|
||||||
|
m_SkinPath += L"Skins\\";
|
||||||
|
|
||||||
if (bPortableInstallation)
|
// Read the skin folder from the ini file
|
||||||
|
tmpSzPath[0] = L'\0';
|
||||||
|
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||||
{
|
{
|
||||||
m_SkinPath = m_Path;
|
m_SkinPath = tmpSzPath;
|
||||||
m_SkinPath += L"Skins\\";
|
ExpandEnvironmentVariables(m_SkinPath);
|
||||||
}
|
|
||||||
else
|
if (!m_SkinPath.empty())
|
||||||
{
|
|
||||||
// Read the skin folder from the ini file
|
|
||||||
tmpSzPath[0] = L'\0';
|
|
||||||
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
|
||||||
{
|
{
|
||||||
m_SkinPath = tmpSzPath;
|
WCHAR ch = m_SkinPath[m_SkinPath.size() - 1];
|
||||||
ExpandEnvironmentVariables(m_SkinPath);
|
if (ch != L'\\' && ch != L'/')
|
||||||
|
|
||||||
if (!m_SkinPath.empty())
|
|
||||||
{
|
{
|
||||||
WCHAR ch = m_SkinPath[m_SkinPath.size() - 1];
|
m_SkinPath += L"\\";
|
||||||
if (ch != L'\\' && ch != L'/')
|
}
|
||||||
{
|
}
|
||||||
m_SkinPath += L"\\";
|
}
|
||||||
}
|
else if (bDefaultIniLocation)
|
||||||
|
{
|
||||||
|
// If the skin path is not defined in the Rainmeter.ini file use My Documents/Rainmeter/Skins
|
||||||
|
tmpSzPath[0] = L'\0';
|
||||||
|
HRESULT hr = SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, tmpSzPath);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
// Make the folders if they don't exist yet
|
||||||
|
m_SkinPath = tmpSzPath;
|
||||||
|
m_SkinPath += L"\\Rainmeter";
|
||||||
|
CreateDirectory(m_SkinPath.c_str(), NULL);
|
||||||
|
m_SkinPath += L"\\Skins\\";
|
||||||
|
DWORD result = CreateDirectory(m_SkinPath.c_str(), NULL);
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
// The folder was created successfully which means that it wasn't available yet.
|
||||||
|
// Copy the default skin to the Skins folder
|
||||||
|
std::wstring strFrom(m_Path + L"Skins\\*.*");
|
||||||
|
std::wstring strTo(m_SkinPath);
|
||||||
|
CSystem::CopyFiles(strFrom, strTo);
|
||||||
|
|
||||||
|
// This shouldn't be copied
|
||||||
|
std::wstring strNote = strTo + L"Read me before copying skins here.txt";
|
||||||
|
CSystem::RemoveFile(strNote);
|
||||||
|
|
||||||
|
// Copy also the themes to the %APPDATA%
|
||||||
|
strFrom = std::wstring(m_Path + L"Themes\\*.*");
|
||||||
|
strTo = std::wstring(GetSettingsPath() + L"Themes\\");
|
||||||
|
CreateDirectory(strTo.c_str(), NULL);
|
||||||
|
CSystem::CopyFiles(strFrom, strTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If the skin path is not defined in the Rainmeter.ini file use My Documents/Rainmeter/Skins
|
Log(LOG_WARNING, L"Unable to get the My Documents location.");
|
||||||
tmpSzPath[0] = L'\0';
|
|
||||||
HRESULT hr = SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, tmpSzPath);
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
|
||||||
// Make the folders if they don't exist yet
|
|
||||||
m_SkinPath = tmpSzPath;
|
|
||||||
m_SkinPath += L"\\Rainmeter";
|
|
||||||
CreateDirectory(m_SkinPath.c_str(), NULL);
|
|
||||||
m_SkinPath += L"\\Skins\\";
|
|
||||||
DWORD result = CreateDirectory(m_SkinPath.c_str(), NULL);
|
|
||||||
if (result != 0)
|
|
||||||
{
|
|
||||||
// The folder was created successfully which means that it wasn't available yet.
|
|
||||||
// Copy the default skin to the Skins folder
|
|
||||||
std::wstring strFrom(m_Path + L"Skins\\*.*");
|
|
||||||
std::wstring strTo(m_SkinPath);
|
|
||||||
CSystem::CopyFiles(strFrom, strTo);
|
|
||||||
|
|
||||||
// This shouldn't be copied
|
|
||||||
std::wstring strNote = strTo + L"Read me before copying skins here.txt";
|
|
||||||
CSystem::RemoveFile(strNote);
|
|
||||||
|
|
||||||
// Copy also the themes to the %APPDATA%
|
|
||||||
strFrom = std::wstring(m_Path + L"Themes\\*.*");
|
|
||||||
strTo = std::wstring(GetSettingsPath() + L"Themes\\");
|
|
||||||
CreateDirectory(strTo.c_str(), NULL);
|
|
||||||
CSystem::CopyFiles(strFrom, strTo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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);
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user