QTfrontend/team.cpp
changeset 1240 16b85f292030
parent 1066 1f1b3686a2b0
child 1242 4aca5f7b2504
equal deleted inserted replaced
1239:4901abe4c3b0 1240:16b85f292030
    24 #include "team.h"
    24 #include "team.h"
    25 #include "hwform.h"
    25 #include "hwform.h"
    26 #include "predefteams.h"
    26 #include "predefteams.h"
    27 #include "pages.h"
    27 #include "pages.h"
    28 #include "hwconsts.h"
    28 #include "hwconsts.h"
    29 
    29 #include "hats.h"
    30 
    30 
    31 HWTeam::HWTeam(const QString & teamname, unsigned int netID) :
    31 HWTeam::HWTeam(const QString & teamname, unsigned int netID) :
    32   difficulty(0),
    32   difficulty(0),
    33   numHedgehogs(4),
    33   numHedgehogs(4),
    34   m_netID(netID)
    34   m_netID(netID)
    35 {
    35 {
    36 	TeamName = teamname;
    36 	TeamName = teamname;
    37 	OldTeamName = TeamName;
    37 	OldTeamName = TeamName;
    38 	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
    38 	for (int i = 0; i < 8; i++)
       
    39 	{
       
    40 		HHName[i].sprintf("hedgehog %d", i);
       
    41 		HHHat[i] = "NoHat";
       
    42 	}
    39 	Grave = "Simple";
    43 	Grave = "Simple";
    40 	Fort = "Barrelhouse";
    44 	Fort = "Barrelhouse";
    41 	for(int i = 0; i < BINDS_NUMBER; i++)
    45 	for(int i = 0; i < BINDS_NUMBER; i++)
    42 	{
    46 	{
    43 		binds[i].action = cbinds[i].action;
    47 		binds[i].action = cbinds[i].action;
   108 			long i = str.left(1).toLong();
   112 			long i = str.left(1).toLong();
   109 			if ((i < 0) || (i > 7)) continue;
   113 			if ((i < 0) || (i > 7)) continue;
   110 			str.remove(0, 2);
   114 			str.remove(0, 2);
   111 			HHName[i] = str;
   115 			HHName[i] = str;
   112 		} else
   116 		} else
       
   117 		if (str.startsWith("hat"))
       
   118 		{
       
   119 			str.remove(0, 3);
       
   120 			long i = str.left(1).toLong();
       
   121 			if ((i < 0) || (i > 7)) continue;
       
   122 			str.remove(0, 2);
       
   123 			HHHat[i] = str;
       
   124 		} else
   113 		if (str.startsWith("grave "))
   125 		if (str.startsWith("grave "))
   114 		{
   126 		{
   115 			str.remove(0, 6);
   127 			str.remove(0, 6);
   116 			Grave = str;
   128 			Grave = str;
   117 		} else
   129 		} else
   157 	QTextStream stream(&cfgfile);
   169 	QTextStream stream(&cfgfile);
   158 	stream.setCodec("UTF-8");
   170 	stream.setCodec("UTF-8");
   159 	stream << "; Generated by Hedgewars, do not modify" << endl;
   171 	stream << "; Generated by Hedgewars, do not modify" << endl;
   160 	stream << "name team " << TeamName << endl;
   172 	stream << "name team " << TeamName << endl;
   161 	for (int i = 0; i < 8; i++)
   173 	for (int i = 0; i < 8; i++)
       
   174 	{
   162 		stream << "name hh" << i << " " << HHName[i] << endl;
   175 		stream << "name hh" << i << " " << HHName[i] << endl;
       
   176 		stream << "hat" << i << " " << HHHat[i] << endl;
       
   177 	}
   163 	stream << "grave " << Grave << endl;
   178 	stream << "grave " << Grave << endl;
   164 	stream << "fort " << Fort << endl;
   179 	stream << "fort " << Fort << endl;
   165 	for(int i = 0; i < BINDS_NUMBER; i++)
   180 	for(int i = 0; i < BINDS_NUMBER; i++)
   166 	{
   181 	{
   167 		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
   182 		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
   177 	hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty);
   192 	hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty);
   178 	hwform->ui.pageEditTeam->CBTeamLvl_activated(difficulty);
   193 	hwform->ui.pageEditTeam->CBTeamLvl_activated(difficulty);
   179 	for(int i = 0; i < 8; i++)
   194 	for(int i = 0; i < 8; i++)
   180 	{
   195 	{
   181 		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
   196 		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
       
   197 		hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole));
   182 	}
   198 	}
   183 	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
   199 	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
   184 	hwform->ui.pageEditTeam->CBGrave_activated(Grave);
   200 	hwform->ui.pageEditTeam->CBGrave_activated(Grave);
   185 
   201 
   186 	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
   202 	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
   197 	TeamName  = hwform->ui.pageEditTeam->TeamNameEdit->text();
   213 	TeamName  = hwform->ui.pageEditTeam->TeamNameEdit->text();
   198 	difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex();
   214 	difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex();
   199 	for(int i = 0; i < 8; i++)
   215 	for(int i = 0; i < 8; i++)
   200 	{
   216 	{
   201 		HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
   217 		HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text();
       
   218 		HHHat[i] = hwform->ui.pageEditTeam->HHHats[i]->currentText();
   202 	}
   219 	}
   203 
   220 
   204 	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
   221 	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
   205 	Fort = hwform->ui.pageEditTeam->CBFort->currentText();
   222 	Fort = hwform->ui.pageEditTeam->CBFort->currentText();
   206 	for(int i = 0; i < BINDS_NUMBER; i++)
   223 	for(int i = 0; i < BINDS_NUMBER; i++)