QTfrontend/mapContainer.cpp
changeset 5238 46ddaf14509d
parent 4976 088d40d8aba2
child 5252 ded882439548
equal deleted inserted replaced
5237:963d787a25c2 5238:46ddaf14509d
    83 
    83 
    84     chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions
    84     chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions
    85 
    85 
    86     int missionindex = chooseMap->count();
    86     int missionindex = chooseMap->count();
    87     numMissions = 0;
    87     numMissions = 0;
       
    88     QFile mapLuaFile;
       
    89     QFile mapCfgFile;
    88     for (int i = 0; i < mapList->size(); ++i) {
    90     for (int i = 0; i < mapList->size(); ++i) {
    89         QString map = (*mapList)[i];
    91         QString map = (*mapList)[i];
    90         QFile mapCfgFile(
    92         mapCfgFile.setFileName(
    91                 QString("%1/Maps/%2/map.cfg")
    93                 QString("%1/Data/Maps/%2/map.cfg")
    92                 .arg(datadir->absolutePath())
    94                 .arg(cfgdir->absolutePath())
    93                 .arg(map));
    95                 .arg(map));
    94         QFile mapLuaFile(
    96         if (mapCfgFile.exists()) {
    95                 QString("%1/Maps/%2/map.lua")
    97             mapLuaFile.setFileName(
    96                 .arg(datadir->absolutePath())
    98                     QString("%1/Data/Maps/%2/map.lua")
    97                 .arg(map));
    99                     .arg(cfgdir->absolutePath())
       
   100                     .arg(map));
       
   101         } else {
       
   102             mapCfgFile.setFileName(
       
   103                     QString("%1/Maps/%2/map.cfg")
       
   104                     .arg(datadir->absolutePath())
       
   105                     .arg(map));
       
   106             mapLuaFile.setFileName(
       
   107                     QString("%1/Maps/%2/map.lua")
       
   108                     .arg(datadir->absolutePath())
       
   109                     .arg(map));
       
   110         }
    98 
   111 
    99         if (mapCfgFile.open(QFile::ReadOnly)) {
   112         if (mapCfgFile.open(QFile::ReadOnly)) {
   100             QString theme;
   113             QString theme;
   101             quint32 limit = 0;
   114             quint32 limit = 0;
   102             QString scheme;
   115             QString scheme;
   188     gbTLayout->setContentsMargins(0, 0, 0 ,0);
   201     gbTLayout->setContentsMargins(0, 0, 0 ,0);
   189     gbTLayout->setSpacing(0);
   202     gbTLayout->setSpacing(0);
   190     lwThemes = new QListWidget(mapWidget);
   203     lwThemes = new QListWidget(mapWidget);
   191     lwThemes->setMinimumHeight(30);
   204     lwThemes->setMinimumHeight(30);
   192     lwThemes->setFixedWidth(140);
   205     lwThemes->setFixedWidth(140);
       
   206     QFile tmpfile;
   193     for (int i = 0; i < Themes->size(); ++i) {
   207     for (int i = 0; i < Themes->size(); ++i) {
   194         QListWidgetItem * lwi = new QListWidgetItem();
   208         QListWidgetItem * lwi = new QListWidgetItem();
   195         lwi->setText(Themes->at(i));
   209         lwi->setText(Themes->at(i));
   196         lwi->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(Themes->at(i))));
   210         tmpfile.setFileName(QString("%1/Data/Themes/%2/icon.png").arg(cfgdir->absolutePath()).arg(Themes->at(i)));
       
   211         if (tmpfile.exists()) lwi->setIcon(QIcon(QFileInfo(tmpfile).absoluteFilePath()));
       
   212         else lwi->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(Themes->at(i))));
   197         //lwi->setTextAlignment(Qt::AlignHCenter);
   213         //lwi->setTextAlignment(Qt::AlignHCenter);
   198         lwThemes->addItem(lwi);
   214         lwThemes->addItem(lwi);
   199     }
   215     }
   200     connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int)));
   216     connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int)));
   201 
   217 
   371     chooseMap->setItemData(0, mapInfo);
   387     chooseMap->setItemData(0, mapInfo);
   372     mapInfo[0] = QString("+maze+");
   388     mapInfo[0] = QString("+maze+");
   373     chooseMap->setItemData(1, mapInfo);
   389     chooseMap->setItemData(1, mapInfo);
   374     mapInfo[0] = QString("+drawn+");
   390     mapInfo[0] = QString("+drawn+");
   375     chooseMap->setItemData(2, mapInfo);
   391     chooseMap->setItemData(2, mapInfo);
   376     gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon@2x.png").arg(datadir->absolutePath()).arg(theme)));
   392     QFile tmpfile;
       
   393     tmpfile.setFileName(QString("%1/Data/Themes/%2/icon@2x.png").arg(cfgdir->absolutePath()).arg(theme));
       
   394     if (tmpfile.exists()) gbThemes->setIcon(QIcon(QFileInfo(tmpfile).absoluteFilePath()));
       
   395     else gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon@2x.png").arg(datadir->absolutePath()).arg(theme)));
   377     emit themeChanged(theme);
   396     emit themeChanged(theme);
   378 }
   397 }
   379 
   398 
   380 QString HWMapContainer::getCurrentSeed() const
   399 QString HWMapContainer::getCurrentSeed() const
   381 {
   400 {
   630         askForGeneratedPreview();
   649         askForGeneratedPreview();
   631         break;
   650         break;
   632     default:
   651     default:
   633         QPixmap mapImage;
   652         QPixmap mapImage;
   634         qDebug() << "Map data" << curIndex << chooseMap->currentText() << chooseMap->itemData(curIndex);
   653         qDebug() << "Map data" << curIndex << chooseMap->currentText() << chooseMap->itemData(curIndex);
   635         if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png")) {
   654         QFile tmpfile;
       
   655         tmpfile.setFileName(cfgdir->absolutePath() + "/Data//Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png");
       
   656         if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png");
       
   657         if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) {
   636             imageButt->setIcon(QIcon());
   658             imageButt->setIcon(QIcon());
   637             return;
   659             return;
   638         }
   660         }
   639 
   661 
   640         hhLimit = chooseMap->itemData(curIndex).toList()[2].toInt();
   662         hhLimit = chooseMap->itemData(curIndex).toList()[2].toInt();