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