diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index fe633575..496d332e 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -125,7 +125,7 @@ bool CMeasureScript::Update() */ const WCHAR* CMeasureScript::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual) { - return m_StringValue.c_str(); + return CheckSubstitute(m_StringValue.c_str()); } /* diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 3e105d63..080edb9c 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -5100,16 +5100,3 @@ CMeasure* CMeterWindow::GetMeasure(const std::wstring& measureName) } return NULL; } - - -const char* CMeterWindow::ReplaceVariables(const char* p_str) -{ - static std::string aStr = ""; - std::wstring value = ConvertToWide(p_str); - - m_Parser.ReplaceVariables(value); - m_Parser.ReplaceMeasures(value); - aStr = ConvertToAscii(value.c_str()); - const char* str = aStr.c_str(); - return str; -} \ No newline at end of file diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 73077e51..6141c725 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -243,8 +243,6 @@ public: CMeter* GetMeter(const std::wstring& meterName); CMeasure* GetMeasure(const std::wstring& measureName); - const char* ReplaceVariables(const char* p_str); - protected: static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); diff --git a/Library/lua/glue/LuaMeter.cpp b/Library/lua/glue/LuaMeter.cpp index 06a620d6..c00f169c 100644 --- a/Library/lua/glue/LuaMeter.cpp +++ b/Library/lua/glue/LuaMeter.cpp @@ -2,24 +2,6 @@ #include "../LuaManager.h" #include "../../Meter.h" -static int Meter_Update(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->Update(); - tolua_pushboolean(L, val); - - return 1; -} - -static int Meter_HasActiveTransition(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->HasActiveTransition(); - tolua_pushboolean(L, val); - - return 1; -} - static int Meter_HasDynamicVariables(lua_State* L) { CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); @@ -131,14 +113,6 @@ static int Meter_SetToolTipHidden(lua_State* L) return 0; } -static int Meter_UpdateToolTip(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - self->UpdateToolTip(); - - return 0; -} - static int Meter_HasMouseAction(lua_State* L) { CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); @@ -191,27 +165,6 @@ static int Meter_IsHidden(lua_State* L) return 1; } -static int Meter_HitTest(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - int x = (int)tolua_tonumber(L, 2, 0); - int y = (int)tolua_tonumber(L, 3, 0); - - bool val = self->HitTest(x, y); - tolua_pushboolean(L, val); - - return 1; -} - -static int Meter_IsMouseOver(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->IsMouseOver(); - tolua_pushboolean(L, val); - - return 1; -} - static int Meter_GetName(lua_State* L) { CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); @@ -226,8 +179,6 @@ void LuaManager::RegisterMeter(lua_State* L) tolua_cclass(L, "CMeter", "CMeter", "CGroup", NULL); tolua_beginmodule(L, "CMeter"); - tolua_function(L, "Update", Meter_Update); - tolua_function(L, "HasActiveTransition", Meter_HasActiveTransition); tolua_function(L, "HasDynamicVariables", Meter_HasDynamicVariables); tolua_function(L, "GetW", Meter_GetW); tolua_function(L, "GetH", Meter_GetH); @@ -240,15 +191,12 @@ void LuaManager::RegisterMeter(lua_State* L) tolua_function(L, "GetToolTipText", Meter_GetToolTipText); tolua_function(L, "HasToolTip", Meter_HasToolTip); tolua_function(L, "SetToolTipHidden", Meter_SetToolTipHidden); - tolua_function(L, "UpdateToolTip", Meter_UpdateToolTip); tolua_function(L, "HasMouseAction", Meter_HasMouseAction); tolua_function(L, "HasMouseActionCursor", Meter_HasMouseActionCursor); tolua_function(L, "SetMouseActionCursor", Meter_SetMouseActionCursor); tolua_function(L, "Hide", Meter_Hide); tolua_function(L, "Show", Meter_Show); tolua_function(L, "IsHidden", Meter_IsHidden); - tolua_function(L, "HitTest", Meter_HitTest); - tolua_function(L, "IsMouseOver", Meter_IsMouseOver); tolua_function(L, "GetName", Meter_GetName); tolua_endmodule(L); } diff --git a/Library/lua/glue/LuaMeterWindow.cpp b/Library/lua/glue/LuaMeterWindow.cpp index d717be37..4db7c72b 100644 --- a/Library/lua/glue/LuaMeterWindow.cpp +++ b/Library/lua/glue/LuaMeterWindow.cpp @@ -115,16 +115,6 @@ static int MeterWindow_MoveWindow(lua_State* L) return 0; } -static int MeterWindow_ChangeZPos(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - ZPOSITION zPos = ((ZPOSITION) (int)tolua_tonumber(L, 2, 0)); - bool all = ((bool)tolua_toboolean(L, 3, false)); - self->ChangeZPos(zPos, all); - - return 0; -} - static int MeterWindow_FadeWindow(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); @@ -153,51 +143,6 @@ static int MeterWindow_GetSkinIniFile(lua_State* L) return 1; } -static int MeterWindow_GetWindowZPosition(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - ZPOSITION val = (ZPOSITION)self->GetWindowZPosition(); - tolua_pushnumber(L, (lua_Number)val); - - return 1; -} - -static int MeterWindow_GetXPercentage(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetXPercentage(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetYPercentage(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetYPercentage(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetXFromRight(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetXFromRight(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetYFromBottom(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetYFromBottom(); - tolua_pushboolean(L, val); - - return 1; -} - static int MeterWindow_GetW(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); @@ -234,24 +179,6 @@ static int MeterWindow_GetY(lua_State* L) return 1; } -static int MeterWindow_GetXScreenDefined(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetXScreenDefined(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetYScreenDefined(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetYScreenDefined(); - tolua_pushboolean(L, val); - - return 1; -} - static int MeterWindow_GetXScreen(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); @@ -270,104 +197,6 @@ static int MeterWindow_GetYScreen(lua_State* L) return 1; } -static int MeterWindow_GetNativeTransparency(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetNativeTransparency(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetClickThrough(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetClickThrough(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetKeepOnScreen(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetKeepOnScreen(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetAutoSelectScreen(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetAutoSelectScreen(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetWindowDraggable(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetWindowDraggable(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetSavePosition(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetSavePosition(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetSnapEdges(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - bool val = self->GetSnapEdges(); - tolua_pushboolean(L, val); - - return 1; -} - -static int MeterWindow_GetWindowHide(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - HIDEMODE val = (HIDEMODE)self->GetWindowHide(); - tolua_pushnumber(L, (lua_Number)val); - - return 1; -} - -static int MeterWindow_GetAlphaValue(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - int val = (int)self->GetAlphaValue(); - tolua_pushnumber(L, (lua_Number)val); - - return 1; -} - -static int MeterWindow_GetUpdateCounter(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - int val = (int)self->GetUpdateCounter(); - tolua_pushnumber(L, (lua_Number)val); - - return 1; -} - -static int MeterWindow_GetTransitionUpdate(lua_State* L) -{ - CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - int val = (int)self->GetTransitionUpdate(); - tolua_pushnumber(L, (lua_Number)val); - return 1; -} - static int MeterWindow_MakePathAbsolute(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); @@ -417,12 +246,33 @@ static int MeterWindow_GetMeasure(lua_State* L) return 1; } +static int MeterWindow_GetVariable(lua_State* L) +{ + CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); + const char* arg = (const char*)tolua_tostring(L, 2, 0); + std::wstring strTmp = ConvertToWide(arg); + + if (self->GetParser().GetVariable(strTmp, strTmp)) + { + std::string val = ConvertToAscii(strTmp.c_str()); + tolua_pushstring(L, val.c_str()); + return 1; + } + else + { + return 0; + } +} + static int MeterWindow_ReplaceVariables(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); const char* arg = (const char*)tolua_tostring(L, 2, 0); - const char* val = (const char*)self->ReplaceVariables(arg); - tolua_pushstring(L, (const char*)val); + std::wstring strTmp = ConvertToWide(arg); + + self->GetParser().ReplaceVariables(strTmp); + std::string val = ConvertToAscii(strTmp.c_str()); + tolua_pushstring(L, val.c_str()); return 1; } @@ -430,27 +280,19 @@ static int MeterWindow_ReplaceVariables(lua_State* L) static int MeterWindow_Bang(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); - const char* p_str = (const char*)tolua_tostring(L, 2, 0); + const char* arg = (const char*)tolua_tostring(L, 2, 0); + std::wstring strTmp = ConvertToWide(arg); - p_str = self->ReplaceVariables(p_str); - std::wstring bang = ConvertToWide(p_str); - self->GetMainObject()->ExecuteCommand(bang.c_str(), self); + CConfigParser& parser = self->GetParser(); + parser.ReplaceVariables(strTmp); + parser.ReplaceMeasures(strTmp); + self->GetMainObject()->ExecuteCommand(strTmp.c_str(), self); return 0; } void LuaManager::RegisterMeterWindow(lua_State* L) { - tolua_constant(L, "ZPOSITION_ONDESKTOP", ZPOSITION_ONDESKTOP); - tolua_constant(L, "ZPOSITION_ONBOTTOM", ZPOSITION_ONBOTTOM); - tolua_constant(L, "ZPOSITION_NORMAL", ZPOSITION_NORMAL); - tolua_constant(L, "ZPOSITION_ONTOP", ZPOSITION_ONTOP); - tolua_constant(L, "ZPOSITION_ONTOPMOST", ZPOSITION_ONTOPMOST); - tolua_constant(L, "HIDEMODE_NONE", HIDEMODE_NONE); - tolua_constant(L, "HIDEMODE_HIDE", HIDEMODE_HIDE); - tolua_constant(L, "HIDEMODE_FADEIN", HIDEMODE_FADEIN); - tolua_constant(L, "HIDEMODE_FADEOUT", HIDEMODE_FADEOUT); - tolua_usertype(L, "CMeterWindow"); tolua_cclass(L, "CMeterWindow", "CMeterWindow", "CGroup", NULL); @@ -466,37 +308,19 @@ void LuaManager::RegisterMeterWindow(lua_State* L) tolua_function(L, "UpdateMeasure", MeterWindow_UpdateMeasure); tolua_function(L, "Redraw", MeterWindow_Redraw); tolua_function(L, "MoveWindow", MeterWindow_MoveWindow); - tolua_function(L, "ChangeZPos", MeterWindow_ChangeZPos); tolua_function(L, "FadeWindow", MeterWindow_FadeWindow); tolua_function(L, "GetSkinName", MeterWindow_GetSkinName); tolua_function(L, "GetSkinIniFile", MeterWindow_GetSkinIniFile); - tolua_function(L, "GetWindowZPosition", MeterWindow_GetWindowZPosition); - tolua_function(L, "GetXPercentage", MeterWindow_GetXPercentage); - tolua_function(L, "GetYPercentage", MeterWindow_GetYPercentage); - tolua_function(L, "GetXFromRight", MeterWindow_GetXFromRight); - tolua_function(L, "GetYFromBottom", MeterWindow_GetYFromBottom); tolua_function(L, "GetW", MeterWindow_GetW); tolua_function(L, "GetH", MeterWindow_GetH); tolua_function(L, "GetX", MeterWindow_GetX); tolua_function(L, "GetY", MeterWindow_GetY); - tolua_function(L, "GetXScreenDefined", MeterWindow_GetXScreenDefined); - tolua_function(L, "GetYScreenDefined", MeterWindow_GetYScreenDefined); tolua_function(L, "GetXScreen", MeterWindow_GetXScreen); tolua_function(L, "GetYScreen", MeterWindow_GetYScreen); - tolua_function(L, "GetNativeTransparency", MeterWindow_GetNativeTransparency); - tolua_function(L, "GetClickThrough", MeterWindow_GetClickThrough); - tolua_function(L, "GetKeepOnScreen", MeterWindow_GetKeepOnScreen); - tolua_function(L, "GetAutoSelectScreen", MeterWindow_GetAutoSelectScreen); - tolua_function(L, "GetWindowDraggable", MeterWindow_GetWindowDraggable); - tolua_function(L, "GetSavePosition", MeterWindow_GetSavePosition); - tolua_function(L, "GetSnapEdges", MeterWindow_GetSnapEdges); - tolua_function(L, "GetWindowHide", MeterWindow_GetWindowHide); - tolua_function(L, "GetAlphaValue", MeterWindow_GetAlphaValue); - tolua_function(L, "GetUpdateCounter", MeterWindow_GetUpdateCounter); - tolua_function(L, "GetTransitionUpdate", MeterWindow_GetTransitionUpdate); tolua_function(L, "MakePathAbsolute", MeterWindow_MakePathAbsolute); tolua_function(L, "GetMeter", MeterWindow_GetMeter); tolua_function(L, "GetMeasure", MeterWindow_GetMeasure); + tolua_function(L, "GetVariable", MeterWindow_GetVariable); tolua_function(L, "ReplaceVariables", MeterWindow_ReplaceVariables); tolua_function(L, "Bang", MeterWindow_Bang); tolua_endmodule(L);