/*** Utilities for drawing GUI things on the screen @module gui */ #include #include #include #include extern "C" { #include #include #include } #include #include "gui/iguibutton.hpp" #include "gui/iguilabel.hpp" #include "gui/iguiwindow.hpp" #include "gui/iguicheckbox.hpp" #include "gui/iguiimage.hpp" #include "gui/iguieditbox.hpp" #include "gui/iguicolorselector.hpp" #include "gui/iguifiledialog.hpp" #include "gui/iguispinbox.hpp" #include "gui/iguitreeview.hpp" #include "gui/iguicombobox.hpp" #include "../callbackhandeler.hpp" #include "guiparts.hpp" using namespace irr; using namespace gui; using namespace core; extern IrrlichtDevice* device; //Things from guiparts.hpp std::map iguielements; IrrlichtDevice* guidevice; //long gui_elenum; //std::vector guielements(1); lua_State* tL; int screenwidth(lua_State* L); int screenheight(lua_State* L); /*** @function gui.scrw() @treturn number The width of the screen */ /*** @function gui.scrh() @treturn number The height of the screen */ void load_guifuncs(lua_State* L){ printf("Started loading gui...\n"); tL = L; guidevice = device; IGUIFont *font = device->getGUIEnvironment()->getFont("../data/res/font.xml"); //Set the transparency of new igui windows IGUISkin *skin = device->getGUIEnvironment()->getSkin(); for(int i = 0; i < EGDC_COUNT; i++){ video::SColor col = skin->getColor((EGUI_DEFAULT_COLOR)i); col.setAlpha(255); skin->setColor((EGUI_DEFAULT_COLOR)i, col); } for(int i = 0; i < EGDF_COUNT; i++){ skin->setFont(font,(EGUI_DEFAULT_FONT)i); } //Various enums lua_newtable(L); lua_setglobal(L,"gui"); iguilabel_register(L); iguicheckbox_register(L); iguiwindow_register(L,device); iguiimage_register(L); iguibutton_register(L); iguicolorselector_register(L); iguidialog_register(L); iguispinbox_register(L); iguitreeview_register(L); iguieditbox_register(L); iguicombobox_register(L); lua_pushcfunction(L,screenwidth); lua_setglobal(L,"scrw"); lua_pushcfunction(L,screenheight); lua_setglobal(L,"scrh"); } int screenheight(lua_State* L){ core::rect 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 dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); lua_pushnumber(L,dim.getWidth()); //printf("Got screen width:%d\n",dim.getWidth()); return 1; }