local schemeMgr = CEGUI.SchemeManager:getSingleton() local winMgr = CEGUI.WindowManager:getSingleton() local logger = CEGUI.Logger:getSingleton() local system = CEGUI.System:getSingleton() local cursor = CEGUI.MouseCursor:getSingleton() schemeMgr:loadScheme("TaharezLookSkin.scheme") -- load scheme with our own images schemeMgr:loadScheme("OrxonoxGUIScheme.scheme") system:setDefaultMouseCursor("TaharezLook", "MouseArrow") system:setDefaultFont("BlueHighway-12") local current = nil local loadedGUIs = {} local showing -- we cannot directly call functions with parameters and so need this as a global variable, which sucks of course filename = "" datapath = "" -- points to media-folder (set after loading the script) -- function to add a reference to list of reference of loaded GUIs loadedGUIs.addGUI = function (gui) loadedGUIs[#loadedGUIs+1] = gui end -- function which returns a GUI by name loadedGUIs.getGUIbyName = function (str) for i = 1, #loadedGUIs, 1 do if str == loadedGUIs[i].filename then return loadedGUIs[i] end end return nil end -- loads the GUI with the specified filename -- be sure to set the global variable "filename" before calling this function function loadGUI() -- check if it already exists newlyLoaded = loadedGUIs:getGUIbyName(filename) if newlyLoaded == nil then dofile(datapath .. "gui/scripts/" .. filename) newlyLoaded = winMgr:loadWindowLayout(layoutPath) newlyLoaded.filename = filename loadedGUIs:addGUI(newlyLoaded) -- if there has no GUI been loaded yet, set new GUI as current if #loadedGUIs == 1 then current = loadedGUIs[1] showing = false end -- hide new GUI as we do not want to show it accidentially newlyLoaded:hide() end return newlyLoaded end -- shows the specified and loads it if not loaded already -- be sure to set the global variable "filename" before calling this function function showGUI() if current == nil or current.filename ~= filename then current = loadedGUIs.getGUIbyName(filename) if current == nil then current = loadGUI(filename) end system:setGUISheet(current) end current:show() cursor:show() showing = true end function toggleGUI() if showing == true then current:hide() cursor:hide() showing = false else current:show() cursor:show() showing = true end return showing end function hideGUI() current:hide() showing = false end