diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index f0f0d4e4..a6177770 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -132,27 +132,14 @@ void CConfigParser::SetVariable(const std::wstring& strVariable, const std::wstr ** ** */ -const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures) +const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures, bool bReplaceDefValue) { static std::wstring result; - if (section == NULL) - { - section = L""; - } - if (key == NULL) - { - key = L""; - } - if (defValue == NULL) - { - defValue = L""; - } - result = GetValue(section, key, defValue); - if (result == defValue) + if (result == defValue && bReplaceDefValue == false) { - return result; + return result; } // Check Litestep vars @@ -458,7 +445,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile) items[0] = 0; int res = GetPrivateProfileString( NULL, NULL, NULL, items, size, iniFile.c_str()); if (res == 0) return; // File not found - if (res < size - 2) break; // Fits in the buffer + if (res != size - 2) break; // Fits in the buffer delete [] items; size *= 2; @@ -487,7 +474,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile) { items[0] = 0; int res = GetPrivateProfileString((*iter).first.c_str(), NULL, NULL, items, size, iniFile.c_str()); - if (res < size - 2) break; // Fits in the buffer + if (res != size - 2) break; // Fits in the buffer delete [] items; size *= 2; @@ -503,11 +490,11 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile) { buffer[0] = 0; int res = GetPrivateProfileString((*iter).first.c_str(), strKey.c_str(), L"", buffer, bufferSize, iniFile.c_str()); - if (res < bufferSize - 2) break; // Fits in the buffer + if (res != size - 2) break; // Fits in the buffer delete [] buffer; bufferSize *= 2; - buffer = new WCHAR[bufferSize]; + buffer = new WCHAR[size]; }; SetValue((*iter).first, strKey, buffer); @@ -606,3 +593,4 @@ std::vector CConfigParser::GetKeys(const std::wstring& strSection) return std::vector(); } + diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index 777120ec..acf57b87 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -40,7 +40,7 @@ public: void AddMeasure(CMeasure* pMeasure); void SetVariable(const std::wstring& strVariable, const std::wstring& strValue); - const std::wstring& ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures = true); + const std::wstring& ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures = true, bool bReplaceDefValue = false); double ReadFloat(LPCTSTR section, LPCTSTR key, double defValue); double ReadFormula(LPCTSTR section, LPCTSTR key, double defValue); int ReadInt(LPCTSTR section, LPCTSTR key, int defValue); diff --git a/Library/Meter.cpp b/Library/Meter.cpp index cf54611c..d09b383e 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -212,6 +212,8 @@ void CMeter::ReadConfig(const WCHAR* section) { CConfigParser& parser = m_MeterWindow->GetParser(); + m_StyleName = parser.ReadString(section, L"MeterStyle", L""); + const std::wstring& x = parser.ReadString(section, L"X", L"0"); if (x.size() > 0) { @@ -248,29 +250,30 @@ void CMeter::ReadConfig(const WCHAR* section) } } - m_W = (int)parser.ReadFormula(section, L"W", 1.0); - m_H = (int)parser.ReadFormula(section, L"H", 1.0); - m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0); - m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", m_SolidBevel); + m_W = (int)parser.ReadFormula(section, L"W", (int)parser.ReadFormula(m_StyleName.c_str(), L"W", 1.0)); + m_H = (int)parser.ReadFormula(section, L"H", (int)parser.ReadFormula(m_StyleName.c_str(), L"H", 1.0)); - m_SolidColor = parser.ReadColor(section, L"SolidColor", Color(0, 0, 0, 0)); - m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor); - m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0); + m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0!=parser.ReadInt(m_StyleName.c_str(), L"Hidden", 0)); + m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", (BEVELTYPE)parser.ReadInt(m_StyleName.c_str(), L"BevelType", m_SolidBevel)); - m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", L""); - m_LeftMouseDownAction = parser.ReadString(section, L"LeftMouseDownAction", L""); - m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", L""); - m_LeftMouseUpAction = parser.ReadString(section, L"LeftMouseUpAction", L""); - m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L""); - m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L""); + m_SolidColor = parser.ReadColor(section, L"SolidColor", parser.ReadColor(m_StyleName.c_str(), L"SolidColor", Color(0, 0, 0, 0))); + m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", parser.ReadColor(m_StyleName.c_str(), L"SolidColor2", m_SolidColor)); + m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", (Gdiplus::REAL)parser.ReadFloat(m_StyleName.c_str(), L"GradientAngle", 0.0)); - m_MeasureName = parser.ReadString(section, L"MeasureName", L""); + m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", parser.ReadString(m_StyleName.c_str(), L"RightMouseDownAction", L"").c_str(),true,true); + m_LeftMouseDownAction = parser.ReadString(section, L"LeftMouseDownAction", parser.ReadString(m_StyleName.c_str(), L"LeftMouseDownAction", L"").c_str(),true,true); + m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", parser.ReadString(m_StyleName.c_str(), L"RightMouseUpAction", L"").c_str(),true,true); + m_LeftMouseUpAction = parser.ReadString(section, L"LeftMouseUpAction", parser.ReadString(m_StyleName.c_str(), L"LeftMouseUpAction", L"").c_str(),true,true); + m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", parser.ReadString(m_StyleName.c_str(), L"MouseOverAction", L"").c_str(),true,true); + m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", parser.ReadString(m_StyleName.c_str(), L"MouseLeaveAction", L"").c_str(),true,true); - m_UpdateDivider = parser.ReadInt(section, L"UpdateDivider", 1); + m_MeasureName = parser.ReadString(section, L"MeasureName", parser.ReadString(m_StyleName.c_str(), L"MeasureName", L"").c_str(),true,true); + + m_UpdateDivider = parser.ReadInt(section, L"UpdateDivider", parser.ReadInt(m_StyleName.c_str(), L"UpdateDivider", 1)); m_UpdateCounter = m_UpdateDivider; - m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); - m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0); + m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0!=parser.ReadInt(m_StyleName.c_str(), L"AntiAlias", 0)); + m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0!=parser.ReadInt(m_StyleName.c_str(), L"DynamicVariables", 0)); std::vector matrix = parser.ReadFloats(section, L"TransformationMatrix"); if (matrix.size() == 6) diff --git a/Library/Meter.h b/Library/Meter.h index 4a1478e0..3409b535 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -128,6 +128,8 @@ protected: bool m_AntiAlias; // If true, the line is antialiased bool m_Initialized; + std::wstring m_StyleName; + CMeterWindow* m_MeterWindow; }; diff --git a/Library/MeterBar.cpp b/Library/MeterBar.cpp index fbf34015..7c6bde94 100644 --- a/Library/MeterBar.cpp +++ b/Library/MeterBar.cpp @@ -94,17 +94,17 @@ void CMeterBar::ReadConfig(const WCHAR* section) CConfigParser& parser = m_MeterWindow->GetParser(); - m_Color = parser.ReadColor(section, L"BarColor", Color::Green); + m_Color = parser.ReadColor(section, L"BarColor", parser.ReadColor(m_StyleName.c_str(), L"BarColor", Color::Green)); - m_ImageName = parser.ReadString(section, L"BarImage", L""); + m_ImageName = parser.ReadString(section, L"BarImage", parser.ReadString(m_StyleName.c_str(), L"BarImage", L"").c_str(),true,true); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - m_Border = parser.ReadInt(section, L"BarBorder", 0); + m_Border = parser.ReadInt(section, L"BarBorder", parser.ReadInt(m_StyleName.c_str(), L"BarBorder", 0)); m_Flip = parser.ReadInt(section, L"Flip", 0) == 1; std::wstring orientation; - orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL"); + orientation = parser.ReadString(section, L"BarOrientation", parser.ReadString(m_StyleName.c_str(), L"BarOrientation", L"VERTICAL").c_str(),true,true); if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0) { diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index d7b13137..9a50887e 100644 --- a/Library/MeterBitmap.cpp +++ b/Library/MeterBitmap.cpp @@ -168,20 +168,20 @@ void CMeterBitmap::ReadConfig(const WCHAR* section) CConfigParser& parser = m_MeterWindow->GetParser(); - m_ImageName = parser.ReadString(section, L"BitmapImage", L""); + m_ImageName = parser.ReadString(section, L"BitmapImage", parser.ReadString(m_StyleName.c_str(), L"BitmapImage", L"").c_str(),true,true); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1); - m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0); + m_FrameCount = parser.ReadInt(section, L"BitmapFrames", parser.ReadInt(m_StyleName.c_str(), L"BitmapFrames", 1)); + m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0!=parser.ReadInt(m_StyleName.c_str(), L"BitmapZeroFrame", 0)); - m_Separation = parser.ReadInt(section, L"BitmapSeparation", 0); - m_Extend = 0!=parser.ReadInt(section, L"BitmapExtend", 0); - m_Digits = parser.ReadInt(section, L"BitmapDigits", 0); + m_Separation = parser.ReadInt(section, L"BitmapSeparation", parser.ReadInt(m_StyleName.c_str(), L"BitmapSeparation", 0)); + m_Extend = 0!=parser.ReadInt(section, L"BitmapExtend", 0!=parser.ReadInt(m_StyleName.c_str(), L"BitmapExtend", 0)); + m_Digits = parser.ReadInt(section, L"BitmapDigits", parser.ReadInt(m_StyleName.c_str(), L"BitmapDigits", 0)); - m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0); + m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", parser.ReadInt(m_StyleName.c_str(), L"BitmapTransitionFrames", 0)); std::wstring align; - align = parser.ReadString(section, L"BitmapAlign", L"LEFT"); + align = parser.ReadString(section, L"BitmapAlign", parser.ReadString(m_StyleName.c_str(), L"BitmapAlign", L"LEFT").c_str(),true,true); if(_wcsicmp(align.c_str(), L"LEFT") == 0) { diff --git a/Library/MeterButton.cpp b/Library/MeterButton.cpp index 709c01fd..78e3b893 100644 --- a/Library/MeterButton.cpp +++ b/Library/MeterButton.cpp @@ -135,10 +135,10 @@ void CMeterButton::ReadConfig(const WCHAR* section) CConfigParser& parser = m_MeterWindow->GetParser(); - m_ImageName = parser.ReadString(section, L"ButtonImage", L""); + m_ImageName = parser.ReadString(section, L"ButtonImage", parser.ReadString(m_StyleName.c_str(), L"ButtonImage", L"").c_str(),true,true); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - m_Command = parser.ReadString(section, L"ButtonCommand", L""); + m_Command = parser.ReadString(section, L"ButtonCommand", parser.ReadString(m_StyleName.c_str(), L"ButtonCommand", L"").c_str(),true,true); } /* diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index 672dba1c..7bdb5f13 100644 --- a/Library/MeterHistogram.cpp +++ b/Library/MeterHistogram.cpp @@ -143,22 +143,22 @@ void CMeterHistogram::ReadConfig(const WCHAR* section) CConfigParser& parser = m_MeterWindow->GetParser(); - m_PrimaryColor = parser.ReadColor(section, L"PrimaryColor", Color::Green); - m_SecondaryColor = parser.ReadColor(section, L"SecondaryColor", Color::Red); - m_BothColor = parser.ReadColor(section, L"BothColor", Color::Yellow); + m_PrimaryColor = parser.ReadColor(section, L"PrimaryColor", parser.ReadColor(m_StyleName.c_str(), L"PrimaryColor", Color::Green)); + m_SecondaryColor = parser.ReadColor(section, L"SecondaryColor", parser.ReadColor(m_StyleName.c_str(), L"SecondaryColor", Color::Red)); + m_BothColor = parser.ReadColor(section, L"BothColor", parser.ReadColor(m_StyleName.c_str(), L"BothColor", Color::Yellow)); - m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", L""); + m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", parser.ReadString(m_StyleName.c_str(), L"SecondaryMeasureName", L"").c_str(),true,true); - m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", L""); + m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", parser.ReadString(m_StyleName.c_str(), L"PrimaryImage", L"").c_str(),true,true); m_PrimaryImageName = m_MeterWindow->MakePathAbsolute(m_PrimaryImageName); - m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L""); + m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", parser.ReadString(m_StyleName.c_str(), L"SecondaryImage", L"").c_str(),true,true); m_SecondaryImageName = m_MeterWindow->MakePathAbsolute(m_SecondaryImageName); - m_BothImageName = parser.ReadString(section, L"BothImage", L""); + m_BothImageName = parser.ReadString(section, L"BothImage", parser.ReadString(m_StyleName.c_str(), L"BothImage", L"").c_str(),true,true); m_BothImageName = m_MeterWindow->MakePathAbsolute(m_BothImageName); - m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); + m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0!=parser.ReadInt(m_StyleName.c_str(), L"AutoScale", 0)); m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); } diff --git a/Library/MeterImage.cpp b/Library/MeterImage.cpp index 5c577815..c8e44895 100644 --- a/Library/MeterImage.cpp +++ b/Library/MeterImage.cpp @@ -197,9 +197,9 @@ void CMeterImage::ReadConfig(const WCHAR* section) CConfigParser& parser = m_MeterWindow->GetParser(); - m_ImageName = parser.ReadString(section, L"ImageName", L""); + m_ImageName = parser.ReadString(section, L"ImageName", parser.ReadString(m_StyleName.c_str(), L"ImageName", L"").c_str(),true,true); - m_Path = parser.ReadString(section, L"Path", L""); + m_Path = parser.ReadString(section, L"Path", parser.ReadString(m_StyleName.c_str(), L"Path", L"").c_str(),true,true); if (!m_Path.empty()) { if (m_Path[m_Path.length() - 1] != L'\\') @@ -209,7 +209,7 @@ void CMeterImage::ReadConfig(const WCHAR* section) } m_ImageName = m_MeterWindow->MakePathAbsolute(m_Path + m_ImageName); - m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0); + m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0!=parser.ReadInt(m_StyleName.c_str(), L"PreserveAspectRatio", 0)); if (-1 != parser.ReadInt(section, L"W", -1)) { diff --git a/Library/MeterLine.cpp b/Library/MeterLine.cpp index 4a4b94b7..1fd8eaaa 100644 --- a/Library/MeterLine.cpp +++ b/Library/MeterLine.cpp @@ -86,7 +86,7 @@ void CMeterLine::ReadConfig(const WCHAR* section) CConfigParser& parser = m_MeterWindow->GetParser(); - int lineCount = parser.ReadInt(section, L"LineCount", 1); + int lineCount = parser.ReadInt(section, L"LineCount", parser.ReadInt(m_StyleName.c_str(), L"LineCount", 1)); for (i = 0; i < lineCount; i++) { @@ -99,7 +99,7 @@ void CMeterLine::ReadConfig(const WCHAR* section) swprintf(tmpName, L"LineColor%i", i + 1); } - m_Colors.push_back(parser.ReadColor(section, tmpName, Color::White)); + m_Colors.push_back(parser.ReadColor(section, tmpName, parser.ReadColor(m_StyleName.c_str(), tmpName, Color::White))); if (i == 0) { @@ -110,21 +110,21 @@ void CMeterLine::ReadConfig(const WCHAR* section) swprintf(tmpName, L"Scale%i", i + 1); } - m_ScaleValues.push_back(parser.ReadFloat(section, tmpName, 1.0)); + m_ScaleValues.push_back(parser.ReadFloat(section, tmpName, parser.ReadFloat(m_StyleName.c_str(), tmpName, 1.0))); if (i != 0) { swprintf(tmpName, L"MeasureName%i", i + 1); - m_MeasureNames.push_back(parser.ReadString(section, tmpName, L"")); + m_MeasureNames.push_back(parser.ReadString(section, tmpName, parser.ReadString(m_StyleName.c_str(), tmpName, L"").c_str(),true,true)); } } - m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); - m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); - m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0); - m_HorizontalLines = 0!=parser.ReadInt(section, L"HorizontalLines", 0); - m_HorizontalColor = parser.ReadColor(section, L"HorizontalColor", Color::Black); // This is left here for backwards compatibility - m_HorizontalColor = parser.ReadColor(section, L"HorizontalLineColor", m_HorizontalColor); // This is what it should be + m_Flip = 0!=parser.ReadInt(section, L"Flip", 0!=parser.ReadInt(m_StyleName.c_str(), L"Flip", 0)); + m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0!=parser.ReadInt(m_StyleName.c_str(), L"AutoScale", 0)); + m_LineWidth = parser.ReadFloat(section, L"LineWidth", parser.ReadFloat(m_StyleName.c_str(), L"LineWidth", 1.0)); + m_HorizontalLines = 0!=parser.ReadInt(section, L"HorizontalLines", 0!=parser.ReadInt(m_StyleName.c_str(), L"HorizontalLines", 0)); + m_HorizontalColor = parser.ReadColor(section, L"HorizontalColor", parser.ReadColor(m_StyleName.c_str(), L"HorizontalColor", Color::Black)); // This is left here for backwards compatibility + m_HorizontalColor = parser.ReadColor(section, L"HorizontalLineColor", parser.ReadColor(m_StyleName.c_str(), L"HorizontalLineColor", m_HorizontalColor)); // This is what it should be } /* diff --git a/Library/MeterRotator.cpp b/Library/MeterRotator.cpp index ee3dff2d..1175677b 100644 --- a/Library/MeterRotator.cpp +++ b/Library/MeterRotator.cpp @@ -87,16 +87,16 @@ void CMeterRotator::ReadConfig(const WCHAR* section) CConfigParser& parser = m_MeterWindow->GetParser(); - m_ImageName = parser.ReadString(section, L"ImageName", L""); + m_ImageName = parser.ReadString(section, L"ImageName", parser.ReadString(m_StyleName.c_str(), L"ImageName", L"").c_str(),true,true); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - m_OffsetX = parser.ReadFloat(section, L"OffsetX", 0.0); - m_OffsetY = parser.ReadFloat(section, L"OffsetY", 0.0); - m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0); - m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832); + m_OffsetX = parser.ReadFloat(section, L"OffsetX", parser.ReadFloat(m_StyleName.c_str(), L"OffsetX", 0.0)); + m_OffsetY = parser.ReadFloat(section, L"OffsetY", parser.ReadFloat(m_StyleName.c_str(), L"OffsetY", 0.0)); + m_StartAngle = parser.ReadFloat(section, L"StartAngle", parser.ReadFloat(m_StyleName.c_str(), L"StartAngle", 0.0)); + m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", parser.ReadFloat(m_StyleName.c_str(), L"RotationAngle", 6.2832)); - m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo - m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder); + m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", parser.ReadInt(m_StyleName.c_str(), L"ValueReminder", 0)); // Typo + m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", parser.ReadInt(m_StyleName.c_str(), L"ValueRemainder", m_ValueRemainder)); } /* diff --git a/Library/MeterRoundLine.cpp b/Library/MeterRoundLine.cpp index 6e769b2f..600b85f9 100644 --- a/Library/MeterRoundLine.cpp +++ b/Library/MeterRoundLine.cpp @@ -73,21 +73,24 @@ void CMeterRoundLine::ReadConfig(const WCHAR* section) CMeter::ReadConfig(section); CConfigParser& parser = m_MeterWindow->GetParser(); + - m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0); - m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0); - m_LineStart = parser.ReadFloat(section, L"LineStart", -1.0); - m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0); - m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832); - m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo - m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder); - m_LineColor = parser.ReadColor(section, L"LineColor", Color::Black); - m_Solid = 0!=parser.ReadInt(section, L"Solid", 0); - m_CntrlAngle = 0!=parser.ReadInt(section, L"ControlAngle", 1); - m_CntrlLineStart = 0!=parser.ReadInt(section, L"ControlStart", 0); - m_CntrlLineLength = 0!=parser.ReadInt(section, L"ControlLength", 0); - m_LineStartShift = parser.ReadFloat(section, L"StartShift", 0); - m_LineLengthShift = parser.ReadFloat(section, L"LengthShift", 0); + parser.ReadString(section, L"Prefix", parser.ReadString(m_StyleName.c_str(), L"Prefix", L"").c_str(),true,true); + + m_LineWidth = parser.ReadFloat(section, L"LineWidth", parser.ReadFloat(m_StyleName.c_str(), L"LineWidth", 1.0)); + m_LineLength = parser.ReadFloat(section, L"LineLength", parser.ReadFloat(m_StyleName.c_str(), L"LineLength", 20.0)); + m_LineStart = parser.ReadFloat(section, L"LineStart", parser.ReadFloat(m_StyleName.c_str(), L"LineStart", -1.0)); + m_StartAngle = parser.ReadFloat(section, L"StartAngle", parser.ReadFloat(m_StyleName.c_str(), L"StartAngle", 0.0)); + m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", parser.ReadFloat(m_StyleName.c_str(), L"RotationAngle", 6.2832)); + m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", parser.ReadInt(m_StyleName.c_str(), L"ValueReminder", 0)); // Typo + m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", parser.ReadInt(m_StyleName.c_str(), L"ValueRemainder", m_ValueRemainder)); + m_LineColor = parser.ReadColor(section, L"LineColor", parser.ReadColor(m_StyleName.c_str(), L"LineColor", Color::Black)); + m_Solid = 0!=parser.ReadInt(section, L"Solid", 0!=parser.ReadInt(m_StyleName.c_str(), L"Solid", 0)); + m_CntrlAngle = 0!=parser.ReadInt(section, L"ControlAngle", 0!=parser.ReadInt(m_StyleName.c_str(), L"ControlAngle", 1)); + m_CntrlLineStart = 0!=parser.ReadInt(section, L"ControlStart", 0!=parser.ReadInt(m_StyleName.c_str(), L"ControlStart", 0)); + m_CntrlLineLength = 0!=parser.ReadInt(section, L"ControlLength", 0!=parser.ReadInt(m_StyleName.c_str(), L"ControlLength", 0)); + m_LineStartShift = parser.ReadFloat(section, L"StartShift", parser.ReadFloat(m_StyleName.c_str(), L"StartShift", 0)); + m_LineLengthShift = parser.ReadFloat(section, L"LengthShift", parser.ReadFloat(m_StyleName.c_str(), L"LengthShift", 0)); } /* diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index ca836afb..a8d2d3e1 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -109,6 +109,7 @@ void CMeterString::Initialize() if(m_FontFamily) delete m_FontFamily; m_FontFamily = new FontFamily(m_FontFace.c_str()); Status status = m_FontFamily->GetLastStatus(); + //=================================================== /* Matt King Code */ // It couldn't find the font family @@ -212,25 +213,27 @@ void CMeterString::ReadConfig(const WCHAR* section) } i++; } while(loop); + + + m_Color = parser.ReadColor(section, L"FontColor", parser.ReadColor(m_StyleName.c_str(), L"FontColor", Color::Black)); + m_EffectColor = parser.ReadColor(section, L"FontEffectColor", parser.ReadColor(m_StyleName.c_str(), L"FontEffectColor", Color::Black)); - m_Color = parser.ReadColor(section, L"FontColor", Color::Black); - m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black); + m_Prefix = parser.ReadString(section, L"Prefix", parser.ReadString(m_StyleName.c_str(), L"Prefix", L"").c_str(),true,true); + m_Postfix = parser.ReadString(section, L"Postfix", parser.ReadString(m_StyleName.c_str(), L"Postfix", L"").c_str(),true,true); + m_Text = parser.ReadString(section, L"Text", parser.ReadString(m_StyleName.c_str(), L"Text", L"").c_str(),true,true); - m_Prefix = parser.ReadString(section, L"Prefix", L""); - m_Postfix = parser.ReadString(section, L"Postfix", L""); - m_Text = parser.ReadString(section, L"Text", L""); + m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0!=parser.ReadInt(m_StyleName.c_str(), L"Percentual", 0)); + m_AutoScale = 0!=parser.ReadInt(section, L"AutoScale", 0!=parser.ReadInt(m_StyleName.c_str(), L"AutoScale", 0)); + m_ClipString = 0!=parser.ReadInt(section, L"ClipString", 0!=parser.ReadInt(m_StyleName.c_str(), L"ClipString", 0)); - m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0); - m_AutoScale = 0!=parser.ReadInt(section, L"AutoScale", 0); - m_ClipString = 0!=parser.ReadInt(section, L"ClipString", 0); + m_FontSize = parser.ReadFormula(section, L"FontSize", parser.ReadFormula(m_StyleName.c_str(), L"FontSize", 10)); - m_FontSize = parser.ReadFormula(section, L"FontSize", 10); - m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1); + m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", parser.ReadInt(m_StyleName.c_str(), L"NumOfDecimals", -1)); - m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0); + m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", (Gdiplus::REAL)parser.ReadFloat(m_StyleName.c_str(), L"Angle",0.0)); std::wstring scale; - scale = parser.ReadString(section, L"Scale", L"1"); + scale = parser.ReadString(section, L"Scale", parser.ReadString(m_StyleName.c_str(), L"Scale", L"1").c_str(),true,true); if (wcschr(scale.c_str(), '.') == NULL) { @@ -242,10 +245,11 @@ void CMeterString::ReadConfig(const WCHAR* section) } m_Scale = wcstod(scale.c_str(), NULL); - m_FontFace = parser.ReadString(section, L"FontFace", L"Arial"); + m_FontFace = parser.ReadString(section, L"FontFace", parser.ReadString(m_StyleName.c_str(), L"FontFace", L"Arial").c_str(),true,true); + std::wstring align; - align = parser.ReadString(section, L"StringAlign", L"LEFT"); + align = parser.ReadString(section, L"StringAlign", parser.ReadString(m_StyleName.c_str(), L"StringAlign", L"LEFT").c_str(),true,true); if(_wcsicmp(align.c_str(), L"LEFT") == 0) { @@ -265,8 +269,8 @@ void CMeterString::ReadConfig(const WCHAR* section) } std::wstring style; - style = parser.ReadString(section, L"StringStyle", L"NORMAL"); - + style = parser.ReadString(section, L"StringStyle", parser.ReadString(m_StyleName.c_str(), L"StringStyle", L"NORMAL").c_str(),true,true); + if(_wcsicmp(style.c_str(), L"NORMAL") == 0) { m_Style = NORMAL; @@ -289,8 +293,8 @@ void CMeterString::ReadConfig(const WCHAR* section) } std::wstring effect; - effect = parser.ReadString(section, L"StringEffect", L"NONE"); - + effect = parser.ReadString(section, L"StringEffect", parser.ReadString(m_StyleName.c_str(), L"StringEffect", L"NONE").c_str(),true,true); + if(_wcsicmp(effect.c_str(), L"NONE") == 0) { m_Effect = EFFECT_NONE; @@ -322,6 +326,15 @@ void CMeterString::ReadConfig(const WCHAR* section) } } +/* +** Update +** +** Updates the value(s) from the measures. +** +*/ + + + /* ** Update ** diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index f3c8139f..b397ca96 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -38,6 +38,7 @@ #include "MeasureNet.h" #include "MeasurePlugin.h" #include "MeterButton.h" +#include using namespace Gdiplus; @@ -1521,7 +1522,7 @@ void CMeterWindow::ReadSkin() { int res = GetPrivateProfileString( NULL, NULL, NULL, items, size, iniFile.c_str()); if (res == 0) return; // File not found - if (res < size - 2) break; // Fits in the buffer + if (res != size - 2) break; // Fits in the buffer delete [] items; size *= 2; @@ -1535,11 +1536,12 @@ void CMeterWindow::ReadSkin() wcsicmp(L"Variables", pos) != 0 && wcsicmp(L"Metadata", pos) != 0) { - std::wstring meterName, measureName; + std::wstring meterName, measureName, styleName; // Check if the item is a meter or a measure (or perhaps something else) measureName = m_Parser.ReadString(pos, L"Measure", L""); meterName = m_Parser.ReadString(pos, L"Meter", L""); + styleName = m_Parser.ReadString(pos, L"Style", L""); if (measureName.length() > 0) { try @@ -1572,6 +1574,10 @@ void CMeterWindow::ReadSkin() MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); } } + else if (styleName.length() > 0) + { + //ignore sections with Style= in them. + } else { // It's something else @@ -3380,3 +3386,4 @@ std::wstring CMeterWindow::MakePathAbsolute(std::wstring path) return root + path; } + diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 6de9230f..25cd1d42 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -28,6 +28,8 @@ #include #include "ConfigParser.h" #include "Export.h" +#include +#include #define BEGIN_MESSAGEPROC switch(uMsg) { #define MESSAGE(handler, msg) case msg: return Window?Window->handler(wParam, lParam):DefWindowProc(hWnd, uMsg, wParam, lParam); @@ -113,6 +115,7 @@ typedef struct int vsT, vsL, vsH, vsW; } MULTIMONITOR_INFO; + class CRainmeter; class CMeasure; class CMeter; diff --git a/Rainmeter.sln b/Rainmeter.sln index dfa1e37e..d59fd6c8 100644 --- a/Rainmeter.sln +++ b/Rainmeter.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 +# Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Application", "Application\Application.vcproj", "{D2A0903C-E760-4134-AE61-3D55BF8F760C}" ProjectSection(ProjectDependencies) = postProject {BE9D2400-7F1C-49D6-8498-5CE495491AD6} = {BE9D2400-7F1C-49D6-8498-5CE495491AD6} @@ -138,6 +138,7 @@ Global {761BAD94-EA54-4DBD-9FF0-50FDAFECBE93}.Release64|Win32.ActiveCfg = Release64|Win32 {761BAD94-EA54-4DBD-9FF0-50FDAFECBE93}.Release64|Win32.Build.0 = Release64|Win32 {761BAD94-EA54-4DBD-9FF0-50FDAFECBE93}.Release64|x64.ActiveCfg = Release64|x64 + {761BAD94-EA54-4DBD-9FF0-50FDAFECBE93}.Release64|x64.Build.0 = Release64|x64 {BCE0E543-7ADC-4E10-AD66-52E90F70ED4A}.Debug|Win32.ActiveCfg = Debug|Win32 {BCE0E543-7ADC-4E10-AD66-52E90F70ED4A}.Debug|Win32.Build.0 = Debug|Win32 {BCE0E543-7ADC-4E10-AD66-52E90F70ED4A}.Debug|x64.ActiveCfg = Debug|Win32