62 imageButt->setObjectName("imageButt"); |
62 imageButt->setObjectName("imageButt"); |
63 imageButt->setFixedSize(256 + 6, 128 + 6); |
63 imageButt->setFixedSize(256 + 6, 128 + 6); |
64 imageButt->setFlat(true); |
64 imageButt->setFlat(true); |
65 imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); |
65 imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); |
66 mapLayout->addWidget(imageButt, 0, 0, 1, 2); |
66 mapLayout->addWidget(imageButt, 0, 0, 1, 2); |
67 //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); |
|
68 //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); |
|
69 connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
67 connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
70 |
68 |
71 chooseMap = new QComboBox(mapWidget); |
69 chooseMap = new QComboBox(mapWidget); |
72 chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
70 chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
73 chooseMap->addItem( |
71 chooseMap->addItem( |
291 lblFilter->show(); |
289 lblFilter->show(); |
292 cbTemplateFilter->show(); |
290 cbTemplateFilter->show(); |
293 maze_size_label->hide(); |
291 maze_size_label->hide(); |
294 cbMazeSize->hide(); |
292 cbMazeSize->hide(); |
295 emit mapChanged("+rnd+"); |
293 emit mapChanged("+rnd+"); |
296 emit mapgenChanged(mapgen); |
|
297 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
294 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
298 break; |
295 break; |
299 case MAPGEN_MAZE: |
296 case MAPGEN_MAZE: |
300 mapgen = MAPGEN_MAZE; |
297 mapgen = MAPGEN_MAZE; |
301 updatePreview(); |
298 updatePreview(); |
303 lblFilter->hide(); |
300 lblFilter->hide(); |
304 cbTemplateFilter->hide(); |
301 cbTemplateFilter->hide(); |
305 maze_size_label->show(); |
302 maze_size_label->show(); |
306 cbMazeSize->show(); |
303 cbMazeSize->show(); |
307 emit mapChanged("+maze+"); |
304 emit mapChanged("+maze+"); |
308 emit mapgenChanged(mapgen); |
|
309 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
305 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
310 break; |
306 break; |
311 case MAPGEN_DRAWN: |
307 case MAPGEN_DRAWN: |
312 mapgen = MAPGEN_DRAWN; |
308 mapgen = MAPGEN_DRAWN; |
313 updatePreview(); |
309 updatePreview(); |
315 lblFilter->hide(); |
311 lblFilter->hide(); |
316 cbTemplateFilter->hide(); |
312 cbTemplateFilter->hide(); |
317 maze_size_label->hide(); |
313 maze_size_label->hide(); |
318 cbMazeSize->hide(); |
314 cbMazeSize->hide(); |
319 emit mapChanged("+drawn+"); |
315 emit mapChanged("+drawn+"); |
320 emit mapgenChanged(mapgen); |
|
321 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
316 emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
322 break; |
317 break; |
323 default: |
318 default: |
|
319 mapgen = MAPGEN_MAP; |
324 updatePreview(); |
320 updatePreview(); |
325 gbThemes->hide(); |
321 gbThemes->hide(); |
326 lblFilter->hide(); |
322 lblFilter->hide(); |
327 cbTemplateFilter->hide(); |
323 cbTemplateFilter->hide(); |
328 maze_size_label->hide(); |
324 maze_size_label->hide(); |
329 cbMazeSize->hide(); |
325 cbMazeSize->hide(); |
330 emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); |
326 emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); |
331 } |
327 } |
|
328 |
|
329 emit mapgenChanged(mapgen); |
332 } |
330 } |
333 |
331 |
334 // Should this add text to identify map size? |
332 // Should this add text to identify map size? |
335 void HWMapContainer::addInfoToPreview(QPixmap image) |
333 void HWMapContainer::addInfoToPreview(QPixmap image) |
336 { |
334 { |
509 |
507 |
510 void HWMapContainer::setRandomStatic() |
508 void HWMapContainer::setRandomStatic() |
511 { |
509 { |
512 int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions); |
510 int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions); |
513 chooseMap->setCurrentIndex(i); |
511 chooseMap->setCurrentIndex(i); |
514 setRandomSeed(); |
512 updatePreview(); |
515 } |
513 } |
516 |
514 |
517 void HWMapContainer::setRandomMission() |
515 void HWMapContainer::setRandomMission() |
518 { |
516 { |
519 int i = MAPGEN_MAP + 2 + rand() % numMissions; |
517 int i = MAPGEN_MAP + 2 + rand() % numMissions; |
520 qDebug() << i << MAPGEN_MAP << numMissions; |
|
521 chooseMap->setCurrentIndex(i); |
518 chooseMap->setCurrentIndex(i); |
522 setRandomSeed(); |
519 updatePreview(); |
523 } |
520 } |
524 |
521 |
525 void HWMapContainer::setRandomSeed() |
522 void HWMapContainer::setRandomSeed() |
526 { |
523 { |
527 m_seed = QUuid::createUuid().toString(); |
524 m_seed = QUuid::createUuid().toString(); |
642 case MAPGEN_DRAWN: |
642 case MAPGEN_DRAWN: |
643 askForGeneratedPreview(); |
643 askForGeneratedPreview(); |
644 break; |
644 break; |
645 default: |
645 default: |
646 QPixmap mapImage; |
646 QPixmap mapImage; |
647 qDebug() << "Map data" << curIndex << chooseMap->currentText() << chooseMap->itemData(curIndex); |
|
648 QFile tmpfile; |
647 QFile tmpfile; |
649 tmpfile.setFileName(cfgdir->absolutePath() + "/Data//Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
648 tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
650 if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
649 if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); |
651 if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) { |
650 if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) { |
652 imageButt->setIcon(QIcon()); |
651 imageButt->setIcon(QIcon()); |
653 return; |
652 return; |
654 } |
653 } |