Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 2, 2011, 1:31:12 PM (13 years ago)
Author:
baermatt
Message:

Added screenshots and description-box in singleplayer menu

Location:
code/branches/menue/data/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menue/data/gui/scripts/CreditsMenu.lua

    r8079 r8912  
    1414function P.onShow()
    1515    local description = winMgr:getWindow("orxonox/CreditsText")
    16     description:setProperty("HorzFormatting", "WordWrapLeftAligned")
    17     description:setProperty("VertFormatting", "TopAligned")
    18     description:setText("                                   Orxonox version 0.0.3 \n\n       Programming Language:  C++ - lua - tcl \n       Environment:  OpenAL - Ogre - OIS - CEGUI - enet - ODE \n       Licence:  GNU General Public Licence - Creative Commons \n       http://www.orxonox.net \n \n       Credits:")
    1916
    20     description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
    2117    height = getStaticTextWindowHeight(description)
    22     description:setHeight(CEGUI.UDim(0, height))
     18    description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height)))
    2319end
    2420
  • code/branches/menue/data/gui/scripts/SingleplayerMenu.lua

    r8894 r8912  
    44
    55P.levelList = {}
     6P.activeTabIndexes = {}
     7P.scrollbarWidth = 13
    68
    79function P.onLoad()
     
    911   
    1012    -- create tabs with desired tab as argument (nil for all)
    11     P.createFilterTab("Show All", nil)
    1213    P.createFilterTab("Tests", "test")
    1314    P.createFilterTab("Tutorials", "tutorial")
     
    1516    P.createFilterTab("SP?", "singleplayer")
    1617    P.createFilterTab("Presentations", "presentation")
     18    P.createFilterTab("Show All", nil)
    1719
    18     --buttons are arranged in a 1x2 matrix
     20    --buttons are arranged in a 1x3 matrix
    1921    P:setButton(1, 1, {
    2022            ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
     
    2325
    2426    P:setButton(1, 2, {
     27            ["button"] = winMgr:getWindow("orxonox/SingleplayerConfigButton"),
     28            ["callback"]  = P.SingleplayerConfigButton_clicked
     29    })
     30
     31    P:setButton(1, 3, {
    2532            ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
    2633            ["callback"]  = P.SingleplayerBackButton_clicked
     
    3643        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
    3744        if level ~= nil then
     45            local levelXMLFilename = level:getXMLFilename()
     46            local imageName = level:getScreenshot()
     47            if imageName ~= "" then
     48                CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile(levelXMLFilename..imageName, imageName)
     49            else
     50                CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile(levelXMLFilename..imageName, "noScreenshot.png")
     51            end
    3852            table.insert(P.levelList, level)
    3953        end
     
    4458function P.createFilterTab(name, tag)
    4559    -- create unique tab window name
    46     local tabName = "orxonox/SingleplayerLevelListbox"
     60    local tabName = "orxonox/SingleplayerLevelTab"
    4761    if tag ~= nil then
    4862        tabName = tabName..tag
     
    5064    -- add new tab window with desired name
    5165    local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl")
    52     local newWindow = winMgr:createWindow("MenuWidgets/Listbox", tabName)
    53     newWindow:setText(name)
    54     newWindow:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
    55     newWindow:setProperty("UnifiedAreaRect", "{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}")
     66    local listbox = CEGUI.toListbox(winMgr:createWindow("MenuWidgets/Listbox", tabName))
     67    listbox:setText(name)
     68    listbox:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
     69    listbox:setProperty("UnifiedAreaRect", "{{0.05,0},{0.1,0},{0.5,0},{0.7,0}}")
    5670    tabControl:addChildWindow(tabName)
    5771    -- fill listbox with items
    58     local listbox = CEGUI.toListbox(newWindow)
    5972    listbox:resetList()
    6073    orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
    6174    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     75    local tabIndexes = {}
    6276    for k,v in pairs(P.levelList) do
    6377        -- only add level if it has desired tag
     
    6680            item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    6781            listbox:addItem(item)
     82            table.insert(tabIndexes, k)
    6883            if v:getXMLFilename() == preselect then
    6984                listbox:setItemSelectState(item, true)
     
    7287        end
    7388    end
     89    table.insert(P.activeTabIndexes, tabIndexes)
     90    listbox:subscribeEvent("ItemSelectionChanged", "SingleplayerSelectionChanged")
     91    tabControl:subscribeEvent("TabSelectionChanged", "SingleplayerSelectionChanged")
     92    SingleplayerSelectionChanged()
    7493end
    7594
    76 function P.SingleplayerStartButton_clicked(e)
     95function P.SingleplayerGetSelectedLevel()
    7796    -- choose the active listbox
    7897    local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/SingleplayerTabControl"))
     
    8099    local choice = listbox:getFirstSelectedItem()
    81100    if choice ~= nil then
    82         local index = listbox:getItemIndex(choice)
    83         local level = P.levelList[index+1]
    84         if level ~= nil then
    85             orxonox.execute("startGame " .. level:getXMLFilename())
    86             hideAllMenuSheets()
    87         end
     101        local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1]
     102        local index = tabIndexes[listbox:getItemIndex(choice)+1]
     103        return P.levelList[index]
     104    else
     105        return nil
    88106    end
     107end
     108
     109function SingleplayerSelectionChanged(e)
     110    local level = P.SingleplayerGetSelectedLevel()
     111    if level ~= nil then
     112        local levelXMLFilename = level:getXMLFilename()
     113        local imageName = level:getScreenshot()
     114        local levelImage = winMgr:getWindow("orxonox/SingleplayerLevelImage")
     115        levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
     116        local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription")
     117        local height = getStaticTextWindowHeight(levelDescription)
     118--        local width = getStaticTextWindowWidth(levelDescription)
     119        levelDescription:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height)))
     120        levelDescription:setText(level:getDescription())
     121    end
     122end
     123
     124function P.SingleplayerStartButton_clicked(e)
     125    local level = P.SingleplayerGetSelectedLevel()
     126    if level ~= nil then
     127        orxonox.execute("startGame " .. level:getXMLFilename())
     128        hideAllMenuSheets()
     129    end
     130end
     131
     132function P.SingleplayerConfigButton_clicked(e)
     133    hideMenuSheet(P.name)
    89134end
    90135
Note: See TracChangeset for help on using the changeset viewer.