Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2009, 4:52:37 PM (15 years ago)
Author:
scheusso
Message:

merged menu branch to presentation2 branch with some additional fixes and features ;)

Location:
code/branches/presentation2
Files:
6 edited
26 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2

  • code/branches/presentation2/data/defaultConfig/keybindings.ini

    r6149 r6150  
    2323KeyEnd=boost
    2424KeyEquals=
    25 KeyEscape="exit"
     25KeyEscape="keyESC"
    2626KeyF="scale -1 moveUpDown"
    2727KeyF1="OverlayGroup toggleVisibility Debug"
  • code/branches/presentation2/data/gui/layouts/MainMenu.layout

    r5781 r6150  
    11<?xml version="1.0" ?>
    22<GUILayout>
    3     <Window Type="TaharezLook/StaticImage" Name="orxonox/Background">
    4     <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
    5     <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
    6     <Property Name="FrameEnabled" Value="set:true"/>
    7     <Property Name="BackgroundEnabled" Value="set:false"/>
    8  
     3    <Window Type="DefaultWindow" Name="orxonox/MainMenuRootWindow">
     4    <Property Name="InheritsAlpha" Value="false"/>
    95        <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
    106            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/>
  • code/branches/presentation2/data/gui/layouts/QuestGUI.layout

    r5781 r6150  
    66    <Property Name="FrameEnabled" Value="set:true"/>
    77    <Property Name="BackgroundEnabled" Value="set:false"/>
     8    <Property Name="InheritsAlpha" Value="False" />
    89
    910        <Window Type="TaharezLook/Titlebar" Name="orxonox/QuestGUI/Title">
  • code/branches/presentation2/data/gui/scripts/InGameMenu.lua

    r6146 r6150  
    2525    orxonox.Game:getInstance():popState()
    2626    orxonox.Game:getInstance():requestState("mainmenu")
    27     orxonox.CommandExecutor:execute("showGUI MainMenu")
    2827    orxonox.CommandExecutor:execute("hideGUI InGameMenu")
    2928end
  • code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua

    r5781 r6150  
    1414
    1515loadedGUIs = {}
     16cursorVisibility = {}
     17activeSheets = {}
     18nrOfActiveSheets = 0
     19root = nil
     20bShowsCursor = false
     21bHidePrevious = {}
     22
     23-- Require all tools
     24require("GUITools")
    1625
    1726-- loads the GUI with the specified filename
     
    2231    if loadedGui == nil then
    2332        loadedGuiNS = require(filename)
     33        if loadedGuiNS == nil then
     34            return
     35        end
    2436        loadedGui = loadedGuiNS:load()
    2537        loadedGUIs[filename] = loadedGui
     
    2739        if table.getn(loadedGUIs) == 1 then
    2840            current = loadedGUIs[1]
    29             showing = false
    3041        end
    3142        -- hide new GUI as we do not want to show it accidentially
     
    3546end
    3647
    37 function showGUI(filename, ptr)
    38     gui = showGUI(filename)
     48function showGUI(filename, hidePrevious, bCursorVisible, ptr)
     49    gui = showGUI(filename, hidePrevious, bCursorVisible)
    3950    gui.overlay = ptr
    4051end
     
    4253-- shows the specified and loads it if not loaded already
    4354-- 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)
    51     end
    52     current:show()
    53     showing = true
    54     return current
    55 end
    56 
    57 function toggleGUI()
    58     if showing == true then
    59         current:hide()
     55function showGUI(filename, hidePrevious, bCursorVisible)
     56    if bCursorVisible == nil then
     57        bCursorVisible = true
     58    end
     59
     60    if root == nil then
     61        setBackground("")
     62    end
     63
     64    local currentGUI = loadedGUIs[filename]
     65    if(currentGUI == nil) then
     66        currentGUI = loadGUI(filename)
     67    end
     68
     69    if(root:isChild(currentGUI.window)) then
     70        root:removeChildWindow(currentGUI.window)
     71    end
     72    root:addChildWindow(currentGUI.window)
     73
     74    if bCursorVisible then
     75        showCursor()
     76    else
     77        hideCursor()
     78    end
     79   
     80    if find( activeSheets, filename ) ~= nil then
     81        table.remove( activeSheets, find( activeSheets, filename ) )
     82        nrOfActiveSheets = nrOfActiveSheets - 1
     83    else
     84        if nrOfActiveSheets == 0 then
     85            orxonox.InputManager:getInstance():enterState("guiMouseOnly")
     86        end
     87    end
     88    nrOfActiveSheets = nrOfActiveSheets + 1
     89    table.insert(activeSheets, filename)
     90    activeSheets[nrOfActiveSheets] = filename
     91    bHidePrevious[filename]=hidePrevious
     92    cursorVisibility[filename] = bCursorVisible
     93   
     94    if hidePrevious == true then
     95        for i=1,nrOfActiveSheets-1 do
     96            loadedGUIs[ activeSheets[i] ]:hide()
     97        end
     98    end
     99    currentGUI:show()
     100    return currentGUI
     101end
     102
     103function hideCursor()
     104    if bShowsCursor==true then
     105        bShowsCursor=false
    60106        cursor:hide()
    61         showing = false
    62     else
    63         current:show()
     107    end
     108end
     109
     110function showCursor()
     111    if bShowsCursor==false then
     112        bShowsCursor=true
    64113        cursor:show()
    65         showing = true
    66     end
    67     return showing
    68 end
    69 
    70 function hideCursor()
    71     cursor:hide()
    72 end
    73 
    74 function showCursor()
    75     cursor:show()
     114    end
    76115end
    77116
    78117function hideGUI(filename)
    79     current = loadedGUIs[filename]
    80     if current ~= nil then
    81         current:hide()
    82         showing = false
    83     end
    84 end
     118    local currentGUI = loadedGUIs[filename]
     119    if currentGUI == nil then
     120        return
     121    end
     122    currentGUI:hide()
     123    if bHidePrevious[filename] == true then
     124        local i = nrOfActiveSheets-1
     125        while i>0 do
     126            loadedGUIs[ activeSheets[i] ]:show()
     127            if bHidePrevious[filename]==true then
     128                break
     129            else
     130                i=i-1
     131            end
     132        end
     133    end
     134    root:removeChildWindow(currentGUI.window)
     135    local i=1
     136    while activeSheets[i] do
     137        if activeSheets[i+1] == nil then
     138            if activeSheets[i-1] ~= nil then
     139                if cursorVisibility[ activeSheets[i-1] ] == true then
     140                    showCursor()
     141                else
     142                    hideCursor()
     143                end
     144            else
     145                hideCursor()
     146            end
     147        end
     148        if activeSheets[i] == filename then
     149            table.remove( activeSheets, i )
     150            nrOfActiveSheets = nrOfActiveSheets-1
     151        else
     152            i = i+1
     153        end
     154    end
     155    cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
     156    bHidePrevious[filename] = nil
     157    if nrOfActiveSheets == 0 then
     158        orxonox.InputManager:getInstance():leaveState("guiMouseOnly")
     159        hideCursor()
     160    end
     161end
     162
     163function keyESC()
     164    if nrOfActiveSheets > 0 then
     165        orxonox.CommandExecutor:execute("hideGUI "..activeSheets[nrOfActiveSheets])
     166    else
     167        showGUI("InGameMenu")
     168    end
     169end
     170
     171function setBackground(filename)
     172    local newroot
     173    if root ~= nil then
     174        root:rename("oldRootWindow")
     175    end
     176    if filename ~= "" then
     177        newroot = winMgr:loadWindowLayout(filename .. ".layout")
     178        newroot:rename("AbsoluteRootWindow")
     179        system:setGUISheet(newroot)
     180    else
     181        newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow")
     182        newroot:setProperty("Alpha", "0.0")
     183        newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
     184        system:setGUISheet(newroot)
     185    end
     186    if root ~= nil then
     187        local child
     188        while root:getChildCount()~=0 do
     189            debug(root:getChildCount())
     190            child = root:getChildAtIdx(0)
     191            root:removeChildWindow(child)
     192            newroot:addChildWindow(child)
     193        end
     194        winMgr:destroyWindow(root)
     195    end
     196    newroot:show()
     197    root = newroot
     198end
     199
     200function find(table, value)
     201    local i=0
     202    while table[i] ~= nil do
     203        if table[i]==value then
     204            return i
     205        else
     206            i=i+1
     207        end
     208    end
     209    return nil
     210end
  • code/branches/presentation2/data/gui/scripts/MainMenu.lua

    r5781 r6150  
    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.