[Orxonox-commit 4456] r9127 - in code/branches/shipSelection: data/gui/scripts data/levels src/libraries/core src/orxonox

huttemat at orxonox.net huttemat at orxonox.net
Fri Apr 27 15:56:15 CEST 2012


Author: huttemat
Date: 2012-04-27 15:56:15 +0200 (Fri, 27 Apr 2012)
New Revision: 9127

Modified:
   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/libraries/core/Loader.cc
   code/branches/shipSelection/src/orxonox/LevelInfo.h
   code/branches/shipSelection/src/orxonox/LevelManager.cc
Log:
shipselection core works now

Modified: code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua
===================================================================
--- code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua	2012-04-27 13:38:06 UTC (rev 9126)
+++ code/branches/shipSelection/data/gui/scripts/ShipSelectionMenu.lua	2012-04-27 13:56:15 UTC (rev 9127)
@@ -15,6 +15,11 @@
    end]]	
 
    P.shipList = {}
+
+  --for line in io.lines("../levels/templates/.shipmodels") do  orxonox.execute("orxout user_warning " .. line) end
+  for line in io.lines("../levels/templates/.shipmodels") do  
+	P.shipList[#P.shipList+1] = string.lower(line)
+  end 
    --[[for f in io.lines("../levels/templates/.shipmodels") do
         if selectedlevel:hasShip(f) then
             P.shipList[#P.shipList+1] = f
@@ -150,12 +155,12 @@
         configButton:setProperty("Disabled", "True")
     end
 end
---]]
+
 function P.ShipSelectionStartButton_clicked(e)
 
     if selectedlevel ~= nil then
-	selectedlevel:selectShip("meinModell")
-        --orxonox.execute("startGame " .. selectedlevel:getXMLFilename())
+	selectedlevel:selectShip(P.ShipSelectionGetSelectedLevel())
+        orxonox.execute("startGame " .. "_temp.oxw")
         hideAllMenuSheets()
     else
         orxonox.execute("keyESC")

Modified: code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua	2012-04-27 13:38:06 UTC (rev 9126)
+++ code/branches/shipSelection/data/gui/scripts/SingleplayerMenu.lua	2012-04-27 13:56:15 UTC (rev 9127)
@@ -46,7 +46,8 @@
     local level = nil
     while index < size do
         level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
-        if level ~= nil then
+        if (level ~= nil and level:getXMLFilename() ~= "_temp.oxw") then
+	    --os.execute("echo " .. level:getXMLFilename() .." >> ~/outputorx")
             local levelXMLFilename = level:getXMLFilename()
             -- create an imageset for each screenshot
             local imageName = level:getScreenshot()

Modified: code/branches/shipSelection/data/levels/tutorial.oxw
===================================================================
--- code/branches/shipSelection/data/levels/tutorial.oxw	2012-04-27 13:38:06 UTC (rev 9126)
+++ code/branches/shipSelection/data/levels/tutorial.oxw	2012-04-27 13:56:15 UTC (rev 9127)
@@ -3,13 +3,15 @@
  description = "Level for the coding tutorial."
  tags = "tutorial, shipselection"
  screenshot = "codingtutorial.png"
- startingships = "spaceshipGhost, spaceshipPirate, spaceshipSpacecruiser"
+ startingships = "spaceshipghost, spaceshippirate, spaceshipspacecruiser"
 />
 
 <?lua
   include("HUDTemplates3.oxo")
   include("stats.oxo")
   include("templates/spaceshipAssff.oxt")
+  include("templates/spaceshipGhost.oxt")
+  include("templates/spaceshipSpacecruiser.oxt")
   include("templates/lodInformation.oxt")
 ?>
 

Modified: code/branches/shipSelection/src/libraries/core/Loader.cc
===================================================================
--- code/branches/shipSelection/src/libraries/core/Loader.cc	2012-04-27 13:38:06 UTC (rev 9126)
+++ code/branches/shipSelection/src/libraries/core/Loader.cc	2012-04-27 13:56:15 UTC (rev 9127)
@@ -221,7 +221,7 @@
                 orxout(verbose, context::loader) << "Finished loading " << file->getFilename() << '.' << endl;
 
             orxout(verbose, context::loader) << "Namespace-tree:" << '\n' << rootNamespace->toString("  ") << endl;
-
+			
             return true;
         }
         catch (ticpp::Exception& ex)

Modified: code/branches/shipSelection/src/orxonox/LevelInfo.h
===================================================================
--- code/branches/shipSelection/src/orxonox/LevelInfo.h	2012-04-27 13:38:06 UTC (rev 9126)
+++ code/branches/shipSelection/src/orxonox/LevelInfo.h	2012-04-27 13:56:15 UTC (rev 9127)
@@ -151,20 +151,32 @@
             std::string xmlfilename_; //!< The XML-filename of the Level.
 
         private:
+
 	    inline void changeShip (const std::string& model) {
-                //HACK: Read Level XML File, find "shipselection", replace with ship model
-                std::string text;
- 		std::ifstream myLevel ("test.txt");
-		std::ofstream tempLevel ("test2.txt");
-		while(!myLevel.eof())
-		{
-			std::string buff;
-			std::getline(myLevel, buff);
-			tempLevel.write(buff.c_str(), buff.length());
-		}
-		myLevel.close();
-		tempLevel.close();
-		orxout(user_status) << "done" << endl;
+	        static std::string shipSelectionTag = "shipselection";
+        	//HACK: Read Level XML File, find "shipselection", replace with ship model
+        	std::string levelPath = "../levels/";
+        	levelPath.append(this->getXMLFilename());
+        	std::string tempPath = "../levels/";
+        	tempPath.append("_temp.oxw");
+        	orxout(user_status) << levelPath << endl;
+        	orxout(user_status) << tempPath << endl;
+        	std::ifstream myLevel (levelPath.c_str());
+			std::ofstream tempLevel (tempPath.c_str());
+			while(!myLevel.eof())
+			{
+				std::string buff;
+				std::getline(myLevel, buff);
+				std::string pawndesignString = "pawndesign=";
+				size_t found = buff.find(pawndesignString.append(shipSelectionTag)); 
+				if (found!= std::string::npos) 
+					buff = buff.substr(0, found + 11) + model + buff.substr(found+11+shipSelectionTag.length(), std::string::npos);
+				tempLevel.write(buff.c_str(), buff.length());
+				tempLevel << std::endl;
+			}
+			myLevel.close();
+			tempLevel.close();
+			orxout(user_status) << "done" << endl;
 	    } 
             void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
             void shipsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.

Modified: code/branches/shipSelection/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/shipSelection/src/orxonox/LevelManager.cc	2012-04-27 13:38:06 UTC (rev 9126)
+++ code/branches/shipSelection/src/orxonox/LevelManager.cc	2012-04-27 13:56:15 UTC (rev 9127)
@@ -255,7 +255,7 @@
         for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
         {
             // TODO: Replace with tag?
-            if (it->find("old/") != 0)
+            if (it->find("old/") != 0 )
             {
                 LevelInfoItem* info = NULL;
 




More information about the Orxonox-commit mailing list