Changeset 9157
- Timestamp:
- May 4, 2012, 4:05:53 PM (13 years ago)
- Location:
- code/branches/shipSelection
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua
r9127 r9157 6 6 P.shipList = {} 7 7 function P.onLoad() 8 --orxonox.execute("orxout internal_warning Ships= " .. selectedlevel:hasShip("abcdef"))8 --orxonox.execute("orxout user_warning Ships= " .. selectedlevel:hasShip("abcdef")) 9 9 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. 10 10 os.execute(dircmd .. " > ../levels/templates/.shipmodels") --saves output in a textfile … … 16 16 17 17 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") 18 24 19 --for line in io.lines("../levels/templates/.shipmodels") do orxonox.execute("orxout user_warning " .. line) end20 for line in io.lines("../levels/templates/.shipmodels") do21 P.shipList[#P.shipList+1] = string.lower(line)22 end23 --[[for f in io.lines("../levels/templates/.shipmodels") do24 if selectedlevel:hasShip(f) then25 P.shipList[#P.shipList+1] = f26 table.insert(P.shipList, f)27 end28 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()--]]37 25 end 38 26 … … 45 33 46 34 function P.createFilterTab(name) 47 48 --[[-- create unique tab window name49 orxonox.execute("orxout user_warning test")50 local tabName = "orxonox/SchipSelectionLevelTab"51 -- create new tab window with desired name52 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 items57 listbox:resetList()58 orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)59 local preselect = "spaceshipAssff"60 local tabIndexes = {}61 for k,v in pairs(P.shipList) do62 --for i = 1 ,#P.shipList,1 do63 -- only add level if it has desired tag64 --if v:hasShip(Ship) then65 local item = CEGUI.createListboxTextItem("asbsergse")66 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")67 listbox:addItem(item)68 table.insert(tabIndexes, k)69 if v:getXMLFilename() == preselect then70 listbox:setItemSelectState(item, true)71 end72 --orxonox.GUIManager:setTooltipTextHelper(item, v:getDescription())73 -- end74 end75 table.insert(P.activeTabIndexes, tabIndexes)76 -- listen to selection changes77 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 then81 tabControl:addChildWindow(tabName)82 end--]]83 -- create unique tab window name84 35 85 36 local tabName = "orxonox/ShipSelectionLevelTab" … … 117 68 end 118 69 119 function P.ShipSelectionGetSelected Level()70 function P.ShipSelectionGetSelectedModel() 120 71 -- choose the active listbox 121 72 local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/ShipSelectionTabControl")) … … 126 77 local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1] 127 78 local index = tabIndexes[listbox:getItemIndex(choice)+1] 128 --return P.levelList[index]79 return P.shipList[index] 129 80 else 130 81 return nil … … 136 87 local levelDescription = winMgr:getWindow("orxonox/ShipSelectionLevelDescription") 137 88 local configButton = winMgr:getWindow("orxonox/ShipSelectionConfigButton") 138 local level = P.ShipSelectionGetSelected Level()89 local level = P.ShipSelectionGetSelectedModel() 139 90 if level ~= nil then 140 local levelXMLFilename =level:getXMLFilename()141 local imageName =level:getScreenshot()91 --local levelXMLFilename = selectedlevel:getXMLFilename() 92 --local imageName = selectedlevel:getScreenshot() 142 93 -- 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()) 145 96 -- only enable config button for "gametype" levels 146 if level:hasTag("gametype") then147 configButton:setProperty("Disabled", "False")148 else149 configButton:setProperty("Disabled", "True")150 end97 --if level:hasTag("gametype") then 98 -- configButton:setProperty("Disabled", "False") 99 --else 100 -- configButton:setProperty("Disabled", "True") 101 --end 151 102 else 152 103 -- also take care of "no level selected" … … 160 111 161 112 if selectedlevel ~= nil then 162 selectedlevel:selectShip(P.ShipSelectionGetSelected Level())113 selectedlevel:selectShip(P.ShipSelectionGetSelectedModel()) 163 114 orxonox.execute("startGame " .. "_temp.oxw") 164 115 hideAllMenuSheets() … … 170 121 function P.ShipSelectionConfigButton_clicked(e) 171 122 --[[ 172 local level = P.ShipSelectionGetSelected Level()123 local level = P.ShipSelectionGetSelectedModel() 173 124 if level ~= nil then 174 125 local configMenu = showMenuSheet("ShipSelectionConfigMenu") -
code/branches/shipSelection/data/levels/tutorial.oxw
r9128 r9157 4 4 tags = "tutorial, shipselection" 5 5 screenshot = "codingtutorial.png" 6 startingships = "spaceship Assff, spaceshipGhost, spaceshipSpacecruiser"6 startingships = "spaceshipassff, spaceshipghost, spaceshipspacecruiser" 7 7 /> 8 8 -
code/branches/shipSelection/src/orxonox/LevelInfo.cc
r9057 r9157 163 163 bool LevelInfoItem::addShip(const std::string& ship, bool update) 164 164 { 165 bool success = this-> tags_.insert(ship).second;165 bool success = this->ships_.insert(ship).second; 166 166 if(update && success) 167 this->tagsUpdated(); 167 this->shipsUpdated(); 168 168 169 return success; 169 170 }
Note: See TracChangeset
for help on using the changeset viewer.