mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Script: Fixed that Initialize() was not called when the script is changed dynamically
This commit is contained in:
parent
67a57ca9ee
commit
a0a0c61e79
@ -30,7 +30,6 @@ const char* g_GetStringFunctionName = "GetStringValue";
|
|||||||
*/
|
*/
|
||||||
CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
CMeasureScript::CMeasureScript(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
||||||
m_LuaScript(),
|
m_LuaScript(),
|
||||||
m_HasInitializeFunction(false),
|
|
||||||
m_HasUpdateFunction(false),
|
m_HasUpdateFunction(false),
|
||||||
m_HasGetStringFunction(false),
|
m_HasGetStringFunction(false),
|
||||||
m_ValueType(LUA_TNIL)
|
m_ValueType(LUA_TNIL)
|
||||||
@ -53,27 +52,12 @@ void CMeasureScript::DeleteLuaScript()
|
|||||||
delete m_LuaScript;
|
delete m_LuaScript;
|
||||||
m_LuaScript = NULL;
|
m_LuaScript = NULL;
|
||||||
|
|
||||||
m_HasInitializeFunction = false;
|
|
||||||
m_HasUpdateFunction = false;
|
m_HasUpdateFunction = false;
|
||||||
m_HasGetStringFunction = false;
|
m_HasGetStringFunction = false;
|
||||||
|
|
||||||
m_ScriptFile.clear();
|
m_ScriptFile.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** Initializes the measure.
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
void CMeasureScript::Initialize()
|
|
||||||
{
|
|
||||||
CMeasure::Initialize();
|
|
||||||
|
|
||||||
if (m_HasInitializeFunction)
|
|
||||||
{
|
|
||||||
m_LuaScript->RunFunction(g_InitializeFunctionName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Updates the current disk free space value.
|
** Updates the current disk free space value.
|
||||||
**
|
**
|
||||||
@ -134,7 +118,7 @@ void CMeasureScript::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
|||||||
|
|
||||||
if (m_LuaScript->IsInitialized())
|
if (m_LuaScript->IsInitialized())
|
||||||
{
|
{
|
||||||
m_HasInitializeFunction = m_LuaScript->IsFunction(g_InitializeFunctionName);
|
bool hasInitializeFunction = m_LuaScript->IsFunction(g_InitializeFunctionName);
|
||||||
m_HasUpdateFunction = m_LuaScript->IsFunction(g_UpdateFunctionName);
|
m_HasUpdateFunction = m_LuaScript->IsFunction(g_UpdateFunctionName);
|
||||||
m_HasGetStringFunction = m_LuaScript->IsFunction(g_GetStringFunctionName); // For backwards compatbility
|
m_HasGetStringFunction = m_LuaScript->IsFunction(g_GetStringFunctionName); // For backwards compatbility
|
||||||
|
|
||||||
@ -180,6 +164,11 @@ void CMeasureScript::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
|||||||
|
|
||||||
// Pop PROPERTIES table and our table
|
// Pop PROPERTIES table and our table
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
|
|
||||||
|
if (hasInitializeFunction)
|
||||||
|
{
|
||||||
|
m_LuaScript->RunFunction(g_InitializeFunctionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,6 @@ public:
|
|||||||
|
|
||||||
virtual UINT GetTypeID() { return TypeID<CMeasureScript>(); }
|
virtual UINT GetTypeID() { return TypeID<CMeasureScript>(); }
|
||||||
|
|
||||||
virtual void Initialize();
|
|
||||||
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual);
|
||||||
virtual void Command(const std::wstring& command);
|
virtual void Command(const std::wstring& command);
|
||||||
|
|
||||||
@ -42,7 +41,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
LuaScript* m_LuaScript;
|
LuaScript* m_LuaScript;
|
||||||
|
|
||||||
bool m_HasInitializeFunction;
|
|
||||||
bool m_HasUpdateFunction;
|
bool m_HasUpdateFunction;
|
||||||
bool m_HasGetStringFunction;
|
bool m_HasGetStringFunction;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user