Minor optimizations & fixes.

This commit is contained in:
spx
2011-05-22 16:02:43 +00:00
parent 7dd3bb1ed4
commit 3356448dbe
5 changed files with 67 additions and 32 deletions

View File

@ -99,6 +99,7 @@ CMeterWindow::CMeterWindow(const std::wstring& path, const std::wstring& config,
m_TransitionUpdate(100),
m_ActiveTransition(false),
m_HasNetMeasures(false),
m_HasPluginMeasures(false),
m_HasButtons(false),
m_WindowHide(HIDEMODE_NONE),
m_WindowStartHidden(false),
@ -126,6 +127,7 @@ CMeterWindow::CMeterWindow(const std::wstring& path, const std::wstring& config,
m_FadeEndValue(),
m_TransparencyValue(),
m_Refreshing(false),
m_BulkUpdating(false),
m_Hidden(false),
m_ResetRegion(false),
m_UpdateCounter(),
@ -2111,6 +2113,7 @@ bool CMeterWindow::ReadSkin()
// Create the meters and measures
m_HasNetMeasures = false;
m_HasPluginMeasures = false;
m_HasButtons = false;
// Get all the sections (i.e. different meters, measures and the other stuff)
@ -2142,16 +2145,23 @@ bool CMeterWindow::ReadSkin()
m_Measures.push_back(measure);
m_Parser.AddMeasure(measure);
if (!m_HasNetMeasures && dynamic_cast<CMeasureNet*>(measure))
{
m_HasNetMeasures = true;
}
CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure);
if (measureScript)
{
m_ScriptMeasures.push_back(measureScript);
}
else
{
if (!m_HasNetMeasures && dynamic_cast<CMeasureNet*>(measure))
{
m_HasNetMeasures = true;
}
if (!m_HasPluginMeasures && dynamic_cast<CMeasurePlugin*>(measure))
{
m_HasPluginMeasures = true;
}
}
}
}
catch (CError& error)
@ -2822,18 +2832,24 @@ void CMeterWindow::Update(bool nodraw)
{
++m_UpdateCounter;
// Pre-updates
m_BulkUpdating = true;
if (!m_Measures.empty())
{
// Pre-updates
if (m_HasNetMeasures) CMeasureNet::UpdateIFTable();
CMeasureCalc::UpdateVariableMap(*this);
}
// Update all measures
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for ( ; i != m_Measures.end(); ++i)
{
UpdateMeasure((*i), false);
// Update all measures
if (m_HasPluginMeasures) CSystem::SetWorkingDirectory(m_SkinPath + m_SkinName);
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
for ( ; i != m_Measures.end(); ++i)
{
UpdateMeasure((*i), false);
}
if (m_HasPluginMeasures) CSystem::ResetWorkingDirectory();
}
// Update all meters
@ -2868,6 +2884,8 @@ void CMeterWindow::Update(bool nodraw)
// Post-updates
PostUpdate(bActiveTransition);
m_BulkUpdating = false;
// if (m_MeasuresToVariables) // BUG: LSSetVariable doens't seem to work for some reason.
// {
// std::list<CMeasure*>::iterator i = m_Measures.begin();
@ -3486,7 +3504,6 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
std::wstring command = m_Rainmeter->GetConfigEditor() + L" \"";
command += m_SkinPath;
command += L"\\";
command += m_SkinName;
command += L"\\";
command += m_SkinIniFile;
@ -3505,7 +3522,6 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
else if (wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
{
std::wstring command = L"\"" + m_SkinPath;
command += L"\\";
command += m_SkinName;
command += L"\"";
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);