Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

media update for a working main menu. I hope this does not destroy something, I think it shouldn't.

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")
13system:setDefaultTooltip("TaharezLook/Tooltip")
14
15loadedGUIs = {}
16
17-- datapath is set before executing the script and points to media-folder
18package.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
22function 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 #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
38end
39
40function showGUI(filename, ptr)
41    gui = showGUI(filename)
42    gui.overlay = ptr
43end
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
47function 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
58end
59
60function 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
71end
72
73function hideCursor()
74    cursor:hide()
75end
76
77function showCursor()
78    cursor:show()
79end
80
81function hideGUI(filename)
82    current = loadedGUIs[filename]
83    if current ~= nil then
84        current:hide()
85        showing = false
86    end
87end
Note: See TracBrowser for help on using the repository browser.