| 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 | local showing | 
|---|
| 17 |  | 
|---|
| 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 | 
|---|
| 33 | end | 
|---|
| 34 |  | 
|---|
| 35 | -- loads the GUI with the specified filename | 
|---|
| 36 | -- be sure to set the global variable "filename" before calling this function | 
|---|
| 37 | function loadGUI(filename) | 
|---|
| 38 |     -- check if it already exists | 
|---|
| 39 |     newlyLoaded = loadedGUIs:getGUIbyName(filename) | 
|---|
| 40 |     if newlyLoaded == nil then | 
|---|
| 41 |         dofile(datapath .. "gui/scripts/" .. filename .. ".lua") | 
|---|
| 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 | 
|---|
| 53 |     return newlyLoaded | 
|---|
| 54 | end | 
|---|
| 55 |  | 
|---|
| 56 | -- shows the specified and loads it if not loaded already | 
|---|
| 57 | -- be sure to set the global variable "filename" before calling this function | 
|---|
| 58 | function showGUI(filename) | 
|---|
| 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 | 
|---|
| 70 |  | 
|---|
| 71 | function toggleGUI() | 
|---|
| 72 |     if showing == true then | 
|---|
| 73 |         current:hide() | 
|---|
| 74 |         cursor:hide() | 
|---|
| 75 |         showing = false | 
|---|
| 76 |     else | 
|---|
| 77 |         current:show() | 
|---|
| 78 |         cursor:show() | 
|---|
| 79 |         showing = true | 
|---|
| 80 |     end | 
|---|
| 81 |     return showing | 
|---|
| 82 | end | 
|---|
| 83 |  | 
|---|
| 84 | function hideGUI() | 
|---|
| 85 |     current:hide() | 
|---|
| 86 |     showing = false | 
|---|
| 87 | end | 
|---|