aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui/iguiwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/gui/iguiwindow.cpp')
-rw-r--r--src/client/lua_api/gui/iguiwindow.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/client/lua_api/gui/iguiwindow.cpp b/src/client/lua_api/gui/iguiwindow.cpp
index 150ba68..705af18 100644
--- a/src/client/lua_api/gui/iguiwindow.cpp
+++ b/src/client/lua_api/gui/iguiwindow.cpp
@@ -15,7 +15,7 @@ extern "C" {
#include "iguiwindow.hpp"
#include "iguiutil.hpp"
#include "../../callbackhandeler.hpp"
-#include "../../../shared/lua_api/common.h"
+#include <shared/lua_api/common.hpp>
using namespace irr;
using namespace gui;
@@ -32,39 +32,38 @@ static bool iguiwindowevent(irr::SEvent e){
return shouldclose == 1;
}
-//new({posx,posy},{width,height},"title"[,parent])
+//new({{sx,sy},{ex,ey}},"title"[,{guielement=parent}]) :: {guielement}
static int newiguiwindow(lua_State* L){
IGUIElement* parent = NULL;
int numargs = lua_gettop(L);
if(numargs == 4){
+ lua_getfield(L,-1,"guielement");//{{sx,sy},{ex,ey}},"title",{guielement=parent},parent
parent = (IGUIElement*)lua_touserdata(L,-1);
- lua_pop(L,1);
+ lua_pop(L,2);
}
+ //{{sx,sy},{ex,ey},"title"
const char* title_c = lua_tostring(L,-1);
const wchar_t* title_w = irr::core::stringw(title_c).c_str();
- lua_pop(L,1);
+ lua_pop(L,1);//{{sx,sy},{ex,ey}}
//Frame position
- long x,y,w,h;
- popvector2i(L,&w,&h);
- popvector2i(L,&x,&y);
+ long sx,sy,ex,ey;
+ poprecti(L,&sx,&sy,&ex,&ey);//
//Create the window
IGUIEnvironment* env = guidevice->getGUIEnvironment();
IGUIWindow* wi = env->addWindow(
- core::rect<s32>(x,y,x+w,y+h),
+ core::rect<s32>(sx,sy,ex,ey),
false,
title_w,
parent,
-1
);
- lua_pushlightuserdata(L,wi);
-
lua_newtable(L);//{}
lua_pushlightuserdata(L,wi);//{},{ud_window}
- lua_setfield(L,-2,"element");//{element=ud_window}
+ lua_setfield(L,-2,"guielement");//{element=ud_window}
luaL_getmetatable(L,"gui.window");//{element=ud_window},{m_gui.window}
lua_setmetatable(L,-2);//{element=ud_window, __meta=gui.window}