mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	SkinInstaller: Fixed that user options weren't removed from installed themes
This commit is contained in:
		@@ -877,7 +877,8 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Get skin folder path
 | 
						// Get skin folder path
 | 
				
			||||||
	size_t len = GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, iniFile);
 | 
						size_t len = GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, iniFile);
 | 
				
			||||||
	if (len > 0)
 | 
						if (len > 0 &&
 | 
				
			||||||
 | 
							_waccess(buffer, 0) != -1)	// Temporary fix
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Try Rainmeter.ini first
 | 
							// Try Rainmeter.ini first
 | 
				
			||||||
		m_SkinPath.assign(buffer, len);
 | 
							m_SkinPath.assign(buffer, len);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,6 +49,7 @@ CDialogInstall::CDialogInstall(HWND wnd, const WCHAR* file) : CDialog(wnd),
 | 
				
			|||||||
	m_PackageUnzFile(),
 | 
						m_PackageUnzFile(),
 | 
				
			||||||
	m_PackageFileName(file),
 | 
						m_PackageFileName(file),
 | 
				
			||||||
	m_PackageFormat(PackageFormat::Old),
 | 
						m_PackageFormat(PackageFormat::Old),
 | 
				
			||||||
 | 
						m_BackupPackage(false),
 | 
				
			||||||
	m_BackupSkins(true),
 | 
						m_BackupSkins(true),
 | 
				
			||||||
	m_MergeSkins(false),
 | 
						m_MergeSkins(false),
 | 
				
			||||||
	m_SystemFonts(false)
 | 
						m_SystemFonts(false)
 | 
				
			||||||
