Code cleanup.

This commit is contained in:
spx 2011-11-27 12:46:59 +00:00
parent 34005f14a4
commit d622c88d69
3 changed files with 18 additions and 11 deletions

View File

@ -155,7 +155,7 @@ void CMeasureDiskSpace::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_Value = 0.0;
m_MaxValue = 0.0;
m_OldTotalBytes = 0;
m_LabelName = L"";
m_LabelName.clear();
}
else if (!CSystem::IsPathSeparator(m_Drive[m_Drive.length() - 1])) // E.g. "C:"
{

View File

@ -1908,20 +1908,16 @@ void CMeterWindow::ReadConfig()
m_AutoSelectScreen = false;
m_AlphaValue = 255;
m_FadeDuration = 250;
m_ConfigGroup = L"";
m_ConfigGroup.clear();
CConfigParser parser;
parser.Initialize(iniFile.c_str(), m_Rainmeter, NULL, m_SkinName.c_str());
for (int i = 0; i < 2; ++i)
{
m_WindowX = parser.ReadString(section, L"WindowX", m_WindowX.c_str());
m_WindowY = parser.ReadString(section, L"WindowY", m_WindowY.c_str());
m_AnchorX = parser.ReadString(section, L"AnchorX", m_AnchorX.c_str());
m_AnchorY = parser.ReadString(section, L"AnchorY", m_AnchorY.c_str());
// Check if the window position should be read as a formula
double value;
m_WindowX = parser.ReadString(section, L"WindowX", m_WindowX.c_str());
if (!m_WindowX.empty() && m_WindowX[0] == L'(' && m_WindowX[m_WindowX.size() - 1] == L')')
{
if (!parser.ParseFormula(m_WindowX, &value))
@ -1931,6 +1927,7 @@ void CMeterWindow::ReadConfig()
_itow_s((int)value, buffer, 10);
m_WindowX = buffer;
}
m_WindowY = parser.ReadString(section, L"WindowY", m_WindowY.c_str());
if (!m_WindowY.empty() && m_WindowY[0] == L'(' && m_WindowY[m_WindowY.size() - 1] == L')')
{
if (!parser.ParseFormula(m_WindowY, &value))
@ -1941,6 +1938,9 @@ void CMeterWindow::ReadConfig()
m_WindowY = buffer;
}
m_AnchorX = parser.ReadString(section, L"AnchorX", m_AnchorX.c_str());
m_AnchorY = parser.ReadString(section, L"AnchorY", m_AnchorY.c_str());
int zPos = parser.ReadInt(section, L"AlwaysOnTop", m_WindowZPosition);
m_WindowZPosition = (zPos >= ZPOSITION_ONDESKTOP && zPos <= ZPOSITION_ONTOPMOST) ? (ZPOSITION)zPos : ZPOSITION_NORMAL;

View File

@ -21,10 +21,17 @@ static int Measure_GetOption(lua_State* L)
std::wstring strTmp = LuaManager::ToWide(L, 2);
strTmp = parser.GetValue(self->GetOriginalName(), strTmp, L"");
parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetOriginalName()); // Set temporarily
parser.ReplaceVariables(strTmp);
parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset
parser.ReplaceMeasures(strTmp);
if (strTmp.size() >= 3)
{
if (strTmp.find(L'#') != std::wstring::npos)
{
static const std::wstring CURRENTSECTION = L"CURRENTSECTION";
parser.SetBuiltInVariable(CURRENTSECTION, self->GetOriginalName()); // Set temporarily
parser.ReplaceVariables(strTmp);
parser.SetBuiltInVariable(CURRENTSECTION, L""); // Reset
}
parser.ReplaceMeasures(strTmp);
}
LuaManager::PushWide(L, strTmp.c_str());
return 1;