[3374] | 1 | local schemeMgr = CEGUI.SchemeManager:getSingleton() |
---|
| 2 | local 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") |
---|
| 13 | |
---|
| 14 | local current = nil |
---|
| 15 | local loadedGUIs = {} |
---|
| 16 | -- a bit more complex: GUI is now a class |
---|
| 17 | GUI = {} |
---|
| 18 | GUI.__index = GUI |
---|
| 19 | |
---|
| 20 | -- hide function for the GUI |
---|
| 21 | GUI.hide = function (self) |
---|
| 22 | self.window:hide() |
---|
| 23 | end |
---|
| 24 | |
---|
| 25 | -- show function for the GUI |
---|
| 26 | GUI.show = function (self) |
---|
| 27 | self.window:show() |
---|
| 28 | end |
---|
| 29 | |
---|
| 30 | -- constructor of the GUI |
---|
| 31 | GUI.new = function (gui, fname) |
---|
| 32 | local newElement = { window = gui, filename = fname } |
---|
| 33 | setmetatable(newElement, GUI) -- connects new element with class |
---|
| 34 | return newElement |
---|
| 35 | end |
---|
| 36 | |
---|
| 37 | datapath = "" -- points to media-folder (set after loading the script) |
---|
| 38 | |
---|
| 39 | -- loads the GUI with the specified filename |
---|
| 40 | -- be sure to set the global variable "filename" before calling this function |
---|
| 41 | function loadGUI(filename) |
---|
| 42 | -- check if it already exists |
---|
| 43 | --gui = loadedGUIs:getGUIbyName(filename) |
---|
| 44 | gui = loadedGUIs[filename] |
---|
| 45 | if gui == nil then |
---|
| 46 | dofile(datapath .. "gui/scripts/" .. filename .. ".lua") |
---|
| 47 | win = winMgr:loadWindowLayout(layoutPath) |
---|
| 48 | gui = GUI.new(win, filename) |
---|
| 49 | loadedGUIs[filename] = gui |
---|
| 50 | -- if there has no GUI been loaded yet, set new GUI as current |
---|
| 51 | if table.getn(loadedGUIs) == 1 then |
---|
| 52 | current = loadedGUIs[1] |
---|
| 53 | showing = false |
---|
| 54 | end |
---|
| 55 | -- hide new GUI as we do not want to show it accidentially |
---|
| 56 | gui:hide() |
---|
| 57 | end |
---|
| 58 | return gui |
---|
| 59 | end |
---|
| 60 | |
---|
| 61 | -- shows the specified and loads it if not loaded already |
---|
| 62 | -- be sure to set the global variable "filename" before calling this function |
---|
| 63 | function showGUI(filename) |
---|
| 64 | if current == nil or current.filename ~= filename then |
---|
| 65 | if current ~= nil then |
---|
| 66 | end |
---|
| 67 | current = loadedGUIs[filename] |
---|
| 68 | if current == nil then |
---|
| 69 | current = loadGUI(filename) |
---|
| 70 | end |
---|
| 71 | system:setGUISheet(current.window) |
---|
| 72 | end |
---|
| 73 | current:show() |
---|
| 74 | showing = true |
---|
| 75 | end |
---|
| 76 | |
---|
| 77 | function toggleGUI() |
---|
| 78 | if showing == true then |
---|
| 79 | current:hide() |
---|
| 80 | cursor:hide() |
---|
| 81 | showing = false |
---|
| 82 | else |
---|
| 83 | current:show() |
---|
| 84 | cursor:show() |
---|
| 85 | showing = true |
---|
| 86 | end |
---|
| 87 | return showing |
---|
| 88 | end |
---|
| 89 | |
---|
| 90 | function hideCursor() |
---|
| 91 | cursor:hide() |
---|
| 92 | end |
---|
| 93 | |
---|
| 94 | function showCursor() |
---|
| 95 | cursor:show() |
---|
| 96 | end |
---|
| 97 | |
---|
| 98 | function hideGUI(filename) |
---|
| 99 | current = loadedGUIs[filename] |
---|
| 100 | if current ~= nil then |
---|
| 101 | current:hide() |
---|
| 102 | showing = false |
---|
| 103 | end |
---|
| 104 | end |
---|