Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2009, 5:30:38 PM (15 years ago)
Author:
scheusso
Message:

partially working hiding

File:
1 edited

Legend:

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

    r6024 r6032  
    1919root = nil
    2020bShowsCursor = false
     21bHidePrevious = {}
    2122
    2223-- loads the GUI with the specified filename
     
    3233        if table.getn(loadedGUIs) == 1 then
    3334            current = loadedGUIs[1]
    34             showing = false
    3535        end
    3636        -- hide new GUI as we do not want to show it accidentially
     
    4040end
    4141
    42 function showGUI(filename, bCursorVisible, ptr)
    43     gui = showGUI(filename, bCursorVisible)
     42function showGUI(filename, hidePrevious, bCursorVisible, ptr)
     43    gui = showGUI(filename, hidePrevious, bCursorVisible)
    4444    gui.overlay = ptr
    4545end
     
    4747-- shows the specified and loads it if not loaded already
    4848-- be sure to set the global variable "filename" before calling this function
    49 function showGUI(filename, bCursorVisible)
    50 --     bCursorVisibile=false
     49function showGUI(filename, hidePrevious, bCursorVisible)
    5150    if bCursorVisible == nil then
    52         cursorVisibility= true
     51        bCursorVisible = true
    5352    end
    5453
    5554    if root == nil then
    56         root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow")
    57         root:setProperty("Alpha", "0.0")
    58         root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
    59         system:setGUISheet(root)
     55        setBackground("")
    6056    end
    6157
     
    6561    end
    6662
     63    debug("test")
     64    debug(currentGUI.window:getName())
     65    debug(root:isChild(currentGUI.window))
    6766    if(root:isChild(currentGUI.window)) then
     67        debug("removing window")
    6868        root:removeChildWindow(currentGUI.window)
    6969    end
     
    7575        hideCursor()
    7676    end
    77     cursorVisibility[filename]=bCursorVisible
    7877   
     78    if find( activeSheets, filename ) ~= nil then
     79        table.remove( activeSheets, find( activeSheets, filename ) )
     80        nrOfActiveSheets = nrOfActiveSheets - 1
     81    end
    7982    nrOfActiveSheets = nrOfActiveSheets + 1
    8083    table.insert(activeSheets, filename)
    8184    activeSheets[nrOfActiveSheets] = filename
     85    bHidePrevious[filename]=hidePrevious
     86    cursorVisibility[filename] = bCursorVisible
    8287   
     88    if hidePrevious == true then
     89        for i=1,nrOfActiveSheets-1 do
     90            loadedGUIs[ activeSheets[i] ]:hide()
     91        end
     92    end
    8393    currentGUI:show()
    84     showing = true
    8594    return currentGUI
    8695end
     
    106115    end
    107116    currentGUI:hide()
     117    if bHidePrevious[filename] == true then
     118        local i = nrOfActiveSheets-1
     119        while i>0 do
     120            loadedGUIs[ activeSheets[i] ]:show()
     121            if bHidePrevious[filename]==true then
     122                break
     123            else
     124                i=i-1
     125            end
     126        end
     127    end
    108128    root:removeChildWindow(currentGUI.window)
    109     showing = false
    110     i=1
     129    local i=1
    111130    while activeSheets[i] do
    112131        if activeSheets[i+1] == nil then
     
    129148    end
    130149    cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
     150    bHidePrevious[filename] = nil
    131151end
     152
     153function setBackground(filename)
     154    local newroot
     155    if root ~= nil then
     156        root:rename("oldRootWindow")
     157    end
     158    if filename ~= "" then
     159        newroot = winMgr:loadWindowLayout(filename .. ".layout")
     160        newroot:rename("AbsoluteRootWindow")
     161        system:setGUISheet(newroot)
     162    else
     163        newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow")
     164        newroot:setProperty("Alpha", "0.0")
     165        newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
     166        system:setGUISheet(newroot)
     167    end
     168    if root ~= nil then
     169        local child
     170        for i=0,root:getChildCount()-1 do
     171            child = root:getChildAtIdx(i)
     172            root:removeChildWindow(child)
     173            newroot:addChildWindow(child)
     174        end
     175        winMgr:destroyWindow(root)
     176    end
     177    newroot:show()
     178    root = newroot
     179end
     180
     181function find(table, value)
     182    local i=0
     183    while table[i] ~= nil do
     184        if table[i]==value then
     185            return i
     186        else
     187            i=i+1
     188        end
     189    end
     190    return nil
     191end
Note: See TracChangeset for help on using the changeset viewer.