mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed that themes weren't loaded through Themes context menu if RainThemes was not installed.
This commit is contained in:
parent
38b4c4d865
commit
8c1e7f2dfc
@ -126,20 +126,6 @@ void CDialogManage::UpdateSkins(CMeterWindow* meterWindow, bool deleted)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** UpdateThemes
|
|
||||||
**
|
|
||||||
** Updates Themes tab.
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
void CDialogManage::UpdateThemes()
|
|
||||||
{
|
|
||||||
if (c_Dialog && c_Dialog->m_TabThemes && c_Dialog->m_TabThemes->IsInitialized())
|
|
||||||
{
|
|
||||||
c_Dialog->m_TabThemes->Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetTreeSelectionPath(HWND tree)
|
std::wstring GetTreeSelectionPath(HWND tree)
|
||||||
{
|
{
|
||||||
WCHAR buffer[MAX_PATH];
|
WCHAR buffer[MAX_PATH];
|
||||||
@ -1308,85 +1294,6 @@ void CDialogManage::CTabThemes::Initialize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** Update
|
|
||||||
**
|
|
||||||
** Loads new theme.
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
void CDialogManage::CTabThemes::Update()
|
|
||||||
{
|
|
||||||
if (m_LoadTheme)
|
|
||||||
{
|
|
||||||
// Called by ClearDeleteLaterList(), all MeterWindows have been deleted now so
|
|
||||||
// proceed to loading theme
|
|
||||||
m_LoadTheme = false;
|
|
||||||
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
|
||||||
|
|
||||||
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
|
|
||||||
int sel = ListBox_GetCurSel(item);
|
|
||||||
|
|
||||||
// Make a copy of current Rainmeter.ini
|
|
||||||
std::wstring backup = Rainmeter->GetSettingsPath() + L"Themes\\Backup";
|
|
||||||
CreateDirectory(backup.c_str(), NULL);
|
|
||||||
backup += L"\\Rainmeter.thm";
|
|
||||||
CSystem::CopyFiles(Rainmeter->GetIniFile(), backup);
|
|
||||||
|
|
||||||
// Replace Rainmeter.ini with theme
|
|
||||||
std::wstring theme = Rainmeter->GetSettingsPath() + L"Themes\\";
|
|
||||||
theme += themes[sel];
|
|
||||||
std::wstring wallpaper = theme + L"\\RainThemes.bmp";
|
|
||||||
theme += L"\\Rainmeter.thm";
|
|
||||||
CSystem::CopyFiles(theme, Rainmeter->GetIniFile());
|
|
||||||
|
|
||||||
PreserveSetting(backup, L"SkinPath");
|
|
||||||
PreserveSetting(backup, L"ConfigEditor");
|
|
||||||
PreserveSetting(backup, L"LogViewer");
|
|
||||||
PreserveSetting(backup, L"Logging");
|
|
||||||
PreserveSetting(backup, L"DisableVersionCheck");
|
|
||||||
PreserveSetting(backup, L"TrayExecuteL", false);
|
|
||||||
PreserveSetting(backup, L"TrayExecuteM", false);
|
|
||||||
PreserveSetting(backup, L"TrayExecuteR", false);
|
|
||||||
PreserveSetting(backup, L"TrayExecuteDM", false);
|
|
||||||
PreserveSetting(backup, L"TrayExecuteDR", false);
|
|
||||||
|
|
||||||
Rainmeter->ReadGeneralSettings(Rainmeter->GetIniFile());
|
|
||||||
|
|
||||||
if (_waccess(wallpaper.c_str(), 0) != -1)
|
|
||||||
{
|
|
||||||
// Set wallpaper
|
|
||||||
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create meter windows for active configs
|
|
||||||
const std::multimap<int, int>& configOrders = Rainmeter->m_ConfigOrders;
|
|
||||||
for (std::multimap<int, int>::const_iterator iter = configOrders.begin(); iter != configOrders.end(); ++iter)
|
|
||||||
{
|
|
||||||
const CRainmeter::CONFIG& config = Rainmeter->GetAllConfigs()[(*iter).second];
|
|
||||||
if (config.active > 0 && config.active <= (int)config.iniFiles.size())
|
|
||||||
{
|
|
||||||
Rainmeter->ActivateConfig((*iter).second, config.active - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON);
|
|
||||||
EnableWindow(item, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDialogManage::CTabThemes::PreserveSetting(const std::wstring& backupFile, LPCTSTR key, bool replace)
|
|
||||||
{
|
|
||||||
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
|
|
||||||
|
|
||||||
if ((replace || GetPrivateProfileString(L"Rainmeter", key, L"", buffer, 4, Rainmeter->GetIniFile().c_str()) == 0) &&
|
|
||||||
GetPrivateProfileString(L"Rainmeter", key, L"", buffer, MAX_LINE_LENGTH, backupFile.c_str()) > 0)
|
|
||||||
{
|
|
||||||
WritePrivateProfileString(L"Rainmeter", key, buffer, Rainmeter->GetIniFile().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** DlgProc
|
** DlgProc
|
||||||
**
|
**
|
||||||
@ -1566,23 +1473,9 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case IDC_MANAGETHEMES_LOAD_BUTTON:
|
case IDC_MANAGETHEMES_LOAD_BUTTON:
|
||||||
{
|
{
|
||||||
EnableWindow((HWND)lParam, FALSE);
|
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
|
||||||
m_LoadTheme = true;
|
int sel = ListBox_GetCurSel(item);
|
||||||
|
Rainmeter->LoadTheme(Rainmeter->m_Themes[sel]);
|
||||||
// Deactivate all skins
|
|
||||||
std::map<std::wstring, CMeterWindow*>& meterWindows = Rainmeter->GetAllMeterWindows();
|
|
||||||
if (!meterWindows.empty())
|
|
||||||
{
|
|
||||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = meterWindows.begin();
|
|
||||||
for ( ; iter != meterWindows.end(); ++iter)
|
|
||||||
{
|
|
||||||
Rainmeter->DeactivateConfig((*iter).second, -1, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2330,8 +2330,6 @@ void CRainmeter::ClearDeleteLaterList()
|
|||||||
}
|
}
|
||||||
while (!m_DelayDeleteList.empty());
|
while (!m_DelayDeleteList.empty());
|
||||||
|
|
||||||
|
|
||||||
CDialogManage::UpdateThemes();
|
|
||||||
CDialogAbout::UpdateSkins();
|
CDialogAbout::UpdateSkins();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3540,9 +3538,72 @@ void CRainmeter::RefreshAll()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CDialogAbout::UpdateSkins();
|
||||||
CDialogManage::UpdateSkins(NULL);
|
CDialogManage::UpdateSkins(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRainmeter::LoadTheme(const std::wstring& name)
|
||||||
|
{
|
||||||
|
// Delete all meter windows
|
||||||
|
DeleteMeterWindow(NULL, false);
|
||||||
|
|
||||||
|
// Make a copy of current Rainmeter.ini
|
||||||
|
std::wstring backup = GetSettingsPath() + L"Themes\\Backup";
|
||||||
|
CreateDirectory(backup.c_str(), NULL);
|
||||||
|
backup += L"\\Rainmeter.thm";
|
||||||
|
CSystem::CopyFiles(m_IniFile, backup);
|
||||||
|
|
||||||
|
// Replace Rainmeter.ini with theme
|
||||||
|
std::wstring theme = Rainmeter->GetSettingsPath() + L"Themes\\";
|
||||||
|
theme += name;
|
||||||
|
std::wstring wallpaper = theme + L"\\RainThemes.bmp";
|
||||||
|
theme += L"\\Rainmeter.thm";
|
||||||
|
CSystem::CopyFiles(theme, Rainmeter->GetIniFile());
|
||||||
|
|
||||||
|
PreserveSetting(backup, L"SkinPath");
|
||||||
|
PreserveSetting(backup, L"ConfigEditor");
|
||||||
|
PreserveSetting(backup, L"LogViewer");
|
||||||
|
PreserveSetting(backup, L"Logging");
|
||||||
|
PreserveSetting(backup, L"DisableVersionCheck");
|
||||||
|
PreserveSetting(backup, L"TrayExecuteL", false);
|
||||||
|
PreserveSetting(backup, L"TrayExecuteM", false);
|
||||||
|
PreserveSetting(backup, L"TrayExecuteR", false);
|
||||||
|
PreserveSetting(backup, L"TrayExecuteDM", false);
|
||||||
|
PreserveSetting(backup, L"TrayExecuteDR", false);
|
||||||
|
|
||||||
|
// Set wallpaper if it exists
|
||||||
|
if (_waccess(wallpaper.c_str(), 0) != -1)
|
||||||
|
{
|
||||||
|
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReloadSettings();
|
||||||
|
|
||||||
|
// Create meter windows for active configs
|
||||||
|
std::multimap<int, int>::const_iterator iter = m_ConfigOrders.begin();
|
||||||
|
for ( ; iter != m_ConfigOrders.end(); ++iter)
|
||||||
|
{
|
||||||
|
const CONFIG& config = m_ConfigStrings[(*iter).second];
|
||||||
|
if (config.active > 0 && config.active <= (int)config.iniFiles.size())
|
||||||
|
{
|
||||||
|
ActivateConfig((*iter).second, config.active - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRainmeter::PreserveSetting(const std::wstring& from, LPCTSTR key, bool replace)
|
||||||
|
{
|
||||||
|
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
|
||||||
|
|
||||||
|
if ((replace || GetPrivateProfileString(L"Rainmeter", key, L"", buffer, 4, m_IniFile.c_str()) == 0) &&
|
||||||
|
GetPrivateProfileString(L"Rainmeter", key, L"", buffer, MAX_LINE_LENGTH, from.c_str()) > 0)
|
||||||
|
{
|
||||||
|
WritePrivateProfileString(L"Rainmeter", key, buffer, m_IniFile.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
delete [] buffer;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** UpdateDesktopWorkArea
|
** UpdateDesktopWorkArea
|
||||||
**
|
**
|
||||||
|
@ -256,6 +256,9 @@ public:
|
|||||||
|
|
||||||
void RefreshAll();
|
void RefreshAll();
|
||||||
|
|
||||||
|
void LoadTheme(const std::wstring& name);
|
||||||
|
void PreserveSetting(const std::wstring& from, LPCTSTR key, bool replace = true);
|
||||||
|
|
||||||
void ClearDeleteLaterList();
|
void ClearDeleteLaterList();
|
||||||
|
|
||||||
static std::vector<std::wstring> ParseString(LPCTSTR str);
|
static std::vector<std::wstring> ParseString(LPCTSTR str);
|
||||||
|
@ -495,11 +495,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||||||
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
||||||
if (pos >= 0 && pos < (int)themes.size())
|
if (pos >= 0 && pos < (int)themes.size())
|
||||||
{
|
{
|
||||||
std::wstring command = L"\"" + Rainmeter->GetAddonPath();
|
Rainmeter->LoadTheme(themes[pos]);
|
||||||
command += L"RainThemes\\RainThemes.exe\" /load \"";
|
|
||||||
command += themes[pos];
|
|
||||||
command += L"\"";
|
|
||||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
|
else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
|
||||||
|
@ -78,7 +78,7 @@ void LuaManager::ReportErrors(lua_State* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::wstring str = L"Script: ";
|
std::wstring str = L"Script: ";
|
||||||
str += ConvertUTF8ToWide(error.c_str());
|
str += ConvertToWide(error.c_str());
|
||||||
Log(LOG_ERROR, str.c_str());
|
Log(LOG_ERROR, str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ void LuaManager::LuaLog(int nLevel, const char* format, ... )
|
|||||||
|
|
||||||
_set_invalid_parameter_handler(oldHandler);
|
_set_invalid_parameter_handler(oldHandler);
|
||||||
|
|
||||||
std::wstring str = ConvertUTF8ToWide(buffer);
|
std::wstring str = ConvertToWide(buffer);
|
||||||
Log(nLevel, str.c_str());
|
Log(nLevel, str.c_str());
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user