summaryrefslogtreecommitdiff
path: root/src/cat/LuaComponent.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-11-17 19:44:09 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-11-17 19:44:09 (GMT)
commit058a2edd75debbd0297f92572316daa704bd379f (patch)
treead303f091f9a08b209b91eb34a9fcad996a3de69 /src/cat/LuaComponent.cpp
parente3594aba9e05c6865d396418c028049cda92c2f3 (diff)
parent7a21ae192fe19868539956f3fe28e62b2c7c4429 (diff)
downloadpowder-058a2edd75debbd0297f92572316daa704bd379f.zip
powder-058a2edd75debbd0297f92572316daa704bd379f.tar.gz
Merge branch 'master' of github.com:FacialTurd/PowderToypp
Diffstat (limited to 'src/cat/LuaComponent.cpp')
-rw-r--r--src/cat/LuaComponent.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/cat/LuaComponent.cpp b/src/cat/LuaComponent.cpp
new file mode 100644
index 0000000..8c2d3a4
--- /dev/null
+++ b/src/cat/LuaComponent.cpp
@@ -0,0 +1,82 @@
+extern "C"
+{
+#include "lua.h"
+#include "lauxlib.h"
+#include "lualib.h"
+}
+
+#include <iostream>
+#include "LuaComponent.h"
+#include "LuaScriptInterface.h"
+#include "interface/Component.h"
+
+
+LuaComponent::LuaComponent(lua_State * l)
+{
+ this->l = l;
+
+ lua_pushstring(l, "Luacon_ci");
+ lua_gettable(l, LUA_REGISTRYINDEX);
+ ci = (LuaScriptInterface*)lua_touserdata(l, -1);
+ lua_pop(l, 1);
+}
+
+int LuaComponent::position(lua_State * l)
+{
+ int args = lua_gettop(l);
+ if(args)
+ {
+ luaL_checktype(l, 1, LUA_TNUMBER);
+ luaL_checktype(l, 2, LUA_TNUMBER);
+ component->Position = ui::Point(lua_tointeger(l, 1), lua_tointeger(l, 2));
+ return 0;
+ }
+ else
+ {
+ lua_pushinteger(l, component->Position.X);
+ lua_pushinteger(l, component->Position.Y);
+ return 2;
+ }
+}
+
+int LuaComponent::size(lua_State * l)
+{
+ int args = lua_gettop(l);
+ if(args)
+ {
+ luaL_checktype(l, 1, LUA_TNUMBER);
+ luaL_checktype(l, 2, LUA_TNUMBER);
+ component->Size = ui::Point(lua_tointeger(l, 1), lua_tointeger(l, 2));
+ component->Invalidate();
+ return 0;
+ }
+ else
+ {
+ lua_pushinteger(l, component->Size.X);
+ lua_pushinteger(l, component->Size.Y);
+ return 2;
+ }
+}
+
+int LuaComponent::visible(lua_State * l)
+{
+ int args = lua_gettop(l);
+ if(args)
+ {
+ luaL_checktype(l, 1, LUA_TBOOLEAN);
+ component->Visible = lua_toboolean(l, 1);
+ return 0;
+ }
+ else
+ {
+ lua_pushboolean(l, component->Visible);
+ return 1;
+ }
+}
+
+LuaComponent::~LuaComponent()
+{
+ if(component->GetParentWindow())
+ component->GetParentWindow()->RemoveComponent(component);
+ delete component;
+} \ No newline at end of file