[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) |
---|
[5446] | 27 | print("number of GUIs loaded: " .. #loadedGUIs) |
---|
[5427] | 28 | for i = 1, #loadedGUIs, 1 do |
---|
[5446] | 29 | print("Checking GUI " .. loadedGUIs[i].filename) |
---|
[5427] | 30 | if str == loadedGUIs[i].filename then |
---|
| 31 | return loadedGUIs[i] |
---|
| 32 | end |
---|
| 33 | end |
---|
| 34 | return nil |
---|
[5430] | 35 | end |
---|
[5427] | 36 | |
---|
| 37 | -- loads the GUI with the specified filename |
---|
[5430] | 38 | -- be sure to set the global variable "filename" before calling this function |
---|
[5432] | 39 | function loadGUI(filename) |
---|
[5427] | 40 | -- check if it already exists |
---|
[5446] | 41 | print("about to load " .. filename) |
---|
| 42 | print("search for GUI " .. filename) |
---|
[5427] | 43 | newlyLoaded = loadedGUIs:getGUIbyName(filename) |
---|
| 44 | if newlyLoaded == nil then |
---|
[5432] | 45 | dofile(datapath .. "gui/scripts/" .. filename .. ".lua") |
---|
[5427] | 46 | newlyLoaded = winMgr:loadWindowLayout(layoutPath) |
---|
| 47 | newlyLoaded.filename = filename |
---|
| 48 | loadedGUIs:addGUI(newlyLoaded) |
---|
| 49 | -- if there has no GUI been loaded yet, set new GUI as current |
---|
| 50 | if #loadedGUIs == 1 then |
---|
| 51 | current = loadedGUIs[1] |
---|
| 52 | showing = false |
---|
| 53 | end |
---|
| 54 | -- hide new GUI as we do not want to show it accidentially |
---|
| 55 | newlyLoaded:hide() |
---|
| 56 | end |
---|
[5430] | 57 | return newlyLoaded |
---|
[5414] | 58 | end |
---|
| 59 | |
---|
[5427] | 60 | -- shows the specified and loads it if not loaded already |
---|
| 61 | -- be sure to set the global variable "filename" before calling this function |
---|
[5432] | 62 | function showGUI(filename) |
---|
[5446] | 63 | print("about to show " .. filename) |
---|
[5427] | 64 | if current == nil or current.filename ~= filename then |
---|
[5446] | 65 | print("current not set") |
---|
| 66 | print("search for GUI " .. filename) |
---|
[5427] | 67 | current = loadedGUIs.getGUIbyName(filename) |
---|
| 68 | if current == nil then |
---|
| 69 | current = loadGUI(filename) |
---|
| 70 | end |
---|
| 71 | system:setGUISheet(current) |
---|
| 72 | end |
---|
[5446] | 73 | print("Showing " .. filename) |
---|
[5427] | 74 | current:show() |
---|
| 75 | showing = true |
---|
| 76 | end |
---|
[5414] | 77 | |
---|
| 78 | function toggleGUI() |
---|
| 79 | if showing == true then |
---|
[5427] | 80 | current:hide() |
---|
| 81 | cursor:hide() |
---|
[5414] | 82 | showing = false |
---|
| 83 | else |
---|
[5427] | 84 | current:show() |
---|
| 85 | cursor:show() |
---|
[5414] | 86 | showing = true |
---|
| 87 | end |
---|
[5427] | 88 | return showing |
---|
[5430] | 89 | end |
---|
| 90 | |
---|
[5446] | 91 | function hideCursor() |
---|
| 92 | cursor:hide() |
---|
[5430] | 93 | end |
---|
[5446] | 94 | |
---|
| 95 | function showCursor() |
---|
| 96 | cursor:show() |
---|
| 97 | end |
---|
| 98 | |
---|
| 99 | function hideGUI(filename) |
---|
| 100 | print("about to hide " .. filename) |
---|
| 101 | print("search for GUI " .. filename) |
---|
| 102 | current = loadedGUIs.getGUIbyName(filename) |
---|
| 103 | print("current is: " .. current) |
---|
| 104 | if current ~= nil then |
---|
| 105 | print("Hiding " .. filename) |
---|
| 106 | current:hide() |
---|
| 107 | showing = false |
---|
| 108 | end |
---|
| 109 | end |
---|