QTfrontend/model/MapModel.cpp
changeset 8419 d99f46b676b5
parent 8393 85bd6c7b2641
child 8464 c708b4f5cffc
--- a/QTfrontend/model/MapModel.cpp	Mon Jan 21 13:04:57 2013 -0500
+++ b/QTfrontend/model/MapModel.cpp	Mon Jan 21 14:07:39 2013 -0500
@@ -23,6 +23,7 @@
 
 #include <QSettings>
 
+#include "physfs.h"
 #include "MapModel.h"
 #include "HWApplication.h"
 
@@ -32,6 +33,8 @@
 
 void MapModel::loadMaps(MapType maptype)
 {
+    const QString appDir = QString(PHYSFS_getBaseDir());
+
     // this method resets the contents of this model (important to know for views).
     beginResetModel();
 
@@ -66,12 +69,13 @@
             QString scheme;
             QString weapons;
             QString desc;
+            bool dlc;
 
             // if there is a lua file for this map, then it's a mission
             bool isMission = mapLuaFile.exists();
             MapType type = isMission ? MissionMap : StaticMap;
 
-            // If we're supposed to ignore this type, continue
+            // if we're supposed to ignore this type, continue
             if (type != maptype) continue;
 
             // load map info from file
@@ -84,7 +88,7 @@
             }
             mapCfgFile.close();
 
-            // Load description (if applicable)
+            // load description (if applicable)
             if (isMission)
             {
                 QString locale = HWApplication::keyboardInputLocale().name();
@@ -93,6 +97,10 @@
                 desc = descSettings.value(locale, QString()).toString().replace("|", "\n").replace("\\,", ",");
             }
 
+            // detect if map is dlc
+            QString mapDir = PHYSFS_getRealDir(QString("Maps/%1/map.cfg").arg(map).toLocal8Bit().data());
+            dlc = !mapDir.startsWith(appDir);
+
             // let's use some semi-sane hedgehog limit, rather than none
             if (limit == 0)
                 limit = 18;
@@ -117,7 +125,7 @@
 
             // we know everything there is about the map, let's get am item for it
             QStandardItem * item = MapModel::infoToItem(
-                QIcon(), caption, type, map, theme, limit, scheme, weapons, desc);
+                QIcon(), caption, type, map, theme, limit, scheme, weapons, desc, dlc);
 
             // append item to the list
             mapList.append(item);
@@ -170,9 +178,10 @@
     quint32 limit,
     QString scheme,
     QString weapons,
-    QString desc)
+    QString desc,
+    bool dlc)
 {
-    QStandardItem * item = new QStandardItem(icon, caption);
+    QStandardItem * item = new QStandardItem(icon, (dlc ? "*" : "") + caption);
     MapInfo mapInfo;
     QVariant qvar(QVariant::UserType);
 
@@ -183,6 +192,7 @@
     mapInfo.scheme = scheme;
     mapInfo.weapons = weapons;
     mapInfo.desc = desc.isEmpty() ? tr("No description available.") : desc;
+    mapInfo.dlc = dlc;
 
     qvar.setValue(mapInfo);
     item->setData(qvar, Qt::UserRole + 1);