[Orxonox-commit 4529] r9201 - in code/branches/shipSelection: data/gui/layouts data/gui/scripts data/levels src/orxonox

huttemat at orxonox.net huttemat at orxonox.net
Fri May 18 15:09:07 CEST 2012


Author: huttemat
Date: 2012-05-18 15:09:07 +0200 (Fri, 18 May 2012)
New Revision: 9201

Modified:
   code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout
   code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua
   code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua
   code/branches/shipSelection/data/levels/tutorial.oxw
   code/branches/shipSelection/src/orxonox/ShipManager.cc
Log:
many bugfixes, code cleanup, documentation

Modified: code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout
===================================================================
--- code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout	2012-05-18 13:06:46 UTC (rev 9200)
+++ code/branches/shipSelection/data/gui/layouts/ShipSelectionMenu.layout	2012-05-18 13:09:07 UTC (rev 9201)
@@ -16,14 +16,17 @@
             <Property Name="HorzFormatting" Value="HorzCentred" />
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="VertFormatting" Value="TopAligned" />
-            <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.15,0},{0.8,0},{0.7,0}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.15,0},{0.8,0},{0.7,0}}" /> 
             <Window Type="MenuWidgets/TabControl" Name="orxonox/ShipSelectionTabControl" >
                 <Property Name="TabHeight" Value="{0,26.4388}" />
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                 <Property Name="TabPanePosition" Value="Top" />
-                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.925,0}}" />
+		<Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.925,0}}" />
+		
             </Window>	
-            <Window Type="MenuWidgets/StaticImage" Name="orxonox/ShipSelectionLevelImage" >
+            
+	    <!-- TODO: Ship Description and Image
+	    <Window Type="MenuWidgets/StaticImage" Name="orxonox/ShipSelectionShipImage" >
                 <Property Name="AlwaysOnTop" Value="True" />
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                 <Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.25,0},{0.9,0},{0.675,0}}" />
@@ -34,7 +37,7 @@
                 <Property Name="VertScrollbar" Value="True" />
                 <Property Name="HorzScrollbar" Value="True" />
                 <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.725,0},{0.9,0},{0.875,0}}" />
-            </Window>
+            </Window>--> 
 		 
         </Window>
         <Window Type="MenuWidgets/Button" Name="orxonox/ShipSelectionStartButton" >
@@ -43,13 +46,14 @@
             <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.725,0},{0.4,0},{0.775,0}}" />
             <Event Name="Clicked" Function="ShipSelectionMenu.ShipSelectionStartButton_clicked"/>
         </Window>
-        <Window Type="MenuWidgets/Button" Name="orxonox/ShipSelectionConfigButton" >
+        <!-- TODO: set ship properties
+	<Window Type="MenuWidgets/Button" Name="orxonox/ShipSelectionConfigButton" >
             <Property Name="Text" Value="Configure" />
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="UnifiedAreaRect" Value="{{0.425,0},{0.725,0},{0.575,0},{0.775,0}}" />
             <Property Name="Disabled" Value="True" />
             <Event Name="Clicked" Function="ShipSelectionMenu.ShipSelectionConfigButton_clicked"/>
-        </Window>
+        </Window> --> 
         <Window Type="MenuWidgets/Button" Name="orxonox/ShipSelectionBackButton" >
             <Property Name="Text" Value="Back" />
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />

Modified: code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua
===================================================================
--- code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua	2012-05-18 13:06:46 UTC (rev 9200)
+++ code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua	2012-05-18 13:09:07 UTC (rev 9201)
@@ -5,59 +5,54 @@
 P.scrollbarWidth = 13
 P.shipList = {}
 function P.onLoad()
-   --orxonox.execute("orxout user_warning Ships= " .. selectedlevel:hasShip("abcdef"))
    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.
    os.execute(dircmd .. " > ../levels/templates/.shipmodels") --saves output in a textfile
