"Default" weapon is now default :)
authordisplacer
Sat, 12 Jan 2008 17:17:09 +0000
changeset 702 97858a6682bb
parent 701 8841f71b5e79
child 703 424297e3165a
"Default" weapon is now default :)
QTfrontend/hwform.cpp
--- a/QTfrontend/hwform.cpp	Fri Jan 11 23:37:23 2008 +0000
+++ b/QTfrontend/hwform.cpp	Sat Jan 12 17:17:09 2008 +0000
@@ -125,14 +125,20 @@
 
 void HWForm::UpdateWeapons()
 {
-  ui.pageOptions->WeaponsName->clear();
-  ui.pageOptions->WeaponsName->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
+  // FIXME: rewrite this with boost (or TR1/0x)
+  QVector<QComboBox*> combos;
+  combos.push_back(ui.pageOptions->WeaponsName);
+  combos.push_back(ui.pageMultiplayer->gameCFG->WeaponsName);
+  combos.push_back(ui.pageNetGame->pGameCFG->WeaponsName);
 
-  ui.pageMultiplayer->gameCFG->WeaponsName->clear();
-  ui.pageMultiplayer->gameCFG->WeaponsName->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
-
-  ui.pageNetGame->pGameCFG->WeaponsName->clear();
-  ui.pageNetGame->pGameCFG->WeaponsName->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
+  for(QVector<QComboBox*>::iterator it=combos.begin(); it!=combos.end(); ++it) {
+    (*it)->clear();
+    (*it)->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
+    int pos=(*it)->findText("Default");
+    if (pos!=-1) {
+      (*it)->setCurrentIndex(pos);
+    }
+  }
 }
 
 void HWForm::NetWeaponNameChanged(const QString& name)