Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua @ 6003

Last change on this file since 6003 was 6003, checked in by dafrick, 15 years ago

Implemented support for multiple simultaniously showing GUIs. What happens now, in essence, is, that every root-window of a gui, that is to be showed, is attached to a global root window, which is always displayed and therefore needs to be fully transparent (alpha = 0.0). To not inherit the transparency (and thus be fully transparent as well) each root-window of a gui must (or should) set the property 'InheritsAlpha' to false.

  • Property svn:eol-style set to native
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 = {}
16root = nil;
17
18-- loads the GUI with the specified filename
19-- be sure to set the global variable "filename" before calling this function
20function loadGUI(filename)
21    -- check if it already exists
22    loadedGui = loadedGUIs[filename]
23    if loadedGui == nil then
24        loadedGuiNS = require(filename)
25        loadedGui = loadedGuiNS:load()
26        loadedGUIs[filename] = loadedGui
27        -- if there has no GUI been loaded yet, set new GUI as current
28        if table.getn(loadedGUIs) == 1 then
29            current = loadedGUIs[1]
30            showing = false
31        end
32        -- hide new GUI as we do not want to show it accidentially
33        loadedGui:hide()
34    end
35    return loadedGui
36end
37
38function showGUI(filename, ptr)
39    gui = showGUI(filename)
40    gui.overlay = ptr
41end
42
43-- shows the specified and loads it if not loaded already
44-- be sure to set the global variable "filename" before calling this function
45function showGUI(filename)
46    if root == nil then
47        root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow")
48        root:setProperty("Alpha", "0.0")
49        root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
50        system:setGUISheet(root)
51    end
52
53    local currentGUI = loadedGUIs[filename]
54    if(currentGUI == nil) then
55        currentGUI = loadGUI(filename)
56    end
57
58    if(root:isChild(currentGUI.window)) then
59        root:removeChildWindow(currentGUI.window)
60    end
61    root:addChildWindow(currentGUI.window)
62
63    currentGUI:show()
64    showing = true
65    return currentGUI
66end
67
68function hideCursor()
69    cursor:hide()
70end
71
72function showCursor()
73    cursor:show()
74end
75
76function hideGUI(filename)
77    local currentGUI = loadedGUIs[filename]
78    if currentGUI ~= nil then
79        currentGUI:hide()
80        root:removeChildWindow(currentGUI.window)
81        showing = false
82    end
83end
Note: See TracBrowser for help on using the repository browser.