Changed Themes to Layouts

This commit is contained in:
Birunthan Mohanathas 2012-10-02 17:44:47 +03:00
parent 4a15878b9b
commit 3cae4f743c
13 changed files with 196 additions and 176 deletions

View File

@ -1,28 +0,0 @@
[Rainmeter]
[illustro\Clock]
Active=1
WindowX=(#SCREENAREAWIDTH#-200)
WindowY=0
[illustro\Disk]
Active=2
WindowX=(#SCREENAREAWIDTH#-200)
WindowY=176
[illustro\Feeds]
Active=1
WindowX=(#SCREENAREAWIDTH#-200)
WindowY=264
[illustro\System]
Active=1
WindowX=(#SCREENAREAWIDTH#-200)
WindowY=68
[illustro\Welcome]
Active=1
WindowX=50.000000%
WindowY=50.000000%
AnchorX=50.000000%
AnchorY=50.000000%

Binary file not shown.

View File

@ -40,7 +40,7 @@ CDialogManage* CDialogManage::c_Dialog = NULL;
*/
CDialogManage::CDialogManage(HWND wnd) : CDialog(wnd),
m_TabSkins(wnd),
m_TabThemes(wnd),
m_TabLayouts(wnd),
m_TabSettings(wnd)
{
}
@ -63,7 +63,8 @@ void CDialogManage::Open(const WCHAR* name)
if (name)
{
if (_wcsicmp(name, L"Themes") == 0)
if (_wcsicmp(name, L"Layouts") == 0 ||
_wcsicmp(name, L"Themes") == 0) // For backwards compatibility.
{
tab = 1;
}
@ -146,7 +147,7 @@ CDialog::CTab& CDialogManage::GetActiveTab()
}
else if (sel == 1)
{
return m_TabThemes;
return m_TabLayouts;
}
else // if (sel == 2)
{
@ -283,7 +284,7 @@ INT_PTR CDialogManage::OnNotify(WPARAM wParam, LPARAM lParam)
{
// Disable all tab windows first
EnableWindow(m_TabSkins.GetWindow(), FALSE);
EnableWindow(m_TabThemes.GetWindow(), FALSE);
EnableWindow(m_TabLayouts.GetWindow(), FALSE);
EnableWindow(m_TabSettings.GetWindow(), FALSE);
GetActiveTab().Activate();
@ -1321,7 +1322,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
// -----------------------------------------------------------------------------------------------
//
// Themes tab
// Layouts tab
//
// -----------------------------------------------------------------------------------------------
@ -1329,7 +1330,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
** Constructor.
**
*/
CDialogManage::CTabThemes::CTabThemes(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_MANAGETHEMES_DIALOG, DlgProc)
CDialogManage::CTabLayouts::CTabLayouts(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_MANAGETHEMES_DIALOG, DlgProc)
{
}
@ -1337,34 +1338,34 @@ CDialogManage::CTabThemes::CTabThemes(HWND owner) : CTab(Rainmeter->GetResourceI
** Called when tab is displayed.
**
*/
void CDialogManage::CTabThemes::Initialize()
void CDialogManage::CTabLayouts::Initialize()
{
m_Initialized = true;
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
for (int i = 0, isize = themes.size(); i < isize; ++i)
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
for (int i = 0, isize = layouts.size(); i < isize; ++i)
{
ListBox_AddString(item, themes[i].c_str());
ListBox_AddString(item, layouts[i].c_str());
}
}
/*
** Dialog procedure for the Themes tab.
** Dialog procedure for the Layouts tab.
**
*/
INT_PTR CALLBACK CDialogManage::CTabThemes::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK CDialogManage::CTabLayouts::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
return c_Dialog->m_TabThemes.OnCommand(wParam, lParam);
return c_Dialog->m_TabLayouts.OnCommand(wParam, lParam);
}
return FALSE;
}
INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
INT_PTR CDialogManage::CTabLayouts::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch (LOWORD(wParam))
{
@ -1407,12 +1408,12 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EDIT_BUTTON);
EnableWindow(item, TRUE);
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
int sel = ListBox_GetCurSel(item);
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
Edit_SetText(item, themes[sel].c_str());
Edit_SetText(item, layouts[sel].c_str());
}
}
break;
@ -1423,15 +1424,15 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT);
Edit_GetText(item, buffer, MAX_PATH);
std::wstring theme = buffer;
std::wstring path = Rainmeter->GetThemePath();
std::wstring layout = buffer;
std::wstring path = Rainmeter->GetLayoutPath();
CreateDirectory(path.c_str(), 0);
path += theme;
path += layout;
bool alreadyExists = (_waccess(path.c_str(), 0) != -1);
if (alreadyExists)
{
std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, theme.c_str());
std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, layout.c_str());
if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES)
{
// Cancel
@ -1444,7 +1445,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
CreateDirectory(path.c_str(), NULL);
}
path += L"\\Rainmeter.thm";
path += L"\\Rainmeter.ini";
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX);
if (Button_GetCheck(item) != BST_CHECKED)
@ -1482,14 +1483,14 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
if (SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, &buffer, 0))
{
std::wstring::size_type pos = path.find_last_of(L'\\');
path.replace(pos + 1, path.length() - pos - 1, L"RainThemes.bmp");
path.replace(pos + 1, path.length() - pos - 1, L"Wallpaper.bmp");
CSystem::CopyFiles((std::wstring)buffer, path);
}
}
}
else
{
// Create empty theme
// Create empty layout
HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file == INVALID_HANDLE_VALUE)
{
@ -1504,9 +1505,9 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
if (!alreadyExists)
{
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
ListBox_AddString(item, theme.c_str());
ListBox_AddString(item, layout.c_str());
Rainmeter->ScanForThemes();
Rainmeter->ScanForLayouts();
}
}
break;
@ -1515,7 +1516,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
{
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
int sel = ListBox_GetCurSel(item);
Rainmeter->LoadTheme(Rainmeter->m_Themes[sel]);
Rainmeter->LoadLayout(Rainmeter->m_Layouts[sel]);
}
break;
@ -1523,11 +1524,11 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
{
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
int sel = ListBox_GetCurSel(item);
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
std::wstring args = L"\"" + Rainmeter->GetThemePath();
args += themes[sel];
args += L"\\Rainmeter.thm";
std::wstring args = L"\"" + Rainmeter->GetLayoutPath();
args += layouts[sel];
args += L"\\Rainmeter.ini";
args += L'"';
RunFile(Rainmeter->GetSkinEditor().c_str(), args.c_str());
}
@ -1537,29 +1538,29 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
{
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
int sel = ListBox_GetCurSel(item);
std::vector<std::wstring>& themes = const_cast<std::vector<std::wstring>&>(Rainmeter->GetAllThemes());
std::vector<std::wstring>& layouts = const_cast<std::vector<std::wstring>&>(Rainmeter->GetAllLayouts());
std::wstring text = GetFormattedString(ID_STR_THEMEDELETE, themes[sel].c_str());
std::wstring text = GetFormattedString(ID_STR_THEMEDELETE, layouts[sel].c_str());
if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONQUESTION | MB_YESNO) != IDYES)
{
// Cancel
break;
}
std::wstring folder = Rainmeter->GetThemePath();
folder += themes[sel];
std::wstring folder = Rainmeter->GetLayoutPath();
folder += layouts[sel];
if (CSystem::RemoveFolder(folder))
{
ListBox_DeleteString(item, sel);
// Remove theme from vector
std::vector<std::wstring>::iterator iter = themes.begin();
for ( ; iter != themes.end(); ++iter)
// Remove layout from vector
std::vector<std::wstring>::iterator iter = layouts.begin();
for ( ; iter != layouts.end(); ++iter)
{
if (wcscmp(themes[sel].c_str(), (*iter).c_str()) == 0)
if (wcscmp(layouts[sel].c_str(), (*iter).c_str()) == 0)
{
themes.erase(iter);
layouts.erase(iter);
break;
}
}

View File

@ -76,11 +76,11 @@ private:
bool m_IgnoreUpdate;
};
// Themes tab
class CTabThemes : public CTab
// Layouts tab
class CTabLayouts : public CTab
{
public:
CTabThemes(HWND owner);
CTabLayouts(HWND owner);
virtual void Initialize();
@ -104,7 +104,7 @@ private:
CTab& GetActiveTab();
CTabSkins m_TabSkins;
CTabThemes m_TabThemes;
CTabLayouts m_TabLayouts;
CTabSettings m_TabSettings;
};

