QTfrontend/mapContainer.cpp
changeset 5801 531f64292489
parent 5795 3f36293e6945
child 5993 412ada3d2041
--- a/QTfrontend/mapContainer.cpp	Thu Sep 08 00:34:57 2011 +0200
+++ b/QTfrontend/mapContainer.cpp	Sat Oct 08 16:45:52 2011 +0200
@@ -64,8 +64,6 @@
     imageButt->setFlat(true);
     imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
     mapLayout->addWidget(imageButt, 0, 0, 1, 2);
-    //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
-    //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme()));
     connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap()));
 
     chooseMap = new QComboBox(mapWidget);
@@ -293,7 +291,6 @@
         maze_size_label->hide();
         cbMazeSize->hide();
         emit mapChanged("+rnd+");
-        emit mapgenChanged(mapgen);
         emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
         break;
     case MAPGEN_MAZE:
@@ -305,7 +302,6 @@
         maze_size_label->show();
         cbMazeSize->show();
         emit mapChanged("+maze+");
-        emit mapgenChanged(mapgen);
         emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
         break;
     case MAPGEN_DRAWN:
@@ -317,10 +313,10 @@
         maze_size_label->hide();
         cbMazeSize->hide();
         emit mapChanged("+drawn+");
-        emit mapgenChanged(mapgen);
         emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
         break;
     default:
+        mapgen = MAPGEN_MAP;
         updatePreview();
         gbThemes->hide();
         lblFilter->hide();
@@ -329,6 +325,8 @@
         cbMazeSize->hide();
         emit mapChanged(chooseMap->itemData(index).toList()[0].toString());
     }
+
+    emit mapgenChanged(mapgen);
 }
 
 // Should this add text to identify map size?
@@ -447,7 +445,7 @@
 void HWMapContainer::setSeed(const QString & seed)
 {
     intSetSeed(seed);
-    if (chooseMap->currentIndex() < MAPGEN_MAP)
+    if (chooseMap->currentIndex() < MAPGEN_DRAWN)
         updatePreview();
 }
 
@@ -511,15 +509,14 @@
 {
     int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions);
     chooseMap->setCurrentIndex(i);
-    setRandomSeed();
+    updatePreview();
 }
 
 void HWMapContainer::setRandomMission()
 {
     int i = MAPGEN_MAP + 2 + rand() % numMissions;
-    qDebug() << i << MAPGEN_MAP << numMissions;
     chooseMap->setCurrentIndex(i);
-    setRandomSeed();
+    updatePreview();
 }
 
 void HWMapContainer::setRandomSeed()
@@ -575,7 +572,10 @@
 void HWMapContainer::intSetMapgen(MapGenerator m)
 {
     mapgen = m;
-    chooseMap->setCurrentIndex(m);
+
+    if(m != MAPGEN_MAP)
+        chooseMap->setCurrentIndex(m);
+
     emit mapgenChanged(m);
 }
 
@@ -644,9 +644,8 @@
         break;
     default:
         QPixmap mapImage;
-        qDebug() << "Map data" << curIndex << chooseMap->currentText() << chooseMap->itemData(curIndex);
         QFile tmpfile;
-        tmpfile.setFileName(cfgdir->absolutePath() + "/Data//Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png");
+        tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png");
         if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png");
         if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) {
             imageButt->setIcon(QIcon());