Store selected hats in team config
authorunc0rr
Sun, 31 Aug 2008 16:00:31 +0000
changeset 1240 16b85f292030
parent 1239 4901abe4c3b0
child 1241 9a2def515c98
Store selected hats in team config
QTfrontend/pages.cpp
QTfrontend/team.cpp
QTfrontend/team.h
--- a/QTfrontend/pages.cpp	Fri Aug 29 22:04:50 2008 +0000
+++ b/QTfrontend/pages.cpp	Sun Aug 31 16:00:31 2008 +0000
@@ -125,7 +125,7 @@
 		HHHats[i] = new QComboBox(GBoxHedgehogs);
 		HHHats[i]->setModel(hatsModel);
 		//HHHats[i]->setModelColumn(1);
-		HHHats[i]->setMinimumWidth(132);
+		//HHHats[i]->setMinimumWidth(132);
 		GBHLayout->addWidget(HHHats[i], i, 1);
 	}
 	pageLayout->addWidget(GBoxHedgehogs, 1, 0, 2, 1);
--- a/QTfrontend/team.cpp	Fri Aug 29 22:04:50 2008 +0000
+++ b/QTfrontend/team.cpp	Sun Aug 31 16:00:31 2008 +0000
@@ -26,7 +26,7 @@
 #include "predefteams.h"
 #include "pages.h"
 #include "hwconsts.h"
-
+#include "hats.h"
 
 HWTeam::HWTeam(const QString & teamname, unsigned int netID) :
   difficulty(0),
@@ -35,7 +35,11 @@
 {
 	TeamName = teamname;
 	OldTeamName = TeamName;
-	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
+	for (int i = 0; i < 8; i++)
+	{
+		HHName[i].sprintf("hedgehog %d", i);
+		HHHat[i] = "NoHat";
+	}
 	Grave = "Simple";
 	Fort = "Barrelhouse";
 	for(int i = 0; i < BINDS_NUMBER; i++)
@@ -110,6 +114,14 @@
 			str.remove(0, 2);
 			HHName[i] = str;
 		} else
+		if (str.startsWith("hat"))
+		{
+			str.remove(0, 3);
+			long i = str.left(1).toLong();
+			if ((i < 0) || (i > 7)) continue;
+			str.remove(0, 2);
+			HHHat[i] = str;
+		} else
 		if (str.startsWith("grave "))
 		{
 			str.remove(0, 6);
@@ -159,7 +171,10 @@
 	stream << "; Generated by Hedgewars, do not modify" << endl;
 	stream << "name team " << TeamName << endl;
 	for (int i = 0; i < 8; i++)
+	{
 		stream << "name hh" << i << " " << HHName[i] << endl;
+		stream << "hat" << i << " " << HHHat[i] << endl;
+	}
 	stream << "grave " << Grave << endl;
 	stream << "fort " << Fort << endl;
 	for(int i = 0; i < BINDS_NUMBER; i++)
@@ -179,6 +194,7 @@
 	for(int i = 0; i < 8; i++)
 	{
 		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
+		hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole));
 	}
 	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
 	hwform->ui.pageEditTeam->CBGrave_activated(Grave);
@@ -199,6 +215,7 @@
 	for(int i = 0; i < 8; i++)
 	{
 		HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
+		HHHat[i] = hwform->ui.pageEditTeam->HHHats[i]->currentText();
 	}
 
 	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
--- a/QTfrontend/team.h	Fri Aug 29 22:04:50 2008 +0000
+++ b/QTfrontend/team.h	Sun Aug 31 16:00:31 2008 +0000
@@ -43,7 +43,8 @@
 
 		QString TeamName;
 		QString HHName[8];
-		QString	Grave;
+		QString HHHat[8];
+		QString Grave;
 		QString Fort;
 		unsigned int difficulty;
 		BindAction binds[BINDS_NUMBER];