mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed a problem that "Random" is case-sensitive in CALC measure.
Fixed a problem that a deletion of the meter window encounters enormous delays when the meter window has enormous Update=. Some small cosmetics.
This commit is contained in:
parent
54fe29a062
commit
32db892e2c
@ -148,20 +148,25 @@ void CMeasureCalc::RandomFormulaReplace()
|
||||
//To implement random numbers the word "Random" in the string
|
||||
//formula is being replaced by the random number value
|
||||
m_Formula = m_FormulaHolder;
|
||||
std::wstring::size_type loc = m_Formula.find(L"Random");
|
||||
std::wstring::size_type loc = 0;
|
||||
|
||||
while(loc != std::wstring::npos)
|
||||
while ((loc = m_Formula.find_first_of(L"Rr", loc)) != std::wstring::npos)
|
||||
{
|
||||
int range = (m_HighBound - m_LowBound);
|
||||
srand((unsigned) rand());
|
||||
int randNumber = m_LowBound + (range * rand()/(RAND_MAX + 1.0));
|
||||
if (wcsnicmp(L"Random", m_Formula.c_str() + loc, 6) == 0)
|
||||
{
|
||||
int range = (m_HighBound - m_LowBound);
|
||||
srand((unsigned) rand());
|
||||
int randNumber = m_LowBound + (range * rand()/(RAND_MAX + 1.0));
|
||||
|
||||
std::wstring randomNumberString= (L"");
|
||||
wchar_t buf[8];
|
||||
_itow(randNumber,buf,10);
|
||||
randomNumberString.append(buf);
|
||||
WCHAR buffer[32];
|
||||
wsprintf(buffer, L"%i", randNumber);
|
||||
|
||||
m_Formula.replace(loc, 6, randomNumberString);
|
||||
loc = m_Formula.find(L"Random");
|
||||
m_Formula.replace(loc, 6, buffer);
|
||||
loc += wcslen(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
++loc;
|
||||
}
|
||||
}
|
||||
}
|
@ -92,7 +92,6 @@ void CMeterLine::Initialize()
|
||||
*/
|
||||
void CMeterLine::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
int i;
|
||||
WCHAR tmpName[256];
|
||||
|
||||
// Store the current number of lines so we know if the buffer needs to be updated
|
||||
@ -109,7 +108,7 @@ void CMeterLine::ReadConfig(const WCHAR* section)
|
||||
m_ScaleValues.clear();
|
||||
m_MeasureNames.clear();
|
||||
|
||||
for (i = 0; i < lineCount; ++i)
|
||||
for (int i = 0; i < lineCount; ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
|
@ -148,6 +148,12 @@ CMeterWindow::~CMeterWindow()
|
||||
{
|
||||
WriteConfig();
|
||||
|
||||
// Kill the timer
|
||||
KillTimer(m_Window, METERTIMER);
|
||||
KillTimer(m_Window, MOUSETIMER);
|
||||
KillTimer(m_Window, FADETIMER);
|
||||
KillTimer(m_Window, TRANSITIONTIMER);
|
||||
|
||||
// Destroy the meters
|
||||
std::list<CMeter*>::iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
@ -312,9 +318,11 @@ void CMeterWindow::Refresh(bool init, bool all)
|
||||
// First destroy everything
|
||||
// WriteConfig(); //Not clear why this is needed and it messes up resolution changes
|
||||
|
||||
KillTimer(m_Window, METERTIMER); // Kill the timer
|
||||
KillTimer(m_Window, MOUSETIMER); // Kill the timer
|
||||
KillTimer(m_Window, FADETIMER); // Kill the timer
|
||||
// Kill the timer
|
||||
KillTimer(m_Window, METERTIMER);
|
||||
KillTimer(m_Window, MOUSETIMER);
|
||||
KillTimer(m_Window, FADETIMER);
|
||||
KillTimer(m_Window, TRANSITIONTIMER);
|
||||
|
||||
std::list<CMeasure*>::iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
@ -2157,7 +2165,6 @@ void CMeterWindow::Update(bool nodraw)
|
||||
|
||||
// Update all measures
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
try
|
||||
@ -2335,8 +2342,6 @@ LRESULT CMeterWindow::OnTimer(WPARAM wParam, LPARAM lParam)
|
||||
// MoveWindow(x, y);
|
||||
// }
|
||||
//}
|
||||
|
||||
Rainmeter->ClearDeleteLaterList();
|
||||
}
|
||||
else if(wParam == TRANSITIONTIMER)
|
||||
{
|
||||
|
@ -1341,7 +1341,6 @@ void CRainmeter::ClearDeleteLaterList()
|
||||
while (!m_DelayDeleteList.empty())
|
||||
{
|
||||
CMeterWindow* meterWindow = m_DelayDeleteList.front();
|
||||
delete meterWindow;
|
||||
|
||||
// Remove from the delete later list
|
||||
m_DelayDeleteList.remove(meterWindow);
|
||||
@ -1356,6 +1355,8 @@ void CRainmeter::ClearDeleteLaterList()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete meterWindow;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1382,8 +1383,8 @@ bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater)
|
||||
}
|
||||
else if ((*iter).second == meterWindow)
|
||||
{
|
||||
delete meterWindow;
|
||||
m_Meters.erase(iter);
|
||||
delete meterWindow;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,15 @@ enum TIMER
|
||||
{
|
||||
TIMER_SHOWDESKTOP = 1,
|
||||
TIMER_COMPOSITION = 2,
|
||||
TIMER_NETSTATS = 3
|
||||
TIMER_NETSTATS = 3,
|
||||
TIMER_DELETELATER = 4
|
||||
};
|
||||
enum INTERVAL
|
||||
{
|
||||
INTERVAL_SHOWDESKTOP = 250,
|
||||
INTERVAL_COMPOSITION = 250,
|
||||
INTERVAL_NETSTATS = 10000
|
||||
INTERVAL_NETSTATS = 10000,
|
||||
INTERVAL_DELETELATER = 1000
|
||||
};
|
||||
|
||||
MULTIMONITOR_INFO CSystem::c_Monitors = { 0 };
|
||||
@ -116,6 +118,7 @@ void CSystem::Initialize(HINSTANCE instance)
|
||||
|
||||
SetTimer(c_Window, TIMER_SHOWDESKTOP, INTERVAL_SHOWDESKTOP, NULL);
|
||||
SetTimer(c_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, NULL);
|
||||
SetTimer(c_Window, TIMER_DELETELATER, INTERVAL_DELETELATER, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -129,6 +132,7 @@ void CSystem::Finalize()
|
||||
KillTimer(c_Window, TIMER_SHOWDESKTOP);
|
||||
KillTimer(c_Window, TIMER_COMPOSITION);
|
||||
KillTimer(c_Window, TIMER_NETSTATS);
|
||||
KillTimer(c_Window, TIMER_DELETELATER);
|
||||
|
||||
if (c_WinEventHook) UnhookWinEvent(c_WinEventHook);
|
||||
|
||||
@ -896,9 +900,13 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||
|
||||
// Statistics
|
||||
CMeasureNet::UpdateStats();
|
||||
Rainmeter->WriteStats(false);
|
||||
if (Rainmeter) Rainmeter->WriteStats(false);
|
||||
|
||||
return 0;
|
||||
|
||||
case TIMER_DELETELATER:
|
||||
if (Rainmeter) Rainmeter->ClearDeleteLaterList();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user