[5430] | 1 | local schemeMgr = CEGUI.SchemeManager:getSingleton() |
---|
| 2 | local winMgr = CEGUI.WindowManager:getSingleton() |
---|
| 3 | local logger = CEGUI.Logger:getSingleton() |
---|
[5427] | 4 | local system = CEGUI.System:getSingleton() |
---|
[5430] | 5 | local cursor = CEGUI.MouseCursor:getSingleton() |
---|
| 6 | |
---|
[5427] | 7 | schemeMgr:loadScheme("TaharezLookSkin.scheme") |
---|
| 8 | -- load scheme with our own images |
---|
| 9 | schemeMgr:loadScheme("OrxonoxGUIScheme.scheme") |
---|
| 10 | |
---|
[5430] | 11 | system:setDefaultMouseCursor("TaharezLook", "MouseArrow") |
---|
| 12 | system:setDefaultFont("BlueHighway-12") |
---|
[5414] | 13 | |
---|
[5427] | 14 | local current = nil |
---|
| 15 | local loadedGUIs = {} |
---|
| 16 | local showing |
---|
[5432] | 17 | |
---|
[5427] | 18 | datapath = "" -- points to media-folder (set after loading the script) |
---|
| 19 | |
---|
| 20 | -- function to add a reference to list of reference of loaded GUIs |
---|
| 21 | loadedGUIs.addGUI = function (gui) |
---|
| 22 | loadedGUIs[#loadedGUIs+1] = gui |
---|
| 23 | end |
---|
| 24 | |
---|
| 25 | -- function which returns a GUI by name |
---|
| 26 | loadedGUIs.getGUIbyName = function (str) |
---|
| 27 | for i = 1, #loadedGUIs, 1 do |
---|
| 28 | if str == loadedGUIs[i].filename then |
---|
| 29 | return loadedGUIs[i] |
---|
| 30 | end |
---|
| 31 | end |
---|
| 32 | return nil |
---|
[5430] | 33 | end |
---|
[5427] | 34 | |
---|
| 35 | -- loads the GUI with the specified filename |
---|
[5430] | 36 | -- be sure to set the global variable "filename" before calling this function |
---|
[5432] | 37 | function loadGUI(filename) |
---|
[5427] | 38 | -- check if it already exists |
---|
| 39 | newlyLoaded = loadedGUIs:getGUIbyName(filename) |
---|
| 40 | if newlyLoaded == nil then |
---|
[5432] | 41 | dofile(datapath .. "gui/scripts/" .. filename .. ".lua") |
---|
[5427] | 42 | newlyLoaded = winMgr:loadWindowLayout(layoutPath) |
---|
| 43 | newlyLoaded.filename = filename |
---|
| 44 | loadedGUIs:addGUI(newlyLoaded) |
---|
| 45 | -- if there has no GUI been loaded yet, set new GUI as current |
---|
| 46 | if #loadedGUIs == 1 then |
---|
| 47 | current = loadedGUIs[1] |
---|
| 48 | showing = false |
---|
| 49 | end |
---|
| 50 | -- hide new GUI as we do not want to show it accidentially |
---|
| 51 | newlyLoaded:hide() |
---|
| 52 | end |
---|
[5430] | 53 | return newlyLoaded |
---|
[5414] | 54 | end |
---|
| 55 | |
---|
[5427] | 56 | -- shows the specified and loads it if not loaded already |
---|
| 57 | -- be sure to set the global variable "filename" before calling this function |
---|
[5432] | 58 | function showGUI(filename) |
---|
[5427] | 59 | if current == nil or current.filename ~= filename then |
---|
| 60 | current = loadedGUIs.getGUIbyName(filename) |
---|
| 61 | if current == nil then |
---|
| 62 | current = loadGUI(filename) |
---|
| 63 | end |
---|
| 64 | system:setGUISheet(current) |
---|
| 65 | end |
---|
| 66 | current:show() |
---|
| 67 | cursor:show() |
---|
| 68 | showing = true |
---|
| 69 | end |
---|
[5414] | 70 | |
---|
| 71 | function toggleGUI() |
---|
| 72 | if showing == true then |
---|
[5427] | 73 | current:hide() |
---|
| 74 | cursor:hide() |
---|
[5414] | 75 | showing = false |
---|
| 76 | else |
---|
[5427] | 77 | current:show() |
---|
| 78 | cursor:show() |
---|
[5414] | 79 | showing = true |
---|
| 80 | end |
---|
[5427] | 81 | return showing |
---|
[5430] | 82 | end |
---|
| 83 | |
---|
[5427] | 84 | function hideGUI() |
---|
| 85 | current:hide() |
---|
[5430] | 86 | showing = false |
---|
| 87 | end |
---|