# HG changeset patch # User smxx # Date 1268822880 0 # Node ID e57cafce4227a4dd822cabfb0c4a6708e7fe5239 # Parent 489ae87cdf9ba05869e7e8284dcccefd8da8708d Frontend: * Map selection detects maps with scripts as missions * Disabled scheme selection for missions diff -r 489ae87cdf9b -r e57cafce4227 QTfrontend/gamecfgwidget.cpp --- 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)); } diff -r 489ae87cdf9b -r e57cafce4227 QTfrontend/mapContainer.cpp --- 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 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) { diff -r 489ae87cdf9b -r e57cafce4227 QTfrontend/mapContainer.h --- 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();