[5491] | 1 | local schemeMgr = CEGUI.SchemeManager:getSingleton() |
---|
| 2 | winMgr = CEGUI.WindowManager:getSingleton() |
---|
| 3 | local logger = CEGUI.Logger:getSingleton() |
---|
| 4 | local system = CEGUI.System:getSingleton() |
---|
| 5 | local cursor = CEGUI.MouseCursor:getSingleton() |
---|
| 6 | |
---|
| 7 | schemeMgr:loadScheme("TaharezLookSkin.scheme") |
---|
| 8 | -- load scheme with our own images |
---|
| 9 | schemeMgr:loadScheme("OrxonoxGUIScheme.scheme") |
---|
| 10 | |
---|
| 11 | system:setDefaultMouseCursor("TaharezLook", "MouseArrow") |
---|
| 12 | system:setDefaultFont("BlueHighway-12") |
---|
[5527] | 13 | system:setDefaultTooltip("TaharezLook/Tooltip") |
---|
[5491] | 14 | |
---|
| 15 | loadedGUIs = {} |
---|
[6003] | 16 | root = nil; |
---|
[5491] | 17 | |
---|
| 18 | -- loads the GUI with the specified filename |
---|
| 19 | -- be sure to set the global variable "filename" before calling this function |
---|
| 20 | function loadGUI(filename) |
---|
| 21 | -- check if it already exists |
---|
| 22 | loadedGui = loadedGUIs[filename] |
---|
| 23 | if loadedGui == nil then |
---|
| 24 | loadedGuiNS = require(filename) |
---|
| 25 | loadedGui = loadedGuiNS:load() |
---|
| 26 | loadedGUIs[filename] = loadedGui |
---|
| 27 | -- if there has no GUI been loaded yet, set new GUI as current |
---|
[5580] | 28 | if table.getn(loadedGUIs) == 1 then |
---|
[5491] | 29 | current = loadedGUIs[1] |
---|
| 30 | showing = false |
---|
| 31 | end |
---|
| 32 | -- hide new GUI as we do not want to show it accidentially |
---|
| 33 | loadedGui:hide() |
---|
| 34 | end |
---|
| 35 | return loadedGui |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | function showGUI(filename, ptr) |
---|
| 39 | gui = showGUI(filename) |
---|
| 40 | gui.overlay = ptr |
---|
| 41 | end |
---|
| 42 | |
---|
| 43 | -- shows the specified and loads it if not loaded already |
---|
| 44 | -- be sure to set the global variable "filename" before calling this function |
---|
| 45 | function showGUI(filename) |
---|
[6003] | 46 | if root == nil then |
---|
| 47 | root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow") |
---|
| 48 | root:setProperty("Alpha", "0.0") |
---|
| 49 | root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0))) |
---|
| 50 | system:setGUISheet(root) |
---|
[5491] | 51 | end |
---|
| 52 | |
---|
[6003] | 53 | local currentGUI = loadedGUIs[filename] |
---|
| 54 | if(currentGUI == nil) then |
---|
| 55 | currentGUI = loadGUI(filename) |
---|
[5491] | 56 | end |
---|
[6003] | 57 | |
---|
| 58 | if(root:isChild(currentGUI.window)) then |
---|
| 59 | root:removeChildWindow(currentGUI.window) |
---|
| 60 | end |
---|
| 61 | root:addChildWindow(currentGUI.window) |
---|
| 62 | |
---|
| 63 | currentGUI:show() |
---|
| 64 | showing = true |
---|
| 65 | return currentGUI |
---|
[5491] | 66 | end |
---|
| 67 | |
---|
| 68 | function hideCursor() |
---|
| 69 | cursor:hide() |
---|
| 70 | end |
---|
| 71 | |
---|
| 72 | function showCursor() |
---|
| 73 | cursor:show() |
---|
| 74 | end |
---|
| 75 | |
---|
| 76 | function hideGUI(filename) |
---|
[6003] | 77 | local currentGUI = loadedGUIs[filename] |
---|
| 78 | if currentGUI ~= nil then |
---|
| 79 | currentGUI:hide() |
---|
| 80 | root:removeChildWindow(currentGUI.window) |
---|
[5491] | 81 | showing = false |
---|
| 82 | end |
---|
| 83 | end |
---|