QTfrontend/team.cpp
changeset 2747 7889a3a9724f
parent 2428 6800f8aa0184
child 2833 9c2accd92cc7
equal deleted inserted replaced
2746:55593f8a490b 2747:7889a3a9724f
    40 		HHHat[i] = "NoHat";
    40 		HHHat[i] = "NoHat";
    41 	}
    41 	}
    42 	Grave = "Statue";
    42 	Grave = "Statue";
    43 	Fort = "Plane";
    43 	Fort = "Plane";
    44 	Voicepack = "Default";
    44 	Voicepack = "Default";
       
    45 	Flag = "hedgewars";
    45 	for(int i = 0; i < BINDS_NUMBER; i++)
    46 	for(int i = 0; i < BINDS_NUMBER; i++)
    46 	{
    47 	{
    47 		binds[i].action = cbinds[i].action;
    48 		binds[i].action = cbinds[i].action;
    48 		binds[i].strbind = cbinds[i].strbind;
    49 		binds[i].strbind = cbinds[i].strbind;
    49 	}
    50 	}
    52 HWTeam::HWTeam(const QStringList& strLst) :
    53 HWTeam::HWTeam(const QStringList& strLst) :
    53   numHedgehogs(4),
    54   numHedgehogs(4),
    54   m_isNetTeam(true)
    55   m_isNetTeam(true)
    55 {
    56 {
    56 	// net teams are configured from QStringList
    57 	// net teams are configured from QStringList
    57 	if(strLst.size() != 22) throw HWTeamConstructException();
    58 	if(strLst.size() != 23) throw HWTeamConstructException();
    58 	TeamName = strLst[0];
    59 	TeamName = strLst[0];
    59 	Grave = strLst[1];
    60 	Grave = strLst[1];
    60 	Fort = strLst[2];
    61 	Fort = strLst[2];
    61 	Voicepack = strLst[3];
    62 	Voicepack = strLst[3];
    62 	Owner = strLst[4];
    63 	Flag = strLst[4];
    63 	difficulty = strLst[5].toUInt();
    64 	Owner = strLst[5];
       
    65 	difficulty = strLst[6].toUInt();
    64 	for(int i = 0; i < 8; i++)
    66 	for(int i = 0; i < 8; i++)
    65 	{
    67 	{
    66 		HHName[i]=strLst[i * 2 + 6];
    68 		HHName[i]=strLst[i * 2 + 7];
    67 		HHHat[i]=strLst[i * 2 + 7];
    69 		HHHat[i]=strLst[i * 2 + 8];
    68 	}
    70 	}
    69 }
    71 }
    70 
    72 
    71 HWTeam::HWTeam() :
    73 HWTeam::HWTeam() :
    72   difficulty(0),
    74   difficulty(0),
    81 	}
    83 	}
    82 
    84 
    83 	Grave = QString("Simple"); // default
    85 	Grave = QString("Simple"); // default
    84 	Fort = QString("Island"); // default
    86 	Fort = QString("Island"); // default
    85 	Voicepack = "Default";
    87 	Voicepack = "Default";
       
    88 	Flag = "hedgewars";
    86 
    89 
    87 	for(int i = 0; i < BINDS_NUMBER; i++)
    90 	for(int i = 0; i < BINDS_NUMBER; i++)
    88 	{
    91 	{
    89 		binds[i].action = cbinds[i].action;
    92 		binds[i].action = cbinds[i].action;
    90 		binds[i].strbind = cbinds[i].strbind;
    93 		binds[i].strbind = cbinds[i].strbind;
   134 		} else
   137 		} else
   135 		if (str.startsWith("fort "))
   138 		if (str.startsWith("fort "))
   136 		{
   139 		{
   137 			str.remove(0, 5);
   140 			str.remove(0, 5);
   138 			Fort = str;
   141 			Fort = str;
       
   142 		} else
       
   143 		if (str.startsWith("flag "))
       
   144 		{
       
   145 			str.remove(0, 5);
       
   146 			Flag = str;
   139 		} else
   147 		} else
   140 		if (str.startsWith("voicepack "))
   148 		if (str.startsWith("voicepack "))
   141 		{
   149 		{
   142 			str.remove(0, 10);
   150 			str.remove(0, 10);
   143 			Voicepack = str;
   151 			Voicepack = str;
   186 		stream << "hat" << i << " " << HHHat[i] << endl;
   194 		stream << "hat" << i << " " << HHHat[i] << endl;
   187 	}
   195 	}
   188 	stream << "grave " << Grave << endl;
   196 	stream << "grave " << Grave << endl;
   189 	stream << "fort " << Fort << endl;
   197 	stream << "fort " << Fort << endl;
   190 	stream << "voicepack " << Voicepack << endl;
   198 	stream << "voicepack " << Voicepack << endl;
       
   199 	stream << "flag " << Flag << endl;
   191 	for(int i = 0; i < BINDS_NUMBER; i++)
   200 	for(int i = 0; i < BINDS_NUMBER; i++)
   192 	{
   201 	{
   193 		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
   202 		stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
   194 	}
   203 	}
   195 	stream << "difficulty " << difficulty << endl;
   204 	stream << "difficulty " << difficulty << endl;
   205 	{
   214 	{
   206 		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
   215 		hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]);
   207 		hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole));
   216 		hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole));
   208 	}
   217 	}
   209 	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
   218 	hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave));
       
   219 	hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findText(Flag));
   210 
   220 
   211 	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
   221 	hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort));
   212 	hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(Voicepack));
   222 	hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(Voicepack));
   213 	//hwform->ui.pageEditTeam->CBFort_activated(Fort);
   223 	//hwform->ui.pageEditTeam->CBFort_activated(Fort);
   214 
   224 
   229 	}
   239 	}
   230 
   240 
   231 	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
   241 	Grave = hwform->ui.pageEditTeam->CBGrave->currentText();
   232 	Fort = hwform->ui.pageEditTeam->CBFort->currentText();
   242 	Fort = hwform->ui.pageEditTeam->CBFort->currentText();
   233 	Voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText();
   243 	Voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText();
       
   244 	Flag = hwform->ui.pageEditTeam->CBFlag->currentText();
   234 	for(int i = 0; i < BINDS_NUMBER; i++)
   245 	for(int i = 0; i < BINDS_NUMBER; i++)
   235 	{
   246 	{
   236 		binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString();
   247 		binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString();
   237 	}
   248 	}
   238 }
   249 }
   246 		sl.push_back("erdriven");
   257 		sl.push_back("erdriven");
   247 
   258 
   248 	sl.push_back(QString("egrave " + Grave));
   259 	sl.push_back(QString("egrave " + Grave));
   249 	sl.push_back(QString("efort " + Fort));
   260 	sl.push_back(QString("efort " + Fort));
   250 	sl.push_back(QString("evoicepack " + Voicepack));
   261 	sl.push_back(QString("evoicepack " + Voicepack));
       
   262 	sl.push_back(QString("eflag " + Flag));
   251 
   263 
   252 	if (!m_isNetTeam)
   264 	if (!m_isNetTeam)
   253 		for(int i = 0; i < BINDS_NUMBER; i++)
   265 		for(int i = 0; i < BINDS_NUMBER; i++)
   254 			if(!binds[i].strbind.isEmpty())
   266 			if(!binds[i].strbind.isEmpty())
   255 				sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action));
   267 				sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action));