143 { |
143 { |
144 QHBoxLayout * hbox = new QHBoxLayout(); |
144 QHBoxLayout * hbox = new QHBoxLayout(); |
145 CBVoicepack = new QComboBox(GBoxTeam); |
145 CBVoicepack = new QComboBox(GBoxTeam); |
146 { |
146 { |
147 QDir tmpdir; |
147 QDir tmpdir; |
|
148 tmpdir.cd(cfgdir->absolutePath()); |
|
149 tmpdir.cd("Data/Sounds/voices"); |
|
150 QStringList list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
|
151 CBVoicepack->addItems(list); |
|
152 |
148 tmpdir.cd(datadir->absolutePath()); |
153 tmpdir.cd(datadir->absolutePath()); |
149 tmpdir.cd("Sounds/voices"); |
154 tmpdir.cd("Sounds/voices"); |
150 QStringList list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
155 QStringList tmplist = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
151 CBVoicepack->addItems(list); |
156 QStringList tmplist2; |
|
157 for (QStringList::Iterator it = tmplist.begin(); it != tmplist.end(); ++it) |
|
158 if (!list.contains(*it,Qt::CaseInsensitive)) tmplist2.append(*it); |
|
159 |
|
160 CBVoicepack->addItems(tmplist2); |
152 } |
161 } |
153 hbox->addWidget(CBVoicepack, 100); |
162 hbox->addWidget(CBVoicepack, 100); |
154 BtnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); |
163 BtnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); |
155 hbox->setStretchFactor(BtnTestSound, 1); |
164 hbox->setStretchFactor(BtnTestSound, 1); |
156 connect(BtnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); |
165 connect(BtnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); |
171 //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true); |
180 //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true); |
172 GBFLayout->addWidget(FortPreview, 1, 0); |
181 GBFLayout->addWidget(FortPreview, 1, 0); |
173 vbox2->addWidget(GBoxFort); |
182 vbox2->addWidget(GBoxFort); |
174 |
183 |
175 QDir tmpdir; |
184 QDir tmpdir; |
|
185 tmpdir.cd(cfgdir->absolutePath()); |
|
186 tmpdir.cd("Data/Forts"); |
|
187 tmpdir.setFilter(QDir::Files); |
|
188 |
|
189 QStringList userforts = tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"); |
|
190 CBFort->addItems(userforts); |
|
191 |
|
192 tmpdir.cd("../Graphics/Graves"); |
|
193 QStringList userlist = tmpdir.entryList(QStringList("*.png")); |
|
194 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
195 { |
|
196 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Graves/" + *it); |
|
197 QIcon icon(pix.copy(0, 0, 32, 32)); |
|
198 CBGrave->addItem(icon, QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
199 } |
|
200 |
176 tmpdir.cd(datadir->absolutePath()); |
201 tmpdir.cd(datadir->absolutePath()); |
177 tmpdir.cd("Forts"); |
202 tmpdir.cd("Forts"); |
178 tmpdir.setFilter(QDir::Files); |
203 tmpdir.setFilter(QDir::Files); |
179 |
204 |
|
205 QStringList tmplist = tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"); |
|
206 QStringList dataforts; |
|
207 for (QStringList::Iterator it = tmplist.begin(); it != tmplist.end(); ++it) |
|
208 if (!userforts.contains(*it,Qt::CaseInsensitive)) dataforts.append(*it); |
|
209 |
|
210 CBVoicepack->addItems(dataforts); |
180 connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
211 connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
181 CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
|
182 |
212 |
183 tmpdir.cd("../Graphics/Graves"); |
213 tmpdir.cd("../Graphics/Graves"); |
184 QStringList list = tmpdir.entryList(QStringList("*.png")); |
214 QStringList datalist = tmpdir.entryList(QStringList("*.png")); |
185 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
215 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
186 { |
216 { |
|
217 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
187 QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); |
218 QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); |
188 QIcon icon(pix.copy(0, 0, 32, 32)); |
219 QIcon icon(pix.copy(0, 0, 32, 32)); |
189 CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
220 CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
190 } |
221 } |
191 |
222 |
|
223 // add the default flag |
|
224 CBFlag->addItem(QIcon(QPixmap(datadir->absolutePath() + "/Graphics/Flags/hedgewars.png").copy(0, 0, 22, 15)), "Hedgewars", "hedgewars"); |
|
225 CBFlag->insertSeparator(CBFlag->count()); |
|
226 |
|
227 tmpdir.cd(cfgdir->absolutePath()); |
|
228 tmpdir.cd("Data/Graphics/Flags"); |
|
229 userlist = tmpdir.entryList(QStringList("*.png")); |
|
230 |
|
231 // add all country flags |
|
232 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
233 { |
|
234 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Flags/" + *it); |
|
235 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
236 if(it->compare("cpu.png") && it->compare("hedgewars.png") && (it->indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
|
237 { |
|
238 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
239 CBFlag->addItem(icon, QString(flag).replace("_", " "), flag); |
|
240 } |
|
241 } |
|
242 |
|
243 CBFlag->insertSeparator(CBFlag->count()); |
|
244 |
|
245 // add all community flags |
|
246 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
247 { |
|
248 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Flags/" + *it); |
|
249 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
250 if(it->indexOf("cm_") > -1) // skip non community flags this time |
|
251 { |
|
252 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
253 CBFlag->addItem(icon, QString(flag).replace("cm_", QComboBox::tr("Community") + ": "), flag); |
|
254 } |
|
255 } |
|
256 |
|
257 CBFlag->insertSeparator(CBFlag->count()); |
|
258 |
192 tmpdir.cd(datadir->absolutePath()); |
259 tmpdir.cd(datadir->absolutePath()); |
193 tmpdir.cd("Graphics/Flags"); |
260 tmpdir.cd("Graphics/Flags"); |
194 list = tmpdir.entryList(QStringList("*.png")); |
261 datalist = tmpdir.entryList(QStringList("*.png")); |
195 |
262 |
196 // add the default flag |
|
197 CBFlag->addItem(QIcon(QPixmap(datadir->absolutePath() + "/Graphics/Flags/hedgewars.png").copy(0, 0, 22, 15)), "Hedgewars", "hedgewars"); |
|
198 |
|
199 CBFlag->insertSeparator(CBFlag->count()); |
|
200 // add all country flags |
263 // add all country flags |
201 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
264 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
202 { |
265 { |
|
266 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
203 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
267 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
204 QIcon icon(pix.copy(0, 0, 22, 15)); |
268 QIcon icon(pix.copy(0, 0, 22, 15)); |
205 if(it->compare("cpu.png") && it->compare("hedgewars.png") && (it->indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
269 if(it->compare("cpu.png") && it->compare("hedgewars.png") && (it->indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
206 { |
270 { |
207 QString flag = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
271 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
208 CBFlag->addItem(icon, QString(flag).replace("_", " "), flag); |
272 CBFlag->addItem(icon, QString(flag).replace("_", " "), flag); |
209 } |
273 } |
210 } |
274 } |
|
275 |
211 CBFlag->insertSeparator(CBFlag->count()); |
276 CBFlag->insertSeparator(CBFlag->count()); |
|
277 |
212 // add all community flags |
278 // add all community flags |
213 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
279 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
214 { |
280 { |
|
281 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
215 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
282 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
216 QIcon icon(pix.copy(0, 0, 22, 15)); |
283 QIcon icon(pix.copy(0, 0, 22, 15)); |
217 if(it->indexOf("cm_") > -1) // skip non community flags this time |
284 if(it->indexOf("cm_") > -1) // skip non community flags this time |
218 { |
285 { |
219 QString flag = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
286 QString flag = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
270 } |
337 } |
271 } |
338 } |
272 |
339 |
273 void PageEditTeam::CBFort_activated(const QString & fortname) |
340 void PageEditTeam::CBFort_activated(const QString & fortname) |
274 { |
341 { |
275 QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); |
342 QFile tmp; |
|
343 tmp.setFileName(cfgdir->absolutePath() + "/Data/Forts/" + fortname + "L.png"); |
|
344 if (!tmp.exists()) tmp.setFileName(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); |
|
345 QPixmap pix(QFileInfo(tmp).absoluteFilePath()); |
276 FortPreview->setPixmap(pix); |
346 FortPreview->setPixmap(pix); |
277 } |
347 } |
278 |
348 |
279 void PageEditTeam::testSound() |
349 void PageEditTeam::testSound() |
280 { |
350 { |
281 Mix_Chunk *sound; |
351 Mix_Chunk *sound; |
282 QDir tmpdir; |
352 QDir tmpdir; |
283 mySdli->SDLMusicInit(); |
353 mySdli->SDLMusicInit(); |
284 |
354 |
285 tmpdir.cd(datadir->absolutePath()); |
355 tmpdir.cd(cfgdir->absolutePath()); |
286 tmpdir.cd("Sounds/voices"); |
356 tmpdir.cd("Data/Sounds/voices"); |
287 tmpdir.cd(CBVoicepack->currentText()); |
357 tmpdir.cd(CBVoicepack->currentText()); |
|
358 |
|
359 if (!tmpdir.exists()) { |
|
360 tmpdir.cd(datadir->absolutePath()); |
|
361 tmpdir.cd("Sounds/voices"); |
|
362 tmpdir.cd(CBVoicepack->currentText()); |
|
363 } |
|
364 |
288 QStringList list = tmpdir.entryList(QStringList() << "Illgetyou.ogg" << "Incoming.ogg" << "Stupid.ogg" << "Coward.ogg" << "Firstblood.ogg", QDir::Files); |
365 QStringList list = tmpdir.entryList(QStringList() << "Illgetyou.ogg" << "Incoming.ogg" << "Stupid.ogg" << "Coward.ogg" << "Firstblood.ogg", QDir::Files); |
289 if (list.size()) { |
366 if (list.size()) { |
290 sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/" + list[rand() % list.size()]).toLocal8Bit().constData()); |
367 sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/" + list[rand() % list.size()]).toLocal8Bit().constData()); |
291 Mix_PlayChannel(-1, sound, 0); |
368 Mix_PlayChannel(-1, sound, 0); |
292 } |
369 } |