@@ -199,7 +200,7 @@ INT_PTR CDialogInstall::OnCommand(WPARAM wParam, LPARAM lParam)
 | 
				
			|||||||
			HMENU menu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_INSTALL_MENU));
 | 
								HMENU menu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_INSTALL_MENU));
 | 
				
			||||||
			HMENU subMenu = GetSubMenu(menu, 0);
 | 
								HMENU subMenu = GetSubMenu(menu, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (m_PackageSkins.empty() || m_MergeSkins)
 | 
								if (m_PackageSkins.empty() || m_MergeSkins || m_BackupPackage)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				EnableMenuItem(subMenu, IDM_INSTALL_BACKUPSKINS, MF_BYCOMMAND | MF_GRAYED);
 | 
									EnableMenuItem(subMenu, IDM_INSTALL_BACKUPSKINS, MF_BYCOMMAND | MF_GRAYED);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -355,7 +356,7 @@ bool CDialogInstall::ReadPackage()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			if (footer.flags)
 | 
								if (footer.flags)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				m_BackupSkins = !(footer.flags & PackageFlag::Backup);
 | 
									m_BackupPackage = !(footer.flags & PackageFlag::Backup);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -556,7 +557,7 @@ bool CDialogInstall::ReadOptions(const WCHAR* file)
 | 
				
			|||||||
		// Determine if skins need to backed up based on name
 | 
							// Determine if skins need to backed up based on name
 | 
				
			||||||
		int s;
 | 
							int s;
 | 
				
			||||||
		int scanned = swscanf(buffer, L"Backup-%d.%d.%d-%d.%d.rmskin", &s, &s, &s, &s, &s);
 | 
							int scanned = swscanf(buffer, L"Backup-%d.%d.%d-%d.%d.rmskin", &s, &s, &s, &s, &s);
 | 
				
			||||||
		m_BackupSkins = scanned != 5;
 | 
							m_BackupPackage = scanned == 5;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	GetPrivateProfileString(section, L"Author", L"", buffer, 64, file);
 | 
						GetPrivateProfileString(section, L"Author", L"", buffer, 64, file);
 | 
				
			||||||
@@ -637,33 +638,50 @@ bool CDialogInstall::InstallPackage()
 | 
				
			|||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!m_MergeSkins && m_BackupSkins)
 | 
						if ((!m_MergeSkins && m_BackupSkins) || m_BackupPackage)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Move skins into backup folder
 | 
							// Move skins into backup folder
 | 
				
			||||||
		for (auto iter = m_PackageSkins.cbegin(); iter != m_PackageSkins.cend(); ++iter)
 | 
							for (auto iter = m_PackageSkins.cbegin(); iter != m_PackageSkins.cend(); ++iter)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			std::wstring from = g_Data.skinsPath + *iter;
 | 
								std::wstring from = g_Data.skinsPath + *iter;
 | 
				
			||||||
			std::wstring to = g_Data.skinsPath + L"Backup\\";
 | 
								if (_waccess(from.c_str(), 0) == -1)
 | 
				
			||||||
			CreateDirectory(to.c_str(), NULL);
 | 
								{
 | 
				
			||||||
			to += *iter;
 | 
									continue;
 | 
				
			||||||
			to += L'\0';	// For SHFileOperation
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Delete current backup
 | 
					 | 
				
			||||||
			SHFILEOPSTRUCT fo =
 | 
								SHFILEOPSTRUCT fo =
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				NULL,
 | 
									NULL,
 | 
				
			||||||
				FO_DELETE,
 | 
									FO_DELETE,
 | 
				
			||||||
				to.c_str(),
 | 
									NULL,
 | 
				
			||||||
				NULL,
 | 
									NULL,
 | 
				
			||||||
				FOF_NO_UI | FOF_NOCONFIRMATION | FOF_ALLOWUNDO
 | 
									FOF_NO_UI | FOF_NOCONFIRMATION | FOF_ALLOWUNDO
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
			SHFileOperation(&fo);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (!CopyFiles(from, to, true))
 | 
								if (m_BackupPackage)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				m_ErrorMessage = L"Unable to move to:\n";
 | 
									// Remove current skin
 | 
				
			||||||
				m_ErrorMessage += to;
 | 
									from += L'\0';
 | 
				
			||||||
				return false;
 | 
									fo.pFrom = from.c_str();
 | 
				
			||||||
 | 
									SHFileOperation(&fo);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									std::wstring to = g_Data.skinsPath + L"Backup\\";
 | 
				
			||||||
 | 
									CreateDirectory(to.c_str(), NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									// Delete current backup
 | 
				
			||||||
 | 
									to += *iter;
 | 
				
			||||||
 | 
									to += L'\0';
 | 
				
			||||||
 | 
									fo.pFrom = to.c_str();
 | 
				
			||||||
 | 
									SHFileOperation(&fo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (!CopyFiles(from, to, true))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										m_ErrorMessage = L"Unable to move to:\n";
 | 
				
			||||||
 | 
										m_ErrorMessage += to;
 | 
				
			||||||
 | 
										return false;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -727,13 +745,6 @@ bool CDialogInstall::InstallPackage()
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				targetPath = g_Data.skinsPath;
 | 
									targetPath = g_Data.skinsPath;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else if (_wcsicmp(component, L"Themes") == 0 &&
 | 
					 | 
				
			||||||
				_wcsicmp(extension, L".thm") == 0 &&
 | 
					 | 
				
			||||||
				m_PackageThemes.find(item) != m_PackageThemes.end())
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				targetPath = g_Data.settingsPath;
 | 
					 | 
				
			||||||
				targetPath += L"Themes\\";
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else if (_wcsicmp(component, L"Addons") == 0 &&
 | 
								else if (_wcsicmp(component, L"Addons") == 0 &&
 | 
				
			||||||
				m_PackageFormat == PackageFormat::Old &&
 | 
									m_PackageFormat == PackageFormat::Old &&
 | 
				
			||||||
				m_PackageAddons.find(item) != m_PackageAddons.end())
 | 
									m_PackageAddons.find(item) != m_PackageAddons.end())
 | 
				
			||||||
@@ -760,6 +771,29 @@ bool CDialogInstall::InstallPackage()
 | 
				
			|||||||
				targetPath += path;
 | 
									targetPath += path;
 | 
				
			||||||
				error = !ExtractCurrentFile(targetPath);
 | 
									error = !ExtractCurrentFile(targetPath);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								else if (_wcsicmp(component, L"Themes") == 0 &&
 | 
				
			||||||
 | 
									_wcsicmp(extension, L".thm") == 0 &&
 | 
				
			||||||
 | 
									m_PackageThemes.find(item) != m_PackageThemes.end())
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									targetPath = g_Data.settingsPath;
 | 
				
			||||||
 | 
									targetPath += L"Themes\\";
 | 
				
			||||||
 | 
									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);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -1359,7 +1393,8 @@ void CDialogInstall::CTabInstall::Initialize()
 | 
				
			|||||||
			WCHAR* text = L"Add";
 | 
								WCHAR* text = L"Add";
 | 
				
			||||||
			if (_waccess(itemPath.c_str(), 0) != -1)
 | 
								if (_waccess(itemPath.c_str(), 0) != -1)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				text = (groupId == 0 && c_Dialog->m_BackupSkins) ? L"Backup and replace" : L"Replace";
 | 
									bool backup = groupId == 0 && c_Dialog->m_BackupSkins && !c_Dialog->m_BackupPackage;
 | 
				
			||||||
 | 
									text = backup ? L"Backup and replace" : L"Replace";
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			ListView_SetItemText(item, lvi.iItem, 1, text);
 | 
								ListView_SetItemText(item, lvi.iItem, 1, text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -120,6 +120,7 @@ private:
 | 
				
			|||||||
	std::set<std::wstring> m_PackageFonts;
 | 
						std::set<std::wstring> m_PackageFonts;
 | 
				
			||||||
	std::set<std::wstring> m_PackagePlugins;
 | 
						std::set<std::wstring> m_PackagePlugins;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool m_BackupPackage;
 | 
				
			||||||
	bool m_BackupSkins;
 | 
						bool m_BackupSkins;
 | 
				
			||||||
	bool m_MergeSkins;
 | 
						bool m_MergeSkins;
 | 
				
			||||||
	bool m_SystemFonts;
 | 
						bool m_SystemFonts;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user