diff options
| author | Alexander Pickering <alex@cogarr.net> | 2018-06-23 06:52:55 -0600 |
|---|---|---|
| committer | Alexander Pickering <alex@cogarr.net> | 2018-06-23 06:52:55 -0600 |
| commit | e6faff1394864a1fe0d517584d1c104997dff39f (patch) | |
| tree | d7956fc8aabef903f354578d69d4d7fdf64ec928 /src/client/lua_api/gui/iguielement.cpp | |
| parent | 1aaa348ac080c97c0aeb0a02146ae26b74add5a1 (diff) | |
| parent | 9fa5dcc9310a8c6ff8c77a47a86303f7b950dcf3 (diff) | |
| download | brokengine-e6faff1394864a1fe0d517584d1c104997dff39f.tar.gz brokengine-e6faff1394864a1fe0d517584d1c104997dff39f.tar.bz2 brokengine-e6faff1394864a1fe0d517584d1c104997dff39f.zip | |
Merge branch 'master' of ssh://cogarr.net:43/home/git/brokengine
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..436bf93 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){ |
