Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/media/gui/scripts/loadGUI_3.lua @ 5506

Last change on this file since 5506 was 5491, checked in by bknecht, 16 years ago

new version of the GUI

File size: 2.3 KB
Line 
1local schemeMgr = CEGUI.SchemeManager:getSingleton()
2winMgr = CEGUI.WindowManager:getSingleton()
3local logger = CEGUI.Logger:getSingleton()
4local system = CEGUI.System:getSingleton()
5local cursor = CEGUI.MouseCursor:getSingleton()
6
7schemeMgr:loadScheme("TaharezLookSkin.scheme")
8-- load scheme with our own images
9schemeMgr:loadScheme("OrxonoxGUIScheme.scheme")
10
11system:setDefaultMouseCursor("TaharezLook", "MouseArrow")
12system:setDefaultFont("BlueHighway-12")
13
14loadedGUIs = {}
15
16-- datapath is set before executing the script and points to media-folder
17package.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
21function 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
37end
38
39function showGUI(filename, ptr)
40    gui = showGUI(filename)
41    gui.overlay = ptr
42end
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
46function 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
57end
58
59function 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
70end
71
72function hideCursor()
73    cursor:hide()
74end
75
76function showCursor()
77    cursor:show()
78end
79
80function hideGUI(filename)
81    current = loadedGUIs[filename]
82    if current ~= nil then
83        current:hide()
84        showing = false
85    end
86end
Note: See TracBrowser for help on using the repository browser.