Display style name correctly if host selects a style you don't have
authorWuzzy <Wuzzy2@mail.ru>
Thu, 22 Mar 2018 13:18:45 +0100
changeset 13268 0f7623f722dc
parent 13267 2877c1ec5877
child 13269 ad6c8069fe1a
Display style name correctly if host selects a style you don't have
ChangeLog.txt
QTfrontend/ui/widget/gamecfgwidget.cpp
QTfrontend/ui/widget/gamecfgwidget.h
--- a/ChangeLog.txt	Thu Mar 22 00:17:13 2018 +0100
+++ b/ChangeLog.txt	Thu Mar 22 13:18:45 2018 +0100
@@ -23,6 +23,7 @@
  + Schemes are now stored in separate files under Schemes
  + Add default directory DrawnMaps for hand-drawn maps
  + Lead player to training missions when starting Hedgewars the first time
+ * Fix map preview, map name, style name not being displayed if host selects map or style you don't have
  * Remove “Upload to YouTube” functionality (it was broken for years)
  * Fix broken preview of team hats (e.g. cap_team)
  * Fix chart in stats screen not supporting negative numbers
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Thu Mar 22 00:17:13 2018 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Thu Mar 22 13:18:45 2018 +0100
@@ -112,9 +112,13 @@
     Scripts = new QComboBox(this);
     Scripts->setMaxVisibleItems(30);
     GBoxOptionsLayout->addWidget(Scripts, 1, 1);
-
     Scripts->setModel(DataManager::instance().gameStyleModel());
     m_curScript = Scripts->currentText();
+
+    ScriptsLabel = new QLabel(this);
+    ScriptsLabel->setHidden(true);
+    GBoxOptionsLayout->addWidget(ScriptsLabel, 1, 1);
+
     connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int)));
 
     QWidget *SchemeWidget = new QWidget(this);
@@ -126,6 +130,11 @@
     GameSchemes = new QComboBox(SchemeWidget);
     GameSchemes->setMaxVisibleItems(30);
     SchemeWidgetLayout->addWidget(GameSchemes, 0, 2);
+
+    GameSchemesLabel = new QLabel(SchemeWidget);
+    GameSchemesLabel->setHidden(true);
+    SchemeWidgetLayout->addWidget(GameSchemesLabel, 0, 2);
+
     connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int)));
 
     lblScheme = new QLabel(QLabel::tr("Scheme"), SchemeWidget);
@@ -149,6 +158,10 @@
     WeaponsName->setMaxVisibleItems(30);
     SchemeWidgetLayout->addWidget(WeaponsName, 1, 2);
 
+    WeaponsNameLabel = new QLabel(SchemeWidget);
+    WeaponsNameLabel->setHidden(true);
+    SchemeWidgetLayout->addWidget(WeaponsNameLabel, 1, 2);
+
     connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
 
     goToWeaponPage = new QPushButton(SchemeWidget);
@@ -470,7 +483,9 @@
         }
         if (param == "SCRIPT")
         {
-            Scripts->setCurrentIndex(Scripts->findText(value));
+            int in = Scripts->findText(value);
+            Scripts->setCurrentIndex(in);
+            ScriptsLabel->setText(value);
             pMapContainer->setScript(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString().toUtf8(), schemeData(43).toString());
             return;
         }
@@ -515,11 +530,16 @@
 {
     if (index >= 0)
     {
+        WeaponsNameLabel->setText(WeaponsName->currentText());
         emit paramChanged(
             "AMMO",
             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
         );
     }
+    else
+    {
+        WeaponsNameLabel->setText("");
+    }
 }
 
 void GameCFGWidget::mapChanged(const QString & value)
@@ -632,6 +652,12 @@
             }
         }
     }
+
+    if(index == -1)
+        GameSchemesLabel->setText("");
+    else
+        GameSchemesLabel->setText(GameSchemes->currentText());
+
     pMapContainer->setScript(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString().toUtf8(), schemeData(43).toString());
 }
 
@@ -698,14 +724,18 @@
         lblWeapons->setEnabled(true);
         bindEntries->setEnabled(true);
     }
-    if (!index)
+    if (index == -1)
     {
         pMapContainer->setScript(QString(""), QString(""));
+        ScriptsLabel->setStyleSheet("color: #b50000;");
     }
     else
     {
         pMapContainer->setScript(Scripts->itemData(index, GameStyleModel::ScriptRole).toString().toUtf8(), schemeData(43).toString());
+        ScriptsLabel->setText(Scripts->currentText());
+        ScriptsLabel->setStyleSheet("");
     }
+
     emit paramChanged("SCRIPT", QStringList(name));
 }
 
@@ -763,8 +793,28 @@
     if (master == m_master) return;
     m_master = master;
 
+    if (master)
+    {
+        // Reset script if not found
+        if (Scripts->currentIndex() == -1)
+        {
+            Scripts->setCurrentIndex(Scripts->findText("Normal"));
+        }
+    }
+
     pMapContainer->setMaster(master);
 
+    GameSchemes->setHidden(!master);
+    WeaponsName->setHidden(!master);
+    Scripts->setHidden(!master);
+    goToSchemePage->setHidden(!master);
+    goToWeaponPage->setHidden(!master);
+    bindEntries->setHidden(!master);
+
+    GameSchemesLabel->setHidden(master);
+    WeaponsNameLabel->setHidden(master);
+    ScriptsLabel->setHidden(master);
+
     foreach (QWidget *widget, m_childWidgets)
         widget->setEnabled(master);
 }
--- a/QTfrontend/ui/widget/gamecfgwidget.h	Thu Mar 22 00:17:13 2018 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.h	Thu Mar 22 13:18:45 2018 +0100
@@ -49,6 +49,9 @@
         QComboBox * WeaponsName;
         QPushButton * goToSchemePage;
         QPushButton * goToWeaponPage;
+        QLabel * ScriptsLabel;
+        QLabel * GameSchemesLabel;
+        QLabel * WeaponsNameLabel;
         HWMapContainer* pMapContainer;
         QVariant schemeData(int column) const;
         bool isMaster();