Frontend:
authorsmxx
Wed, 17 Mar 2010 10:48:00 +0000
changeset 3008 e57cafce4227
parent 3007 489ae87cdf9b
child 3009 8f4e6de8e4ef
Frontend: * Map selection detects maps with scripts as missions * Disabled scheme selection for missions
QTfrontend/gamecfgwidget.cpp
QTfrontend/mapContainer.cpp
QTfrontend/mapContainer.h
--- a/QTfrontend/gamecfgwidget.cpp	Wed Mar 17 01:03:22 2010 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Wed Mar 17 10:48:00 2010 +0000
@@ -160,12 +160,10 @@
     if (currentMap.size() > 0)
     {
         sl.append("emap " + currentMap);
-        QFile mapLuaFile(
-                QString("%1/Maps/%2/map.lua")
+        if(pMapContainer->getCurrentIsMission())
+            sl.append(QString("escript %1/Maps/%2/map.lua")
                 .arg(datadir->absolutePath())
                 .arg(currentMap));
-        if(mapLuaFile.exists())
-            sl.append(QString("escript %1").arg(mapLuaFile.fileName()));
     }
     sl.append("etheme " + pMapContainer->getCurrentTheme());
     return sl;
@@ -248,6 +246,18 @@
 
 void GameCFGWidget::mapChanged(const QString & value)
 {
+    if(pMapContainer->getCurrentIsMission())
+    {
+        GameSchemes->setCurrentIndex(0);
+        WeaponsName->setCurrentIndex(0);
+        GameSchemes->setEnabled(false);
+        WeaponsName->setEnabled(false);
+    }
+    else
+    {
+        GameSchemes->setEnabled(true);
+        WeaponsName->setEnabled(true);
+    }
     emit paramChanged("MAP", QStringList(value));
 }
 
--- a/QTfrontend/mapContainer.cpp	Wed Mar 17 01:03:22 2010 +0000
+++ b/QTfrontend/mapContainer.cpp	Wed Mar 17 10:48:00 2010 +0000
@@ -66,6 +66,10 @@
                 QString("%1/Maps/%2/map.cfg")
                 .arg(datadir->absolutePath())
                 .arg(map));
+        QFile mapLuaFile(
+                QString("%1/Maps/%2/map.lua")
+                .arg(datadir->absolutePath())
+                .arg(map));
 
         if (mapCfgFile.open(QFile::ReadOnly)) {
             QString theme;
@@ -74,12 +78,14 @@
             QTextStream input(&mapCfgFile);
             input >> theme;
             input >> limit;
+            mapInfo.push_back(map);
             mapInfo.push_back(theme);
             if (limit)
                 mapInfo.push_back(limit);
             else
                 mapInfo.push_back(18);
-            chooseMap->addItem(map, mapInfo);
+            mapInfo.push_back(mapLuaFile.exists());
+            chooseMap->addItem(mapLuaFile.exists() ? (QComboBox::tr("Mission") + ": " + map) : map, mapInfo);
             mapCfgFile.close();
         }
     }
@@ -183,27 +189,27 @@
         lblFilter->show();
         CB_TemplateFilter->show();
         emit mapChanged("+rnd+");
-        emit themeChanged(chooseMap->itemData(0).toList()[0].toString());
+        emit themeChanged(chooseMap->itemData(0).toList()[1].toString());
     } else
     {
         loadMap(index);
         gbThemes->hide();
         lblFilter->hide();
         CB_TemplateFilter->hide();
-        emit mapChanged(chooseMap->currentText());
+        emit mapChanged(chooseMap->itemData(0).toList()[0].toString());
     }
 }
 
 void HWMapContainer::loadMap(int index)
 {
     QPixmap mapImage;
-    if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->currentText() + "/preview.png")) {
+    if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(index).toList()[0].toString() + "/preview.png")) {
         changeImage();
         chooseMap->setCurrentIndex(0);
         return;
     }
 
-    hhLimit = chooseMap->itemData(index).toList()[1].toInt();
+    hhLimit = chooseMap->itemData(index).toList()[2].toInt();
     addInfoToPreview(mapImage);
 }
 
@@ -246,6 +252,7 @@
 {
     QString theme = Themes->at(currentRow);
     QList<QVariant> mapInfo;
+    mapInfo.push_back(QString("+rnd+"));
     mapInfo.push_back(theme);
     mapInfo.push_back(18);
     chooseMap->setItemData(0, mapInfo);
@@ -261,12 +268,18 @@
 QString HWMapContainer::getCurrentMap() const
 {
     if(!chooseMap->currentIndex()) return QString();
-    return chooseMap->currentText();
+    return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString();
 }
 
 QString HWMapContainer::getCurrentTheme() const
 {
-    return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString();
+    return chooseMap->itemData(chooseMap->currentIndex()).toList()[1].toString();
+}
+
+bool HWMapContainer::getCurrentIsMission() const
+{
+    if(!chooseMap->currentIndex()) return false;
+    return chooseMap->itemData(chooseMap->currentIndex()).toList()[3].toBool();
 }
 
 int HWMapContainer::getCurrentHHLimit() const
@@ -298,7 +311,14 @@
         return;
     }
 
-    int id = chooseMap->findText(map);
+    int id = 0;
+    for(int i = 0; i < chooseMap->count(); i++)
+        if(chooseMap->itemData(i).toList()[0].toString() == map)
+        {
+            id = i;
+            break;
+        }
+
     if(id > 0) {
         if (pMap)
         {
--- a/QTfrontend/mapContainer.h	Wed Mar 17 01:03:22 2010 +0000
+++ b/QTfrontend/mapContainer.h	Wed Mar 17 10:48:00 2010 +0000
@@ -45,6 +45,7 @@
   QString getCurrentTheme() const;
   int     getCurrentHHLimit() const;
   quint32 getTemplateFilter() const;
+  bool getCurrentIsMission() const;
 
  public slots:
   void changeImage();