diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 9a22b25e..021d142d 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -668,7 +668,7 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure) { if (pMeasure) { - m_Measures[StrToLower(pMeasure->GetName())] = pMeasure; + m_Measures[StrToLower(pMeasure->GetOriginalName())] = pMeasure; } } diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index 109ef68c..436eae87 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -108,8 +108,8 @@ private: static void SetMultiMonitorVariables(bool reset); static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); } - static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); return StrToLowerC(strTmp); } - static std::wstring StrToLower(const WCHAR* str) { std::wstring strTmp(str); return StrToLowerC(strTmp); } + static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; } + static std::wstring StrToLower(const WCHAR* str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; } static std::wstring& StrToLowerC(std::wstring& str) { std::transform(str.begin(), str.end(), str.begin(), ::towlower); return str; } std::wstring m_Filename; diff --git a/Library/Measure.h b/Library/Measure.h index cddf76e4..6b3f25bd 100644 --- a/Library/Measure.h +++ b/Library/Measure.h @@ -56,6 +56,7 @@ public: virtual const WCHAR* GetStats(); const WCHAR* GetName() { return m_Name.c_str(); } + const std::wstring& GetOriginalName() { return m_Name; } const char* GetAsciiName() { return m_AsciiName.c_str(); } void Disable() { m_Disabled = true; } diff --git a/Library/Meter.cpp b/Library/Meter.cpp index c7f9bbc1..6146d495 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -390,14 +390,14 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section) m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor); m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0); - m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", L"", false); m_LeftMouseDownAction = parser.ReadString(section, L"LeftMouseDownAction", L"", false); + m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", L"", false); m_MiddleMouseDownAction = parser.ReadString(section, L"MiddleMouseDownAction", L"", false); - m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", L"", false); m_LeftMouseUpAction = parser.ReadString(section, L"LeftMouseUpAction", L"", false); + m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", L"", false); m_MiddleMouseUpAction = parser.ReadString(section, L"MiddleMouseUpAction", L"", false); - m_RightMouseDoubleClickAction = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false); m_LeftMouseDoubleClickAction = parser.ReadString(section, L"LeftMouseDoubleClickAction", L"", false); + m_RightMouseDoubleClickAction = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false); m_MiddleMouseDoubleClickAction = parser.ReadString(section, L"MiddleMouseDoubleClickAction", L"", false); m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L"", false); m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false); diff --git a/Library/Meter.h b/Library/Meter.h index 708a5595..c09c64c1 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -92,6 +92,7 @@ public: bool IsMouseOver() { return m_MouseOver; } const WCHAR* GetName() { return m_Name.c_str(); } + const std::wstring& GetOriginalName() { return m_Name; } void ResetUpdateCounter() { m_UpdateCounter = m_UpdateDivider; } int GetUpdateCounter() { return m_UpdateCounter; } @@ -156,14 +157,14 @@ protected: HWND m_ToolTipHandle; - std::wstring m_RightMouseDownAction; // Actions for left and right and middle mouse buttons - std::wstring m_RightMouseUpAction; - std::wstring m_RightMouseDoubleClickAction; - std::wstring m_LeftMouseDownAction; - std::wstring m_LeftMouseUpAction; - std::wstring m_LeftMouseDoubleClickAction; + std::wstring m_LeftMouseDownAction; // Actions for left/right/middle mouse buttons + std::wstring m_RightMouseDownAction; std::wstring m_MiddleMouseDownAction; + std::wstring m_LeftMouseUpAction; + std::wstring m_RightMouseUpAction; std::wstring m_MiddleMouseUpAction; + std::wstring m_LeftMouseDoubleClickAction; + std::wstring m_RightMouseDoubleClickAction; std::wstring m_MiddleMouseDoubleClickAction; std::wstring m_MouseOverAction; std::wstring m_MouseLeaveAction; diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index e227ad29..7c6a0471 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1468,11 +1468,11 @@ void CMeterWindow::SetOption(const WCHAR* arg, bool group) if (value.empty()) { - GetParser().DeleteValue((*j)->GetName(), option); + GetParser().DeleteValue((*j)->GetOriginalName(), option); } else { - GetParser().SetValue((*j)->GetName(), option, value); + GetParser().SetValue((*j)->GetOriginalName(), option, value); } } } @@ -2138,14 +2138,14 @@ bool CMeterWindow::ReadSkin() } } - m_RightMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseDownAction", L"", false); m_LeftMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"LeftMouseDownAction", L"", false); + m_RightMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseDownAction", L"", false); m_MiddleMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"MiddleMouseDownAction", L"", false); - m_RightMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseUpAction", L"", false); m_LeftMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"LeftMouseUpAction", L"", false); + m_RightMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseUpAction", L"", false); m_MiddleMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"MiddleMouseUpAction", L"", false); - m_RightMouseDoubleClickAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseDoubleClickAction", L"", false); m_LeftMouseDoubleClickAction = m_Parser.ReadString(L"Rainmeter", L"LeftMouseDoubleClickAction", L"", false); + m_RightMouseDoubleClickAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseDoubleClickAction", L"", false); m_MiddleMouseDoubleClickAction = m_Parser.ReadString(L"Rainmeter", L"MiddleMouseDoubleClickAction", L"", false); m_MouseOverAction = m_Parser.ReadString(L"Rainmeter", L"MouseOverAction", L"", false); m_MouseLeaveAction = m_Parser.ReadString(L"Rainmeter", L"MouseLeaveAction", L"", false); diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index fe4b6803..26642e61 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -360,14 +360,14 @@ private: HWND m_Window; // Handle to the Rainmeter window - std::wstring m_RightMouseDownAction; // Action to run when right mouse is pressed std::wstring m_LeftMouseDownAction; // Action to run when left mouse is pressed + std::wstring m_RightMouseDownAction; // Action to run when right mouse is pressed std::wstring m_MiddleMouseDownAction; // Action to run when middle mouse is pressed - std::wstring m_RightMouseUpAction; // Action to run when right mouse is released std::wstring m_LeftMouseUpAction; // Action to run when left mouse is released + std::wstring m_RightMouseUpAction; // Action to run when right mouse is released std::wstring m_MiddleMouseUpAction; // Action to run when middle mouse is released - std::wstring m_RightMouseDoubleClickAction; // Action to run when right mouse is double-clicked std::wstring m_LeftMouseDoubleClickAction; // Action to run when left mouse is double-clicked + std::wstring m_RightMouseDoubleClickAction; // Action to run when right mouse is double-clicked std::wstring m_MiddleMouseDoubleClickAction; // Action to run when middle mouse is double-clicked std::wstring m_MouseOverAction; // Action to run when mouse goes over the window std::wstring m_MouseLeaveAction; // Action to run when mouse leaves the window diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 5d91d99f..6c12ea97 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1148,10 +1148,10 @@ void CRainmeter::ActivateActiveConfigs() std::multimap::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()) + const CONFIG& configS = m_ConfigStrings[(*iter).second]; + if (configS.active > 0 && configS.active <= (int)configS.iniFiles.size()) { - ActivateConfig((*iter).second, config.active - 1); + ActivateConfig((*iter).second, configS.active - 1); } } } @@ -1403,12 +1403,13 @@ std::pair CRainmeter::GetMeterWindowIndex(const std::wstring& config, for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i) { - if (_wcsicmp(m_ConfigStrings[i].config.c_str(), configName) == 0) + const CONFIG& configS = m_ConfigStrings[i]; + if (_wcsicmp(configS.config.c_str(), configName) == 0) { const WCHAR* iniFileName = iniFile.c_str(); - for (int j = 0, jsize = (int)m_ConfigStrings[i].iniFiles.size(); j < jsize; ++j) + for (int j = 0, jsize = (int)configS.iniFiles.size(); j < jsize; ++j) { - if (_wcsicmp(m_ConfigStrings[i].iniFiles[j].c_str(), iniFileName) == 0) + if (_wcsicmp(configS.iniFiles[j].c_str(), iniFileName) == 0) { indexes = std::make_pair(i, j); return indexes; @@ -1430,10 +1431,11 @@ std::pair CRainmeter::GetMeterWindowIndex(UINT menuCommand) // Check which config was selected for (size_t i = 0, isize = m_ConfigStrings.size(); i < isize; ++i) { - if (menuCommand >= m_ConfigStrings[i].commandBase && - menuCommand < (m_ConfigStrings[i].commandBase + m_ConfigStrings[i].iniFiles.size())) + const CONFIG& configS = m_ConfigStrings[i]; + if (menuCommand >= configS.commandBase && + menuCommand < (configS.commandBase + configS.iniFiles.size())) { - indexes = std::make_pair(i, menuCommand - m_ConfigStrings[i].commandBase); + indexes = std::make_pair(i, menuCommand - configS.commandBase); return indexes; } } @@ -1443,7 +1445,6 @@ std::pair CRainmeter::GetMeterWindowIndex(UINT menuCommand) return indexes; } - CMeterWindow* CRainmeter::GetMeterWindow(HWND hwnd) { std::map::const_iterator iter = m_Meters.begin(); @@ -1593,6 +1594,8 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b base += L"\\"; } + menu.reserve(menu.size() + folders.size()); + std::list::const_iterator iter = folders.begin(); for ( ; iter != folders.end(); ++iter) { @@ -2227,15 +2230,16 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile) for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i) { - int active = parser.ReadInt(m_ConfigStrings[i].config.c_str(), L"Active", 0); + CONFIG& configS = m_ConfigStrings[i]; + int active = parser.ReadInt(configS.config.c_str(), L"Active", 0); // Make sure there is a ini file available - if (active > 0 && active <= (int)m_ConfigStrings[i].iniFiles.size()) + if (active > 0 && active <= (int)configS.iniFiles.size()) { - m_ConfigStrings[i].active = active; + configS.active = active; } - int order = parser.ReadInt(m_ConfigStrings[i].config.c_str(), L"LoadOrder", 0); + int order = parser.ReadInt(configS.config.c_str(), L"LoadOrder", 0); SetLoadOrder(i, order); } } @@ -2277,19 +2281,20 @@ void CRainmeter::RefreshAll() const std::wstring& skinConfig = mw->GetSkinName(); for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i) { - if (_wcsicmp(skinConfig.c_str(), m_ConfigStrings[i].config.c_str()) == 0) + CONFIG& configS = m_ConfigStrings[i]; + if (_wcsicmp(skinConfig.c_str(), configS.config.c_str()) == 0) { found = 1; const std::wstring& skinIniFile = mw->GetSkinIniFile(); - for (int j = 0, jsize = (int)m_ConfigStrings[i].iniFiles.size(); j < jsize; ++j) + for (int j = 0, jsize = (int)configS.iniFiles.size(); j < jsize; ++j) { - if (_wcsicmp(skinIniFile.c_str(), m_ConfigStrings[i].iniFiles[j].c_str()) == 0) + if (_wcsicmp(skinIniFile.c_str(), configS.iniFiles[j].c_str()) == 0) { found = 2; - if (m_ConfigStrings[i].active != j + 1) + if (configS.active != j + 1) { // Switch to new ini-file order - m_ConfigStrings[i].active = j + 1; + configS.active = j + 1; WriteActive(skinConfig, j); } break; @@ -2738,9 +2743,10 @@ HMENU CRainmeter::CreateConfigMenu(HMENU configMenu, const std::vectorGetParser(); std::wstring strTmp = LuaManager::ToWide(L, 2); - strTmp = parser.GetValue(self->GetName(), strTmp, L""); + strTmp = parser.GetValue(self->GetOriginalName(), strTmp, L""); - parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetName()); // Set temporarily + parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetOriginalName()); // Set temporarily parser.ReplaceVariables(strTmp); parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset parser.ReplaceMeasures(strTmp); diff --git a/Library/lua/glue/LuaMeter.cpp b/Library/lua/glue/LuaMeter.cpp index 16829c9a..175a4b08 100644 --- a/Library/lua/glue/LuaMeter.cpp +++ b/Library/lua/glue/LuaMeter.cpp @@ -18,9 +18,9 @@ static int Meter_GetOption(lua_State* L) CConfigParser& parser = meterWindow->GetParser(); std::wstring strTmp = LuaManager::ToWide(L, 2); - strTmp = parser.GetValue(self->GetName(), strTmp, L""); + strTmp = parser.GetValue(self->GetOriginalName(), strTmp, L""); - parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetName()); // Set temporarily + parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetOriginalName()); // Set temporarily parser.ReplaceVariables(strTmp); parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset parser.ReplaceMeasures(strTmp);