diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 912136b2..357c2d9a 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -714,12 +714,9 @@ CMeasure* CConfigParser::GetMeasure(const std::wstring& name) double CConfigParser::ReadFloat(LPCTSTR section, LPCTSTR key, double defValue) { - TCHAR buffer[256]; - swprintf(buffer, L"%f", defValue); + const std::wstring& result = ReadString(section, key, L""); - const std::wstring& result = ReadString(section, key, buffer); - - return ParseDouble(result, defValue); + return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue); } std::vector CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR key) @@ -742,21 +739,15 @@ std::vector CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR ke int CConfigParser::ReadInt(LPCTSTR section, LPCTSTR key, int defValue) { - TCHAR buffer[32]; - swprintf(buffer, L"%i", defValue); + const std::wstring& result = ReadString(section, key, L""); - const std::wstring& result = ReadString(section, key, buffer); - - return (int)ParseDouble(result, defValue, true); + return (m_LastDefaultUsed) ? defValue : (int)ParseDouble(result, defValue, true); } // Works as ReadFloat except if the value is surrounded by parenthesis in which case it tries to evaluate the formula double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue) { - TCHAR buffer[256]; - swprintf(buffer, L"%f", defValue); - - const std::wstring& result = ReadString(section, key, buffer); + const std::wstring& result = ReadString(section, key, L""); // Formulas must be surrounded by parenthesis if (!result.empty() && result[0] == L'(' && result[result.size() - 1] == L')') @@ -771,7 +762,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue) return resultValue; } - return ParseDouble(result, defValue); + return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue); } // Returns an int if the formula was read successfully, -1 for failure. @@ -797,12 +788,9 @@ int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue) Color CConfigParser::ReadColor(LPCTSTR section, LPCTSTR key, const Color& defValue) { - TCHAR buffer[128]; - swprintf(buffer, L"%i, %i, %i, %i", defValue.GetR(), defValue.GetG(), defValue.GetB(), defValue.GetA()); + const std::wstring& result = ReadString(section, key, L""); - const std::wstring& result = ReadString(section, key, buffer); - - return ParseColor(result.c_str()); + return (m_LastDefaultUsed) ? defValue : ParseColor(result.c_str()); } /* diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index d1c2e8c3..3fd47bd4 100644 --- a/Library/MeterHistogram.cpp +++ b/Library/MeterHistogram.cpp @@ -259,7 +259,7 @@ void CMeterHistogram::ReadConfig(const WCHAR* section) m_BothColor = parser.ReadColor(section, L"BothColor", Color::Yellow); m_SecondaryMeasureName = parser.ReadString(section, L"MeasureName2", L""); - if (m_SecondaryMeasureName == L"") + if (m_SecondaryMeasureName.empty()) { m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", L""); } diff --git a/Library/MeterImage.cpp b/Library/MeterImage.cpp index 94dd2806..c893723e 100644 --- a/Library/MeterImage.cpp +++ b/Library/MeterImage.cpp @@ -447,7 +447,7 @@ void CMeterImage::ReadConfig(const WCHAR* section) if (alpha != tint.GetAlpha()) { - tint = Color(alpha, tint.GetRed(), tint.GetGreen(), tint.GetBlue()); + tint.SetValue(Color::MakeARGB(alpha, tint.GetRed(), tint.GetGreen(), tint.GetBlue())); } m_ColorMatrix = c_IdentifyMatrix; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 7d851ff5..d11a6e56 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -259,22 +259,25 @@ void CMeterString::ReadConfig(const WCHAR* section) m_MeasureNames.clear(); // Check for extra measures - int i = 2; - bool loop = true; - do + if (!m_MeasureName.empty()) { - swprintf(tmpName, L"MeasureName%i", i); - std::wstring measure = parser.ReadString(section, tmpName, L""); - if (!measure.empty()) + int i = 2; + bool loop = true; + do { - m_MeasureNames.push_back(measure); - } - else - { - loop = false; - } - ++i; - } while(loop); + swprintf(tmpName, L"MeasureName%i", i); + std::wstring measure = parser.ReadString(section, tmpName, L""); + if (!measure.empty()) + { + m_MeasureNames.push_back(measure); + } + else + { + loop = false; + } + ++i; + } while(loop); + } m_Color = parser.ReadColor(section, L"FontColor", Color::Black); m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black);