Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9157


Ignore:
Timestamp:
May 4, 2012, 4:05:53 PM (12 years ago)
Author:
huttemat
Message:

ShipSelecting working, still hackish and featureless though

Location:
code/branches/shipSelection
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua

    r9127 r9157  
    66P.shipList = {}
    77function P.onLoad()
    8    --orxonox.execute("orxout internal_warning Ships= " .. selectedlevel:hasShip("abcdef"))
     8   --orxonox.execute("orxout user_warning Ships= " .. selectedlevel:hasShip("abcdef"))
    99   local dircmd = "ls ../levels/templates/ -l | awk '{print $9}' | grep \"spaceship\" | sed -e 's/\\.[a-zA-Z]*$//'" -- go to spaceships folder and generate a list of installed shipmodels.
    1010   os.execute(dircmd .. " > ../levels/templates/.shipmodels") --saves output in a textfile
     
    1616
    1717   P.shipList = {}
     18   for line in io.lines("../levels/templates/.shipmodels") do 
     19        if selectedlevel:hasShip(string.lower(line)) then
     20                P.shipList[#P.shipList+1] = string.lower(line)
     21        end
     22   end
     23   P.createFilterTab("Show All")
    1824
    19   --for line in io.lines("../levels/templates/.shipmodels") do  orxonox.execute("orxout user_warning " .. line) end
    20   for line in io.lines("../levels/templates/.shipmodels") do 
    21         P.shipList[#P.shipList+1] = string.lower(line)
    22   end
    23    --[[for f in io.lines("../levels/templates/.shipmodels") do
    24         if selectedlevel:hasShip(f) then
    25             P.shipList[#P.shipList+1] = f
    26             table.insert(P.shipList, f)
    27         end
    28     end--]]
    29     P.shipList[1]="spaceshipAssff"
    30     P.shipList[2]="spaceshipGhost"
    31     P.shipList[3]="spaceshipPirate"
    32     P.createFilterTab("Show All")
    33     --[[list = winMgr:createWindow("MenuWidgets/Listbox", "listbox")
    34     item = CEGUI.createListboxTextItem("Text")
    35     CEGUI.toListbox(list):addItem(item)
    36     list:enable()--]]
    3725end
    3826
     
    4533
    4634function P.createFilterTab(name)
    47 
    48  --[[-- create unique tab window name
    49     orxonox.execute("orxout user_warning test")
    50     local tabName = "orxonox/SchipSelectionLevelTab"
    51     -- create new tab window with desired name
    52     local listbox = CEGUI.toListbox(winMgr:createWindow("MenuWidgets/Listbox", tabName))
    53     listbox:setText(name)
    54     listbox:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
    55     listbox:setProperty("UnifiedAreaRect", "{{0.05,0},{0.1,0},{0.5,0},{0.675,0}}")
    56     -- fill listbox with items
    57     listbox:resetList()
    58     orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
    59     local preselect = "spaceshipAssff"
    60     local tabIndexes = {}
    61     for k,v in pairs(P.shipList) do
    62     --for i = 1 ,#P.shipList,1 do
    63         -- only add level if it has desired tag
    64          --if v:hasShip(Ship) then
    65             local item = CEGUI.createListboxTextItem("asbsergse")
    66             item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    67             listbox:addItem(item)
    68             table.insert(tabIndexes, k)
    69             if v:getXMLFilename() == preselect then
    70                 listbox:setItemSelectState(item, true)
    71             end
    72             --orxonox.GUIManager:setTooltipTextHelper(item, v:getDescription())
    73        -- end
    74     end
    75     table.insert(P.activeTabIndexes, tabIndexes)
    76     -- listen to selection changes
    77     orxonox.GUIManager:subscribeEventHelper(listbox, "ItemSelectionChanged", P.name..".SingleplayerSelectionChanged")
    78     local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl")
    79     orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".SingleplayerSelectionChanged")
    80     if listbox:getItemCount() > 0 then
    81         tabControl:addChildWindow(tabName)
    82     end--]]
    83     -- create unique tab window name
    8435
    8536    local tabName = "orxonox/ShipSelectionLevelTab"
     
    11768end
    11869
    119 function P.ShipSelectionGetSelectedLevel()
     70function P.ShipSelectionGetSelectedModel()
    12071    -- choose the active listbox
    12172    local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/ShipSelectionTabControl"))
     
    12677        local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1]
    12778        local index = tabIndexes[listbox:getItemIndex(choice)+1]
    128         --return P.levelList[index]
     79        return P.shipList[index]
    12980    else
    13081        return nil
     
    13687    local levelDescription = winMgr:getWindow("orxonox/ShipSelectionLevelDescription")
    13788    local configButton = winMgr:getWindow("orxonox/ShipSelectionConfigButton")
    138     local level = P.ShipSelectionGetSelectedLevel()
     89    local level = P.ShipSelectionGetSelectedModel()
    13990    if level ~= nil then
    140         local levelXMLFilename = level:getXMLFilename()
    141         local imageName = level:getScreenshot()
     91        --local levelXMLFilename = selectedlevel:getXMLFilename()
     92        --local imageName = selectedlevel:getScreenshot()
    14293        -- set the screenshot and the description for the selected level
    143         levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
    144         levelDescription:setText(level:getDescription())
     94        --levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
     95        --levelDescription:setText(level:getDescription())
    14596        -- only enable config button for "gametype" levels
    146         if level:hasTag("gametype") then
    147             configButton:setProperty("Disabled", "False")
    148         else
    149             configButton:setProperty("Disabled", "True")
    150         end
     97        --if level:hasTag("gametype") then
     98         --   configButton:setProperty("Disabled", "False")
     99        --else
     100        --    configButton:setProperty("Disabled", "True")
     101        --end
    151102    else
    152103        -- also take care of "no level selected"
     
    160111
    161112    if selectedlevel ~= nil then
    162         selectedlevel:selectShip(P.ShipSelectionGetSelectedLevel())
     113        selectedlevel:selectShip(P.ShipSelectionGetSelectedModel())
    163114        orxonox.execute("startGame " .. "_temp.oxw")
    164115        hideAllMenuSheets()
     
    170121function P.ShipSelectionConfigButton_clicked(e)
    171122--[[
    172     local level = P.ShipSelectionGetSelectedLevel()
     123    local level = P.ShipSelectionGetSelectedModel()
    173124    if level ~= nil then
    174125        local configMenu = showMenuSheet("ShipSelectionConfigMenu")
  • code/branches/shipSelection/data/levels/tutorial.oxw

    r9128 r9157  
    44 tags = "tutorial, shipselection"
    55 screenshot = "codingtutorial.png"
    6  startingships = "spaceshipAssff, spaceshipGhost, spaceshipSpacecruiser"
     6 startingships = "spaceshipassff, spaceshipghost, spaceshipspacecruiser"
    77/>
    88
  • code/branches/shipSelection/src/orxonox/LevelInfo.cc

    r9057 r9157  
    163163    bool LevelInfoItem::addShip(const std::string& ship, bool update)
    164164    {
    165         bool success = this->tags_.insert(ship).second;
     165        bool success = this->ships_.insert(ship).second;
    166166        if(update && success)
    167             this->tagsUpdated();
     167            this->shipsUpdated();
     168           
    168169        return success;
    169170    }
Note: See TracChangeset for help on using the changeset viewer.