Mark custom forts with asterisk in team editor
authorWuzzy <almikes@aol.com>
Tue, 10 Oct 2017 21:00:11 +0200
changeset 12689 5f68b259305c
parent 12688 047c5b7ec422
child 12690 ad1fd7ae479d
Mark custom forts with asterisk in team editor
ChangeLog.txt
QTfrontend/ui/page/pageeditteam.cpp
QTfrontend/ui/page/pageeditteam.h
--- a/ChangeLog.txt	Tue Oct 10 17:39:11 2017 +0200
+++ b/ChangeLog.txt	Tue Oct 10 21:00:11 2017 +0200
@@ -273,6 +273,7 @@
  + Allow to randomize hog names, hats, team name, flag, grave, voice and fort separately
  + “Random team” button is now able to randomly select from all available hats
  + Creating new game/weapon schemes guarantees unique names
+ + Mark custom forts with asterisk in team editor
  * Fix flag being selectable for computer players although it had no effect
  * Campaign screen does no longer show AI-controlled teams
  * Campaign names and campaign mission names can now be translated
--- a/QTfrontend/ui/page/pageeditteam.cpp	Tue Oct 10 17:39:11 2017 +0200
+++ b/QTfrontend/ui/page/pageeditteam.cpp	Tue Oct 10 21:00:11 2017 +0200
@@ -32,6 +32,7 @@
 #include "HWApplication.h"
 #include "keybinder.h"
 
+#include "physfs.h"
 #include "DataManager.h"
 #include "hatbutton.h"
 
@@ -277,7 +278,7 @@
 
     connect(btnTestSound, SIGNAL(clicked()), this, SLOT(testSound()));
 
-    connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &)));
+    connect(CBFort, SIGNAL(currentIndexChanged(const int)), this, SLOT(CBFort_activated(const int)));
 }
 
 PageEditTeam::PageEditTeam(QWidget* parent) :
@@ -314,8 +315,21 @@
 
     // forts
     list = dataMgr.entryList("Forts", QDir::Files, QStringList("*L.png"));
-    list.replaceInStrings(QRegExp("L\\.png$"), "");
-    CBFort->addItems(list);
+    foreach (QString file, list)
+    {
+        QString fortPath = PHYSFS_getRealDir(QString("Forts/%1").arg(file).toLocal8Bit().data());
+
+        QString fort = file.replace(QRegExp("L\\.png$"), "");
+        QString fortDisplay;
+
+        bool isDLC = !fortPath.startsWith(datadir->absolutePath());
+        if (isDLC)
+            fortDisplay = "*" + fort;
+        else
+            fortDisplay = fort;
+
+        CBFort->addItem(fortDisplay, fort);
+    }
 
 
     // graves
@@ -389,9 +403,10 @@
         HHNameEdit[idx]->setText(QLineEdit::tr("hedgehog %1").arg(idx+1));
 }
 
-void PageEditTeam::CBFort_activated(const QString & fortname)
+void PageEditTeam::CBFort_activated(const int index)
 {
-    QPixmap pix("physfs://Forts/" + fortname + "L.png");
+    QString fortName = CBFort->itemData(index).toString();
+    QPixmap pix("physfs://Forts/" + fortName + "L.png");
     FortPreview->setPixmap(pix);
 }
 
@@ -559,7 +574,7 @@
     CBGrave->setCurrentIndex(CBGrave->findText(team.grave()));
     CBFlag->setCurrentIndex(CBFlag->findData(team.flag()));
 
-    CBFort->setCurrentIndex(CBFort->findText(team.fort()));
+    CBFort->setCurrentIndex(CBFort->findData(team.fort()));
     CBVoicepack->setCurrentIndex(CBVoicepack->findText(team.voicepack()));
 
     QStandardItemModel * binds = DataManager::instance().bindsModel();
@@ -595,7 +610,7 @@
     }
 
     team.setGrave(CBGrave->currentText());
-    team.setFort(CBFort->currentText());
+    team.setFort(CBFort->itemData(CBFort->currentIndex()).toString());
     team.setVoicepack(CBVoicepack->currentText());
     team.setFlag(CBFlag->itemData(CBFlag->currentIndex()).toString());
 
--- a/QTfrontend/ui/page/pageeditteam.h	Tue Oct 10 17:39:11 2017 +0200
+++ b/QTfrontend/ui/page/pageeditteam.h	Tue Oct 10 21:00:11 2017 +0200
@@ -44,7 +44,7 @@
 
     public slots:
         void CBTeamLvl_activated(const int index);
-        void CBFort_activated(const QString & gravename);
+        void CBFort_activated(const int index);
 
     private:
         QTabWidget * tbw;