Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 31, 2016, 3:27:31 PM (8 years ago)
Author:
kappenh
Message:

Layout fertig

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua

    r11245 r11254  
    1515P.resetWidth = 0
    1616P.spaceWidth = 0
     17P.imageHeight = 50
     18P.textHeight = 30
    1719
    1820function P.onLoad()
     
    2628        P.linesList = {}
    2729
    28         --Calculate design parameters:
    29     P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/SampleWindow")
    30     P.sampleWindow:setText("SampleText")
    3130
    3231    -- create tabs with desired tab as argument (nil for all)
    3332   
    34     P.createFilterTab("Gametypes", "gametype")
    35     P.createFilterTab("Missions", "mission")
     33    P.createFilterTab("Game1", "game1")
     34    P.createFilterTab("Game2", "game2")
    3635    --P.createFilterTab("Minigames", "minigame")
    3736    --P.createFilterTab("Showcases", "showcase")
     
    4039    --P.createFilterTab("Show All", nil)
    4140
    42     -- update description and screenshot boxes
    43     --P.SingleplayerSelectionChanged()
    44 
    45     local size = getMinTextSize(P.sampleWindow)
    46     P.lineHeight = size[1]
    47 
    48     P.playerWidth = 0
    49     for k,v in pairs(P.scoreList) do
    50         P.sampleWindow:setText(P.nameList[k])
    51         size = getMinTextSize(P.sampleWindow)
    52         if size[2] > P.playerWidth then
    53             P.playerWidth = size[2]
    54         end
    55     end
    56 
    57     P.sampleWindow:setText("reset")
    58     size = getMinTextSize(P.sampleWindow)
    59     P.resetWidth = size[2]+20
    60 
    61     P.spaceWidth = 10
    6241   
    63     local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
    64     size = pane:getViewableArea()
    65 
    66     P.editboxWidth = size:getWidth() - P.playerWidth - P.resetWidth - 5*P.spaceWidth
    67 
    68     P.createLines()
    69 
    70     P:setButton(1, 1, {
    71             ["button"] = winMgr:getWindow("orxonox/HighscoreBackButton"),
    72             ["callback"]  = P.HighscoreBackButton_clicked
    73     })
    7442end
    7543
     
    8957   
    9058    -- create new tab window with desired name
    91         local default = CEGUI.toListbox(winMgr:createWindow("DefaultWindow", tabName))
     59        local default = (winMgr:createWindow("DefaultWindow", tabName))
    9260    default:setText(name)
     61    default:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
     62    default:setProperty("UnifiedAreaRect", "{{0,0},{0,0},{1,0},{1,0}}")
     63    local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", tabName .. "pane")
     64    pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
     65    default:addChildWindow(pane)
     66
     67   
     68    local offset = 2
     69    for k,v in pairs(P.scoreList) do
     70        local line = P.createPickupEntry(tabName .. k,k,tag)
     71        table.insert(P.linesList, line)
     72        line:setYPosition(CEGUI.UDim(0,offset))
     73        offset = offset + line:getHeight():asAbsolute(1)+2
     74        pane:addChildWindow(line)
     75    end
     76
    9377 
    9478    local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl")
    9579    orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".HighscoreSelectionChanged")
    9680    --if listbox:getItemCount() > 0 then
    97         tabControl:addChildWindow(tabName)
     81        tabControl:addChildWindow(default)
    9882    --end
    9983
    10084   
    10185end
     86function P.createPickupEntry(parent,k,tag)
     87   
     88    local name = "orxonox/HiscoreEntry" .. parent
    10289
     90    local item = winMgr:createWindow("DefaultWindow", name)
     91    item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight)))
     92    item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
     93
     94    local player = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Player")
     95    player:setText(P.nameList[k].. tag)
     96    player:setPosition(CEGUI.UVector2(CEGUI.UDim(0.005,0), CEGUI.UDim(0,0)))
     97    player:setSize(CEGUI.UVector2(CEGUI.UDim(0.49, 0), CEGUI.UDim(0, P.imageHeight)))
     98   
     99    item:addChildWindow(player)
     100       
     101    local score = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Score")
     102    score:setText(P.scoreList[k])
     103    score:setPosition(CEGUI.UVector2(CEGUI.UDim(0.5,0), CEGUI.UDim(0,0)))
     104    score:setSize(CEGUI.UVector2(CEGUI.UDim(0.495, 0), CEGUI.UDim(0, P.imageHeight)))
     105   
     106    item:addChildWindow(score)
     107
     108    return item
     109end
    103110function P.HighscoreGetSelectedLevel()
    104111    -- choose the active listbox
     
    117124
    118125function P.HighscoreSelectionChanged(e)
    119         local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
    120         pane:moveToFront()
     126        --local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
     127        --pane:moveToFront()
    121128    --[[local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription")
    122129    local configButton = winMgr:getWindow("orxonox/SingleplayerConfigButton")
     
    142149end
    143150
    144 function P.createLine(k,tag)
    145 
    146         local tabName = k
    147 
    148         if tag ~= nil then
    149         tabName = tabName..tag
    150     end
    151 
    152     -- content window for the entire line
    153     local line = winMgr:createWindow("DefaultWindow", "orxonox/HighscoreMenuPane/Score" .. tabName)
    154     line:setHeight(CEGUI.UDim(0, P.lineHeight))
    155     line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
    156 
    157     local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")
    158     local half = (pane:getViewableArea()):getWidth() * 0.5
    159     local offset = half * 0.01
    160     -- config name
    161     local player = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. tabName .. "/Player")
    162     player:setText(P.nameList[k])
    163     player:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0)))
    164     player:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
    165     line:addChildWindow(player)
    166    
    167 
    168     -- config value (editable)
    169 
    170     local playerValue = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. tabName .. "/Value")
    171     --playerValue:setProperty("ReadOnly", "set:False")
    172     --local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])SS
    173     playerValue:setText(P.scoreList[k])
    174     playerValue:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0)))
    175     playerValue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, half+offset), CEGUI.UDim(0, 0)))
    176    -- enable the reset button if the value changed
    177     orxonox.GUIManager:subscribeEventHelper(playerValue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted")
    178     line:addChildWindow(playerValue)
    179    
    180    
    181 
    182     line:setWidth(CEGUI.UDim(0, 2*half))
    183 
    184     return line
    185 end
    186 
    187 function P.createLines()
    188     local window = winMgr:getWindow("orxonox/HighscoreMenuPane")
    189 
    190     for k,v in pairs(P.scoreList) do
    191         local line = P.createLine(k,nil)
    192         table.insert(P.linesList, line)
    193         window:addChildWindow(line)
    194     end
    195 
    196     local pane = tolua.cast(window, "CEGUI::ScrollablePane")
    197     pane:setVerticalStepSize(getScrollingStepSize(window))
    198 end
    199 
    200151
    201152function P.HighscoreBackButton_clicked(e)
Note: See TracChangeset for help on using the changeset viewer.