diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 18a020bc..c94e9980 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -51,7 +51,7 @@ CConfigParser::~CConfigParser() { } -void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meterWindow, LPCTSTR config) +void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meterWindow, LPCTSTR config, const std::wstring* includePath) { m_Measures.clear(); m_Sections.clear(); @@ -73,14 +73,7 @@ void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meter CSystem::UpdateIniFileMappingList(); - std::wstring resourcePath; - if (meterWindow) - { - resourcePath = meterWindow->GetSkinRootPath(); - resourcePath += L"@Resources\\"; - } - - ReadIniFile(filename, resourcePath, config); + ReadIniFile(filename, includePath, config); ReadVariables(); // Clear and minimize @@ -1155,7 +1148,7 @@ RECT CConfigParser::ParseRECT(LPCTSTR string) ** Reads the given ini file and fills the m_Values and m_Keys maps. ** */ -void CConfigParser::ReadIniFile(const std::wstring& iniFile, const std::wstring& resourcePath, LPCTSTR config, int depth) +void CConfigParser::ReadIniFile(const std::wstring& iniFile, const std::wstring* includePath, LPCTSTR config, int depth) { if (depth > 100) // Is 100 enough to assume the include loop never ends? { @@ -1319,10 +1312,10 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, const std::wstring& ReplaceVariables(value); if (!CSystem::IsAbsolutePath(value)) { - if (!resourcePath.empty() && + if (includePath && value[0] == L'@' && value[1] == L'\\') // value[1] == L'\0' if value.size() == 1 { - value.replace(0, 2, resourcePath); + value.replace(0, 2, *includePath); } else { @@ -1330,7 +1323,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, const std::wstring& value.insert(0, CRainmeter::ExtractPath(iniFile)); } } - ReadIniFile(value, resourcePath, config, depth + 1); + ReadIniFile(value, includePath, config, depth + 1); } } else diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index 7c96caaa..71ef542c 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -40,7 +40,7 @@ public: CConfigParser(); ~CConfigParser(); - void Initialize(const std::wstring& filename, CMeterWindow* meterWindow = NULL, LPCTSTR config = NULL); + void Initialize(const std::wstring& filename, CMeterWindow* meterWindow = NULL, LPCTSTR config = NULL, const std::wstring* includePath = NULL); void AddMeasure(CMeasure* pMeasure); bool GetVariable(const std::wstring& strVariable, std::wstring& strValue); @@ -106,7 +106,7 @@ private: CMeasure* GetMeasure(const std::wstring& name); - void ReadIniFile(const std::wstring& iniFile, const std::wstring& resourcePath, LPCTSTR config = NULL, int depth = 0); + void ReadIniFile(const std::wstring& iniFile, const std::wstring* includePath, LPCTSTR config = NULL, int depth = 0); void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 667ca73a..f836f9df 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1959,18 +1959,10 @@ bool CMeterWindow::ReadSkin() return false; } - std::wstring::size_type suiteLen; - if ((suiteLen = m_SkinName.find_first_of(L'\\')) == std::wstring::npos) - { - suiteLen = m_SkinName.size(); - } - - std::wstring resourcePath = Rainmeter->GetSkinPath(); - resourcePath.append(m_SkinName, 0, suiteLen); - resourcePath += L"\\@Resources\\"; + std::wstring resourcePath = GetSkinResourcesPath(); m_ResourcesFolder = (_waccess(resourcePath.c_str(), 0) == 0); - m_Parser.Initialize(iniFile, this); + m_Parser.Initialize(iniFile, this, NULL, &resourcePath); // Check the version UINT appVersion = m_Parser.ReadUInt(L"Rainmeter", L"AppVersion", 0); @@ -4744,6 +4736,13 @@ std::wstring CMeterWindow::GetSkinRootPath() return path; } +std::wstring CMeterWindow::GetSkinResourcesPath() +{ + std::wstring path = GetSkinRootPath(); + path += L"@Resources\\"; + return path; +} + CMeter* CMeterWindow::GetMeter(const std::wstring& meterName) { const WCHAR* name = meterName.c_str(); diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 9a0ad131..13f147aa 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -205,6 +205,7 @@ public: const std::wstring& GetSkinIniFile() { return m_SkinIniFile; } std::wstring GetSkinFilePath(); std::wstring GetSkinRootPath(); + std::wstring GetSkinResourcesPath(); std::list& GetMeasures() { return m_Measures; } std::list& GetMeters() { return m_Meters; } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index fa740ee3..4dff10ae 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -2136,6 +2136,14 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow, { std::wstring tmpSz = command; meterWindow->GetParser().ReplaceMeasures(tmpSz); + + std::wstring::size_type pos = tmpSz.find_first_not_of(L" \t\""); + if (pos != std::wstring::npos && + tmpSz[pos] == L'@' && tmpSz[pos + 1] == L'\\') // tmpSz[pos + 1] == L'\0' if tmpSz.size() == 1 + { + tmpSz.replace(pos, 2, meterWindow->GetSkinResourcesPath()); + } + RunCommand(NULL, tmpSz.c_str(), SW_SHOWNORMAL); } else