diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index a6177770..f0f0d4e4 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -132,14 +132,27 @@ void CConfigParser::SetVariable(const std::wstring& strVariable, const std::wstr ** ** */ -const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures, bool bReplaceDefValue) +const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures) { static std::wstring result; - result = GetValue(section, key, defValue); - if (result == defValue && bReplaceDefValue == false) + if (section == NULL) { - return result; + section = L""; + } + if (key == NULL) + { + key = L""; + } + if (defValue == NULL) + { + defValue = L""; + } + + result = GetValue(section, key, defValue); + if (result == defValue) + { + return result; } // Check Litestep vars @@ -445,7 +458,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; @@ -474,7 +487,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; @@ -490,11 +503,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 != size - 2) break; // Fits in the buffer + if (res < bufferSize - 2) break; // Fits in the buffer delete [] buffer; bufferSize *= 2; - buffer = new WCHAR[size]; + buffer = new WCHAR[bufferSize]; }; SetValue((*iter).first, strKey, buffer); @@ -593,4 +606,3 @@ std::vector CConfigParser::GetKeys(const std::wstring& strSection) return std::vector(); } - diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index acf57b87..777120ec 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, bool bReplaceDefValue = false); + const std::wstring& ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures = true); 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 d09b383e..cf54611c 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -212,8 +212,6 @@ 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) { @@ -250,30 +248,29 @@ 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_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_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0); + m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", m_SolidBevel); - 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_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_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_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_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_MeasureName = parser.ReadString(section, L"MeasureName", L""); - 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_UpdateDivider = parser.ReadInt(section, L"UpdateDivider", 1); m_UpdateCounter = m_UpdateDivider; - 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)); + m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); + m_DynamicVariables = 0!=parser.ReadInt(section, 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 3409b535..4a1478e0 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -128,8 +128,6 @@ 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 7c6bde94..fbf34015 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", parser.ReadColor(m_StyleName.c_str(), L"BarColor", Color::Green)); + m_Color = parser.ReadColor(section, L"BarColor", Color::Green); - m_ImageName = parser.ReadString(section, L"BarImage", parser.ReadString(m_StyleName.c_str(), L"BarImage", L"").c_str(),true,true); + m_ImageName = parser.ReadString(section, L"BarImage", L""); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - m_Border = parser.ReadInt(section, L"BarBorder", parser.ReadInt(m_StyleName.c_str(), L"BarBorder", 0)); + m_Border = parser.ReadInt(section, L"BarBorder", 0); m_Flip = parser.ReadInt(section, L"Flip", 0) == 1; std::wstring orientation; - orientation = parser.ReadString(section, L"BarOrientation", parser.ReadString(m_StyleName.c_str(), L"BarOrientation", L"VERTICAL").c_str(),true,true); + orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL"); if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0) { diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index 9a50887e..d7b13137 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", parser.ReadString(m_StyleName.c_str(), L"BitmapImage", L"").c_str(),true,true); + m_ImageName = parser.ReadString(section, L"BitmapImage", L""); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - 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_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1); + m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 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_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_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", parser.ReadInt(m_StyleName.c_str(), L"BitmapTransitionFrames", 0)); + m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0); std::wstring align; - align = parser.ReadString(section, L"BitmapAlign", parser.ReadString(m_StyleName.c_str(), L"BitmapAlign", L"LEFT").c_str(),true,true); + align = parser.ReadString(section, L"BitmapAlign", L"LEFT"); if(_wcsicmp(align.c_str(), L"LEFT") == 0) { diff --git a/Library/MeterButton.cpp b/Library/MeterButton.cpp index 78e3b893..709c01fd 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", parser.ReadString(m_StyleName.c_str(), L"ButtonImage", L"").c_str(),true,true); + m_ImageName = parser.ReadString(section, L"ButtonImage", L""); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - m_Command = parser.ReadString(section, L"ButtonCommand", parser.ReadString(m_StyleName.c_str(), L"ButtonCommand", L"").c_str(),true,true); + m_Command = parser.ReadString(section, L"ButtonCommand", L""); } /* diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index 7bdb5f13..672dba1c 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", 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_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_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", parser.ReadString(m_StyleName.c_str(), L"SecondaryMeasureName", L"").c_str(),true,true); + m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", L""); - m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", parser.ReadString(m_StyleName.c_str(), L"PrimaryImage", L"").c_str(),true,true); + m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", L""); m_PrimaryImageName = m_MeterWindow->MakePathAbsolute(m_PrimaryImageName); - m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", parser.ReadString(m_StyleName.c_str(), L"SecondaryImage", L"").c_str(),true,true); + m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L""); m_SecondaryImageName = m_MeterWindow->MakePathAbsolute(m_SecondaryImageName); - m_BothImageName = parser.ReadString(section, L"BothImage", parser.ReadString(m_StyleName.c_str(), L"BothImage", L"").c_str(),true,true); + m_BothImageName = parser.ReadString(section, L"BothImage", L""); m_BothImageName = m_MeterWindow->MakePathAbsolute(m_BothImageName); - m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0!=parser.ReadInt(m_StyleName.c_str(), L"AutoScale", 0)); + m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); } diff --git a/Library/MeterImage.cpp b/Library/MeterImage.cpp index c8e44895..5c577815 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", parser.ReadString(m_StyleName.c_str(), L"ImageName", L"").c_str(),true,true); + m_ImageName = parser.ReadString(section, L"ImageName", L""); - m_Path = parser.ReadString(section, L"Path", parser.ReadString(m_StyleName.c_str(), L"Path", L"").c_str(),true,true); + m_Path = parser.ReadString(section, L"Path", L""); 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!=parser.ReadInt(m_StyleName.c_str(), L"PreserveAspectRatio", 0)); + m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0); if (-1 != parser.ReadInt(section, L"W", -1)) { diff --git a/Library/MeterLine.cpp b/Library/MeterLine.cpp index 1fd8eaaa..4a4b94b7 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", parser.ReadInt(m_StyleName.c_str(), L"LineCount", 1)); + int lineCount = parser.ReadInt(section, 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, parser.ReadColor(m_StyleName.c_str(), tmpName, Color::White))); + m_Colors.push_back(parser.ReadColor(section, 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, parser.ReadFloat(m_StyleName.c_str(), tmpName, 1.0))); + m_ScaleValues.push_back(parser.ReadFloat(section, tmpName, 1.0)); if (i != 0) { swprintf(tmpName, L"MeasureName%i", i + 1); - m_MeasureNames.push_back(parser.ReadString(section, tmpName, parser.ReadString(m_StyleName.c_str(), tmpName, L"").c_str(),true,true)); + m_MeasureNames.push_back(parser.ReadString(section, tmpName, L"")); } } - 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 + 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 } /* diff --git a/Library/MeterRotator.cpp b/Library/MeterRotator.cpp index 1175677b..ee3dff2d 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", parser.ReadString(m_StyleName.c_str(), L"ImageName", L"").c_str(),true,true); + m_ImageName = parser.ReadString(section, L"ImageName", L""); m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName); - 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_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_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_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo + m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder); } /* diff --git a/Library/MeterRoundLine.cpp b/Library/MeterRoundLine.cpp index 600b85f9..6e769b2f 100644 --- a/Library/MeterRoundLine.cpp +++ b/Library/MeterRoundLine.cpp @@ -73,24 +73,21 @@ void CMeterRoundLine::ReadConfig(const WCHAR* section) CMeter::ReadConfig(section); CConfigParser& parser = m_MeterWindow->GetParser(); - - 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)); + 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); } /* diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index a8d2d3e1..ca836afb 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -109,7 +109,6 @@ 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 @@ -213,27 +212,25 @@ 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_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_Color = parser.ReadColor(section, L"FontColor", Color::Black); + m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black); - 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_Prefix = parser.ReadString(section, L"Prefix", L""); + m_Postfix = parser.ReadString(section, L"Postfix", L""); + m_Text = parser.ReadString(section, L"Text", L""); - m_FontSize = parser.ReadFormula(section, L"FontSize", parser.ReadFormula(m_StyleName.c_str(), L"FontSize", 10)); + 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_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", parser.ReadInt(m_StyleName.c_str(), L"NumOfDecimals", -1)); + m_FontSize = parser.ReadFormula(section, L"FontSize", 10); + m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1); - m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", (Gdiplus::REAL)parser.ReadFloat(m_StyleName.c_str(), L"Angle",0.0)); + m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0); std::wstring scale; - scale = parser.ReadString(section, L"Scale", parser.ReadString(m_StyleName.c_str(), L"Scale", L"1").c_str(),true,true); + scale = parser.ReadString(section, L"Scale", L"1"); if (wcschr(scale.c_str(), '.') == NULL) { @@ -245,11 +242,10 @@ void CMeterString::ReadConfig(const WCHAR* section) } m_Scale = wcstod(scale.c_str(), NULL); - m_FontFace = parser.ReadString(section, L"FontFace", parser.ReadString(m_StyleName.c_str(), L"FontFace", L"Arial").c_str(),true,true); - + m_FontFace = parser.ReadString(section, L"FontFace", L"Arial"); std::wstring align; - align = parser.ReadString(section, L"StringAlign", parser.ReadString(m_StyleName.c_str(), L"StringAlign", L"LEFT").c_str(),true,true); + align = parser.ReadString(section, L"StringAlign", L"LEFT"); if(_wcsicmp(align.c_str(), L"LEFT") == 0) { @@ -269,8 +265,8 @@ void CMeterString::ReadConfig(const WCHAR* section) } std::wstring style; - style = parser.ReadString(section, L"StringStyle", parser.ReadString(m_StyleName.c_str(), L"StringStyle", L"NORMAL").c_str(),true,true); - + style = parser.ReadString(section, L"StringStyle", L"NORMAL"); + if(_wcsicmp(style.c_str(), L"NORMAL") == 0) { m_Style = NORMAL; @@ -293,8 +289,8 @@ void CMeterString::ReadConfig(const WCHAR* section) } std::wstring effect; - effect = parser.ReadString(section, L"StringEffect", parser.ReadString(m_StyleName.c_str(), L"StringEffect", L"NONE").c_str(),true,true); - + effect = parser.ReadString(section, L"StringEffect", L"NONE"); + if(_wcsicmp(effect.c_str(), L"NONE") == 0) { m_Effect = EFFECT_NONE; @@ -326,15 +322,6 @@ 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 b397ca96..f3c8139f 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -38,7 +38,6 @@ #include "MeasureNet.h" #include "MeasurePlugin.h" #include "MeterButton.h" -#include using namespace Gdiplus; @@ -1522,7 +1521,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; @@ -1536,12 +1535,11 @@ void CMeterWindow::ReadSkin() wcsicmp(L"Variables", pos) != 0 && wcsicmp(L"Metadata", pos) != 0) { - std::wstring meterName, measureName, styleName; + std::wstring meterName, measureName; // 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 @@ -1574,10 +1572,6 @@ 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 @@ -3386,4 +3380,3 @@ std::wstring CMeterWindow::MakePathAbsolute(std::wstring path) return root + path; } - diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 25cd1d42..6de9230f 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -28,8 +28,6 @@ #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); @@ -115,7 +113,6 @@ typedef struct int vsT, vsL, vsH, vsW; } MULTIMONITOR_INFO; - class CRainmeter; class CMeasure; class CMeter; diff --git a/Rainmeter.sln b/Rainmeter.sln index d59fd6c8..dfa1e37e 100644 --- a/Rainmeter.sln +++ b/Rainmeter.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 +# Visual C++ Express 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,7 +138,6 @@ 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