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/iguibutton.cpp10
-rw-r--r--src/client/lua_api/gui/iguifiledialog.cpp16
-rw-r--r--src/client/lua_api/gui/iguiimage.cpp14
3 files changed, 29 insertions, 11 deletions
diff --git a/src/client/lua_api/gui/iguibutton.cpp b/src/client/lua_api/gui/iguibutton.cpp
index 42d2846..b8ff517 100644
--- a/src/client/lua_api/gui/iguibutton.cpp
+++ b/src/client/lua_api/gui/iguibutton.cpp
@@ -30,11 +30,11 @@ char lhashkey[20];
/***
Creates a new button.
Buttons may have the following fields set for callbacks:
-`.onClick(self)`
-`.onFocus(self)`
-`.onUnfocus(self)`
-`.onHover(self)`
-`.onLeave(self)`
+ .onClick(self)
+ .onFocus(self)
+ .onUnfocus(self)
+ .onHover(self)
+ .onLeave(self)
@function newbutton()
@tparam rect dimensions The rectangle to place the button at. If the box has a parent,
it is offset from the upper-left of the parent element.
diff --git a/src/client/lua_api/gui/iguifiledialog.cpp b/src/client/lua_api/gui/iguifiledialog.cpp
index 6303230..d717673 100644
--- a/src/client/lua_api/gui/iguifiledialog.cpp
+++ b/src/client/lua_api/gui/iguifiledialog.cpp
@@ -28,7 +28,11 @@ extern IrrlichtDevice* device;
/***
@function newfileopendialog()
-Creates a new dialog to open a file
+Creates a new dialog to open a file.
+The file creation window may have the following fields set for callbacks:
+ .onDirectorySelect(self)
+ .onFileSelect(self)
+ .onCanceled(self)
@tparam ?string title The rectangle to place the button at. If the box has a parent,
it is offset from the upper-left of the parent element.
@tparam ?string path The path to open the file dialog to
@@ -66,10 +70,10 @@ static int newfileopendialog(lua_State* L){
mbstowcs(title,titlec,titlecslen);
title[titlecslen] = L'\0';
}
-
+ //printf("Got all arguments\n");
IGUIEnvironment *env = device->getGUIEnvironment();
IGUIFileOpenDialog *but = env->addFileOpenDialog(title,modal,parent,-1,false,path);
-
+ //printf("Created file open dialog\n");
//printf("Added file open dialog\n");
lua_newtable(L);//{}
lua_pushlightuserdata(L,but);//{},ud_iguibutton
@@ -78,13 +82,13 @@ static int newfileopendialog(lua_State* L){
lua_setmetatable(L,-2);//{guielement}
//printf("Created lua representation\n");
- setelementcallback(L,EGET_DIRECTORY_SELECTED,"onDirectory");//
- setelementcallback(L,EGET_FILE_SELECTED,"onFileSelected");
+ setelementcallback(L,EGET_DIRECTORY_SELECTED,"onDirectorySelect");//
+ setelementcallback(L,EGET_FILE_SELECTED,"onFileSelect");
setelementcallback(L,EGET_FILE_CHOOSE_DIALOG_CANCELLED,"onCanceled");
//printf("Finished registering callback\n");
free(title);
- free(path);
+ //printf("Freed everything\n");
return 1;
}
diff --git a/src/client/lua_api/gui/iguiimage.cpp b/src/client/lua_api/gui/iguiimage.cpp
index 1d0f4dc..267cbd2 100644
--- a/src/client/lua_api/gui/iguiimage.cpp
+++ b/src/client/lua_api/gui/iguiimage.cpp
@@ -21,6 +21,7 @@ extern "C" {
@module gui
*/
using namespace irr;
+using namespace video;
using namespace gui;
extern IrrlichtDevice* device;
@@ -80,8 +81,21 @@ int setcolor(lua_State* L){
return 0;
}
+//setimage(self,itexture)
+int setimage(lua_State *L){
+ lua_getfield(L,-1,"texture");//{iguiimg},{itex}
+ ITexture* img = (ITexture*)lua_touserdata(L,-1);//{iguiimg},{itex},ud_itexture
+ lua_pop(L,2);//{iguiimg}
+ lua_getfield(L,-1,"guielement");//{iguiimg},ud_guiimg
+ IGUIImage *gimg = (IGUIImage*)lua_touserdata(L,-1);//{iguiimg},ud_guiimg
+ lua_pop(L,2);//
+ gimg->setImage(img);
+ return 0;
+}
+
static const luaL_reg iguiimage_m[] = {
{"setcolor", setcolor},
+ {"setimage", setimage},
{0, 0},
};