View File

@ -922,7 +922,7 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
m_SkinPath = m_Path + L"Skins\\";
}
// Create user skins, themes, addons, and plugins folders if needed
// Create user skins, layouts, addons, and plugins folders if needed
CreateComponentFolders(bDefaultIniLocation);
delete [] buffer;
@ -1153,8 +1153,8 @@ void CRainmeter::CreateOptionsFile()
{
CreateDirectory(m_SettingsPath.c_str(), NULL);
std::wstring defaultIni = GetDefaultThemePath();
defaultIni += L"illustro default\\Rainmeter.thm";
std::wstring defaultIni = GetDefaultLayoutPath();
defaultIni += L"illustro default\\Rainmeter.ini";
CSystem::CopyFiles(defaultIni, m_IniFile);
}
@ -1202,13 +1202,61 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
}
}
path = GetThemePath();
path = GetLayoutPath();
if (_waccess(path.c_str(), 0) == -1)
{
std::wstring from = GetDefaultThemePath();
if (_waccess(from.c_str(), 0) != -1)
// TODO: If Skin Installer creates Layouts first, old Themes is not migrated.
std::wstring themesPath = m_SettingsPath + L"Themes";
if (_waccess(themesPath.c_str(), 0) != -1)
{
CSystem::CopyFiles(from, m_SettingsPath);
// Migrate Themes into Layouts for backwards compatibility and rename
// Rainmeter.thm to Rainmeter.ini and RainThemes.bmp to Wallpaper.bmp.
MoveFile(themesPath.c_str(), path.c_str());
path += L'*'; // For FindFirstFile.
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(path.c_str(), &fd);
path.pop_back(); // Remove '*'.
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
wcscmp(L".", fd.cFileName) != 0 &&
wcscmp(L"..", fd.cFileName) != 0)
{
std::wstring layoutFolder = path + fd.cFileName;
layoutFolder += L'\\';
std::wstring file = layoutFolder + L"Rainmeter.thm";
if (_waccess(file.c_str(), 0) != -1)
{
std::wstring newFile = layoutFolder + L"Rainmeter.ini";
MoveFile(file.c_str(), newFile.c_str());
}
file = layoutFolder + L"RainThemes.bmp";
if (_waccess(file.c_str(), 0) != -1)
{
std::wstring newFile = layoutFolder + L"Wallpaper.ini";
MoveFile(file.c_str(), newFile.c_str());
}
}
}
while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
else
{
std::wstring from = GetDefaultLayoutPath();
if (_waccess(from.c_str(), 0) != -1)
{
CSystem::CopyFiles(from, m_SettingsPath);
}
}
}
else
@ -1216,7 +1264,7 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
path += L"Backup";
if (_waccess(path.c_str(), 0) != -1)
{
std::wstring newPath = GetThemePath();
std::wstring newPath = GetLayoutPath();
newPath += L"@Backup";
MoveFile(path.c_str(), newPath.c_str());
}
@ -1277,7 +1325,7 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
void CRainmeter::ReloadSettings()
{
ScanForSkins();
ScanForThemes();
ScanForLayouts();
ReadGeneralSettings(m_IniFile);
}
@ -1789,17 +1837,17 @@ int CRainmeter::ScanForSkinsRecursive(const std::wstring& path, std::wstring bas
}
/*
** Scans the given folder for themes
** Scans the given folder for layouts
*/
void CRainmeter::ScanForThemes()
void CRainmeter::ScanForLayouts()
{
m_Themes.clear();
m_Layouts.clear();
WIN32_FIND_DATA fileData; // Data structure describes the file found
HANDLE hSearch; // Search handle returned by FindFirstFile
// Scan for folders
std::wstring folders = GetThemePath();
std::wstring folders = GetLayoutPath();
folders += L'*';
hSearch = FindFirstFileEx(
@ -1818,7 +1866,7 @@ void CRainmeter::ScanForThemes()
wcscmp(L".", fileData.cFileName) != 0 &&
wcscmp(L"..", fileData.cFileName) != 0)
{
m_Themes.push_back(fileData.cFileName);
m_Layouts.push_back(fileData.cFileName);
}
}
while (FindNextFile(hSearch, &fileData));
@ -2482,15 +2530,15 @@ void CRainmeter::RefreshAll()
CDialogManage::UpdateSkins(NULL);
}
void CRainmeter::LoadTheme(const std::wstring& name)
void CRainmeter::LoadLayout(const std::wstring& name)
{
// Delete all meter windows
DeleteMeterWindow(NULL);
std::wstring backup = GetThemePath();
std::wstring backup = GetLayoutPath();
backup += L"@Backup";
CreateDirectory(backup.c_str(), NULL);
backup += L"\\Rainmeter.thm";
backup += L"\\Rainmeter.ini";
if (_wcsicmp(name.c_str(), L"@Backup") == 0)
{
@ -2502,12 +2550,12 @@ void CRainmeter::LoadTheme(const std::wstring& name)
// Make a copy of current Rainmeter.ini
CSystem::CopyFiles(m_IniFile, backup);
// Replace Rainmeter.ini with theme
std::wstring theme = GetThemePath();
theme += name;
std::wstring wallpaper = theme + L"\\RainThemes.bmp";
theme += L"\\Rainmeter.thm";
CSystem::CopyFiles(theme, GetIniFile());
// Replace Rainmeter.ini with layout
std::wstring layout = GetLayoutPath();
layout += name;
std::wstring wallpaper = layout + L"\\Wallpaper.bmp";
layout += L"\\Rainmeter.ini";
CSystem::CopyFiles(layout, GetIniFile());
PreserveSetting(backup, L"SkinPath");
PreserveSetting(backup, L"ConfigEditor");
@ -2797,13 +2845,13 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
}
}
HMENU themeMenu = GetSubMenu(subMenu, 5);
if (themeMenu)
HMENU layoutMenu = GetSubMenu(subMenu, 5);
if (layoutMenu)
{
if (!m_Themes.empty())
if (!m_Layouts.empty())
{
DeleteMenu(themeMenu, 0, MF_BYPOSITION); // "No themes available" menuitem
CreateThemeMenu(themeMenu);
DeleteMenu(layoutMenu, 0, MF_BYPOSITION); // "No layouts available" menuitem
CreateLayoutMenu(layoutMenu);
}
}
@ -3115,11 +3163,11 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU men
return skinMenu;
}
void CRainmeter::CreateThemeMenu(HMENU themeMenu)
void CRainmeter::CreateLayoutMenu(HMENU layoutMenu)
{
for (size_t i = 0, isize = m_Themes.size(); i < isize; ++i)
for (size_t i = 0, isize = m_Layouts.size(); i < isize; ++i)
{
InsertMenu(themeMenu, i, MF_BYPOSITION, ID_THEME_FIRST + i, m_Themes[i].c_str());
InsertMenu(layoutMenu, i, MF_BYPOSITION, ID_THEME_FIRST + i, m_Layouts[i].c_str());
}
}

