mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Small code optimization.
This commit is contained in:
parent
fc046ac4eb
commit
f689bbe6f1
@ -714,12 +714,9 @@ CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
|
|||||||
|
|
||||||
double CConfigParser::ReadFloat(LPCTSTR section, LPCTSTR key, double defValue)
|
double CConfigParser::ReadFloat(LPCTSTR section, LPCTSTR key, double defValue)
|
||||||
{
|
{
|
||||||
TCHAR buffer[256];
|
const std::wstring& result = ReadString(section, key, L"");
|
||||||
swprintf(buffer, L"%f", defValue);
|
|
||||||
|
|
||||||
const std::wstring& result = ReadString(section, key, buffer);
|
return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue);
|
||||||
|
|
||||||
return ParseDouble(result, defValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Gdiplus::REAL> CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR key)
|
std::vector<Gdiplus::REAL> CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR key)
|
||||||
@ -742,21 +739,15 @@ std::vector<Gdiplus::REAL> CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR ke
|
|||||||
|
|
||||||
int CConfigParser::ReadInt(LPCTSTR section, LPCTSTR key, int defValue)
|
int CConfigParser::ReadInt(LPCTSTR section, LPCTSTR key, int defValue)
|
||||||
{
|
{
|
||||||
TCHAR buffer[32];
|
const std::wstring& result = ReadString(section, key, L"");
|
||||||
swprintf(buffer, L"%i", defValue);
|
|
||||||
|
|
||||||
const std::wstring& result = ReadString(section, key, buffer);
|
return (m_LastDefaultUsed) ? defValue : (int)ParseDouble(result, defValue, true);
|
||||||
|
|
||||||
return (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
|
// 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)
|
double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
|
||||||
{
|
{
|
||||||
TCHAR buffer[256];
|
const std::wstring& result = ReadString(section, key, L"");
|
||||||
swprintf(buffer, L"%f", defValue);
|
|
||||||
|
|
||||||
const std::wstring& result = ReadString(section, key, buffer);
|
|
||||||
|
|
||||||
// Formulas must be surrounded by parenthesis
|
// Formulas must be surrounded by parenthesis
|
||||||
if (!result.empty() && result[0] == L'(' && result[result.size() - 1] == L')')
|
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 resultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ParseDouble(result, defValue);
|
return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an int if the formula was read successfully, -1 for failure.
|
// 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)
|
Color CConfigParser::ReadColor(LPCTSTR section, LPCTSTR key, const Color& defValue)
|
||||||
{
|
{
|
||||||
TCHAR buffer[128];
|
const std::wstring& result = ReadString(section, key, L"");
|
||||||
swprintf(buffer, L"%i, %i, %i, %i", defValue.GetR(), defValue.GetG(), defValue.GetB(), defValue.GetA());
|
|
||||||
|
|
||||||
const std::wstring& result = ReadString(section, key, buffer);
|
return (m_LastDefaultUsed) ? defValue : ParseColor(result.c_str());
|
||||||
|
|
||||||
return ParseColor(result.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -259,7 +259,7 @@ void CMeterHistogram::ReadConfig(const WCHAR* section)
|
|||||||
m_BothColor = parser.ReadColor(section, L"BothColor", Color::Yellow);
|
m_BothColor = parser.ReadColor(section, L"BothColor", Color::Yellow);
|
||||||
|
|
||||||
m_SecondaryMeasureName = parser.ReadString(section, L"MeasureName2", L"");
|
m_SecondaryMeasureName = parser.ReadString(section, L"MeasureName2", L"");
|
||||||
if (m_SecondaryMeasureName == L"")
|
if (m_SecondaryMeasureName.empty())
|
||||||
{
|
{
|
||||||
m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", L"");
|
m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", L"");
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ void CMeterImage::ReadConfig(const WCHAR* section)
|
|||||||
|
|
||||||
if (alpha != tint.GetAlpha())
|
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;
|
m_ColorMatrix = c_IdentifyMatrix;
|
||||||
|
@ -259,6 +259,8 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
|||||||
m_MeasureNames.clear();
|
m_MeasureNames.clear();
|
||||||
|
|
||||||
// Check for extra measures
|
// Check for extra measures
|
||||||
|
if (!m_MeasureName.empty())
|
||||||
|
{
|
||||||
int i = 2;
|
int i = 2;
|
||||||
bool loop = true;
|
bool loop = true;
|
||||||
do
|
do
|
||||||
@ -275,6 +277,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
|||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
} while(loop);
|
} while(loop);
|
||||||
|
}
|
||||||
|
|
||||||
m_Color = parser.ReadColor(section, L"FontColor", Color::Black);
|
m_Color = parser.ReadColor(section, L"FontColor", Color::Black);
|
||||||
m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black);
|
m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black);
|
||||||
|
Loading…
Reference in New Issue
Block a user