aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/load_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/load_gui.cpp')
-rw-r--r--src/client/lua_api/load_gui.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/client/lua_api/load_gui.cpp b/src/client/lua_api/load_gui.cpp
new file mode 100644
index 0000000..ed7faac
--- /dev/null
+++ b/src/client/lua_api/load_gui.cpp
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <vector>
+#include <map>
+extern "C" {
+ #include <lua.h>
+ #include <lauxlib.h>
+ #include <lualib.h>
+}
+#include <irrlicht.h>
+
+#include "gui/iguibutton.hpp"
+#include "gui/iguilabel.hpp"
+#include "../callbackhandeler.hpp"
+#include "guiparts.hpp"
+
+using namespace irr;
+using namespace gui;
+using namespace core;
+
+//Things from guiparts.hpp
+std::map<irr::gui::IGUIElement*,int> iguielements;
+IrrlichtDevice* guidevice;
+long gui_elenum;
+std::vector<irr::gui::IGUIElement*> guielements(1);
+lua_State* tL;
+
+int screenwidth(lua_State* L);
+int screenheight(lua_State* L);
+
+void load_guifuncs(lua_State* L, IrrlichtDevice* d){
+ tL = L;
+ guidevice = d;
+ gui_elenum = 0;
+ guielements[0] = NULL;
+ printf("About to initalize guielements vector\n");
+ printf("Done initalizeing guilements vector\n");
+
+ iguibutton_register(L,d);
+ iguilabel_register(L,d);
+ lua_pop(L, 1);
+
+ lua_newtable(L);
+ //lua_pushcfunction(L,createiguibutton);
+ //lua_setfield(L,-2,"createButton");
+ lua_setglobal(L,"gui");
+
+ lua_pushcfunction(L,screenwidth);
+ lua_setglobal(L,"scrw");
+
+ lua_pushcfunction(L,screenheight);
+ lua_setglobal(L,"scrh");
+
+}
+
+
+int screenheight(lua_State* L){
+ core::rect<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect();
+ lua_pushnumber(L,dim.getHeight());
+ printf("Got screen height:%d\n",dim.getWidth());
+ return 1;
+}
+
+int screenwidth(lua_State* L){
+ core::rect<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect();
+ lua_pushnumber(L,dim.getWidth());
+ printf("Got screen width:%d\n",dim.getWidth());
+ return 1;
+}