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