From 822c10060a8d7b27a8e5c9624f2105fd50b30005 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 27 Jul 2011 10:42:35 +0000 Subject: [PATCH] - Added !SetOption/!SetOptionGroup bangs. - Script: Added GetOption() function --- Library/ConfigParser.cpp | 20 +++++ Library/ConfigParser.h | 6 +- Library/Measure.h | 3 + Library/MeasureScript.cpp | 4 - Library/Meter.h | 3 + Library/MeterWindow.cpp | 106 +++++++++++++++++++++++++ Library/MeterWindow.h | 5 +- Library/Rainmeter.cpp | 29 +++++++ Library/Rainmeter.h | 2 + Library/lua/LuaManager.cpp | 1 - Library/lua/LuaManager.h | 1 - Library/lua/glue/LuaGroup.cpp | 2 +- Library/lua/glue/LuaMeasure.cpp | 60 ++++++-------- Library/lua/glue/LuaMeter.cpp | 118 ++++++++-------------------- Library/lua/glue/LuaMeterString.cpp | 4 +- Library/lua/glue/LuaMeterWindow.cpp | 12 +-- Library/lua/glue/LuaRainmeter.cpp | 61 -------------- Library/lua/glue/lua_meterimage.cpp | 116 --------------------------- Library/lua/glue/meter_image.tolua | 11 --- 19 files changed, 235 insertions(+), 329 deletions(-) delete mode 100644 Library/lua/glue/LuaRainmeter.cpp delete mode 100644 Library/lua/glue/lua_meterimage.cpp delete mode 100644 Library/lua/glue/meter_image.tolua diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index baa73525..89b50c2a 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -1195,6 +1195,26 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring& m_Values[StrToLower(strTmp)] = strValue; } +//============================================================================== +/** +** Deletes the value for the key under the given section. +** +** \param strSection The name of the section. +** \param strKey The name of the key. +** \param strValue The value for the key. +*/ +void CConfigParser::DeleteValue(const std::wstring& strSection, const std::wstring& strKey) +{ + std::wstring strTmp = strSection + L"::"; + strTmp += strKey; + + std::unordered_map::iterator i = m_Values.find(StrToLower(strTmp)); + if (i != m_Values.end()) + { + m_Values.erase(i); + } +} + //============================================================================== /** ** Returns the value for the key under the given section. diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index 4d0e24a3..5748a8b0 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -47,6 +47,10 @@ public: void SetBuiltInVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_BuiltInVariables, strVariable, strValue); } bool GetVariable(const std::wstring& strVariable, std::wstring& strValue); + const std::wstring& GetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strDefault); + void SetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strValue); + void DeleteValue(const std::wstring& strSection, const std::wstring& strKey); + void SetStyleTemplate(const std::wstring& strStyle) { m_StyleTemplate = Tokenize(strStyle, L"|"); } void ClearStyleTemplate() { m_StyleTemplate.clear(); } @@ -94,8 +98,6 @@ private: CMeasure* GetMeasure(const std::wstring& name); void ReadIniFile(const std::vector& iniFileMappings, const std::wstring& strFileName, LPCTSTR config = NULL, int depth = 0); - void SetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strValue); - const std::wstring& GetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strDefault); void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow); diff --git a/Library/Measure.h b/Library/Measure.h index 5d2f8443..54d12474 100644 --- a/Library/Measure.h +++ b/Library/Measure.h @@ -63,6 +63,7 @@ public: bool IsDisabled() { return m_Disabled; } bool HasDynamicVariables() { return m_DynamicVariables; } + void SetDynamicVariables(bool b) { m_DynamicVariables = b; } virtual void ExecuteBang(const WCHAR* args); @@ -80,6 +81,8 @@ public: static void GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue, WCHAR* buffer, size_t sizeInWords); static void RemoveTrailingZero(WCHAR* str, int strLen); + CMeterWindow* GetMeterWindow() { return m_MeterWindow; } + static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name); protected: diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index 52dca406..ec566362 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -173,10 +173,6 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section) tolua_pushusertype(L, m_MeterWindow, "CMeterWindow"); lua_settable(L, -3); - //lua_pushstring(L, "RAINMETER"); - //tolua_pushusertype(L, m_MeterWindow->GetMainObject(), "CRainmeter"); - //lua_settable(L, -3); - // Look in the properties table for values to read from the section. lua_getfield(L, -1, "PROPERTIES"); if (lua_isnil(L, -1) == 0) diff --git a/Library/Meter.h b/Library/Meter.h index d279810a..8bcc58bd 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -46,6 +46,7 @@ public: virtual bool HasActiveTransition() { return false; } bool HasDynamicVariables() { return m_DynamicVariables; } + void SetDynamicVariables(bool b) { m_DynamicVariables = b; } virtual int GetW() { return m_Hidden ? 0 : m_W; } virtual int GetH() { return m_Hidden ? 0 : m_H; } @@ -98,6 +99,8 @@ public: int GetUpdateCounter() { return m_UpdateCounter; } int GetUpdateDivider() { return m_UpdateDivider; } + CMeterWindow* GetMeterWindow() { return m_MeterWindow; } + static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name); static void DrawBevel(Gdiplus::Graphics& graphics, const Gdiplus::Rect& rect, const Gdiplus::Pen& light, const Gdiplus::Pen& dark); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 5a792a0b..d4c381ff 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1026,6 +1026,14 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg) Log(LOG_ERROR, L"Unable to parse parameters for !SetVariable"); } break; + + case BANG_SETOPTION: + SetOption(arg, false); + break; + + case BANG_SETOPTIONGROUP: + SetOption(arg, true); + break; } } @@ -1435,6 +1443,104 @@ void CMeterWindow::UpdateMeasure(const WCHAR* name, bool group) if (!group) LogWithArgs(LOG_NOTICE, L"Unable to update the measure %s (there is no such thing in %s)", name, m_SkinName.c_str()); } +/* +** SetOption +** +** Changes the property of a meter or measure. +** +*/ +void CMeterWindow::SetOption(const WCHAR* arg, bool group) +{ + const WCHAR* pos = wcschr(arg, L' '); + if (pos != NULL) + { + const WCHAR* pos2 = wcschr(pos + 1, L' '); + std::wstring section(arg, pos - arg); + std::wstring option(pos + 1, pos2); + std::wstring value(pos2 + 1); + + if (group) + { + for (std::list::const_iterator i = m_Meters.begin(); i != m_Meters.end(); ++i) + { + if ((*i)->BelongsToGroup(section)) + { + (*i)->SetDynamicVariables(true); + + if (value.empty()) + { + GetParser().DeleteValue((*i)->GetName(), option); + } + else + { + GetParser().SetValue((*i)->GetName(), option, value); + } + } + } + + for (std::list::const_iterator i = m_Measures.begin(); i != m_Measures.end(); ++i) + { + if ((*i)->BelongsToGroup(section)) + { + (*i)->SetDynamicVariables(true); + + if (value.empty()) + { + GetParser().DeleteValue(section, option); + } + else + { + GetParser().SetValue(section, option, value); + } + } + } + } + else + { + CMeter* meter = GetMeter(section); + if (meter) + { + // Force DynamicVariables temporarily (it will reset back to original setting in ReadConfig()) + meter->SetDynamicVariables(true); + + if (value.empty()) + { + GetParser().DeleteValue(section, option); + } + else + { + GetParser().SetValue(section, option, value); + } + + return; + } + + CMeasure* measure = GetMeasure(section); + if (measure) + { + measure->SetDynamicVariables(true); + + if (value.empty()) + { + GetParser().DeleteValue(section, option); + } + else + { + GetParser().SetValue(section, option, value); + } + + return; + } + + // Is it a style? + } + } + else + { + Log(LOG_ERROR, L"Unable to parse parameters for !SetOption"); + } +} + /* WindowToScreen ** ** Calculates the screen cordinates from the WindowX/Y config diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index e2054b3b..4be503f4 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -150,7 +150,9 @@ enum BANGCOMMAND BANG_LSHOOK, BANG_PLUGIN, - BANG_SETVARIABLE + BANG_SETVARIABLE, + BANG_SETOPTION, + BANG_SETOPTIONGROUP }; class CRainmeter; @@ -181,6 +183,7 @@ public: void UpdateMeasure(const WCHAR* name, bool group = false); void Refresh(bool init, bool all = false); void Redraw(); + void SetOption(const WCHAR* name, bool group); void SetMouseLeaveEvent(bool cancel); diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index be2a4b04..c40cf61f 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -856,6 +856,17 @@ void RainmeterSetVariable(HWND, const char* arg) BangWithArgs(BANG_SETVARIABLE, ConvertToWide(arg).c_str(), 2); } +/* +** RainmeterSetOption +** +** Callback for the !RainmeterSetOption bang +** +*/ +void RainmeterSetOption(HWND, const char* arg) +{ + BangWithArgs(BANG_SETOPTION, ConvertToWide(arg).c_str(), 3); +} + /* ** RainmeterHideGroup ** @@ -1130,6 +1141,16 @@ void RainmeterSetVariableGroup(HWND, const char* arg) { BangGroupWithArgs(BANG_SETVARIABLE, ConvertToWide(arg).c_str(), 2); } +/* +** RainmeterSetOptionGroup +** +** Callback for the !RainmeterSetOptionGroup bang +** +*/ +void RainmeterSetOptionGroup(HWND, const char* arg) +{ + BangGroupWithArgs(BANG_SETOPTION, ConvertToWide(arg).c_str(), 3); +} /* ** RainmeterLsHook @@ -2940,6 +2961,10 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg, { BangWithArgs(BANG_SETVARIABLE, arg.c_str(), 2); } + else if (_wcsicmp(name, L"SetOption") == 0) + { + BangWithArgs(BANG_SETOPTION, arg.c_str(), 3); + } else if (_wcsicmp(name, L"RefreshGroup") == 0) { BangGroupWithArgs(BANG_REFRESH, arg.c_str(), 0); @@ -3040,6 +3065,10 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg, { BangGroupWithArgs(BANG_SETVARIABLE, arg.c_str(), 2); } + else if (_wcsicmp(name, L"SetOptionGroup") == 0) + { + BangWithArgs(BANG_SETOPTIONGROUP, arg.c_str(), 3); + } else if (_wcsicmp(name, L"About") == 0) { RainmeterAboutWide(); diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 051a7141..093f0e92 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -73,6 +73,7 @@ void RainmeterSnapEdges(HWND, const char* arg); void RainmeterKeepOnScreen(HWND, const char* arg); void RainmeterSetTransparency(HWND, const char* arg); void RainmeterSetVariable(HWND, const char* arg); +void RainmeterSetOption(HWND, const char* arg); void RainmeterRefreshGroup(HWND, const char* arg); void RainmeterRedrawGroup(HWND, const char* arg); @@ -99,6 +100,7 @@ void RainmeterSnapEdgesGroup(HWND, const char* arg); void RainmeterKeepOnScreenGroup(HWND, const char* arg); void RainmeterSetTransparencyGroup(HWND, const char* arg); void RainmeterSetVariableGroup(HWND, const char* arg); +void RainmeterSetOptionGroup(HWND, const char* arg); void RainmeterLsHook(HWND, const char* arg); void RainmeterAbout(HWND, const char* arg); diff --git a/Library/lua/LuaManager.cpp b/Library/lua/LuaManager.cpp index 205933e2..2960dac6 100644 --- a/Library/lua/LuaManager.cpp +++ b/Library/lua/LuaManager.cpp @@ -43,7 +43,6 @@ void LuaManager::Init() RegisterMeasure(c_State); RegisterMeter(c_State); RegisterMeterWindow(c_State); - RegisterRainmeter(c_State); RegisterMeterString(c_State); tolua_endmodule(c_State); } diff --git a/Library/lua/LuaManager.h b/Library/lua/LuaManager.h index e258a2d0..1aff6af8 100644 --- a/Library/lua/LuaManager.h +++ b/Library/lua/LuaManager.h @@ -38,7 +38,6 @@ protected: private: static void RegisterGlobal(lua_State* L); - static void RegisterRainmeter(lua_State* L); static void RegisterGroup(lua_State* L); static void RegisterMeasure(lua_State* L); static void RegisterMeter(lua_State* L); diff --git a/Library/lua/glue/LuaGroup.cpp b/Library/lua/glue/LuaGroup.cpp index d02b1bb0..b4b4acdc 100644 --- a/Library/lua/glue/LuaGroup.cpp +++ b/Library/lua/glue/LuaGroup.cpp @@ -7,7 +7,7 @@ static int Group_BelongsToGroup(lua_State* L) CGroup* self = (CGroup*)tolua_tousertype(L, 1, 0); const std::wstring group = (const std::wstring)to_wstring(L, 2, 0); bool val = self->BelongsToGroup(group); - tolua_pushboolean(L, val); + lua_pushboolean(L, val); return 1; } diff --git a/Library/lua/glue/LuaMeasure.cpp b/Library/lua/glue/LuaMeasure.cpp index 6876faa4..6d8c25fa 100644 --- a/Library/lua/glue/LuaMeasure.cpp +++ b/Library/lua/glue/LuaMeasure.cpp @@ -1,6 +1,7 @@ #include "../../StdAfx.h" #include "../LuaManager.h" #include "../../Measure.h" +#include "../../MeterWindow.h" static int Measure_GetName(lua_State* L) { @@ -11,12 +12,26 @@ static int Measure_GetName(lua_State* L) return 1; } -static int Measure_GetANSIName(lua_State* L) +static int Measure_GetOption(lua_State* L) { CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); - const char* val = (const char*)self->GetANSIName(); - tolua_pushstring(L, (const char*)val); + CMeterWindow* meterWindow = self->GetMeterWindow(); + CConfigParser& parser = meterWindow->GetParser(); + const char* arg = (const char*)tolua_tostring(L, 2, 0); + std::wstring strTmp = ConvertToWide(arg); + strTmp = parser.GetValue(self->GetName(), strTmp, L""); + + parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetName()); // Set temporarily + parser.ReplaceVariables(strTmp); + parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset + + if (self->HasDynamicVariables()) + { + parser.ReplaceMeasures(strTmp); + } + + push_wchar(L, strTmp.c_str()); return 1; } @@ -36,29 +51,11 @@ static int Measure_Enable(lua_State* L) return 0; } -static int Measure_IsDisabled(lua_State* L) -{ - CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); - bool val = self->IsDisabled(); - tolua_pushboolean(L, val); - - return 1; -} - -static int Measure_HasDynamicVariables(lua_State* L) -{ - CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); - bool val = self->HasDynamicVariables(); - tolua_pushboolean(L, val); - - return 1; -} - static int Measure_GetValue(lua_State* L) { CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); double val = (double)self->GetValue(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -67,7 +64,7 @@ static int Measure_GetRelativeValue(lua_State* L) { CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); double val = (double)self->GetRelativeValue(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -76,7 +73,7 @@ static int Measure_GetValueRange(lua_State* L) { CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); double val = (double)self->GetValueRange(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -85,7 +82,7 @@ static int Measure_GetMinValue(lua_State* L) { CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); double val = (double)self->GetMinValue(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -94,7 +91,7 @@ static int Measure_GetMaxValue(lua_State* L) { CMeasure* self = (CMeasure*)tolua_tousertype(L, 1, 0); double val = (double)self->GetMaxValue(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -115,23 +112,14 @@ static int Measure_GetStringValue(lua_State* L) void LuaManager::RegisterMeasure(lua_State* L) { - tolua_constant(L, "AUTOSCALE_1024", AUTOSCALE_1024); - tolua_constant(L, "AUTOSCALE_1000", AUTOSCALE_1000); - tolua_constant(L, "AUTOSCALE_1024K", AUTOSCALE_1024K); - tolua_constant(L, "AUTOSCALE_1000K", AUTOSCALE_1000K); - tolua_constant(L, "AUTOSCALE_OFF", AUTOSCALE_OFF); - tolua_constant(L, "AUTOSCALE_ON", AUTOSCALE_ON); - tolua_usertype(L, "CMeasure"); tolua_cclass(L, "CMeasure", "CMeasure", "CGroup", NULL); tolua_beginmodule(L, "CMeasure"); tolua_function(L, "GetName", Measure_GetName); - tolua_function(L, "GetANSIName", Measure_GetANSIName); + tolua_function(L, "GetOption", Measure_GetOption); tolua_function(L, "Disable", Measure_Disable); tolua_function(L, "Enable", Measure_Enable); - tolua_function(L, "IsDisabled", Measure_IsDisabled); - tolua_function(L, "HasDynamicVariables", Measure_HasDynamicVariables); tolua_function(L, "GetValue", Measure_GetValue); tolua_function(L, "GetRelativeValue", Measure_GetRelativeValue); tolua_function(L, "GetValueRange", Measure_GetValueRange); diff --git a/Library/lua/glue/LuaMeter.cpp b/Library/lua/glue/LuaMeter.cpp index c00f169c..aca42b5a 100644 --- a/Library/lua/glue/LuaMeter.cpp +++ b/Library/lua/glue/LuaMeter.cpp @@ -2,12 +2,34 @@ #include "../LuaManager.h" #include "../../Meter.h" -static int Meter_HasDynamicVariables(lua_State* L) +static int Meter_GetName(lua_State* L) { CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->HasDynamicVariables(); - tolua_pushboolean(L, val); + const WCHAR* val = (const WCHAR*)self->GetName(); + push_wchar(L, val); + return 1; +} +static int Meter_GetOption(lua_State* L) +{ + CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); + CMeterWindow* meterWindow = self->GetMeterWindow(); + CConfigParser& parser = meterWindow->GetParser(); + + const char* arg = (const char*)tolua_tostring(L, 2, 0); + std::wstring strTmp = ConvertToWide(arg); + strTmp = parser.GetValue(self->GetName(), strTmp, L""); + + parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetName()); // Set temporarily + parser.ReplaceVariables(strTmp); + parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset + + if (self->HasDynamicVariables()) + { + parser.ReplaceMeasures(strTmp); + } + + push_wchar(L, strTmp.c_str()); return 1; } @@ -15,7 +37,7 @@ static int Meter_GetW(lua_State* L) { CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); int val = (int)self->GetW(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -24,7 +46,7 @@ static int Meter_GetH(lua_State* L) { CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); int val = (int)self->GetH(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; @@ -35,7 +57,7 @@ static int Meter_GetX(lua_State* L) CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); bool abs = ((bool)tolua_toboolean(L, 2, false)); int val = (int)self->GetX(abs); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -45,7 +67,7 @@ static int Meter_GetY(lua_State* L) CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); bool abs = ((bool)tolua_toboolean(L, 2, false)); int val = (int)self->GetY(abs); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -86,60 +108,6 @@ static int Meter_SetY(lua_State* L) return 0; } -static int Meter_GetToolTipText(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - const std::wstring& val = self->GetToolTipText(); - push_wchar(L, val.c_str()); - - return 1; -} - -static int Meter_HasToolTip(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->HasToolTip(); - tolua_pushboolean(L, val); - - return 1; -} - -static int Meter_SetToolTipHidden(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool b = (bool)tolua_toboolean(L, 2, 0); - self->SetToolTipHidden(b); - - return 0; -} - -static int Meter_HasMouseAction(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->HasMouseAction(); - tolua_pushboolean(L, val); - - return 1; -} - -static int Meter_HasMouseActionCursor(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->HasMouseActionCursor(); - tolua_pushboolean(L, val); - - return 1; -} - -static int Meter_SetMouseActionCursor(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool b = (bool)tolua_toboolean(L, 2, 0); - self->SetMouseActionCursor(b); - - return 0; -} - static int Meter_Hide(lua_State* L) { CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); @@ -156,30 +124,14 @@ static int Meter_Show(lua_State* L) return 0; } -static int Meter_IsHidden(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - bool val = self->IsHidden(); - tolua_pushboolean(L, val); - - return 1; -} - -static int Meter_GetName(lua_State* L) -{ - CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0); - const WCHAR* val = (const WCHAR*)self->GetName(); - push_wchar(L, val); - return 1; -} - void LuaManager::RegisterMeter(lua_State* L) { tolua_usertype(L, "CMeter"); tolua_cclass(L, "CMeter", "CMeter", "CGroup", NULL); tolua_beginmodule(L, "CMeter"); - tolua_function(L, "HasDynamicVariables", Meter_HasDynamicVariables); + tolua_function(L, "GetName", Meter_GetName); + tolua_function(L, "GetOption", Meter_GetOption); tolua_function(L, "GetW", Meter_GetW); tolua_function(L, "GetH", Meter_GetH); tolua_function(L, "GetX", Meter_GetX); @@ -188,15 +140,7 @@ void LuaManager::RegisterMeter(lua_State* L) tolua_function(L, "SetH", Meter_SetH); tolua_function(L, "SetX", Meter_SetX); tolua_function(L, "SetY", Meter_SetY); - tolua_function(L, "GetToolTipText", Meter_GetToolTipText); - tolua_function(L, "HasToolTip", Meter_HasToolTip); - tolua_function(L, "SetToolTipHidden", Meter_SetToolTipHidden); - 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, "GetName", Meter_GetName); tolua_endmodule(L); } diff --git a/Library/lua/glue/LuaMeterString.cpp b/Library/lua/glue/LuaMeterString.cpp index 3c44cfc9..add6d286 100644 --- a/Library/lua/glue/LuaMeterString.cpp +++ b/Library/lua/glue/LuaMeterString.cpp @@ -7,7 +7,7 @@ static int MeterString_GetX(lua_State* L) CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0); bool abs = (bool)tolua_toboolean(L, 2, false); int val = self->GetX(abs); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -16,7 +16,7 @@ static int MeterString_Update(lua_State* L) { CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0); bool val = self->Update(); - tolua_pushboolean(L, val); + lua_pushboolean(L, val); return 1; } diff --git a/Library/lua/glue/LuaMeterWindow.cpp b/Library/lua/glue/LuaMeterWindow.cpp index 4db7c72b..3504f171 100644 --- a/Library/lua/glue/LuaMeterWindow.cpp +++ b/Library/lua/glue/LuaMeterWindow.cpp @@ -147,7 +147,7 @@ static int MeterWindow_GetW(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); int val = (int)self->GetW(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -156,7 +156,7 @@ static int MeterWindow_GetH(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); int val = (int)self->GetH(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -165,7 +165,7 @@ static int MeterWindow_GetX(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); int val = (int)self->GetX(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -174,7 +174,7 @@ static int MeterWindow_GetY(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); int val = (int)self->GetY(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -183,7 +183,7 @@ static int MeterWindow_GetXScreen(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); int val = (int)self->GetXScreen(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } @@ -192,7 +192,7 @@ static int MeterWindow_GetYScreen(lua_State* L) { CMeterWindow* self = (CMeterWindow*)tolua_tousertype(L, 1, 0); int val = (int)self->GetYScreen(); - tolua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, (lua_Number)val); return 1; } diff --git a/Library/lua/glue/LuaRainmeter.cpp b/Library/lua/glue/LuaRainmeter.cpp deleted file mode 100644 index 3a228679..00000000 --- a/Library/lua/glue/LuaRainmeter.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "../../StdAfx.h" -#include "../LuaManager.h" -#include "../../Rainmeter.h" - -static int Rainmeter_GetConfigEditor(lua_State* L) -{ - CRainmeter* self = (CRainmeter*)tolua_tousertype(L, 1, 0); - const std::wstring& val = self->GetConfigEditor(); - push_wstring(L, val); - - return 1; -} - -static int Rainmeter_GetLogViewer(lua_State* L) -{ - CRainmeter* self = (CRainmeter*)tolua_tousertype(L, 1, 0); - const std::wstring& val = self->GetLogViewer(); - push_wstring(L, val); - - return 1; -} - -static int Rainmeter_GetStatsDate(lua_State* L) -{ - CRainmeter* self = (CRainmeter*)tolua_tousertype(L, 1, 0); - const std::wstring& val = self->GetStatsDate(); - push_wstring(L, val); - - return 1; -} - -static int Rainmeter_GetDebug(lua_State* L) -{ - bool val = CRainmeter::GetDebug(); - tolua_pushboolean(L, val); - - return 1; -} - -static int Rainmeter_IsMenuActive(lua_State* L) -{ - CRainmeter* self = (CRainmeter*)tolua_tousertype(L, 1, 0); - bool val = self->IsMenuActive(); - tolua_pushboolean(L, val); - - return 1; -} - -void LuaManager::RegisterRainmeter(lua_State* L) -{ - tolua_usertype(L, "CRainmeter"); - tolua_cclass(L, "CRainmeter", "CRainmeter", "", NULL); - - tolua_beginmodule(L, "CRainmeter"); - tolua_function(L, "GetConfigEditor", Rainmeter_GetConfigEditor); - tolua_function(L, "GetLogViewer", Rainmeter_GetLogViewer); - tolua_function(L, "GetStatsDate", Rainmeter_GetStatsDate); - tolua_function(L, "GetDebug", Rainmeter_GetDebug); - tolua_function(L, "IsMenuActive", Rainmeter_IsMenuActive); - tolua_endmodule(L); -} diff --git a/Library/lua/glue/lua_meterimage.cpp b/Library/lua/glue/lua_meterimage.cpp deleted file mode 100644 index d96996e9..00000000 --- a/Library/lua/glue/lua_meterimage.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -** Lua binding: meter_image -** Generated automatically by tolua++-1.0.92 on 02/15/11 03:01:12. -*/ - -#include "../../StdAfx.h" - -#ifndef __cplusplus -#include "stdlib.h" -#endif -#include "string.h" - -#include "tolua++.h" - -/* Exported function */ -TOLUA_API int tolua_meter_image_open (lua_State* tolua_S); - -#include "../../MeterImage.h" -#include "../LuaPush.h" - -/* function to register type */ -static void tolua_reg_types (lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"CMeterImage"); - tolua_usertype(tolua_S,"WCHAR"); - tolua_usertype(tolua_S,"CMeter"); -} - -/* method: SetImage of class CMeterImage */ -#ifndef TOLUA_DISABLE_tolua_meter_image_CMeterImage_SetImage00 -static int tolua_meter_image_CMeterImage_SetImage00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"CMeterImage",0,&tolua_err) || - !is_wchar(tolua_S,2,"const WCHAR",0,&tolua_err) || - !tolua_isnoobj(tolua_S,3,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - CMeterImage* self = (CMeterImage*) tolua_tousertype(tolua_S,1,0); - const WCHAR* imageName = ((const WCHAR*) to_wchar(tolua_S,2,0)); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetImage'", NULL); -#endif - { - self->SetImage(imageName); - } - } - return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'SetImage'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* method: GetImage of class CMeterImage */ -#ifndef TOLUA_DISABLE_tolua_meter_image_CMeterImage_GetImage00 -static int tolua_meter_image_CMeterImage_GetImage00(lua_State* tolua_S) -{ -#ifndef TOLUA_RELEASE - tolua_Error tolua_err; - if ( - !tolua_isusertype(tolua_S,1,"CMeterImage",0,&tolua_err) || - !tolua_isnoobj(tolua_S,2,&tolua_err) - ) - goto tolua_lerror; - else -#endif - { - CMeterImage* self = (CMeterImage*) tolua_tousertype(tolua_S,1,0); -#ifndef TOLUA_RELEASE - if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetImage'", NULL); -#endif - { - const WCHAR* tolua_ret = (const WCHAR*) self->GetImage(); - push_wchar(tolua_S,(void*)tolua_ret,"const WCHAR"); - } - } - return 1; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'GetImage'.",&tolua_err); - return 0; -#endif -} -#endif //#ifndef TOLUA_DISABLE - -/* Open function */ -TOLUA_API int tolua_meter_image_open (lua_State* tolua_S) -{ - tolua_open(tolua_S); - tolua_reg_types(tolua_S); - tolua_module(tolua_S,NULL,0); - tolua_beginmodule(tolua_S,NULL); - tolua_cclass(tolua_S,"CMeterImage","CMeterImage","CMeter",NULL); - tolua_beginmodule(tolua_S,"CMeterImage"); - tolua_function(tolua_S,"SetImage",tolua_meter_image_CMeterImage_SetImage00); - tolua_function(tolua_S,"GetImage",tolua_meter_image_CMeterImage_GetImage00); - tolua_endmodule(tolua_S); - tolua_endmodule(tolua_S); - return 1; -} - - -#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 - TOLUA_API int luaopen_meter_image (lua_State* tolua_S) { - return tolua_meter_image_open(tolua_S); -}; -#endif - diff --git a/Library/lua/glue/meter_image.tolua b/Library/lua/glue/meter_image.tolua deleted file mode 100644 index 90338377..00000000 --- a/Library/lua/glue/meter_image.tolua +++ /dev/null @@ -1,11 +0,0 @@ -$#include "../../MeterImage.h" -$#include "../LuaPush.h" - -class CMeterImage : public CMeter -{ -public: - - void SetImage(const WCHAR* imageName); - const WCHAR* GetImage(); - -};