aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2022-07-04 18:19:26 -0500
committerAlexander M Pickering <alex@cogarr.net>2022-07-04 18:19:26 -0500
commit9f6b7ecb31179ee980f729578d84d7889f5065b8 (patch)
treeed1cc4b2614f2c134830c7431efae9f6afa34faa /src/client/lua_api/gui
parentcb39716f1ee896473ed03bcb6dbf927715f74cee (diff)
downloadbrokengine-9f6b7ecb31179ee980f729578d84d7889f5065b8.tar.gz
brokengine-9f6b7ecb31179ee980f729578d84d7889f5065b8.tar.bz2
brokengine-9f6b7ecb31179ee980f729578d84d7889f5065b8.zip
Minor bugfixes, preparing to overhaul
Diffstat (limited to 'src/client/lua_api/gui')
-rw-r--r--src/client/lua_api/gui/iguifiledialog.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/client/lua_api/gui/iguifiledialog.cpp b/src/client/lua_api/gui/iguifiledialog.cpp
index 88fcae0..8e038c5 100644
--- a/src/client/lua_api/gui/iguifiledialog.cpp
+++ b/src/client/lua_api/gui/iguifiledialog.cpp
@@ -26,9 +26,11 @@ extern IrrlichtDevice* device;
/***
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)
+
@function gui.newfileopendialog()
@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.
@@ -39,10 +41,11 @@ it is offset from the upper-left of the parent element.
*/
//gui.newfileopendialog(["title"][,"path"][,parent][,modal])
static int newfileopendialog(lua_State* L){
- wchar_t *title = NULL;// = L"File open dialog";
- io::path::char_type *path = NULL;// = L"";
+ printf("Creating openfiledialog\n");
+ wchar_t *title = (wchar_t*)calloc(sizeof(wchar_t),1);// = L"File open dialog";
+ io::path::char_type *path = 0;// = L"";
bool modal = true;
- IGUIElement* parent = NULL;
+ IGUIElement* parent = 0;
int nargs = lua_gettop(L);
if(nargs > 3){
@@ -50,9 +53,13 @@ static int newfileopendialog(lua_State* L){
lua_pop(L,1);//"title","path",{parent}
}
if(nargs > 2){
- lua_getfield(L,-1,"guielement");//"title","path",{parent},ud_parent
- parent = (IGUIElement*)lua_touserdata(L,-1);//"title","path",{parent},ud_parent
- lua_pop(L,2);//"title","path"
+ if(!lua_isnil(L,-1)){
+ lua_getfield(L,-1,"guielement");//"title","path",{parent},ud_parent
+ parent = (IGUIElement*)lua_touserdata(L,-1);//"title","path",{parent},ud_parent
+ lua_pop(L,2);//"title","path"
+ }else{
+ parent = device->getGUIEnvironment()->getRootGUIElement();
+ }
}
if(nargs > 1){
const char *pathc = lua_tostring(L,-1);//"title","path"
@@ -67,25 +74,28 @@ static int newfileopendialog(lua_State* L){
mbstowcs(title,titlec,titlecslen);
title[titlecslen] = L'\0';
}
- //printf("Got all arguments\n");
+ printf("Got all arguments\n");
IGUIEnvironment *env = device->getGUIEnvironment();
+ printf("Got gui environment: %p\n",(void*)env);
+ printf("Test: %ls\n",title);
IGUIFileOpenDialog *but = env->addFileOpenDialog(title,modal,parent,-1,false,path);
- //printf("Created file open dialog\n");
- //printf("Added file open dialog\n");
+ //IGUIFileOpenDialog *but = env->addFileOpenDialog(L"test",true,0,-1,false,"test");
+ printf("Created file open dialog\n");
+ printf("Added file open dialog\n");
lua_newtable(L);//{}
lua_pushlightuserdata(L,but);//{},ud_iguibutton
lua_setfield(L,-2,"guielement");//{guielement}
luaL_getmetatable(L,"gui.iguifileopendialog");//{guielement},{m_iguibutton}
lua_setmetatable(L,-2);//{guielement}
- //printf("Created lua representation\n");
+ printf("Created lua representation\n");
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");
+ printf("Finished registering callback\n");
free(title);
- //printf("Freed everything\n");
+ printf("Freed everything\n");
return 1;
}