rainmeter-studio/Library/lua/glue/LuaMeterString.cpp
Birunthan Mohanathas c7f9293e9c Script:
- GetMeter dynamically detects STRING meters now (no need to use tolua.cast any longer)
- Removed unneeded (and undocumented) functions to exposed to Lua
- Refactored tolua++ generated code
2011-07-05 13:41:05 +00:00

44 lines
1.1 KiB
C++

#include "../../StdAfx.h"
#include "../LuaManager.h"
#include "../../MeterString.h"
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);
return 1;
}
static int MeterString_Update(lua_State* L)
{
CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0);
bool val = self->Update();
tolua_pushboolean(L, val);
return 1;
}
static int MeterString_SetText(lua_State* L)
{
CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0);
const WCHAR* text = to_wchar(L, 2, 0);
self->SetText(text);
return 0;
}
void LuaManager::RegisterMeterString(lua_State* L)
{
tolua_usertype(L, "CMeterString");
tolua_cclass(L, "CMeterString", "CMeterString", "CMeter", NULL);
tolua_beginmodule(L, "CMeterString");
tolua_function(L, "GetX", MeterString_GetX);
tolua_function(L, "Update", MeterString_Update);
tolua_function(L, "SetText", MeterString_SetText);
tolua_endmodule(L);
}