mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Added Rainmeter.data
This commit is contained in:
		@@ -76,9 +76,7 @@ void* __stdcall RmGet(void* rm, int type)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	case RMG_SETTINGSFILE:
 | 
						case RMG_SETTINGSFILE:
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			g_Buffer = Rainmeter->GetSettingsPath();
 | 
								return (void*)Rainmeter->GetDataFile().c_str();
 | 
				
			||||||
			g_Buffer += L"Plugins.ini";
 | 
					 | 
				
			||||||
			return (void*)g_Buffer.c_str();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -856,27 +856,37 @@ int CRainmeter::Initialize(LPCWSTR szPath)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Set the log file and stats file location
 | 
						const WCHAR* iniFile = m_IniFile.c_str();
 | 
				
			||||||
	m_LogFile = m_StatsFile = m_IniFile;
 | 
					
 | 
				
			||||||
	size_t len = m_LogFile.length();
 | 
						// Set file locations
 | 
				
			||||||
	if (len > 4 && _wcsicmp(m_LogFile.c_str() + (len - 4), L".ini") == 0)
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		m_LogFile.replace(len - 4, 4, L".log");
 | 
							size_t len = m_IniFile.length();
 | 
				
			||||||
		m_StatsFile.replace(len - 4, 4, L".stats");
 | 
							if (len > 4 && _wcsicmp(m_IniFile.c_str() + (len - 4), L".ini") == 0)
 | 
				
			||||||
	}
 | 
							{
 | 
				
			||||||
	else
 | 
								len -= 4;
 | 
				
			||||||
	{
 | 
							}
 | 
				
			||||||
		m_LogFile += L".log";	// Append the extension so that we don't accidentally overwrite the ini file
 | 
					
 | 
				
			||||||
 | 
							m_LogFile.assign(m_IniFile, 0, len);
 | 
				
			||||||
 | 
							m_DataFile = m_StatsFile = m_LogFile;
 | 
				
			||||||
 | 
							m_LogFile += L".log";
 | 
				
			||||||
		m_StatsFile += L".stats";
 | 
							m_StatsFile += L".stats";
 | 
				
			||||||
 | 
							m_DataFile += L".data";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool dataFileCreated = false;
 | 
				
			||||||
 | 
						if (_waccess(m_DataFile.c_str(), 0) == -1)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							dataFileCreated = true;
 | 
				
			||||||
 | 
							CreateDataFile();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Read Logging settings beforehand
 | 
						// Read Logging settings beforehand
 | 
				
			||||||
	m_Logging = 0!=GetPrivateProfileInt(L"Rainmeter", L"Logging", 0, m_IniFile.c_str());
 | 
						m_Logging = 0!=GetPrivateProfileInt(L"Rainmeter", L"Logging", 0, iniFile);
 | 
				
			||||||
	m_Debug = 0!=GetPrivateProfileInt(L"Rainmeter", L"Debug", 0, m_IniFile.c_str());
 | 
						m_Debug = 0!=GetPrivateProfileInt(L"Rainmeter", L"Debug", 0, iniFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Determine the language resource to load
 | 
						// Determine the language resource to load
 | 
				
			||||||
	std::wstring resource = m_Path + L"Languages\\";
 | 
						std::wstring resource = m_Path + L"Languages\\";
 | 
				
			||||||
	if (GetPrivateProfileString(L"Rainmeter", L"Language", L"", buffer, MAX_LINE_LENGTH, m_IniFile.c_str()) == 0)
 | 
						if (GetPrivateProfileString(L"Rainmeter", L"Language", L"", buffer, MAX_LINE_LENGTH, iniFile) == 0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Use whatever the user selected for the installer
 | 
							// Use whatever the user selected for the installer
 | 
				
			||||||
		DWORD size = MAX_LINE_LENGTH;
 | 
							DWORD size = MAX_LINE_LENGTH;
 | 
				
			||||||
@@ -928,7 +938,7 @@ int CRainmeter::Initialize(LPCWSTR szPath)
 | 
				
			|||||||
	m_SkinPath += L"Skins\\";
 | 
						m_SkinPath += L"Skins\\";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Read the skin folder from the ini file
 | 
						// Read the skin folder from the ini file
 | 
				
			||||||
	len = GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, m_IniFile.c_str());
 | 
						size_t len = GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", buffer, MAX_LINE_LENGTH, iniFile);
 | 
				
			||||||
	if (len > 0)
 | 
						if (len > 0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		m_SkinPath.assign(buffer, len);
 | 
							m_SkinPath.assign(buffer, len);
 | 
				
			||||||
@@ -977,14 +987,14 @@ int CRainmeter::Initialize(LPCWSTR szPath)
 | 
				
			|||||||
			Log(LOG_WARNING, L"Documents folder not found");
 | 
								Log(LOG_WARNING, L"Documents folder not found");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), m_IniFile.c_str());
 | 
							WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), iniFile);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	delete [] buffer;
 | 
						delete [] buffer;
 | 
				
			||||||
	buffer = NULL;
 | 
						buffer = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LogWithArgs(LOG_NOTICE, L"Path: %s", m_Path.c_str());
 | 
						LogWithArgs(LOG_NOTICE, L"Path: %s", m_Path.c_str());
 | 
				
			||||||
	LogWithArgs(LOG_NOTICE, L"IniFile: %s", m_IniFile.c_str());
 | 
						LogWithArgs(LOG_NOTICE, L"IniFile: %s", iniFile);
 | 
				
			||||||
	LogWithArgs(LOG_NOTICE, L"SkinPath: %s", m_SkinPath.c_str());
 | 
						LogWithArgs(LOG_NOTICE, L"SkinPath: %s", m_SkinPath.c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Extract volume path from program path
 | 
						// Extract volume path from program path
 | 
				
			||||||
@@ -1033,8 +1043,6 @@ int CRainmeter::Initialize(LPCWSTR szPath)
 | 
				
			|||||||
		MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
 | 
							MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	WritePrivateProfileString(L"Rainmeter", L"CheckUpdate", NULL , m_IniFile.c_str());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ResetStats();
 | 
						ResetStats();
 | 
				
			||||||
	ReadStats();
 | 
						ReadStats();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1047,7 +1055,11 @@ int CRainmeter::Initialize(LPCWSTR szPath)
 | 
				
			|||||||
	// Create meter windows for active configs
 | 
						// Create meter windows for active configs
 | 
				
			||||||
	ActivateActiveConfigs();
 | 
						ActivateActiveConfigs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!m_DisableVersionCheck)
 | 
						if (dataFileCreated)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_TrayWindow->ShowWelcomeNotification();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (!m_DisableVersionCheck)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		CheckUpdate();
 | 
							CheckUpdate();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -1170,6 +1182,29 @@ void CRainmeter::CreateDefaultConfigFile()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CRainmeter::CreateDataFile()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						std::wstring tmpSz = GetSettingsPath();
 | 
				
			||||||
 | 
						tmpSz += L"Plugins.ini";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const WCHAR* pluginsFile = tmpSz.c_str();
 | 
				
			||||||
 | 
						const WCHAR* dataFile = m_DataFile.c_str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (_waccess(pluginsFile, 0) == 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							_wrename(pluginsFile, dataFile);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// Create empty file
 | 
				
			||||||
 | 
							HANDLE file = CreateFile(dataFile, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
 | 
				
			||||||
 | 
							if (file != INVALID_HANDLE_VALUE)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								CloseHandle(file);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CRainmeter::ReloadSettings()
 | 
					void CRainmeter::ReloadSettings()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ScanForConfigs(m_SkinPath);
 | 
						ScanForConfigs(m_SkinPath);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -151,6 +151,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	const std::wstring& GetPath() { return m_Path; }
 | 
						const std::wstring& GetPath() { return m_Path; }
 | 
				
			||||||
	const std::wstring& GetIniFile() { return m_IniFile; }
 | 
						const std::wstring& GetIniFile() { return m_IniFile; }
 | 
				
			||||||
 | 
						const std::wstring& GetDataFile() { return m_DataFile; }
 | 
				
			||||||
	const std::wstring& GetLogFile() { return m_LogFile; }
 | 
						const std::wstring& GetLogFile() { return m_LogFile; }
 | 
				
			||||||
	const std::wstring& GetSkinPath() { return m_SkinPath; }
 | 
						const std::wstring& GetSkinPath() { return m_SkinPath; }
 | 
				
			||||||
	const std::wstring& GetPluginPath() { return m_PluginPath; }
 | 
						const std::wstring& GetPluginPath() { return m_PluginPath; }
 | 
				
			||||||
@@ -263,6 +264,7 @@ private:
 | 
				
			|||||||
	void CreateThemeMenu(HMENU themeMenu);
 | 
						void CreateThemeMenu(HMENU themeMenu);
 | 
				
			||||||
	void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
 | 
						void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
 | 
				
			||||||
	void CreateDefaultConfigFile();
 | 
						void CreateDefaultConfigFile();
 | 
				
			||||||
 | 
						void CreateDataFile();
 | 
				
			||||||
	void SetLogging(bool logging);
 | 
						void SetLogging(bool logging);
 | 
				
			||||||
	void TestSettingsFile(bool bDefaultIniLocation);
 | 
						void TestSettingsFile(bool bDefaultIniLocation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -274,13 +276,14 @@ private:
 | 
				
			|||||||
	std::map<std::wstring, CMeterWindow*> m_MeterWindows;
 | 
						std::map<std::wstring, CMeterWindow*> m_MeterWindows;
 | 
				
			||||||
	std::vector<std::wstring> m_Themes;
 | 
						std::vector<std::wstring> m_Themes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::wstring m_Path;				// Path to the main folder
 | 
						std::wstring m_Path;
 | 
				
			||||||
	std::wstring m_IniFile;				// The main ini file
 | 
						std::wstring m_IniFile;
 | 
				
			||||||
	std::wstring m_StatsFile;			// The statistics ini file
 | 
						std::wstring m_DataFile;
 | 
				
			||||||
	std::wstring m_LogFile;				// The log file
 | 
						std::wstring m_StatsFile;
 | 
				
			||||||
	std::wstring m_SkinPath;			// Path to the folder where the skins are
 | 
						std::wstring m_LogFile;
 | 
				
			||||||
	std::wstring m_PluginPath;			// Path to the folder where the plugins are
 | 
						std::wstring m_SkinPath;
 | 
				
			||||||
	std::wstring m_AddonPath;			// Path to the folder where the addons are
 | 
						std::wstring m_PluginPath;
 | 
				
			||||||
 | 
						std::wstring m_AddonPath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::wstring m_Drive;
 | 
						std::wstring m_Drive;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user