mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Minor optimizations & fixes.
This commit is contained in:
parent
7dd3bb1ed4
commit
3356448dbe
@ -68,15 +68,14 @@ bool CMeasurePlugin::Update()
|
|||||||
{
|
{
|
||||||
if (!CMeasure::PreUpdate()) return false;
|
if (!CMeasure::PreUpdate()) return false;
|
||||||
|
|
||||||
WCHAR buffer[MAX_PATH];
|
bool bulkUpdating = (m_MeterWindow && m_MeterWindow->IsBulkUpdating());
|
||||||
GetCurrentDirectory(MAX_PATH, buffer);
|
|
||||||
|
|
||||||
std::wstring dir = Rainmeter->GetSkinPath();
|
if (!bulkUpdating)
|
||||||
if (m_MeterWindow)
|
|
||||||
{
|
{
|
||||||
dir += m_MeterWindow->GetSkinName();
|
std::wstring dir = Rainmeter->GetSkinPath();
|
||||||
|
if (m_MeterWindow) dir += m_MeterWindow->GetSkinName();
|
||||||
|
CSystem::SetWorkingDirectory(dir);
|
||||||
}
|
}
|
||||||
SetCurrentDirectory(dir.c_str());
|
|
||||||
|
|
||||||
if (UpdateFunc)
|
if (UpdateFunc)
|
||||||
{
|
{
|
||||||
@ -89,7 +88,10 @@ bool CMeasurePlugin::Update()
|
|||||||
m_Value = UpdateFunc2(m_ID);
|
m_Value = UpdateFunc2(m_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCurrentDirectory(buffer);
|
if (!bulkUpdating)
|
||||||
|
{
|
||||||
|
CSystem::ResetWorkingDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
return PostUpdate();
|
return PostUpdate();
|
||||||
}
|
}
|
||||||
@ -181,23 +183,17 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
|||||||
m_ID = id++;
|
m_ID = id++;
|
||||||
if (InitializeFunc)
|
if (InitializeFunc)
|
||||||
{
|
{
|
||||||
WCHAR buffer[MAX_PATH];
|
|
||||||
GetCurrentDirectory(MAX_PATH, buffer);
|
|
||||||
|
|
||||||
std::wstring dir = Rainmeter->GetSkinPath();
|
|
||||||
if (m_MeterWindow)
|
|
||||||
{
|
|
||||||
dir += m_MeterWindow->GetSkinName();
|
|
||||||
}
|
|
||||||
SetCurrentDirectory(dir.c_str());
|
|
||||||
|
|
||||||
// Remove current directory from DLL search path
|
// Remove current directory from DLL search path
|
||||||
SetDllDirectory(L"");
|
SetDllDirectory(L"");
|
||||||
|
|
||||||
|
std::wstring dir = Rainmeter->GetSkinPath();
|
||||||
|
if (m_MeterWindow) dir += m_MeterWindow->GetSkinName();
|
||||||
|
CSystem::SetWorkingDirectory(dir);
|
||||||
|
|
||||||
double maxValue;
|
double maxValue;
|
||||||
maxValue = InitializeFunc(m_Plugin, parser.GetFilename().c_str(), section, m_ID);
|
maxValue = InitializeFunc(m_Plugin, parser.GetFilename().c_str(), section, m_ID);
|
||||||
|
|
||||||
SetCurrentDirectory(buffer);
|
CSystem::ResetWorkingDirectory();
|
||||||
|
|
||||||
std::wstring szMaxValue = parser.ReadString(section, L"MaxValue", L"NotSet");
|
std::wstring szMaxValue = parser.ReadString(section, L"MaxValue", L"NotSet");
|
||||||
if (szMaxValue == L"NotSet")
|
if (szMaxValue == L"NotSet")
|
||||||
|
@ -99,6 +99,7 @@ CMeterWindow::CMeterWindow(const std::wstring& path, const std::wstring& config,
|
|||||||
m_TransitionUpdate(100),
|
m_TransitionUpdate(100),
|
||||||
m_ActiveTransition(false),
|
m_ActiveTransition(false),
|
||||||
m_HasNetMeasures(false),
|
m_HasNetMeasures(false),
|
||||||
|
m_HasPluginMeasures(false),
|
||||||
m_HasButtons(false),
|
m_HasButtons(false),
|
||||||
m_WindowHide(HIDEMODE_NONE),
|
m_WindowHide(HIDEMODE_NONE),
|
||||||
m_WindowStartHidden(false),
|
m_WindowStartHidden(false),
|
||||||
@ -126,6 +127,7 @@ CMeterWindow::CMeterWindow(const std::wstring& path, const std::wstring& config,
|
|||||||
m_FadeEndValue(),
|
m_FadeEndValue(),
|
||||||
m_TransparencyValue(),
|
m_TransparencyValue(),
|
||||||
m_Refreshing(false),
|
m_Refreshing(false),
|
||||||
|
m_BulkUpdating(false),
|
||||||
m_Hidden(false),
|
m_Hidden(false),
|
||||||
m_ResetRegion(false),
|
m_ResetRegion(false),
|
||||||
m_UpdateCounter(),
|
m_UpdateCounter(),
|
||||||
@ -2111,6 +2113,7 @@ bool CMeterWindow::ReadSkin()
|
|||||||
// Create the meters and measures
|
// Create the meters and measures
|
||||||
|
|
||||||
m_HasNetMeasures = false;
|
m_HasNetMeasures = false;
|
||||||
|
m_HasPluginMeasures = false;
|
||||||
m_HasButtons = false;
|
m_HasButtons = false;
|
||||||
|
|
||||||
// Get all the sections (i.e. different meters, measures and the other stuff)
|
// 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_Measures.push_back(measure);
|
||||||
m_Parser.AddMeasure(measure);
|
m_Parser.AddMeasure(measure);
|
||||||
|
|
||||||
if (!m_HasNetMeasures && dynamic_cast<CMeasureNet*>(measure))
|
|
||||||
{
|
|
||||||
m_HasNetMeasures = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure);
|
CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure);
|
||||||
if (measureScript)
|
if (measureScript)
|
||||||
{
|
{
|
||||||
m_ScriptMeasures.push_back(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)
|
catch (CError& error)
|
||||||
@ -2822,18 +2832,24 @@ void CMeterWindow::Update(bool nodraw)
|
|||||||
{
|
{
|
||||||
++m_UpdateCounter;
|
++m_UpdateCounter;
|
||||||
|
|
||||||
// Pre-updates
|
m_BulkUpdating = true;
|
||||||
|
|
||||||
if (!m_Measures.empty())
|
if (!m_Measures.empty())
|
||||||
{
|
{
|
||||||
|
// Pre-updates
|
||||||
if (m_HasNetMeasures) CMeasureNet::UpdateIFTable();
|
if (m_HasNetMeasures) CMeasureNet::UpdateIFTable();
|
||||||
CMeasureCalc::UpdateVariableMap(*this);
|
CMeasureCalc::UpdateVariableMap(*this);
|
||||||
}
|
|
||||||
|
|
||||||
// Update all measures
|
// Update all measures
|
||||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
if (m_HasPluginMeasures) CSystem::SetWorkingDirectory(m_SkinPath + m_SkinName);
|
||||||
for ( ; i != m_Measures.end(); ++i)
|
|
||||||
{
|
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||||
UpdateMeasure((*i), false);
|
for ( ; i != m_Measures.end(); ++i)
|
||||||
|
{
|
||||||
|
UpdateMeasure((*i), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_HasPluginMeasures) CSystem::ResetWorkingDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update all meters
|
// Update all meters
|
||||||
@ -2868,6 +2884,8 @@ void CMeterWindow::Update(bool nodraw)
|
|||||||
// Post-updates
|
// Post-updates
|
||||||
PostUpdate(bActiveTransition);
|
PostUpdate(bActiveTransition);
|
||||||
|
|
||||||
|
m_BulkUpdating = false;
|
||||||
|
|
||||||
// if (m_MeasuresToVariables) // BUG: LSSetVariable doens't seem to work for some reason.
|
// if (m_MeasuresToVariables) // BUG: LSSetVariable doens't seem to work for some reason.
|
||||||
// {
|
// {
|
||||||
// std::list<CMeasure*>::iterator i = m_Measures.begin();
|
// 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" \"";
|
std::wstring command = m_Rainmeter->GetConfigEditor() + L" \"";
|
||||||
command += m_SkinPath;
|
command += m_SkinPath;
|
||||||
command += L"\\";
|
|
||||||
command += m_SkinName;
|
command += m_SkinName;
|
||||||
command += L"\\";
|
command += L"\\";
|
||||||
command += m_SkinIniFile;
|
command += m_SkinIniFile;
|
||||||
@ -3505,7 +3522,6 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
else if (wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
|
else if (wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
|
||||||
{
|
{
|
||||||
std::wstring command = L"\"" + m_SkinPath;
|
std::wstring command = L"\"" + m_SkinPath;
|
||||||
command += L"\\";
|
|
||||||
command += m_SkinName;
|
command += m_SkinName;
|
||||||
command += L"\"";
|
command += L"\"";
|
||||||
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
|
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
|
||||||
|
@ -182,6 +182,8 @@ public:
|
|||||||
void Refresh(bool init, bool all = false);
|
void Refresh(bool init, bool all = false);
|
||||||
void Redraw();
|
void Redraw();
|
||||||
|
|
||||||
|
bool IsBulkUpdating() { return m_BulkUpdating; }
|
||||||
|
|
||||||
void SetMouseLeaveEvent(bool cancel);
|
void SetMouseLeaveEvent(bool cancel);
|
||||||
|
|
||||||
void MoveWindow(int x, int y);
|
void MoveWindow(int x, int y);
|
||||||
@ -383,6 +385,7 @@ private:
|
|||||||
int m_TransitionUpdate; // Transition redraw frequency
|
int m_TransitionUpdate; // Transition redraw frequency
|
||||||
bool m_ActiveTransition;
|
bool m_ActiveTransition;
|
||||||
bool m_HasNetMeasures;
|
bool m_HasNetMeasures;
|
||||||
|
bool m_HasPluginMeasures;
|
||||||
bool m_HasButtons;
|
bool m_HasButtons;
|
||||||
HIDEMODE m_WindowHide; // If true, the window is hidden when mouse is over it
|
HIDEMODE m_WindowHide; // If true, the window is hidden when mouse is over it
|
||||||
bool m_WindowStartHidden; // If true, the window is hidden at startup
|
bool m_WindowStartHidden; // If true, the window is hidden at startup
|
||||||
@ -415,6 +418,7 @@ private:
|
|||||||
int m_TransparencyValue;
|
int m_TransparencyValue;
|
||||||
|
|
||||||
bool m_Refreshing; // This is true, when the meter is refreshing
|
bool m_Refreshing; // This is true, when the meter is refreshing
|
||||||
|
bool m_BulkUpdating;
|
||||||
|
|
||||||
bool m_Hidden; // True, if Rainmeter is hidden
|
bool m_Hidden; // True, if Rainmeter is hidden
|
||||||
bool m_ResetRegion; // If true, the window region is recalculated during the next update
|
bool m_ResetRegion; // If true, the window region is recalculated during the next update
|
||||||
|
@ -50,6 +50,8 @@ bool CSystem::c_ShowDesktop = false;
|
|||||||
|
|
||||||
OSPLATFORM CSystem::c_Platform = OSPLATFORM_UNKNOWN;
|
OSPLATFORM CSystem::c_Platform = OSPLATFORM_UNKNOWN;
|
||||||
|
|
||||||
|
std::wstring CSystem::c_WorkingDirectory;
|
||||||
|
|
||||||
extern CRainmeter* Rainmeter;
|
extern CRainmeter* Rainmeter;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -115,6 +117,18 @@ void CSystem::Initialize(HINSTANCE instance)
|
|||||||
0,
|
0,
|
||||||
WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
|
WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
|
||||||
|
|
||||||
|
WCHAR directory[MAX_PATH] = {0};
|
||||||
|
GetCurrentDirectory(MAX_PATH, directory);
|
||||||
|
c_WorkingDirectory = directory;
|
||||||
|
if (!c_WorkingDirectory.empty())
|
||||||
|
{
|
||||||
|
WCHAR ch = c_WorkingDirectory[c_WorkingDirectory.size() - 1];
|
||||||
|
if (ch != L'\\' && ch != L'/')
|
||||||
|
{
|
||||||
|
c_WorkingDirectory += L"\\";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetTimer(c_Window, TIMER_SHOWDESKTOP, INTERVAL_SHOWDESKTOP, NULL);
|
SetTimer(c_Window, TIMER_SHOWDESKTOP, INTERVAL_SHOWDESKTOP, NULL);
|
||||||
SetTimer(c_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, NULL);
|
SetTimer(c_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, NULL);
|
||||||
SetTimer(c_Window, TIMER_DELETELATER, INTERVAL_DELETELATER, NULL);
|
SetTimer(c_Window, TIMER_DELETELATER, INTERVAL_DELETELATER, NULL);
|
||||||
|
@ -75,6 +75,9 @@ public:
|
|||||||
|
|
||||||
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = NULL, bool ignoreErrors = false);
|
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = NULL, bool ignoreErrors = false);
|
||||||
|
|
||||||
|
static void SetWorkingDirectory(const std::wstring& directory) { SetCurrentDirectory(directory.c_str()); }
|
||||||
|
static void ResetWorkingDirectory() { SetWorkingDirectory(c_WorkingDirectory); }
|
||||||
|
|
||||||
static bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
|
static bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
|
||||||
static bool RemoveFile(const std::wstring& file);
|
static bool RemoveFile(const std::wstring& file);
|
||||||
|
|
||||||
@ -106,6 +109,8 @@ private:
|
|||||||
static bool c_ShowDesktop;
|
static bool c_ShowDesktop;
|
||||||
|
|
||||||
static OSPLATFORM c_Platform;
|
static OSPLATFORM c_Platform;
|
||||||
|
|
||||||
|
static std::wstring c_WorkingDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user