44 m_fort = "Plane"; |
44 m_fort = "Plane"; |
45 m_voicepack = "Default"; |
45 m_voicepack = "Default"; |
46 m_flag = "hedgewars"; |
46 m_flag = "hedgewars"; |
47 for(int i = 0; i < BINDS_NUMBER; i++) |
47 for(int i = 0; i < BINDS_NUMBER; i++) |
48 { |
48 { |
49 binds[i].action = cbinds[i].action; |
49 m_binds[i].action = cbinds[i].action; |
50 binds[i].strbind = cbinds[i].strbind; |
50 m_binds[i].strbind = cbinds[i].strbind; |
51 } |
51 } |
52 m_rounds = 0; |
52 m_rounds = 0; |
53 m_wins = 0; |
53 m_wins = 0; |
54 m_campaignProgress = 0; |
54 m_campaignProgress = 0; |
55 } |
55 } |
56 |
56 |
57 HWTeam::HWTeam(const QStringList& strLst) : |
57 HWTeam::HWTeam(const QStringList& strLst) : |
58 m_numHedgehogs(4), |
58 QObject(0) |
59 m_isNetTeam(true) |
59 , m_numHedgehogs(4) |
|
60 , m_isNetTeam(true) |
60 { |
61 { |
61 // net teams are configured from QStringList |
62 // net teams are configured from QStringList |
62 if(strLst.size() != 23) throw HWTeamConstructException(); |
63 if(strLst.size() != 23) throw HWTeamConstructException(); |
63 m_name = strLst[0]; |
64 m_name = strLst[0]; |
64 m_grave = strLst[1]; |
65 m_grave = strLst[1]; |
97 m_voicepack = "Default"; |
99 m_voicepack = "Default"; |
98 m_flag = "hedgewars"; |
100 m_flag = "hedgewars"; |
99 |
101 |
100 for(int i = 0; i < BINDS_NUMBER; i++) |
102 for(int i = 0; i < BINDS_NUMBER; i++) |
101 { |
103 { |
102 binds[i].action = cbinds[i].action; |
104 m_binds[i].action = cbinds[i].action; |
103 binds[i].strbind = cbinds[i].strbind; |
105 m_binds[i].strbind = cbinds[i].strbind; |
104 } |
106 } |
105 m_rounds = 0; |
107 m_rounds = 0; |
106 m_wins = 0; |
108 m_wins = 0; |
107 m_campaignProgress = 0; |
109 m_campaignProgress = 0; |
108 } |
110 } |
109 |
111 |
|
112 HWTeam::HWTeam(const HWTeam & other) : |
|
113 QObject(0) |
|
114 , OldTeamName(other.OldTeamName) |
|
115 , m_name(other.m_name) |
|
116 , m_grave(other.m_grave) |
|
117 , m_fort(other.m_fort) |
|
118 , m_flag(other.m_flag) |
|
119 , m_voicepack(other.m_voicepack) |
|
120 , m_hedgehogs(other.m_hedgehogs) |
|
121 , m_difficulty(other.m_difficulty) |
|
122 , m_binds(other.m_binds) |
|
123 , m_numHedgehogs(other.m_numHedgehogs) |
|
124 , m_color(other.m_color) |
|
125 , m_isNetTeam(other.m_isNetTeam) |
|
126 , m_owner(other.m_owner) |
|
127 , m_campaignProgress(other.m_campaignProgress) |
|
128 , m_rounds(other.m_rounds) |
|
129 , m_wins(other.m_wins) |
|
130 // , AchievementProgress(other.AchievementProgress) |
|
131 { |
|
132 |
|
133 } |
|
134 |
|
135 HWTeam & HWTeam::operator = (const HWTeam & other) |
|
136 { |
|
137 if(this != &other) |
|
138 { |
|
139 OldTeamName = other.OldTeamName; |
|
140 m_name = other.m_name; |
|
141 m_grave = other.m_grave; |
|
142 m_fort = other.m_fort; |
|
143 m_flag = other.m_flag; |
|
144 m_voicepack = other.m_voicepack; |
|
145 // m_hedgehogs = other.m_hedgehogs; |
|
146 m_difficulty = other.m_difficulty; |
|
147 // m_binds = other.m_binds; |
|
148 m_numHedgehogs = other.m_numHedgehogs; |
|
149 m_color = other.m_color; |
|
150 m_isNetTeam = other.m_isNetTeam; |
|
151 m_owner = other.m_owner; |
|
152 m_campaignProgress = other.m_campaignProgress; |
|
153 m_rounds = other.m_rounds; |
|
154 m_wins = other.m_wins; |
|
155 } |
|
156 |
|
157 return *this; |
|
158 } |
110 |
159 |
111 bool HWTeam::loadFromFile() |
160 bool HWTeam::loadFromFile() |
112 { |
161 { |
113 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + m_name + ".hwt", QSettings::IniFormat, 0); |
162 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + m_name + ".hwt", QSettings::IniFormat, 0); |
114 teamfile.setIniCodec("UTF-8"); |
163 teamfile.setIniCodec("UTF-8"); |
130 m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt(); |
179 m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt(); |
131 m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt(); |
180 m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt(); |
132 m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt(); |
181 m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt(); |
133 } |
182 } |
134 for(int i = 0; i < BINDS_NUMBER; i++) |
183 for(int i = 0; i < BINDS_NUMBER; i++) |
135 binds[i].strbind = teamfile.value(QString("Binds/%1").arg(binds[i].action), cbinds[i].strbind).toString(); |
184 m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString(); |
136 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
185 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
137 if(achievements[i][0][0]) |
186 if(achievements[i][0][0]) |
138 AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt(); |
187 AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt(); |
139 else |
188 else |
140 break; |
189 break; |
184 teamfile.setValue(hh + "Kills", m_hedgehogs[i].Kills); |
233 teamfile.setValue(hh + "Kills", m_hedgehogs[i].Kills); |
185 teamfile.setValue(hh + "Deaths", m_hedgehogs[i].Deaths); |
234 teamfile.setValue(hh + "Deaths", m_hedgehogs[i].Deaths); |
186 teamfile.setValue(hh + "Suicides", m_hedgehogs[i].Suicides); |
235 teamfile.setValue(hh + "Suicides", m_hedgehogs[i].Suicides); |
187 } |
236 } |
188 for(int i = 0; i < BINDS_NUMBER; i++) |
237 for(int i = 0; i < BINDS_NUMBER; i++) |
189 teamfile.setValue(QString("Binds/%1").arg(binds[i].action), binds[i].strbind); |
238 teamfile.setValue(QString("Binds/%1").arg(m_binds[i].action), m_binds[i].strbind); |
190 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
239 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
191 if(achievements[i][0][0]) |
240 if(achievements[i][0][0]) |
192 teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]); |
241 teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]); |
193 else |
242 else |
194 break; |
243 break; |
195 return true; |
244 return true; |
196 } |
245 } |
197 |
246 |
198 void HWTeam::SetToPage(HWForm * hwform) |
|
199 { |
|
200 hwform->ui.pageEditTeam->TeamNameEdit->setText(m_name); |
|
201 hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(m_difficulty); |
|
202 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
|
203 { |
|
204 hwform->ui.pageEditTeam->HHNameEdit[i]->setText(m_hedgehogs[i].Name); |
|
205 if (m_hedgehogs[i].Hat.startsWith("Reserved")) |
|
206 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData("Reserved "+m_hedgehogs[i].Hat.remove(0,40), Qt::DisplayRole)); |
|
207 else |
|
208 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(m_hedgehogs[i].Hat, Qt::DisplayRole)); |
|
209 } |
|
210 hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(m_grave)); |
|
211 hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findData(m_flag)); |
|
212 |
|
213 hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(m_fort)); |
|
214 hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(m_voicepack)); |
|
215 //hwform->ui.pageEditTeam->CBFort_activated(Fort); |
|
216 |
|
217 for(int i = 0; i < BINDS_NUMBER; i++) |
|
218 { |
|
219 hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findData(binds[i].strbind)); |
|
220 } |
|
221 } |
|
222 |
|
223 void HWTeam::GetFromPage(HWForm * hwform) |
|
224 { |
|
225 m_name = hwform->ui.pageEditTeam->TeamNameEdit->text(); |
|
226 m_difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex(); |
|
227 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
|
228 { |
|
229 m_hedgehogs[i].Name = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); |
|
230 if (hwform->ui.pageEditTeam->HHHats[i]->currentText().startsWith("Reserved")) |
|
231 m_hedgehogs[i].Hat = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9); |
|
232 else |
|
233 m_hedgehogs[i].Hat = hwform->ui.pageEditTeam->HHHats[i]->currentText(); |
|
234 } |
|
235 |
|
236 m_grave = hwform->ui.pageEditTeam->CBGrave->currentText(); |
|
237 m_fort = hwform->ui.pageEditTeam->CBFort->currentText(); |
|
238 m_voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText(); |
|
239 m_flag = hwform->ui.pageEditTeam->CBFlag->itemData(hwform->ui.pageEditTeam->CBFlag->currentIndex()).toString(); |
|
240 for(int i = 0; i < BINDS_NUMBER; i++) |
|
241 { |
|
242 binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString(); |
|
243 } |
|
244 } |
|
245 |
|
246 QStringList HWTeam::teamGameConfig(quint32 InitHealth) const |
247 QStringList HWTeam::teamGameConfig(quint32 InitHealth) const |
247 { |
248 { |
248 QStringList sl; |
249 QStringList sl; |
249 if (m_isNetTeam) |
250 if (m_isNetTeam) |
250 { |
251 { |
258 sl.push_back(QString("evoicepack " + m_voicepack)); |
259 sl.push_back(QString("evoicepack " + m_voicepack)); |
259 sl.push_back(QString("eflag " + m_flag)); |
260 sl.push_back(QString("eflag " + m_flag)); |
260 |
261 |
261 if (!m_isNetTeam) |
262 if (!m_isNetTeam) |
262 for(int i = 0; i < BINDS_NUMBER; i++) |
263 for(int i = 0; i < BINDS_NUMBER; i++) |
263 if(!binds[i].strbind.isEmpty()) |
264 if(!m_binds[i].strbind.isEmpty()) |
264 sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action)); |
265 sl.push_back(QString("ebind " + m_binds[i].strbind + " " + m_binds[i].action)); |
265 |
266 |
266 for (int t = 0; t < m_numHedgehogs; t++) |
267 for (int t = 0; t < m_numHedgehogs; t++) |
267 { |
268 { |
268 sl.push_back(QString("eaddhh %1 %2 %3") |
269 sl.push_back(QString("eaddhh %1 %2 %3") |
269 .arg(QString::number(m_difficulty), |
270 .arg(QString::number(m_difficulty), |