adding a combobox to weapon editor as scheme editor, added a few notices for deleting and some buttons in this area.
authorHenek
Mon, 22 Nov 2010 22:05:46 +0100
changeset 4416 29d2d1548387
parent 4415 941251bad467
child 4417 6bf00d99fc47
adding a combobox to weapon editor as scheme editor, added a few notices for deleting and some buttons in this area.
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/itemNum.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/selectWeapon.cpp
QTfrontend/selectWeapon.h
--- a/QTfrontend/gamecfgwidget.cpp	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/gamecfgwidget.cpp	Mon Nov 22 22:05:46 2010 +0100
@@ -103,7 +103,7 @@
 
 void GameCFGWidget::jumpToWeapons()
 {
-    emit goToWeapons(WeaponsName->currentText());
+    emit goToWeapons(WeaponsName->currentIndex());
 }
 
 QVariant GameCFGWidget::schemeData(int column) const
--- a/QTfrontend/gamecfgwidget.h	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/gamecfgwidget.h	Mon Nov 22 22:05:46 2010 +0100
@@ -54,7 +54,7 @@
 signals:
     void paramChanged(const QString & param, const QStringList & value);
     void goToSchemes(int);
-    void goToWeapons(const QString & name);
+    void goToWeapons(int);
 
 private slots:
     void ammoChanged(int index);
--- a/QTfrontend/hwform.cpp	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/hwform.cpp	Mon Nov 22 22:05:46 2010 +0100
@@ -129,7 +129,7 @@
         ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool)));
     connect(ui.pageMultiplayer, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup()));
     connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int)));
-    connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &)));
+    connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int)));
 
     connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
     connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo()));
@@ -147,8 +147,10 @@
 
     connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon()));
     connect(ui.pageOptions->WeaponNew, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon()));
+    connect(ui.pageOptions->WeaponDelete, SIGNAL(clicked()), this, SLOT(DeleteWeaponSet()));
     connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme()));
     connect(ui.pageOptions->SchemeNew, SIGNAL(clicked()), this, SLOT(GoToNewScheme()));
+    connect(ui.pageOptions->SchemeDelete, SIGNAL(clicked()), this, SLOT(DeleteScheme()));
     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons()));
 
     connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
@@ -166,7 +168,7 @@
         ui.pageNetGame->BtnStart, SLOT(setEnabled(bool)));
     connect(ui.pageNetGame, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup()));
     connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int)));
-    connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &)));
+    connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int)));
 
     connect(ui.pageRoomsList->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
     connect(ui.pageRoomsList->BtnAdmin, SIGNAL(clicked()), this, SLOT(GoToAdmin()));
@@ -196,8 +198,8 @@
         ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first
     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()),
         this, SLOT(UpdateWeapons())); // executed second
-    connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()),
-        this, SLOT(GoBack())); // executed third
+    //connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()),
+    //    this, SLOT(GoBack())); // executed third
 
     connect(ui.pageScheme->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
 
@@ -302,6 +304,7 @@
     combos.push_back(ui.pageOptions->WeaponsName);
     combos.push_back(ui.pageMultiplayer->gameCFG->WeaponsName);
     combos.push_back(ui.pageNetGame->pGameCFG->WeaponsName);
+    combos.push_back(ui.pageSelectWeapon->selectWeaponSet);
 
     QStringList names = ui.pageSelectWeapon->pWeapons->getWeaponNames();
 
@@ -366,19 +369,19 @@
 
 void HWForm::GoToSelectNewWeapon()
 {
-    ui.pageSelectWeapon->pWeapons->setWeaponsName(tr("new"));
+    ui.pageSelectWeapon->pWeapons->newWeaponsName();
     GoToPage(ID_PAGE_SELECTWEAPON);
 }
 
 void HWForm::GoToSelectWeapon()
 {
-    ui.pageSelectWeapon->pWeapons->setWeaponsName(ui.pageOptions->WeaponsName->currentText());
+    ui.pageSelectWeapon->selectWeaponSet->setCurrentIndex(ui.pageOptions->WeaponsName->currentIndex());
     GoToPage(ID_PAGE_SELECTWEAPON);
 }
 
-void HWForm::GoToSelectWeaponSet(const QString & name)
+void HWForm::GoToSelectWeaponSet(int index)
 {
-    ui.pageSelectWeapon->pWeapons->setWeaponsName(name);
+    ui.pageSelectWeapon->selectWeaponSet->setCurrentIndex(index);
     GoToPage(ID_PAGE_SELECTWEAPON);
 }
 
@@ -605,11 +608,15 @@
 
 void HWForm::DeleteTeam()
 {
-    editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText());
-    editedTeam->DeleteFile();
+    QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel);
 
-    // Remove from lists
-    ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex());
+    if (reallyDelete.exec() == QMessageBox::Ok) {
+        editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText());
+        editedTeam->DeleteFile();
+
+        // Remove from lists
+        ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex());
+    }
 }
 
 void HWForm::RandomNames()
@@ -643,6 +650,22 @@
     GoBack();
 }
 