-   --[[ Program a Windows Version here:
+   --[[TODO: program a Windows Version / platform independent version here:
    if string.sub(package.config,1,1) == '\\' then
            -- Windows
            dircmd = "dir /b/s"
    end]]	
+   P.createFilterTab("All Ships")   
+end
 
+function P.createShipList() --generates list with tagged shipmodels
    P.shipList = {}
-   for line in io.lines("../levels/templates/.shipmodels") do  
+   for line in io.lines("../levels/templates/.shipmodels") do  --checks if shipmodel is included in level file
 	if selectedlevel:hasShip(string.lower(line)) then
 		P.shipList[#P.shipList+1] = string.lower(line)
 	end
-   end 
-   P.createFilterTab("Show All")
-
+   end  
 end
 
-function P.createShipList()
-       
-
-end
-
-
-
-function P.createFilterTab(name)
-
-    local tabName = "orxonox/ShipSelectionLevelTab"
-    -- create new tab window with desired name
-    local listbox = CEGUI.toListbox(winMgr:createWindow("MenuWidgets/Listbox", tabName))
-    listbox:setText(name)
-    listbox:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
-    listbox:setProperty("UnifiedAreaRect", "{{0.05,0},{0.1,0},{0.5,0},{0.675,0}}")
-    -- fill listbox with items
+function P.update() --updates listbox with found models
+    P.createShipList()
     listbox:resetList()
-    orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
-    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
+    --orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
     local tabIndexes = {}
     for k,v in pairs(P.shipList) do
-        -- only add level if it has desired tag
+        --TODO: only add ship if is in the right filter tab
         --if tag == nil or v:hasShip(tag) then
             local item = CEGUI.createListboxTextItem(v)
             item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
             listbox:addItem(item)
             table.insert(tabIndexes, k)
-            --[[if v:getXMLFilename() == preselect then
-                listbox:setItemSelectState(item, true)
-            end--]]
             --orxonox.GUIManager:setTooltipTextHelper(item, v:getDescription())
         --end
     end
     table.insert(P.activeTabIndexes, tabIndexes)
+end
+
+function P.createFilterTab(name) -- generates filter tab and list box, sets handler for selection changes
+    tabName = "orxonox/ShipSelectionLevelTab"
+    -- create new tab window with desired name
+    listbox = CEGUI.toListbox(winMgr:createWindow("MenuWidgets/Listbox", tabName)) 
+    listbox:setText(name)
+    listbox:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
+    --[[TODO: smaller list if image and description is implemented. 
+	listbox:setProperty("UnifiedAreaRect", "{{0.05,0},{0.1,0},{0.5,0},{0.675,0}}") --]]	 
+    listbox:setProperty("UnifiedAreaRect", "{{0,0},{0,0},{1,0},{1,0}}")
+    -- fill listbox with items
+    P.update()
     -- listen to selection changes
     orxonox.GUIManager:subscribeEventHelper(listbox, "ItemSelectionChanged", P.name..".ShipSelectionSelectionChanged")
     local tabControl = winMgr:getWindow("orxonox/ShipSelectionTabControl")
@@ -67,7 +62,7 @@
     end
 end
 
-function P.ShipSelectionGetSelectedModel()
+function P.ShipSelectionGetSelectedModel() --returns selected model, if available.
     -- choose the active listbox
     local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/ShipSelectionTabControl"))
     local listbox = CEGUI.toListbox(tabControl:getTabContentsAtIndex(tabControl:getSelectedTabIndex()))
@@ -83,6 +78,7 @@
 end
 
 function P.ShipSelectionSelectionChanged(e)
+    --[[ TODO: Get image and description from template file
     local levelImage = winMgr:getWindow("orxonox/ShipSelectionLevelImage")
     local levelDescription = winMgr:getWindow("orxonox/ShipSelectionLevelDescription")
     local configButton = winMgr:getWindow("orxonox/ShipSelectionConfigButton")
@@ -103,33 +99,33 @@
         -- also take care of "no level selected"
         levelImage:setProperty("Image", nil)
         levelDescription:setText("")
-        configButton:setProperty("Disabled", "True")
     end
+   --]]
 end
 
 function P.ShipSelectionStartButton_clicked(e)
 
-    if selectedlevel ~= nil then
+    if (selectedlevel ~= nil and P.ShipSelectionGetSelectedModel() ~= nil)  then
 	selectedlevel:selectShip(P.ShipSelectionGetSelectedModel())
         orxonox.execute("startGame " .. "_temp.oxw")
         hideAllMenuSheets()
     else
-        orxonox.execute("keyESC")
+	orxonox.execute("orxout user_warning no ship model selected or no tagged shipmodel installed")
     end
 end
 
-function P.ShipSelectionConfigButton_clicked(e)
---[[
+--[[ TODO: function P.ShipSelectionConfigButton_clicked(e)
+
     local level = P.ShipSelectionGetSelectedModel()
     if level ~= nil then
         local configMenu = showMenuSheet("ShipSelectionConfigMenu")
         configMenu:loadConfig(level)
     end
---]]
 end
+--]]
 
+
 function P.ShipSelectionBackButton_clicked(e)
-    --hideAllMenuSheets()
     orxonox.execute("keyESC")
 end 
 

Modified: code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua	2012-05-18 13:06:46 UTC (rev 9200)
+++ code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua	2012-05-18 13:09:07 UTC (rev 9201)
@@ -146,7 +146,7 @@
     if selectedlevel ~= nil then
         if selectedlevel:hasTag("shipselection") then
             local shipSelectionMenu = showMenuSheet("ShipSelectionMenu", true)
-            shipSelectionMenu:createShipList()
+            shipSelectionMenu:update()
         else
             orxonox.execute("startGame " .. selectedlevel:getXMLFilename())
             hideAllMenuSheets()

Modified: code/branches/shipSelection/data/levels/tutorial.oxw
===================================================================
--- code/branches/shipSelection/data/levels/tutorial.oxw	2012-05-18 13:06:46 UTC (rev 9200)
+++ code/branches/shipSelection/data/levels/tutorial.oxw	2012-05-18 13:09:07 UTC (rev 9201)
@@ -3,7 +3,7 @@
  description = "Level for the coding tutorial."
  tags = "tutorial, shipselection"
  screenshot = "codingtutorial.png"
- startingships = "spaceshipassff, spaceshipghost, spaceshipspacecruiser,spaceshippirate"
+ startingships = "spaceshipassff, spaceshipghost, spaceshipspacecruiser"
 />
 
 <?lua
@@ -13,7 +13,6 @@
   include("templates/spaceshipGhost.oxt")
   include("templates/spaceshipSpacecruiser.oxt")
   include("templates/lodInformation.oxt")
-  include("templates/spaceshipPirate.oxt")
 ?>
 
 <Level>
@@ -26,10 +25,6 @@
    ambientlight = "0.5, 0.5, 0.5"
    skybox       = "Orxonox/skypanoramagen1"
   >
-
-
-
-
 <Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
   <attached>
     <Model scale="1" mesh="drone.mesh"/>

Modified: code/branches/shipSelection/src/orxonox/ShipManager.cc
===================================================================
--- code/branches/shipSelection/src/orxonox/ShipManager.cc	2012-05-18 13:06:46 UTC (rev 9200)
+++ code/branches/shipSelection/src/orxonox/ShipManager.cc	2012-05-18 13:09:07 UTC (rev 9201)
@@ -20,15 +20,14 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      Damian 'Mozork' Frick
- *
+ *      Matthias Hutter
+ *   
  */
 
 /**
-    @file LevelManager.cc
-    @brief Implementation of the LevelManager singleton.
+    @file ShipManager.cc
+    @brief Work-in Progress: Implementation of the ShipManager singleton.
+    	   Should make SpaceShip info available to lua handlers.
 */
 
 #include "LevelManager.h"




More information about the Orxonox-commit mailing list