diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-05-28 17:07:04 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-05-28 17:07:04 -0400 |
| commit | 06d3e8182d018ca613f177f6ff7a3bbb6494cc79 (patch) | |
| tree | 18289e9d48c03cb3910e5fbe27ffd18c6b81eb53 /src/client/lua_api/gui/iguielement.cpp | |
| parent | 5fc253ce728c6e078886e092376c2e0f0320ebd9 (diff) | |
| download | brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.tar.gz brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.tar.bz2 brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.zip | |
Various additions
Various additions, updates, and bugfixes while making mahjong solitare.
Diffstat (limited to 'src/client/lua_api/gui/iguielement.cpp')
| -rw-r--r-- | src/client/lua_api/gui/iguielement.cpp | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp index c01fa70..b62efef 100644 --- a/src/client/lua_api/gui/iguielement.cpp +++ b/src/client/lua_api/gui/iguielement.cpp @@ -4,6 +4,9 @@ extern "C" { #include <lauxlib.h> #include <lualib.h> } + + +#include "../../../shared/lua_api/common.h" #include <irrlicht.h> #include "../guiparts.hpp" @@ -22,6 +25,41 @@ static LIGUIElement* toiguielement(lua_State* L){ return toiguielement(L,1); } +//move({element},{x,y}) -> nil +int moveiguielement(lua_State* L){ + printf("Got call to move element\n"); + long x,y; + popvector2i(L,&x,&y); //{element} + printf("I want to move to %d %d\n",x,y); + lua_getfield(L,-1,"guielement");//{element},*element + IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1); + printf("Found element to move: %p\n",el); + lua_pop(L,2);// + + el->move(position2d<s32>(x,y)); + el->updateAbsolutePosition(); + return 0; +} + +//getabsrect({element})-> {{sx,sy},{ex,ey}} +int getiguiclippingrect(lua_State* L){ + printf("Getting iguiclipping elemnt\n"); + lua_getfield(L,-1,"guielement"); + IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1); + core::rect<s32> rect = el->getAbsoluteClippingRect(); + position2d<s32> ul = rect.UpperLeftCorner; + position2d<s32> lr = rect.LowerRightCorner; + lua_newtable(L); + lua_pushnumber(L,1); + double sx,sy,ex,ey; + pushvector2i(L,ul.X,ul.Y); + lua_settable(L,-3); + lua_pushnumber(L,2); + pushvector2i(L,lr.X,lr.Y); + lua_settable(L,-3); + return 1; +} +/* int moveiguielement(lua_State* L){ LIGUIElement* ele = toiguielement(L,1); int x = luaL_optint(L,2,0); @@ -29,6 +67,7 @@ int moveiguielement(lua_State* L){ ele->e->move(position2d<s32>(x,y)); return 0; } +*/ int setiguitext(lua_State* L){ LIGUIElement* ele = toiguielement(L,1); @@ -41,12 +80,13 @@ int setiguitext(lua_State* L){ return 0; } +//remove({self}) int removeiguielement(lua_State* L){ - LIGUIElement* ele = toiguielement(L,1); - ele->e->remove(); - hashmap_free(ele->funcmap); - free(ele); - return 0; + lua_getfield(L,-1,"guielement"); + IGUIElement *ele = (IGUIElement*)lua_touserdata(L,-1); + ele->remove(); + lua_pop(L,2); + return 0; } int guigethandeler(lua_State* L){ |