+void HWForm::DeleteScheme()
+{
+    ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex());
+    if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) {
+        QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Can not delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText()));
+    } else {
+        ui.pageScheme->deleteRow();
+    }
+}
+
+void HWForm::DeleteWeaponSet()
+{
+    ui.pageSelectWeapon->selectWeaponSet->setCurrentIndex(ui.pageOptions->WeaponsName->currentIndex());
+    ui.pageSelectWeapon->pWeapons->deleteWeaponsName();
+}
+
 void HWForm::SimpleGame()
 {
     CreateGame(0, 0, *cDefaultAmmoStore);
--- a/QTfrontend/hwform.h	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/hwform.h	Mon Nov 22 22:05:46 2010 +0100
@@ -71,7 +71,7 @@
     void GoToTraining();
     void GoToCampaign();
     void GoToSelectWeapon();
-    void GoToSelectWeaponSet(const QString & name);
+    void GoToSelectWeaponSet(int index);
     void GoToSelectNewWeapon();
     void GoToNetServer();
     void GoToScheme(int index);
@@ -91,6 +91,8 @@
     void RandomName(const int &i);
     void TeamSave();
     void TeamDiscard();
+    void DeleteScheme();
+    void DeleteWeaponSet();
     void SimpleGame();
     void PlayDemo();
     void StartTraining();
--- a/QTfrontend/itemNum.cpp	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/itemNum.cpp	Mon Nov 22 22:05:46 2010 +0100
@@ -108,4 +108,5 @@
 void ItemNum::setEnabled(bool value)
 {
   enabled=value;
+  repaint();
 }
--- a/QTfrontend/pages.cpp	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/pages.cpp	Mon Nov 22 22:05:46 2010 +0100
@@ -563,7 +563,6 @@
             SchemeDelete->setIcon(pmDelete);
             SchemeDelete->setMaximumWidth(pmDelete.width() + 6);
             SchemeDelete->setEnabled(false);
-            SchemeDelete->setVisible(false); // hide for now
             WeaponsLayout->addWidget(SchemeDelete, 1, 4);
 
             QLabel* WeaponLabel = new QLabel(groupWeapons);
@@ -592,8 +591,6 @@
             WeaponDelete->setIconSize(pmDelete.size());
             WeaponDelete->setIcon(pmDelete);
             WeaponDelete->setMaximumWidth(pmDelete.width() + 6);
-            WeaponDelete->setEnabled(false);
-            WeaponDelete->setVisible(false); // hide for now
             WeaponsLayout->addWidget(WeaponDelete, 2, 4);
 
             WeaponTooltip = new QCheckBox(this);
@@ -1106,18 +1103,24 @@
     QGridLayout * pageLayout = new QGridLayout(this);
 
     pWeapons = new SelWeaponWidget(cAmmoNumber, this);
-    pageLayout->addWidget(pWeapons, 0, 0, 1, 4);
+    pageLayout->addWidget(pWeapons, 0, 0, 1, 6);
 
     BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
-    BtnDefault = addButton(tr("Default"), pageLayout, 1, 1);
-    BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2);
-    BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true);
+    BtnDefault = addButton(tr("Default"), pageLayout, 1, 2);
+    BtnNew = addButton(tr("New"), pageLayout, 1, 3);
+    BtnDelete = addButton(tr("Delete"), pageLayout, 1, 4);
+    BtnSave = addButton(":/res/Save.png", pageLayout, 1, 5, true);
     BtnSave->setStyleSheet("QPushButton{margin: 24px 0px 0px 0px;}");
     BtnBack->setFixedHeight(BtnSave->height());
     BtnBack->setStyleSheet("QPushButton{margin-top: 31px;}");
 
+    selectWeaponSet = new QComboBox(this);
+    pageLayout->addWidget(selectWeaponSet, 1, 1);
+
     connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault()));
     connect(BtnSave, SIGNAL(clicked()), pWeapons, SLOT(save()));
+    connect(BtnNew, SIGNAL(clicked()), pWeapons, SLOT(newWeaponsName()));
+    connect(selectWeaponSet, SIGNAL(currentIndexChanged(const QString&)), pWeapons, SLOT(setWeaponsName(const QString&)));
 }
 
 PageInGame::PageInGame(QWidget* parent) :
@@ -1893,8 +1896,12 @@
 
 void PageScheme::deleteRow()
 {
-    QAbstractItemModel * model = mapper->model();
-    model->removeRow(selectScheme->currentIndex());
+    QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel);
+
+    if (reallyDelete.exec() == QMessageBox::Ok) {
+        QAbstractItemModel * model = mapper->model();
+        model->removeRow(selectScheme->currentIndex());
+    }
 }
 
 void PageScheme::schemeSelected(int n)
--- a/QTfrontend/pages.h	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/pages.h	Mon Nov 22 22:05:46 2010 +0100
@@ -390,8 +390,10 @@
     QPushButton *BtnSave;
     QPushButton *BtnDefault;
     QPushButton *BtnDelete;
+    QPushButton *BtnNew;
     QPushButton *BtnBack;
     SelWeaponWidget* pWeapons;
+    QComboBox* selectWeaponSet;
 };
 
 class PageInGame : public AbstractPage
--- a/QTfrontend/selectWeapon.cpp	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/selectWeapon.cpp	Mon Nov 22 22:05:46 2010 +0100
@@ -247,6 +247,11 @@
     }
 }
 
+void SelWeaponWidget::newWeaponsName()
+{
+    setWeaponsName(tr("new"));
+}
+
 void SelWeaponWidget::setWeaponsName(const QString& name)
 {
     m_name->setText(name);
@@ -255,6 +260,8 @@
 
     if(name != "" && wconf->contains(name)) {
         setWeapons(wconf->value(name).toString());
+    } else {
+        setWeapons(*cDefaultAmmoStore);
     }
 }
 
--- a/QTfrontend/selectWeapon.h	Mon Nov 22 21:57:45 2010 +0300
+++ b/QTfrontend/selectWeapon.h	Mon Nov 22 22:05:46 2010 +0100
@@ -57,6 +57,7 @@
   void setWeapons(const QString& ammo);
   void setWeaponsName(const QString& name);
   void deleteWeaponsName();
+  void newWeaponsName();
   void save();
 
  signals: