diff -r 32a546d1eb3e -r 436045756181 QTfrontend/selectWeapon.cpp --- a/QTfrontend/selectWeapon.cpp Mon Jan 07 15:44:13 2008 +0000 +++ b/QTfrontend/selectWeapon.cpp Tue Jan 08 20:32:17 2008 +0000 @@ -25,6 +25,8 @@ #include #include #include +#include +#include QImage getAmmoImage(int num) { @@ -70,6 +72,11 @@ m_numItems(numItems), QWidget(parent) { + wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this); + if (wconf->allKeys().empty()) { + wconf->setValue("Default", cDefaultAmmoStore->mid(10)); + } + currentState=cDefaultAmmoStore->mid(10); pLayout=new QGridLayout(this); @@ -77,16 +84,20 @@ pLayout->setMargin(1); int j=-1; - for(int i=0, k=0; iaddWidget(weaponItems[i], j, k%4); ++k; } + + m_name = new QLineEdit(this); + pLayout->addWidget(m_name, i, 0, 1, 4); } -void SelWeaponWidget::setWeapons(QString ammo) +void SelWeaponWidget::setWeapons(const QString& ammo) { for(int i=0; itext()=="") return; currentState=""; for(int i=0; isetValue(m_name->text(), currentState); } int SelWeaponWidget::operator [] (unsigned int weaponIndex) const @@ -121,3 +134,18 @@ { return currentState; } + +void SelWeaponWidget::setWeaponsName(const QString& name) +{ + if(name!="" && wconf->contains(name)) { + setWeapons(wconf->value(name).toString()); + } + + curWeaponsName=name; + m_name->setText(name); +} + +QStringList SelWeaponWidget::getWeaponNames() const +{ + return wconf->allKeys(); +}