[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 = {} |
---|
[6024] | 16 | cursorVisibility = {} |
---|
| 17 | activeSheets = {} |
---|
| 18 | nrOfActiveSheets = 0 |
---|
| 19 | root = nil |
---|
| 20 | bShowsCursor = false |
---|
[5491] | 21 | |
---|
| 22 | -- loads the GUI with the specified filename |
---|
| 23 | -- be sure to set the global variable "filename" before calling this function |
---|
| 24 | function loadGUI(filename) |
---|
| 25 | -- check if it already exists |
---|
| 26 | loadedGui = loadedGUIs[filename] |
---|
| 27 | if loadedGui == nil then |
---|
| 28 | loadedGuiNS = require(filename) |
---|
| 29 | loadedGui = loadedGuiNS:load() |
---|
| 30 | loadedGUIs[filename] = loadedGui |
---|
| 31 | -- if there has no GUI been loaded yet, set new GUI as current |
---|
[5580] | 32 | if table.getn(loadedGUIs) == 1 then |
---|
[5491] | 33 | current = loadedGUIs[1] |
---|
| 34 | showing = false |
---|
| 35 | end |
---|
| 36 | -- hide new GUI as we do not want to show it accidentially |
---|
| 37 | loadedGui:hide() |
---|
| 38 | end |
---|
| 39 | return loadedGui |
---|
| 40 | end |
---|
| 41 | |
---|
[6024] | 42 | function showGUI(filename, bCursorVisible, ptr) |
---|
| 43 | gui = showGUI(filename, bCursorVisible) |
---|
[5491] | 44 | gui.overlay = ptr |
---|
| 45 | end |
---|
| 46 | |
---|
| 47 | -- shows the specified and loads it if not loaded already |
---|
| 48 | -- be sure to set the global variable "filename" before calling this function |
---|
[6024] | 49 | function showGUI(filename, bCursorVisible) |
---|
| 50 | -- bCursorVisibile=false |
---|
| 51 | if bCursorVisible == nil then |
---|
| 52 | cursorVisibility= true |
---|
[5491] | 53 | end |
---|
| 54 | |
---|
[6024] | 55 | if root == nil then |
---|
| 56 | root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow") |
---|
| 57 | root:setProperty("Alpha", "0.0") |
---|
| 58 | root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0))) |
---|
| 59 | system:setGUISheet(root) |
---|
| 60 | end |
---|
| 61 | |
---|
| 62 | local currentGUI = loadedGUIs[filename] |
---|
| 63 | if(currentGUI == nil) then |
---|
| 64 | currentGUI = loadGUI(filename) |
---|
| 65 | end |
---|
| 66 | |
---|
| 67 | if(root:isChild(currentGUI.window)) then |
---|
| 68 | root:removeChildWindow(currentGUI.window) |
---|
| 69 | end |
---|
| 70 | root:addChildWindow(currentGUI.window) |
---|
| 71 | |
---|
| 72 | if bCursorVisible then |
---|
| 73 | showCursor() |
---|
[5491] | 74 | else |
---|
[6024] | 75 | hideCursor() |
---|
[5491] | 76 | end |
---|
[6024] | 77 | cursorVisibility[filename]=bCursorVisible |
---|
| 78 | |
---|
| 79 | nrOfActiveSheets = nrOfActiveSheets + 1 |
---|
| 80 | table.insert(activeSheets, filename) |
---|
| 81 | activeSheets[nrOfActiveSheets] = filename |
---|
| 82 | |
---|
| 83 | currentGUI:show() |
---|
| 84 | showing = true |
---|
| 85 | return currentGUI |
---|
[5491] | 86 | end |
---|
| 87 | |
---|
| 88 | function hideCursor() |
---|
[6024] | 89 | if bShowsCursor==true then |
---|
| 90 | bShowsCursor=false |
---|
| 91 | cursor:hide() |
---|
| 92 | end |
---|
[5491] | 93 | end |
---|
| 94 | |
---|
| 95 | function showCursor() |
---|
[6024] | 96 | if bShowsCursor==false then |
---|
| 97 | bShowsCursor=true |
---|
| 98 | cursor:show() |
---|
| 99 | end |
---|
[5491] | 100 | end |
---|
| 101 | |
---|
| 102 | function hideGUI(filename) |
---|
[6024] | 103 | local currentGUI = loadedGUIs[filename] |
---|
| 104 | if currentGUI == nil then |
---|
| 105 | return |
---|
[5491] | 106 | end |
---|
[6024] | 107 | currentGUI:hide() |
---|
| 108 | root:removeChildWindow(currentGUI.window) |
---|
| 109 | showing = false |
---|
| 110 | i=1 |
---|
| 111 | while activeSheets[i] do |
---|
| 112 | if activeSheets[i+1] == nil then |
---|
| 113 | if activeSheets[i-1] ~= nil then |
---|
| 114 | if cursorVisibility[ activeSheets[i-1] ] == true then |
---|
| 115 | showCursor() |
---|
| 116 | else |
---|
| 117 | hideCursor() |
---|
| 118 | end |
---|
| 119 | else |
---|
| 120 | hideCursor() |
---|
| 121 | end |
---|
| 122 | end |
---|
| 123 | if activeSheets[i] == filename then |
---|
| 124 | table.remove( activeSheets, i ) |
---|
| 125 | nrOfActiveSheets = nrOfActiveSheets-1 |
---|
| 126 | else |
---|
| 127 | i = i+1 |
---|
| 128 | end |
---|
| 129 | end |
---|
| 130 | cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table |
---|
[5491] | 131 | end |
---|