View File

@ -124,7 +124,7 @@ public:
int FindSkinFolderIndex(const std::wstring& folderPath);
const std::vector<SkinFolder>& GetFolders() { return m_SkinFolders; }
const std::vector<std::wstring>& GetAllThemes() { return m_Themes; }
const std::vector<std::wstring>& GetAllLayouts() { return m_Layouts; }
void DeleteMeterWindow(CMeterWindow* meterWindow, bool force = false);
@ -138,7 +138,7 @@ public:
const std::wstring& GetLogFile() { return m_LogFile; }
const std::wstring& GetSettingsPath() { return m_SettingsPath; }
const std::wstring& GetSkinPath() { return m_SkinPath; }
std::wstring GetThemePath() { return m_SettingsPath + L"Themes\\"; }
std::wstring GetLayoutPath() { return m_SettingsPath + L"Layouts\\"; }
std::wstring GetPluginPath() { return m_Path + L"Plugins\\"; }
std::wstring GetUserPluginPath() { return m_SettingsPath + L"Plugins\\"; }
std::wstring GetAddonPath() { return m_SettingsPath + L"Addons\\"; }
@ -146,7 +146,7 @@ public:
bool HasUserPluginPath() { return (_wcsicmp(m_Path.c_str(), m_SettingsPath.c_str()) != 0); }
std::wstring GetDefaultSkinPath() { return m_Path + L"Defaults\\Skins\\"; }
std::wstring GetDefaultThemePath() { return m_Path + L"Defaults\\Themes\\"; }
std::wstring GetDefaultLayoutPath() { return m_Path + L"Defaults\\Layouts\\"; }
std::wstring GetDefaultPluginPath() { return m_Path + L"Defaults\\Plugins\\"; }
std::wstring GetDefaultAddonPath() { return m_Path + L"Defaults\\Addons\\"; }
@ -215,7 +215,7 @@ public:
void RefreshAll();
void LoadTheme(const std::wstring& name);
void LoadLayout(const std::wstring& name);
void PreserveSetting(const std::wstring& from, LPCTSTR key, bool replace = true);
static std::vector<std::wstring> ParseString(LPCTSTR str, CConfigParser* parser = NULL);
@ -244,7 +244,7 @@ private:
void CreateMeterWindow(const std::wstring& folderPath, const std::wstring& file);
void WriteActive(const std::wstring& folderPath, int fileIndex);
void ScanForSkins();
void ScanForThemes();
void ScanForLayouts();
void ReadGeneralSettings(const std::wstring& iniFile);
void SetLoadOrder(int folderIndex, int order);
int GetLoadOrder(const std::wstring& folderPath);
@ -256,7 +256,7 @@ private:
void CreateAllSkinsMenu(HMENU skinMenu) { CreateAllSkinsMenuRecursive(skinMenu, 0); }
int CreateAllSkinsMenuRecursive(HMENU skinMenu, int index);
void CreateThemeMenu(HMENU themeMenu);
void CreateLayoutMenu(HMENU layoutMenu);
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
void CreateOptionsFile();
void CreateDataFile();
@ -269,7 +269,7 @@ private:
std::vector<SkinFolder> m_SkinFolders;
std::multimap<int, int> m_SkinOrders;
std::map<std::wstring, CMeterWindow*> m_MeterWindows;
std::vector<std::wstring> m_Themes;
std::vector<std::wstring> m_Layouts;
std::wstring m_Path;
std::wstring m_IniFile;

