Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2009, 2:14:53 PM (15 years ago)
Author:
scheusso
Message:

merged ingamemenu branch to menu branch

Location:
code/branches/menu
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/menu

  • code/branches/menu/data/gui/scripts/InitialiseGUI.lua

    r5781 r6024  
    1414
    1515loadedGUIs = {}
     16cursorVisibility = {}
     17activeSheets = {}
     18nrOfActiveSheets = 0
     19root = nil
     20bShowsCursor = false
    1621
    1722-- loads the GUI with the specified filename
     
    3540end
    3641
    37 function showGUI(filename, ptr)
    38     gui = showGUI(filename)
     42function showGUI(filename, bCursorVisible, ptr)
     43    gui = showGUI(filename, bCursorVisible)
    3944    gui.overlay = ptr
    4045end
     
    4247-- shows the specified and loads it if not loaded already
    4348-- be sure to set the global variable "filename" before calling this function
    44 function 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)
     49function showGUI(filename, bCursorVisible)
     50--     bCursorVisibile=false
     51    if bCursorVisible == nil then
     52        cursorVisibility= true
    5153    end
    52     current:show()
     54
     55    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)
     60    end
     61
     62    local currentGUI = loadedGUIs[filename]
     63    if(currentGUI == nil) then
     64        currentGUI = loadGUI(filename)
     65    end
     66
     67    if(root:isChild(currentGUI.window)) then
     68        root:removeChildWindow(currentGUI.window)
     69    end
     70    root:addChildWindow(currentGUI.window)
     71
     72    if bCursorVisible then
     73        showCursor()
     74    else
     75        hideCursor()
     76    end
     77    cursorVisibility[filename]=bCursorVisible
     78   
     79    nrOfActiveSheets = nrOfActiveSheets + 1
     80    table.insert(activeSheets, filename)
     81    activeSheets[nrOfActiveSheets] = filename
     82   
     83    currentGUI:show()
    5384    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
     85    return currentGUI
    6886end
    6987
    7088function hideCursor()
    71     cursor:hide()
     89    if bShowsCursor==true then
     90        bShowsCursor=false
     91        cursor:hide()
     92    end
    7293end
    7394
    7495function showCursor()
    75     cursor:show()
     96    if bShowsCursor==false then
     97        bShowsCursor=true
     98        cursor:show()
     99    end
    76100end
    77101
    78102function hideGUI(filename)
    79     current = loadedGUIs[filename]
    80     if current ~= nil then
    81         current:hide()
    82         showing = false
     103    local currentGUI = loadedGUIs[filename]
     104    if currentGUI == nil then
     105        return
    83106    end
     107    currentGUI:hide()
     108    root:removeChildWindow(currentGUI.window)
     109    showing = false
     110    i=1
     111    while activeSheets[i] do
     112        if activeSheets[i+1] == nil then
     113            if activeSheets[i-1] ~= nil then
     114                if cursorVisibility[ activeSheets[i-1] ] == true then
     115                    showCursor()
     116                else
     117                    hideCursor()
     118                end
     119            else
     120                hideCursor()
     121            end
     122        end
     123        if activeSheets[i] == filename then
     124            table.remove( activeSheets, i )
     125            nrOfActiveSheets = nrOfActiveSheets-1
     126        else
     127            i = i+1
     128        end
     129    end
     130    cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
    84131end
  • code/branches/menu/data/gui/scripts/MainMenu.lua

    r5781 r6024  
    5050        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    5151        orxonox.CommandExecutor:execute("startGame")
    52         toggleGUI()
     52        hideGUI(P.filename)
    5353    end
    5454end
     
    5959        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    6060        orxonox.CommandExecutor:execute("startServer")
    61         toggleGUI()
     61        hideGUI(P.filename)
    6262    end
    6363end
     
    6868        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    6969        orxonox.CommandExecutor:execute("startDedicated")
    70         toggleGUI()
     70        hideGUI(P.filename)
    7171    end
    7272end
     
    7777        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    7878        orxonox.CommandExecutor:execute("startClient")
    79         toggleGUI()
     79        hideGUI(P.filename)
     80
    8081    end
    8182end
Note: See TracChangeset for help on using the changeset viewer.