1 | local schemeMgr = CEGUI.SchemeManager:getSingleton() |
---|
2 | 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 | loadedGUIs = {} |
---|
15 | |
---|
16 | -- datapath is set before executing the script and points to media-folder |
---|
17 | package.path = package.path .. ";" .. datapath .. "gui/scripts/?.lua" |
---|
18 | |
---|
19 | -- loads the GUI with the specified filename |
---|
20 | -- be sure to set the global variable "filename" before calling this function |
---|
21 | function loadGUI(filename) |
---|
22 | -- check if it already exists |
---|
23 | loadedGui = loadedGUIs[filename] |
---|
24 | if loadedGui == nil then |
---|
25 | loadedGuiNS = require(filename) |
---|
26 | loadedGui = loadedGuiNS:load() |
---|
27 | loadedGUIs[filename] = loadedGui |
---|
28 | -- if there has no GUI been loaded yet, set new GUI as current |
---|
29 | if #loadedGUIs == 1 then |
---|
30 | current = loadedGUIs[1] |
---|
31 | showing = false |
---|
32 | end |
---|
33 | -- hide new GUI as we do not want to show it accidentially |
---|
34 | loadedGui:hide() |
---|
35 | end |
---|
36 | return loadedGui |
---|
37 | end |
---|
38 | |
---|
39 | function showGUI(filename, ptr) |
---|
40 | gui = showGUI(filename) |
---|
41 | gui.overlay = ptr |
---|
42 | end |
---|
43 | |
---|
44 | -- shows the specified and loads it if not loaded already |
---|
45 | -- be sure to set the global variable "filename" before calling this function |
---|
46 | function showGUI(filename) |
---|
47 | if current == nil or current.filename ~= filename then |
---|
48 | current = loadedGUIs[filename] |
---|
49 | if current == nil then |
---|
50 | current = loadGUI(filename) |
---|
51 | end |
---|
52 | system:setGUISheet(current.window) |
---|
53 | end |
---|
54 | current:show() |
---|
55 | showing = true |
---|
56 | return current |
---|
57 | end |
---|
58 | |
---|
59 | function toggleGUI() |
---|
60 | if showing == true then |
---|
61 | current:hide() |
---|
62 | cursor:hide() |
---|
63 | showing = false |
---|
64 | else |
---|
65 | current:show() |
---|
66 | cursor:show() |
---|
67 | showing = true |
---|
68 | end |
---|
69 | return showing |
---|
70 | end |
---|
71 | |
---|
72 | function hideCursor() |
---|
73 | cursor:hide() |
---|
74 | end |
---|
75 | |
---|
76 | function showCursor() |
---|
77 | cursor:show() |
---|
78 | end |
---|
79 | |
---|
80 | function hideGUI(filename) |
---|
81 | current = loadedGUIs[filename] |
---|
82 | if current ~= nil then |
---|
83 | current:hide() |
---|
84 | showing = false |
---|
85 | end |
---|
86 | end |
---|