65 Flag = strLst[4]; |
65 Flag = strLst[4]; |
66 Owner = strLst[5]; |
66 Owner = strLst[5]; |
67 difficulty = strLst[6].toUInt(); |
67 difficulty = strLst[6].toUInt(); |
68 for(int i = 0; i < 8; i++) |
68 for(int i = 0; i < 8; i++) |
69 { |
69 { |
70 HHName[i]=strLst[i * 2 + 7]; |
70 Hedgehogs[i].Name=strLst[i * 2 + 7]; |
71 HHHat[i]=strLst[i * 2 + 8]; |
71 Hedgehogs[i].Hat=strLst[i * 2 + 8]; |
72 // Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat |
72 // Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat |
73 // Checking net teams is probably pointless, but can't hurt. |
73 // Checking net teams is probably pointless, but can't hurt. |
74 if (HHHat[i].length() == 0) HHHat[i] = "NoHat"; |
74 if (Hedgehogs[i].Hat.length() == 0) Hedgehogs[i].Hat = "NoHat"; |
75 } |
75 } |
76 } |
76 } |
77 |
77 |
78 HWTeam::HWTeam() : |
78 HWTeam::HWTeam() : |
79 difficulty(0), |
79 difficulty(0), |
81 m_isNetTeam(false) |
81 m_isNetTeam(false) |
82 { |
82 { |
83 TeamName = QString("Team"); |
83 TeamName = QString("Team"); |
84 for (int i = 0; i < 8; i++) |
84 for (int i = 0; i < 8; i++) |
85 { |
85 { |
86 HHName[i].sprintf("hedgehog %d", i); |
86 Hedgehogs[i].Name.sprintf("hedgehog %d", i); |
87 HHHat[i] = "NoHat"; |
87 Hedgehogs[i].Hat = "NoHat"; |
88 } |
88 } |
89 |
89 |
90 Grave = QString("Simple"); // default |
90 Grave = QString("Simple"); // default |
91 Fort = QString("Island"); // default |
91 Fort = QString("Island"); // default |
92 Voicepack = "Default"; |
92 Voicepack = "Default"; |
111 Flag = teamfile.value("Team/Flag", "hedgewars").toString(); |
111 Flag = teamfile.value("Team/Flag", "hedgewars").toString(); |
112 difficulty = teamfile.value("Team/Difficulty", 0).toInt(); |
112 difficulty = teamfile.value("Team/Difficulty", 0).toInt(); |
113 for(int i = 0; i < 8; i++) |
113 for(int i = 0; i < 8; i++) |
114 { |
114 { |
115 QString hh = QString("Hedgehog%1/").arg(i); |
115 QString hh = QString("Hedgehog%1/").arg(i); |
116 HHName[i] = teamfile.value(hh + "Name", QString("hedgehog %1").arg(i)).toString(); |
116 Hedgehogs[i].Name = teamfile.value(hh + "Name", QString("hedgehog %1").arg(i)).toString(); |
117 HHHat[i] = teamfile.value(hh + "Hat", "NoHat").toString(); |
117 Hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString(); |
118 //teamfile.setValue(hh + "Kills", 0); |
118 Hedgehogs[i].Rounds = teamfile.value(hh + "Rounds", 0).toInt(); |
119 //teamfile.setValue(hh + "Deaths", 0); |
119 Hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt(); |
120 //teamfile.setValue(hh + "Rounds", 0); |
120 Hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt(); |
121 //teamfile.setValue(hh + "Suicides", 0); |
121 Hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt(); |
122 } |
122 } |
123 for(int i = 0; i < BINDS_NUMBER; i++) |
123 for(int i = 0; i < BINDS_NUMBER; i++) |
124 binds[i].action = teamfile.value(QString("Binds/%1").arg(binds[i].strbind), cbinds[i].action).toString(); |
124 binds[i].action = teamfile.value(QString("Binds/%1").arg(binds[i].strbind), cbinds[i].action).toString(); |
|
125 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
|
126 if(achievements[i][0][0]) |
|
127 AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt(); |
|
128 else |
|
129 break; |
125 return true; |
130 return true; |
126 } |
131 } |
127 |
132 |
128 bool HWTeam::DeleteFile() |
133 bool HWTeam::DeleteFile() |
129 { |
134 { |
151 teamfile.setValue("Team/Flag", Flag); |
156 teamfile.setValue("Team/Flag", Flag); |
152 teamfile.setValue("Team/Difficulty", difficulty); |
157 teamfile.setValue("Team/Difficulty", difficulty); |
153 for(int i = 0; i < 8; i++) |
158 for(int i = 0; i < 8; i++) |
154 { |
159 { |
155 QString hh = QString("Hedgehog%1/").arg(i); |
160 QString hh = QString("Hedgehog%1/").arg(i); |
156 teamfile.setValue(hh + "Name", HHName[i]); |
161 teamfile.setValue(hh + "Name", Hedgehogs[i].Name); |
157 teamfile.setValue(hh + "Hat", HHHat[i]); |
162 teamfile.setValue(hh + "Hat", Hedgehogs[i].Hat); |
158 teamfile.setValue(hh + "Kills", 0); |
163 teamfile.setValue(hh + "Rounds", Hedgehogs[i].Rounds); |
159 teamfile.setValue(hh + "Deaths", 0); |
164 teamfile.setValue(hh + "Kills", Hedgehogs[i].Kills); |
160 teamfile.setValue(hh + "Rounds", 0); |
165 teamfile.setValue(hh + "Deaths", Hedgehogs[i].Deaths); |
161 teamfile.setValue(hh + "Suicides", 0); |
166 teamfile.setValue(hh + "Suicides", Hedgehogs[i].Suicides); |
162 } |
167 } |
163 for(int i = 0; i < BINDS_NUMBER; i++) |
168 for(int i = 0; i < BINDS_NUMBER; i++) |
164 teamfile.setValue(QString("Binds/%1").arg(binds[i].strbind), binds[i].action); |
169 teamfile.setValue(QString("Binds/%1").arg(binds[i].strbind), binds[i].action); |
|
170 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
|
171 if(achievements[i][0][0]) |
|
172 teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]); |
|
173 else |
|
174 break; |
165 return true; |
175 return true; |
166 } |
176 } |
167 |
177 |
168 void HWTeam::SetToPage(HWForm * hwform) |
178 void HWTeam::SetToPage(HWForm * hwform) |
169 { |
179 { |
170 hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName); |
180 hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName); |
171 hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty); |
181 hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty); |
172 for(int i = 0; i < 8; i++) |
182 for(int i = 0; i < 8; i++) |
173 { |
183 { |
174 hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]); |
184 hwform->ui.pageEditTeam->HHNameEdit[i]->setText(Hedgehogs[i].Name); |
175 if (HHHat[i].startsWith("Reserved")) |
185 if (Hedgehogs[i].Hat.startsWith("Reserved")) |
176 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData("Reserved "+HHHat[i].remove(0,40), Qt::DisplayRole)); |
186 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData("Reserved "+Hedgehogs[i].Hat.remove(0,40), Qt::DisplayRole)); |
177 else |
187 else |
178 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole)); |
188 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(Hedgehogs[i].Hat, Qt::DisplayRole)); |
179 } |
189 } |
180 hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave)); |
190 hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave)); |
181 hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findText(Flag)); |
191 hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findText(Flag)); |
182 |
192 |
183 hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort)); |
193 hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort)); |
194 { |
204 { |
195 TeamName = hwform->ui.pageEditTeam->TeamNameEdit->text(); |
205 TeamName = hwform->ui.pageEditTeam->TeamNameEdit->text(); |
196 difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex(); |
206 difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex(); |
197 for(int i = 0; i < 8; i++) |
207 for(int i = 0; i < 8; i++) |
198 { |
208 { |
199 HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); |
209 Hedgehogs[i].Name = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); |
200 if (hwform->ui.pageEditTeam->HHHats[i]->currentText().startsWith("Reserved")) |
210 if (hwform->ui.pageEditTeam->HHHats[i]->currentText().startsWith("Reserved")) |
201 HHHat[i] = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9); |
211 Hedgehogs[i].Hat = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9); |
202 else |
212 else |
203 HHHat[i] = hwform->ui.pageEditTeam->HHHats[i]->currentText(); |
213 Hedgehogs[i].Hat = hwform->ui.pageEditTeam->HHHats[i]->currentText(); |
204 } |
214 } |
205 |
215 |
206 Grave = hwform->ui.pageEditTeam->CBGrave->currentText(); |
216 Grave = hwform->ui.pageEditTeam->CBGrave->currentText(); |
207 Fort = hwform->ui.pageEditTeam->CBFort->currentText(); |
217 Fort = hwform->ui.pageEditTeam->CBFort->currentText(); |
208 Voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText(); |
218 Voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText(); |
236 for (int t = 0; t < numHedgehogs; t++) |
246 for (int t = 0; t < numHedgehogs; t++) |
237 { |
247 { |
238 sl.push_back(QString("eaddhh %1 %2 %3") |
248 sl.push_back(QString("eaddhh %1 %2 %3") |
239 .arg(QString::number(difficulty), |
249 .arg(QString::number(difficulty), |
240 QString::number(InitHealth), |
250 QString::number(InitHealth), |
241 HHName[t])); |
251 Hedgehogs[t].Name)); |
242 sl.push_back(QString("ehat %1") |
252 sl.push_back(QString("ehat %1") |
243 .arg(HHHat[t])); |
253 .arg(Hedgehogs[t].Hat)); |
244 } |
254 } |
245 return sl; |
255 return sl; |
246 } |
256 } |
247 |
257 |
248 bool HWTeam::isNetTeam() const |
258 bool HWTeam::isNetTeam() const |