Change mission file format to allow more flexible config
authorunc0rr
Sun, 25 Oct 2009 12:40:47 +0000
changeset 2584 cc049fbb65ef
parent 2583 f8da275981e5
child 2585 0899ce8ad77f
Change mission file format to allow more flexible config
QTfrontend/game.cpp
share/hedgewars/Data/Trainings/001_Shotgun.txt
tools/MissionsEditor/editor.cpp
tools/MissionsEditor/editor.ui
--- a/QTfrontend/game.cpp	Sun Oct 25 12:19:47 2009 +0000
+++ b/QTfrontend/game.cpp	Sun Oct 25 12:40:47 2009 +0000
@@ -136,13 +136,6 @@
 	QByteArray traincfg;
 	HWProto::addStringToBuffer(traincfg, "TL");
 
-	HWTeam team1;
-	team1.difficulty = 0;
-	team1.teamColor = *color1;
-	team1.numHedgehogs = 1;
-	HWProto::addStringListToBuffer(traincfg,
-			team1.TeamGameConfig(100));
-
 	QFile file(datadir->absolutePath() + "/Trainings/" + training + ".txt");
 	if(!file.open(QFile::ReadOnly))
 	{
@@ -153,7 +146,14 @@
 	QTextStream stream(&file);
 	while(!stream.atEnd())
 	{
-		HWProto::addStringToBuffer(traincfg, "e" + stream.readLine());
+		QString line = stream.readLine();
+		if(!line.isEmpty() && !line.startsWith("#"))
+			if(line != "<binds>")
+				HWProto::addStringToBuffer(traincfg, "e" + line);
+			else
+				for(int i = 0; i < BINDS_NUMBER; i++)
+					if(!cbinds[i].strbind.isEmpty())
+						HWProto::addStringToBuffer(traincfg, "ebind " + cbinds[i].strbind + " " + cbinds[i].action);
 	}
 
 	RawSendIPC(traincfg);
--- a/share/hedgewars/Data/Trainings/001_Shotgun.txt	Sun Oct 25 12:19:47 2009 +0000
+++ b/share/hedgewars/Data/Trainings/001_Shotgun.txt	Sun Oct 25 12:40:47 2009 +0000
@@ -7,7 +7,16 @@
 map mushrooms
 theme nature
 ammstore 00009000000000000000000000000000000000000000000000000000000000000000000000000000
+
+addteam 14483456 Team
+<binds>
+grave Simple
+fort Island
+voicepack Default
+addhh 0 100 hedgehog 0
+hat NoHat
 hhcoords 2334 1254
+
 addtrig s2147483649 1 1 30 2154 1274 1
 addtrig s1 1 1 30 2334 1914 2
 addtrig s2 1 1 30 2774 1484 3
--- a/tools/MissionsEditor/editor.cpp	Sun Oct 25 12:19:47 2009 +0000
+++ b/tools/MissionsEditor/editor.cpp	Sun Oct 25 12:40:47 2009 +0000
@@ -55,6 +55,12 @@
         if (line.startsWith("seed"))
             ui->leSeed->setText(line.mid(5));
         else
+        if (line.startsWith("map"))
+            ui->leMap->setText(line.mid(4));
+        else
+        if (line.startsWith("theme"))
+            ui->leTheme->setText(line.mid(6));
+        else
         if (line.startsWith("$turntime"))
             ui->sbTurnTime->setValue(line.mid(10).toInt());
         else
--- a/tools/MissionsEditor/editor.ui	Sun Oct 25 12:19:47 2009 +0000
+++ b/tools/MissionsEditor/editor.ui	Sun Oct 25 12:40:47 2009 +0000
@@ -18,7 +18,7 @@
     <item row="0" column="0">
      <widget class="QTabWidget" name="tabWidget">
       <property name="currentIndex">
-       <number>1</number>
+       <number>0</number>
       </property>
       <widget class="QWidget" name="tab_4">
        <attribute name="title">
@@ -33,7 +33,7 @@
          </widget>
         </item>
         <item row="0" column="1">
-         <widget class="QLineEdit" name="lineEdit"/>
+         <widget class="QLineEdit" name="leName"/>
         </item>
         <item row="1" column="0">
          <widget class="QLabel" name="label_5">
@@ -43,7 +43,27 @@
          </widget>
         </item>
         <item row="1" column="1">
-         <widget class="QTextEdit" name="textEdit"/>
+         <widget class="QTextEdit" name="teDescription"/>
+        </item>
+        <item row="2" column="0">
+         <widget class="QLabel" name="label_6">
+          <property name="text">
+           <string>Map</string>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="0">
+         <widget class="QLabel" name="label_7">
+          <property name="text">
+           <string>Theme</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="QLineEdit" name="leMap"/>
+        </item>
+        <item row="3" column="1">
+         <widget class="QLineEdit" name="leTheme"/>
         </item>
        </layout>
       </widget>