aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/gui')
-rw-r--r--src/client/lua_api/gui/iguieditbox.cpp14
-rw-r--r--src/client/lua_api/gui/iguielement.cpp27
-rw-r--r--src/client/lua_api/gui/iguiwindow.cpp4
3 files changed, 44 insertions, 1 deletions
diff --git a/src/client/lua_api/gui/iguieditbox.cpp b/src/client/lua_api/gui/iguieditbox.cpp
index 7b79f34..1ceab1f 100644
--- a/src/client/lua_api/gui/iguieditbox.cpp
+++ b/src/client/lua_api/gui/iguieditbox.cpp
@@ -61,6 +61,19 @@ static int newiguieditbox(lua_State* L){
return 1;
}
+//{guieditbox}:getinput()
+int getinputtext(lua_State* L){
+ lua_getfield(L, -1, "guielement");//{guieditbox},ud_guielement
+ irr::gui::IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1);
+ lua_pop(L,2);//
+ const wchar_t *t = el->getText();
+ size_t strlen = wcslen(t);
+ char output[strlen];
+ wcstombs(output,t,strlen);
+ lua_pushstring(L,output);//"str"
+ return 1;
+}
+
static const luaL_reg iguieditbox_f[] = {
{"neweditbox",newiguieditbox},
{0,0},
@@ -69,6 +82,7 @@ static const luaL_reg iguieditbox_f[] = {
static const luaL_reg iguieditbox_m[] = {
{"move", moveiguielement},
{"settext", setiguitext},
+ {"getinput", getinputtext},
{"remove", removeiguielement},
{0,0},
};
diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp
index fa3d480..5ba998f 100644
--- a/src/client/lua_api/gui/iguielement.cpp
+++ b/src/client/lua_api/gui/iguielement.cpp
@@ -1,4 +1,9 @@
/*This file defines some things that all igui stuff can do*/
+/***
+@module gui
+
+
+*/
extern "C" {
#include <lua.h>
#include <lauxlib.h>
@@ -15,6 +20,11 @@ using namespace irr;
using namespace core;
using namespace gui;
+/***
+Move a window (by an offset)
+@function guielement:move()
+@tparam vec2 position The offset to move this element by
+*/
//move({element},{x,y}) -> nil
int moveiguielement(lua_State* L){
//printf("Got call to move element\n");
@@ -31,6 +41,11 @@ int moveiguielement(lua_State* L){
return 0;
}
+/***
+Find the rectangle that an element occupies
+@function guielement:getabsrect()
+@treturn rect The rectangle that this element occupies
+*/
//getabsrect({element})-> {{sx,sy},{ex,ey}}
int getiguiclippingrect(lua_State* L){
printf("Getting iguiclipping elemnt\n");
@@ -48,6 +63,14 @@ int getiguiclippingrect(lua_State* L){
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.
+On a button, it sets the button's text.
+@function guielement:settext()
+@tparam string text The text to set on the element
+*/
//setText({guielement},"text") :: nil
int setiguitext(lua_State* L){
const char* text = lua_tostring(L, -1);
@@ -63,6 +86,10 @@ int setiguitext(lua_State* L){
return 0;
}
+/***
+Removes a gui element, and any child elements
+@function guielement:remove()
+*/
//remove({self})
int removeiguielement(lua_State* L){
lua_getfield(L,-1,"guielement");
diff --git a/src/client/lua_api/gui/iguiwindow.cpp b/src/client/lua_api/gui/iguiwindow.cpp
index e5c3193..3fbd5e4 100644
--- a/src/client/lua_api/gui/iguiwindow.cpp
+++ b/src/client/lua_api/gui/iguiwindow.cpp
@@ -76,8 +76,10 @@ static const luaL_reg iguiwindow_m[] = {
};
int iguiwindow_register(lua_State* L, IrrlichtDevice* d){
- luaL_newmetatable(L,"gui.window");//m{gui.checkbox}
+ luaL_newmetatable(L,"gui.window");//m{gui.window}
+ lua_newtable(L);
luaL_register(L,NULL,iguiwindow_m);
+ lua_setfield(L,-2,"__index");
lua_pop(L,1);//
lua_getglobal(L,"gui");