QTfrontend/ui/widget/mapContainer.cpp
changeset 11762 6874644a2d00
parent 11759 2e4f0d0fec99
child 11790 947e2d53afc1
equal deleted inserted replaced
11761:df92c83375e2 11762:6874644a2d00
    61     m_missionsViewSetup = false;
    61     m_missionsViewSetup = false;
    62     m_staticViewSetup = false;
    62     m_staticViewSetup = false;
    63     m_script = QString();
    63     m_script = QString();
    64     m_prevMapFeatureSize = 12;
    64     m_prevMapFeatureSize = 12;
    65     m_mapFeatureSize = 12;
    65     m_mapFeatureSize = 12;
       
    66     m_withoutDLC = false;
    66 
    67 
    67     hhSmall.load(":/res/hh_small.png");
    68     hhSmall.load(":/res/hh_small.png");
    68     hhLimit = 18;
    69     hhLimit = 18;
    69     templateFilter = 0;
    70     templateFilter = 0;
    70     m_master = true;
    71     m_master = true;
   498 void HWMapContainer::setRandomMap()
   499 void HWMapContainer::setRandomMap()
   499 {
   500 {
   500     if (!m_master) return;
   501     if (!m_master) return;
   501 
   502 
   502     setRandomSeed();
   503     setRandomSeed();
       
   504 
       
   505     QSortFilterProxyModel * mmodel = NULL;
       
   506 
   503     switch(m_mapInfo.type)
   507     switch(m_mapInfo.type)
   504     {
   508     {
   505         case MapModel::GeneratedMap:
   509         case MapModel::GeneratedMap:
   506         case MapModel::GeneratedMaze:
   510         case MapModel::GeneratedMaze:
   507         case MapModel::GeneratedPerlin:
   511         case MapModel::GeneratedPerlin:
   508         case MapModel::FortsMap:
   512         case MapModel::FortsMap:
   509             setRandomTheme();
   513             setRandomTheme();
   510             break;
   514             break;
   511         case MapModel::MissionMap:
   515         case MapModel::MissionMap:
   512             missionMapChanged(m_missionMapModel->index(rand() % m_missionMapModel->rowCount(), 0));
   516             if (m_withoutDLC)
       
   517             {
       
   518                 mmodel = m_missionMapModel->withoutDLC();
       
   519                 missionMapChanged(mmodel->mapToSource(mmodel->index(rand() % mmodel->rowCount(),0)));
       
   520             }
       
   521             else
       
   522                 missionMapChanged(m_missionMapModel->index(rand() % m_missionMapModel->rowCount(),0));
   513             break;
   523             break;
   514         case MapModel::StaticMap:
   524         case MapModel::StaticMap:
   515             staticMapChanged(m_staticMapModel->index(rand() % m_staticMapModel->rowCount(), 0));
   525             if (m_withoutDLC)
       
   526             {
       
   527                 mmodel = m_staticMapModel->withoutDLC();
       
   528                 staticMapChanged(mmodel->mapToSource(mmodel->index(rand() % mmodel->rowCount(),0)));
       
   529             }
       
   530             else
       
   531                 staticMapChanged(m_staticMapModel->index(rand() % m_staticMapModel->rowCount(),0));
   516             break;
   532             break;
   517         default:
   533         default:
   518             break;
   534             break;
   519     }
   535     }
   520 }
   536 }
   523 {
   539 {
   524     setSeed(QUuid::createUuid().toString());
   540     setSeed(QUuid::createUuid().toString());
   525     emit seedChanged(m_seed);
   541     emit seedChanged(m_seed);
   526 }
   542 }
   527 
   543 
       
   544 void HWMapContainer::setRandomWithoutDLC(bool withoutDLC)
       
   545 {
       
   546     m_withoutDLC = withoutDLC;
       
   547 }
       
   548 
   528 void HWMapContainer::setRandomTheme()
   549 void HWMapContainer::setRandomTheme()
   529 {
   550 {
   530     if(!m_themeModel->rowCount()) return;
   551     QAbstractItemModel * tmodel;
   531     quint32 themeNum = rand() % m_themeModel->rowCount();
   552 
   532     updateTheme(m_themeModel->index(themeNum));
   553     if (m_withoutDLC)
       
   554         tmodel = m_themeModel->withoutDLC();
       
   555     else
       
   556         tmodel = m_themeModel;
       
   557 
       
   558     if(!tmodel->rowCount()) return;
       
   559     quint32 themeNum = rand() % tmodel->rowCount();
       
   560     updateTheme(tmodel->index(themeNum,0));
   533     emit themeChanged(m_theme);
   561     emit themeChanged(m_theme);
   534 }
   562 }
   535 
   563 
   536 void HWMapContainer::intSetTemplateFilter(int filter)
   564 void HWMapContainer::intSetTemplateFilter(int filter)
   537 {
   565 {