by default selecting a game mode will select a weapon with the same name, and viceversa; toggable for every game
authorkoda
Thu, 11 Nov 2010 00:38:12 +0100
changeset 4237 ef9b201c97fe
parent 4236 fa2680cfff86
child 4238 6f1631765ebd
by default selecting a game mode will select a weapon with the same name, and viceversa; toggable for every game
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
QTfrontend/hwconsts.cpp.in
--- a/QTfrontend/gamecfgwidget.cpp	Wed Nov 10 19:43:13 2010 +0100
+++ b/QTfrontend/gamecfgwidget.cpp	Thu Nov 11 00:38:12 2010 +0100
@@ -78,6 +78,13 @@
 
     connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
 
+    GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Bind schemes and weapons"), GBoxOptions), 2, 0);
+
+    bindEntries = new QCheckBox(GBoxOptions);
+    bindEntries->setToolTip(tr("When this option is enabled selecting a game scheme will auto-select a weapon (and viceversa)"));
+    bindEntries->setChecked(true);
+    GBoxOptionsLayout->addWidget(bindEntries, 2, 2);
+
     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
     connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
     connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
@@ -263,11 +270,23 @@
 
 void GameCFGWidget::ammoChanged(int index)
 {
-    if (index >= 0)
+    if (index >= 0) {
         emit paramChanged(
             "AMMO",
             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
         );
+        if (bindEntries->isChecked() == true) {
+            QString weapName = WeaponsName->itemText(index);
+            for (int i = 0; i < GameSchemes->count(); i++) {
+                 QString schemeName = GameSchemes->itemText(i);
+                 int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
+                 if (0 == res) {
+                     GameSchemes->setCurrentIndex(i);
+                     break;
+                 }
+            }
+        }
+    }
 }
 
 void GameCFGWidget::mapChanged(const QString & value)
@@ -276,6 +295,7 @@
     {
         GameSchemes->setEnabled(false);
         WeaponsName->setEnabled(false);
+        bindEntries->setEnabled(false);
         GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
         WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
     }
@@ -283,6 +303,7 @@
     {
         GameSchemes->setEnabled(true);
         WeaponsName->setEnabled(true);
+        bindEntries->setEnabled(true);
     }
     emit paramChanged("MAP", QStringList(value));
 }
@@ -302,7 +323,7 @@
     emit paramChanged("THEME", QStringList(value));
 }
 
-void GameCFGWidget::schemeChanged(int value)
+void GameCFGWidget::schemeChanged(int index)
 {
     QStringList sl;
 
@@ -311,6 +332,18 @@
         sl << schemeData(i).toString();
 
     emit paramChanged("SCHEME", sl);
+
+    if (bindEntries->isChecked() == true) {
+        QString schemeName = GameSchemes->itemText(index);
+        for (int i = 0; i < WeaponsName->count(); i++) {
+             QString weapName = WeaponsName->itemText(i);
+             int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
+             if (0 == res) {
+                 WeaponsName->setCurrentIndex(i);
+                 break;
+             }
+        }
+    }
 }
 
 void GameCFGWidget::mapgenChanged(MapGenerator m)
--- a/QTfrontend/gamecfgwidget.h	Wed Nov 10 19:43:13 2010 +0100
+++ b/QTfrontend/gamecfgwidget.h	Thu Nov 11 00:38:12 2010 +0100
@@ -68,7 +68,7 @@
 
 private:
     QGridLayout mainLayout;
-
+    QCheckBox * bindEntries;
     QString curNetAmmoName;
     QString curNetAmmo;
 
--- a/QTfrontend/hwconsts.cpp.in	Wed Nov 10 19:43:13 2010 +0100
+++ b/QTfrontend/hwconsts.cpp.in	Thu Nov 11 00:38:12 2010 +0100
@@ -53,7 +53,7 @@
         "0000000000000000000000000000000000000000000000000"
         "1311110312111111123114111111111111111211110101111"
         ))
-        << qMakePair(QString("Pro mode"),  QString(
+        << qMakePair(QString("Pro Mode"),  QString(
         "9090009000000000000009000000000000000000000000000"
         "0000000000000000000000000000000000000000000000000"
         "0000000000000205500000040007004000000000200000000"