# HG changeset patch # User displacer # Date 1199824337 0 # Node ID 43604575618199cd8633c5ac6d3c83fee5e7800c # Parent 32a546d1eb3e69dceaf642214c7561e84126f5f2 working save weapons to file diff -r 32a546d1eb3e -r 436045756181 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Mon Jan 07 15:44:13 2008 +0000 +++ b/QTfrontend/hwform.cpp Tue Jan 08 20:32:17 2008 +0000 @@ -84,7 +84,8 @@ connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); + connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); + connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon())); connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); @@ -135,6 +136,10 @@ ui.pageOptions->CBTeamName->clear(); ui.pageOptions->CBTeamName->addItems(teamslist); + + // now updates weapons also + ui.pageOptions->WeaponsName->clear(); + ui.pageOptions->WeaponsName->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames()); } void HWForm::GoToMain() @@ -162,8 +167,15 @@ GoToPage(ID_PAGE_SETUP); } +void HWForm::GoToSelectNewWeapon() +{ + ui.pageSelectWeapon->pWeapons->setWeaponsName(""); + GoToPage(ID_PAGE_SELECTWEAPON); +} + void HWForm::GoToSelectWeapon() { + ui.pageSelectWeapon->pWeapons->setWeaponsName(ui.pageOptions->WeaponsName->currentText()); GoToPage(ID_PAGE_SELECTWEAPON); } diff -r 32a546d1eb3e -r 436045756181 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Mon Jan 07 15:44:13 2008 +0000 +++ b/QTfrontend/hwform.h Tue Jan 08 20:32:17 2008 +0000 @@ -54,6 +54,7 @@ void GoToSimpleGame(); void GoToTraining(); void GoToSelectWeapon(); + void GoToSelectNewWeapon(); void GoToNetServer(); void GoToPage(quint8 id); void GoBack(); 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(); +} diff -r 32a546d1eb3e -r 436045756181 QTfrontend/selectWeapon.h --- a/QTfrontend/selectWeapon.h Mon Jan 07 15:44:13 2008 +0000 +++ b/QTfrontend/selectWeapon.h Tue Jan 08 20:32:17 2008 +0000 @@ -24,6 +24,8 @@ class QGridLayout; class WeaponItem; +class QLineEdit; +class QSettings; class SelWeaponItem : public QWidget { @@ -46,14 +48,22 @@ public: SelWeaponWidget(int numItems, QWidget* parent=0); QString getWeaponsString() const; - void setWeapons(QString ammo); + QStringList getWeaponNames() const; public slots: void setDefault(); + void setWeapons(const QString& ammo); + void setWeaponsName(const QString& name); void save(); private: QString currentState; + QString curWeaponsName; + + QLineEdit* m_name; + + QSettings* wconf; + const int m_numItems; int operator [] (unsigned int weaponIndex) const;