View File

@ -513,10 +513,10 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{
int pos = (wParam & 0x0ffff) - ID_THEME_FIRST;
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
if (pos >= 0 && pos < (int)themes.size())
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
if (pos >= 0 && pos < (int)layouts.size())
{
Rainmeter->LoadTheme(themes[pos]);
Rainmeter->LoadLayout(layouts[pos]);
}
}
else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)

View File

@ -125,7 +125,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
if (*lpCmdLine && CloseRainmeterIfActive())
{
CDialogInstall::LoadTheme(lpCmdLine, true);
CDialogInstall::LoadLayout(lpCmdLine, true);
std::wstring file = g_Data.programPath + L"Rainmeter.exe";
SHELLEXECUTEINFO sei = {0};

View File

@ -517,9 +517,9 @@ bool CDialogInstall::ReadPackage()
}
else if (_wcsicmp(component, m_PackageFormat == PackageFormat::New ? L"Layouts" : L"Themes") == 0 &&
_wcsicmp(extension, m_PackageFormat == PackageFormat::New ? L".ini" : L".thm") == 0 &&
!IsIgnoredTheme(itemSz))
!IsIgnoredLayout(itemSz))
{
m_PackageThemes.insert(item);
m_PackageLayouts.insert(item);
}
else if (_wcsicmp(component, L"Addons") == 0 &&
m_PackageFormat == PackageFormat::Old &&
@ -561,7 +561,7 @@ bool CDialogInstall::ReadPackage()
m_PackageFonts.clear();
}
return !(m_PackageSkins.empty() && m_PackageThemes.empty() &&
return !(m_PackageSkins.empty() && m_PackageLayouts.empty() &&
m_PackageAddons.empty() && m_PackageFonts.empty() && m_PackagePlugins.empty());
}
@ -631,7 +631,7 @@ bool CDialogInstall::ReadOptions(const WCHAR* file)
}
else
{
m_LoadTheme = buffer;
m_LoadLayout = buffer;
}
}
@ -801,30 +801,30 @@ bool CDialogInstall::InstallPackage()
}
else if (_wcsicmp(component, m_PackageFormat == PackageFormat::New ? L"Layouts" : L"Themes") == 0 &&
_wcsicmp(extension, m_PackageFormat == PackageFormat::New ? L".ini" : L".thm") == 0 &&
m_PackageThemes.find(item) != m_PackageThemes.end())
m_PackageLayouts.find(item) != m_PackageLayouts.end())
{
if (m_PackageFormat == PackageFormat::New)
if (m_PackageFormat == PackageFormat::Old)
{
wcscpy_s(extension, 5, L".thm");
wcscpy_s(extension, 5, L".ini");
}
targetPath = g_Data.settingsPath;
targetPath += L"Themes\\";
targetPath += L"Layouts\\";
targetPath += path;
error = !ExtractCurrentFile(targetPath);
if (!error)
{
// Remove user specific options
const WCHAR* theme = targetPath.c_str();
WritePrivateProfileString(L"Rainmeter", L"SkinPath", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"Language", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"Logging", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"ConfigEditor", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"LogViewer", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"DisableDragging", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"DisableRDP", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"DisableVersionCheck", NULL, theme);
WritePrivateProfileString(L"Rainmeter", L"Debug", NULL, theme);
const WCHAR* layout = targetPath.c_str();
WritePrivateProfileString(L"Rainmeter", L"SkinPath", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"Language", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"Logging", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"ConfigEditor", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"LogViewer", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"DisableDragging", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"DisableRDP", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"DisableVersionCheck", NULL, layout);
WritePrivateProfileString(L"Rainmeter", L"Debug", NULL, layout);
}
}
}
@ -881,7 +881,7 @@ void CDialogInstall::BeginInstall()
item = GetDlgItem(m_TabInstall.GetWindow(), IDC_INSTALLTAB_THEME_CHECKBOX);
if (Button_GetCheck(item) == BST_UNCHECKED)
{
m_LoadTheme.clear();
m_LoadLayout.clear();
m_LoadSkins.clear();
}
EnableWindow(item, FALSE);
@ -903,7 +903,7 @@ void CDialogInstall::BeginInstall()
switch (lvi.iGroupId)
{
case 0: component = &m_PackageSkins; break;
case 1: component = &m_PackageThemes; break;
case 1: component = &m_PackageLayouts; break;
case 2: component = &m_PackageAddons; break;
case 3: component = &m_PackagePlugins; break;
}
@ -956,7 +956,7 @@ UINT __stdcall CDialogInstall::InstallThread(void* pParam)
MessageBox(dialog->m_Window, dialog->m_ErrorMessage.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
dialog->m_LoadSkins.clear();
dialog->m_LoadTheme.clear();
dialog->m_LoadLayout.clear();
}
dialog->LaunchRainmeter();
@ -1054,13 +1054,13 @@ void CDialogInstall::KeepVariables()
}
}
void CDialogInstall::LoadTheme(const std::wstring& name, bool setWallpaper)
void CDialogInstall::LoadLayout(const std::wstring& name, bool setWallpaper)
{
// Take a copy of current Rainmeter.ini before doing anything
std::wstring backupFile = g_Data.settingsPath;
backupFile += L"Themes\\@Backup\\";
backupFile += L"Layouts\\@Backup\\";
CreateDirectory(backupFile.c_str(), NULL);
backupFile += L"Rainmeter.thm";
backupFile += L"Rainmeter.ini";
CopyFiles(g_Data.iniFile, backupFile, false);
if (name.empty())
@ -1068,14 +1068,14 @@ void CDialogInstall::LoadTheme(const std::wstring& name, bool setWallpaper)
return;
}
std::wstring themeFile = g_Data.settingsPath;
themeFile += L"Themes\\";
themeFile += name;
std::wstring wallpaperFile = themeFile + L"\\RainThemes.bmp";
themeFile += L"\\Rainmeter.thm";
if (_waccess(themeFile.c_str(), 0) != -1)
std::wstring layoutFile = g_Data.settingsPath;
layoutFile += L"Layouts\\";
layoutFile += name;
std::wstring wallpaperFile = layoutFile + L"\\Wallpaper.bmp";
layoutFile += L"\\Rainmeter.ini";
if (_waccess(layoutFile.c_str(), 0) != -1)
{
CopyFiles(themeFile, g_Data.iniFile, false);
CopyFiles(layoutFile, g_Data.iniFile, false);
const WCHAR* iniFileSz = g_Data.iniFile.c_str();
const WCHAR* backupFileSz = backupFile.c_str();
@ -1112,8 +1112,8 @@ void CDialogInstall::LoadTheme(const std::wstring& name, bool setWallpaper)
void CDialogInstall::LaunchRainmeter()
{
// Backup Rainmeter.ini and load theme (if specified)
LoadTheme(m_LoadTheme, false);
// Backup Rainmeter.ini and load layout (if specified)
LoadLayout(m_LoadLayout, false);
// Execute Rainmeter and wait up to a minute for it process all messages
std::wstring rainmeterExe = g_Data.programPath + L"Rainmeter.exe";
@ -1164,7 +1164,7 @@ bool CDialogInstall::IsIgnoredSkin(const WCHAR* name)
_wcsicmp(name, L"@Backup") == 0;
}
bool CDialogInstall::IsIgnoredTheme(const WCHAR* name)
bool CDialogInstall::IsIgnoredLayout(const WCHAR* name)
{
return _wcsicmp(name, L"Backup") == 0 ||
_wcsicmp(name, L"@Backup") == 0;
@ -1439,12 +1439,12 @@ void CDialogInstall::CTabInstall::Initialize()
};
addComponent(L"Skins", c_Dialog->m_PackageSkins, g_Data.skinsPath, 0);
addComponent(L"Themes", c_Dialog->m_PackageThemes, g_Data.settingsPath + L"Themes\\", 1);
addComponent(L"Layouts", c_Dialog->m_PackageLayouts, g_Data.settingsPath + L"Layouts\\", 1);
addComponent(L"Addons", c_Dialog->m_PackageAddons, g_Data.settingsPath + L"Addons\\", 2);
addComponent(L"Plugins", c_Dialog->m_PackagePlugins, g_Data.settingsPath + L"Plugins\\", 3);
item = GetDlgItem(m_Window, IDC_INSTALLTAB_THEME_CHECKBOX);
if (!c_Dialog->m_LoadTheme.empty())
if (!c_Dialog->m_LoadLayout.empty())
{
Button_SetCheck(item, BST_CHECKED);
}

View File

@ -33,7 +33,7 @@ public:
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
static void LoadTheme(const std::wstring& name, bool setWallpaper);
static void LoadLayout(const std::wstring& name, bool setWallpaper);
static CDialogInstall* c_Dialog;
@ -93,7 +93,7 @@ private:
void KeepVariables();
static bool IsIgnoredSkin(const WCHAR* name);
static bool IsIgnoredTheme(const WCHAR* name);
static bool IsIgnoredLayout(const WCHAR* name);
static bool IsIgnoredAddon(const WCHAR* name);
static bool IsIgnoredPlugin(const WCHAR* name);
@ -117,7 +117,7 @@ private:
std::wstring m_PackageRoot;
PackageFormat m_PackageFormat;
std::set<std::wstring> m_PackageSkins;
std::set<std::wstring> m_PackageThemes;
std::set<std::wstring> m_PackageLayouts;
std::set<std::wstring> m_PackageAddons;
std::set<std::wstring> m_PackageFonts;
std::set<std::wstring> m_PackagePlugins;
@ -128,7 +128,7 @@ private:
bool m_SystemFonts;
std::vector<std::wstring> m_VariablesFiles;
std::vector<std::wstring> m_LoadSkins;
std::wstring m_LoadTheme;
std::wstring m_LoadLayout;
};
#endif

