aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2018-10-03 17:49:26 -0400
committerAlexander Pickering <alex@cogarr.net>2018-10-03 17:49:26 -0400
commit7c165e6c5ba2c92bab5359344f0755fd43d1bb9e (patch)
treed71f9d76bdd9f7a89901251cdc5649b0dd463569 /src/client/lua_api
parent6e8ef86afc5a559ff4df7f43bec53f82a9060731 (diff)
downloadbrokengine-7c165e6c5ba2c92bab5359344f0755fd43d1bb9e.tar.gz
brokengine-7c165e6c5ba2c92bab5359344f0755fd43d1bb9e.tar.bz2
brokengine-7c165e6c5ba2c92bab5359344f0755fd43d1bb9e.zip
Changed and added some methods for generic gui elements.
Changed getabsrect() to now return getAbsolutePosition() Added getabsclippingrect() to return what getabsrect used to return Added getrelrect() to return getRelativePosition()
Diffstat (limited to 'src/client/lua_api')
-rw-r--r--src/client/lua_api/gui/iguielement.cpp41
-rw-r--r--src/client/lua_api/gui/iguielement.hpp4
2 files changed, 45 insertions, 0 deletions
diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp
index 3567d80..81d339f 100644
--- a/src/client/lua_api/gui/iguielement.cpp
+++ b/src/client/lua_api/gui/iguielement.cpp
@@ -49,6 +49,27 @@ int getiguiclippingrect(lua_State* L){
lua_getfield(L,-1,"guielement");
IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);//{element},ud_element
lua_pop(L,2);
+ core::rect<s32> rect = el->getAbsolutePosition();
+ pushrecti(
+ L,
+ rect.UpperLeftCorner.X,
+ rect.UpperLeftCorner.Y,
+ rect.LowerRightCorner.X,
+ rect.LowerRightCorner.Y
+ );
+ return 1;
+}
+
+/***
+Find the rectangle that an element occupies that is visible to the user
+@function guielement:getabsclippingrect()
+@treturn rect The rectangle that this element occupies that is visible to the user
+*/
+//getabsclippingrect({element}) :: {{sx,sy},{ex,ey}}
+int getiguiabsclippingrect(lua_State *L){
+ lua_getfield(L,-1,"guielement");
+ IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);//{element},ud_element
+ lua_pop(L,2);
core::rect<s32> rect = el->getAbsoluteClippingRect();
pushrecti(
L,
@@ -61,6 +82,26 @@ int getiguiclippingrect(lua_State* L){
}
/***
+Find the relative rectangle that this element occupies
+@function guielement:getrelrect()
+@treturn rect The rectangle that this element occupies relative to it's parent
+*/
+int getiguirelrect(lua_State *L){
+ lua_getfield(L,-1,"guielement");
+ IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);//{element},ud_element
+ lua_pop(L,2);
+ core::rect<s32> rect = el->getRelativePosition();
+ pushrecti(
+ L,
+ rect.UpperLeftCorner.X,
+ rect.UpperLeftCorner.Y,
+ rect.LowerRightCorner.X,
+ rect.LowerRightCorner.Y
+ );
+ return 1;
+}
+
+/***
Sets the text of the element
This function may do different things to different gui elements.
For example, on a window, it sets the title.
diff --git a/src/client/lua_api/gui/iguielement.hpp b/src/client/lua_api/gui/iguielement.hpp
index 0e08644..7969c65 100644
--- a/src/client/lua_api/gui/iguielement.hpp
+++ b/src/client/lua_api/gui/iguielement.hpp
@@ -10,6 +10,8 @@ extern "C" {
int moveiguielement(lua_State* L);
int getiguiclippingrect(lua_State* L);
+int getiguiabsclippingrect(lua_State *L);
+int getiguirelrect(lua_State *L);
int setiguitext(lua_State* L);
int getiguitext(lua_State* L);
int removeiguielement(lua_State* L);
@@ -23,6 +25,8 @@ static const luaL_reg iguielement_m[] = {
{"move", moveiguielement},
{"setrect", setrelrect},
{"getabsrect", getiguiclippingrect},
+ {"getabsclippingrect", getiguiabsclippingrect},
+ {"getrelrect", getiguirelrect},
{"settext", setiguitext},
{"gettext", getiguitext},
{"remove", removeiguielement},