54 imageButt->setObjectName("imageButt"); |
54 imageButt->setObjectName("imageButt"); |
55 imageButt->setFixedSize(256 + 6, 128 + 6); |
55 imageButt->setFixedSize(256 + 6, 128 + 6); |
56 imageButt->setFlat(true); |
56 imageButt->setFlat(true); |
57 imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); |
57 imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); |
58 mainLayout.addWidget(imageButt, 0, 0, 1, 2); |
58 mainLayout.addWidget(imageButt, 0, 0, 1, 2); |
59 connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); |
59 //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); |
60 connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); |
60 //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); |
|
61 connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
61 |
62 |
62 chooseMap = new QComboBox(this); |
63 chooseMap = new QComboBox(this); |
63 chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
64 chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
64 chooseMap->addItem(QIcon(":/res/mapRandom.png"), QComboBox::tr("generated map...")); |
65 chooseMap->addItem(QIcon(":/res/mapRandom.png"), QComboBox::tr("generated map...")); |
65 chooseMap->addItem(QIcon(":/res/mapMaze.png"), QComboBox::tr("generated maze...")); |
66 chooseMap->addItem(QIcon(":/res/mapMaze.png"), QComboBox::tr("generated maze...")); |
66 chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
67 chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
67 |
68 |
68 int missionindex = chooseMap->count(); |
69 int missionindex = chooseMap->count(); |
|
70 numMissions = 0; |
69 for (int i = 0; i < mapList->size(); ++i) { |
71 for (int i = 0; i < mapList->size(); ++i) { |
70 QString map = (*mapList)[i]; |
72 QString map = (*mapList)[i]; |
71 QFile mapCfgFile( |
73 QFile mapCfgFile( |
72 QString("%1/Maps/%2/map.cfg") |
74 QString("%1/Maps/%2/map.cfg") |
73 .arg(datadir->absolutePath()) |
75 .arg(datadir->absolutePath()) |
90 mapInfo.push_back(limit); |
92 mapInfo.push_back(limit); |
91 else |
93 else |
92 mapInfo.push_back(18); |
94 mapInfo.push_back(18); |
93 mapInfo.push_back(mapLuaFile.exists()); |
95 mapInfo.push_back(mapLuaFile.exists()); |
94 if(mapLuaFile.exists()) |
96 if(mapLuaFile.exists()) |
|
97 { |
95 chooseMap->insertItem(missionindex++, QIcon(":/res/mapMission.png"), QComboBox::tr("Mission") + ": " + map, mapInfo); |
98 chooseMap->insertItem(missionindex++, QIcon(":/res/mapMission.png"), QComboBox::tr("Mission") + ": " + map, mapInfo); |
|
99 numMissions++; |
|
100 } |
96 else |
101 else |
97 chooseMap->addItem(QIcon(":/res/mapCustom.png"), map, mapInfo); |
102 chooseMap->addItem(QIcon(":/res/mapCustom.png"), map, mapInfo); |
98 mapCfgFile.close(); |
103 mapCfgFile.close(); |
99 } |
104 } |
100 } |
105 } |
388 { |
393 { |
389 QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly); |
394 QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly); |
390 if(items.size()) |
395 if(items.size()) |
391 lwThemes->setCurrentItem(items.at(0)); |
396 lwThemes->setCurrentItem(items.at(0)); |
392 } |
397 } |
|
398 #include <QMessageBox> |
|
399 void HWMapContainer::setRandomMap() |
|
400 { |
|
401 switch(chooseMap->currentIndex()) |
|
402 { |
|
403 case MAPGEN_REGULAR: |
|
404 case MAPGEN_MAZE: |
|
405 setRandomSeed(); |
|
406 setRandomTheme(); |
|
407 break; |
|
408 default: |
|
409 if(chooseMap->currentIndex() < numMissions + 3) |
|
410 setRandomMission(); |
|
411 else |
|
412 setRandomStatic(); |
|
413 break; |
|
414 } |
|
415 } |
|
416 |
|
417 void HWMapContainer::setRandomStatic() |
|
418 { |
|
419 chooseMap->setCurrentIndex(4 + numMissions + rand() % (chooseMap->count() - 4 - numMissions)); |
|
420 m_seed = QUuid::createUuid().toString(); |
|
421 } |
|
422 |
|
423 void HWMapContainer::setRandomMission() |
|
424 { |
|
425 chooseMap->setCurrentIndex(3 + rand() % numMissions); |
|
426 m_seed = QUuid::createUuid().toString(); |
|
427 } |
393 |
428 |
394 void HWMapContainer::setRandomSeed() |
429 void HWMapContainer::setRandomSeed() |
395 { |
430 { |
396 m_seed = QUuid::createUuid().toString(); |
431 m_seed = QUuid::createUuid().toString(); |
397 emit seedChanged(m_seed); |
432 emit seedChanged(m_seed); |