View File

@ -34,7 +34,7 @@ CDialogPackage::CDialogPackage(HWND wnd) : CDialog(wnd),
m_TabInfo(wnd),
m_TabOptions(wnd),
m_TabAdvanced(wnd),
m_LoadTheme(false),
m_LoadLayout(false),
m_MergeSkins(false),
m_PackagerThread(),
m_ZipFile()
@ -246,7 +246,7 @@ bool CDialogPackage::CreatePackage()
if (!c_Dialog->m_Load.empty())
{
WritePrivateProfileString(L"rmskin", L"LoadType", c_Dialog->m_LoadTheme ? L"Layout" : L"Skin", tempFile);
WritePrivateProfileString(L"rmskin", L"LoadType", c_Dialog->m_LoadLayout ? L"Layout" : L"Skin", tempFile);
WritePrivateProfileString(L"rmskin", L"Load", c_Dialog->m_Load.c_str(), tempFile);
}
@ -293,15 +293,15 @@ bool CDialogPackage::CreatePackage()
}
}
// Add themes
for (auto iter = m_ThemeFolders.cbegin(); iter != m_ThemeFolders.cend(); ++iter)
// Add layouts
for (auto iter = m_LayoutFolders.cbegin(); iter != m_LayoutFolders.cend(); ++iter)
{
std::wstring realPath = (*iter).second + L"Rainmeter.thm";
std::wstring realPath = (*iter).second + L"Rainmeter.ini";
std::wstring zipPath = L"Layouts\\" + (*iter).first;
zipPath += L"\\Rainmeter.ini";
if (!AddFileToPackage(realPath.c_str(), zipPath.c_str()))
{
std::wstring error = L"Error adding theme '";
std::wstring error = L"Error adding layout '";
error += (*iter).first;
error += L"'.";
error += L"\n\nClick OK to close Packager.";
@ -846,7 +846,7 @@ void CDialogPackage::CTabInfo::Initialize()
lvg.pszHeader = L"Skin";
ListView_InsertGroup(item, -1, &lvg);
lvg.iGroupId = 1;
lvg.pszHeader = L"Themes";
lvg.pszHeader = L"Layouts";
ListView_InsertGroup(item, -1, &lvg);
lvg.iGroupId = 2;
lvg.pszHeader = L"Plugins";
@ -896,18 +896,18 @@ INT_PTR CDialogPackage::CTabInfo::OnCommand(WPARAM wParam, LPARAM lParam)
case IDC_PACKAGEINFO_ADDTHEME_BUTTON:
{
std::wstring folder = SelectFolder(m_Window, g_Data.settingsPath + L"Themes\\");
std::wstring folder = SelectFolder(m_Window, g_Data.settingsPath + L"Layouts\\");
if (!folder.empty())
{
std::wstring name = PathFindFileName(folder.c_str());
name.pop_back(); // Remove slash
if (c_Dialog->m_ThemeFolders.insert(std::make_pair(name, folder)).second)
if (c_Dialog->m_LayoutFolders.insert(std::make_pair(name, folder)).second)
{
HWND item = GetDlgItem(m_Window, IDC_PACKAGEINFO_COMPONENTS_LIST);
LVITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_GROUPID;
lvi.iItem = c_Dialog->m_ThemeFolders.size() + 1;
lvi.iItem = c_Dialog->m_LayoutFolders.size() + 1;
lvi.iSubItem = 0;
lvi.iGroupId = 1;
lvi.pszText = (WCHAR*)name.c_str();
@ -968,7 +968,7 @@ INT_PTR CDialogPackage::CTabInfo::OnCommand(WPARAM wParam, LPARAM lParam)
break;
case 1:
c_Dialog->m_ThemeFolders.erase(c_Dialog->m_ThemeFolders.find(name));
c_Dialog->m_LayoutFolders.erase(c_Dialog->m_LayoutFolders.find(name));
break;
case 2:
@ -1083,7 +1083,7 @@ void CDialogPackage::CTabOptions::Initialize()
SetWindowText(item,c_Dialog->m_TargetFile.c_str());
item = GetDlgItem(m_Window, IDC_PACKAGEOPTIONS_LOADTHEME_RADIO);
if (c_Dialog->m_ThemeFolders.empty())
if (c_Dialog->m_LayoutFolders.empty())
{
EnableWindow(item, FALSE);
@ -1092,15 +1092,15 @@ void CDialogPackage::CTabOptions::Initialize()
}
else
{
c_Dialog->m_LoadTheme = true;
c_Dialog->m_Load = (*c_Dialog->m_ThemeFolders.cbegin()).first;
c_Dialog->m_LoadLayout = true;
c_Dialog->m_Load = (*c_Dialog->m_LayoutFolders.cbegin()).first;
Button_SetCheck(item, BST_CHECKED);
item = GetDlgItem(m_Window, IDC_PACKAGEOPTIONS_LOADTHEME_COMBO);
ShowWindow(item, SW_SHOWNORMAL);
for (auto iter = c_Dialog->m_ThemeFolders.cbegin(); iter != c_Dialog->m_ThemeFolders.cend(); ++iter)
for (auto iter = c_Dialog->m_LayoutFolders.cbegin(); iter != c_Dialog->m_LayoutFolders.cend(); ++iter)
{
ComboBox_AddString(item, (*iter).first.c_str());
}
@ -1181,7 +1181,7 @@ INT_PTR CDialogPackage::CTabOptions::OnCommand(WPARAM wParam, LPARAM lParam)
WCHAR buffer[MAX_PATH];
GetWindowText(item, buffer, _countof(buffer));
c_Dialog->m_Load = buffer;
c_Dialog->m_LoadTheme = false;
c_Dialog->m_LoadLayout = false;
item = GetDlgItem(m_Window, IDC_PACKAGEOPTIONS_LOADSKINBROWSE_BUTTON);
ShowWindow(item, SW_SHOWNORMAL);
@ -1202,7 +1202,7 @@ INT_PTR CDialogPackage::CTabOptions::OnCommand(WPARAM wParam, LPARAM lParam)
WCHAR buffer[MAX_PATH];
GetWindowText(item, buffer, _countof(buffer));
c_Dialog->m_Load = buffer;
c_Dialog->m_LoadTheme = true;
c_Dialog->m_LoadLayout = true;
}
break;

View File

@ -104,14 +104,14 @@ private:
std::wstring m_Author;
std::wstring m_Version;
std::pair<std::wstring, std::wstring> m_SkinFolder;
std::map<std::wstring, std::wstring> m_ThemeFolders;
std::map<std::wstring, std::wstring> m_LayoutFolders;
std::map<std::wstring, std::pair<std::wstring, std::wstring>> m_PluginFolders;
// Options tab
std::wstring m_TargetFile;
std::wstring m_MinimumRainmeter;
std::wstring m_MinimumWindows;
bool m_LoadTheme;
bool m_LoadLayout;
std::wstring m_Load;
// Advanced tab

View File

@ -94,7 +94,7 @@ FONT 8, "MS Shell Dlg 2"
GROUPBOX "Components", IDC_STATIC, 0, 110, 270, 108
CONTROL "", IDC_PACKAGEINFO_COMPONENTS_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 6, 125, 182, 86
PUSHBUTTON "Add skin...", IDC_PACKAGEINFO_ADDSKIN_BUTTON, 194, 125, 70, 14
PUSHBUTTON "Add theme...", IDC_PACKAGEINFO_ADDTHEME_BUTTON, 194, 144, 70, 14
PUSHBUTTON "Add layout...", IDC_PACKAGEINFO_ADDTHEME_BUTTON, 194, 144, 70, 14
PUSHBUTTON "Add plugin...", IDC_PACKAGEINFO_ADDPLUGIN_BUTTON, 194, 162, 70, 14
PUSHBUTTON "Remove", IDC_PACKAGEINFO_REMOVE_BUTTON, 194, 197, 70, 14, WS_DISABLED
CONTROL "<A>What is a .rmskin package?</A>", IDC_PACKAGEINFO_WHATIS_LINK, "SysLink", 0x0, 0, 225, 264, 9
@ -114,7 +114,7 @@ FONT 8, "MS Shell Dlg 2"
AUTORADIOBUTTON "Load skin", IDC_PACKAGEOPTIONS_LOADSKIN_RADIO, 6, 129, 85, 9, WS_TABSTOP
EDITTEXT IDC_PACKAGEOPTIONS_LOADSKIN_EDIT, 96, 126, 138, 14, ES_READONLY | ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP | NOT WS_VISIBLE
PUSHBUTTON "...", IDC_PACKAGEOPTIONS_LOADSKINBROWSE_BUTTON, 239, 126, 25, 14, WS_TABSTOP | NOT WS_VISIBLE
AUTORADIOBUTTON "Load theme", IDC_PACKAGEOPTIONS_LOADTHEME_RADIO, 6, 142, 85, 9, WS_TABSTOP
AUTORADIOBUTTON "Load layout", IDC_PACKAGEOPTIONS_LOADTHEME_RADIO, 6, 142, 85, 9, WS_TABSTOP
COMBOBOX IDC_PACKAGEOPTIONS_LOADTHEME_COMBO, 96, 139, 168, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | NOT WS_VISIBLE
GROUPBOX "Minimum requirements", IDC_STATIC, 0, 164, 270, 53
@ -193,8 +193,7 @@ FONT 8, "MS Shell Dlg 2"
LTEXT "", IDC_INSTALLTAB_VERSION_TEXT, 50, 26, 200, 9, SS_NOPREFIX
LTEXT "Included components:", IDC_STATIC, 0, 45, 80, 9
CONTROL "", IDC_INSTALLTAB_COMPONENTS_LIST, "SysListView32", LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 0, 60, 234, 86
AUTOCHECKBOX "Apply included theme", IDC_INSTALLTAB_THEME_CHECKBOX, 4, 155, 220, 9
AUTOCHECKBOX "Apply included layout", IDC_INSTALLTAB_THEME_CHECKBOX, 4, 155, 220, 9
LTEXT "Installing...", IDC_INSTALLTAB_INPROGRESS_TEXT, 0, 0, 236, 60, NOT WS_VISIBLE
CONTROL "", IDC_INSTALLTAB_PROGRESS, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 15, 236, 11
}