Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 28, 2009, 5:58:11 PM (15 years ago)
Author:
dafrick
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua

    r5781 r6003  
    1414
    1515loadedGUIs = {}
     16root = nil;
    1617
    1718-- loads the GUI with the specified filename
     
    4344-- be sure to set the global variable "filename" before calling this function
    4445function showGUI(filename)
    45     if current == nil or current.filename ~= filename then
    46         current = loadedGUIs[filename]
    47         if current == nil then
    48             current = loadGUI(filename)
    49         end
    50         system:setGUISheet(current.window)
     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)
    5151    end
    52     current:show()
     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()
    5364    showing = true
    54     return current
    55 end
    56 
    57 function toggleGUI()
    58     if showing == true then
    59         current:hide()
    60         cursor:hide()
    61         showing = false
    62     else
    63         current:show()
    64         cursor:show()
    65         showing = true
    66     end
    67     return showing
     65    return currentGUI
    6866end
    6967
     
    7775
    7876function hideGUI(filename)
    79     current = loadedGUIs[filename]
    80     if current ~= nil then
    81         current:hide()
     77    local currentGUI = loadedGUIs[filename]
     78    if currentGUI ~= nil then
     79        currentGUI:hide()
     80        root:removeChildWindow(currentGUI.window)
    8281        showing = false
    8382    end
Note: See TracChangeset for help on using the changeset viewer.