QTfrontend/mapContainer.cpp
changeset 4941 90572c338e60
parent 4936 d65d438acd23
child 4973 53411a26df7e
--- a/QTfrontend/mapContainer.cpp	Mon Feb 14 08:31:45 2011 -0500
+++ b/QTfrontend/mapContainer.cpp	Tue Feb 15 21:12:22 2011 +0300
@@ -140,7 +140,7 @@
     }
     chooseMap->insertSeparator(missionindex); // separator between missions and maps
 
-    connect(chooseMap, SIGNAL(currentIndexChanged(int)), this, SLOT(mapChanged(int)));
+    connect(chooseMap, SIGNAL(activated(int)), this, SLOT(mapChanged(int)));
     mapLayout->addWidget(chooseMap, 1, 1);
 
     QLabel * lblMap = new QLabel(tr("Map"), mapWidget);
@@ -149,32 +149,32 @@
     lblFilter = new QLabel(tr("Filter"), mapWidget);
     mapLayout->addWidget(lblFilter, 2, 0);
 
-    CB_TemplateFilter = new QComboBox(mapWidget);
-    CB_TemplateFilter->addItem(tr("All"), 0);
-    CB_TemplateFilter->addItem(tr("Small"), 1);
-    CB_TemplateFilter->addItem(tr("Medium"), 2);
-    CB_TemplateFilter->addItem(tr("Large"), 3);
-    CB_TemplateFilter->addItem(tr("Cavern"), 4);
-    CB_TemplateFilter->addItem(tr("Wacky"), 5);
-    mapLayout->addWidget(CB_TemplateFilter, 2, 1);
+    cbTemplateFilter = new QComboBox(mapWidget);
+    cbTemplateFilter->addItem(tr("All"), 0);
+    cbTemplateFilter->addItem(tr("Small"), 1);
+    cbTemplateFilter->addItem(tr("Medium"), 2);
+    cbTemplateFilter->addItem(tr("Large"), 3);
+    cbTemplateFilter->addItem(tr("Cavern"), 4);
+    cbTemplateFilter->addItem(tr("Wacky"), 5);
+    mapLayout->addWidget(cbTemplateFilter, 2, 1);
 
-    connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int)));
+    connect(cbTemplateFilter, SIGNAL(activated(int)), this, SLOT(setTemplateFilter(int)));
 
     maze_size_label = new QLabel(tr("Type"), mapWidget);
     mainLayout.addWidget(maze_size_label, 2, 0);
     maze_size_label->hide();
-    maze_size_selection = new QComboBox(mapWidget);
-    maze_size_selection->addItem(tr("Small tunnels"), 0);
-    maze_size_selection->addItem(tr("Medium tunnels"), 1);
-    maze_size_selection->addItem(tr("Large tunnels"), 2);
-    maze_size_selection->addItem(tr("Small floating islands"), 3);
-    maze_size_selection->addItem(tr("Medium floating islands"), 4);
-    maze_size_selection->addItem(tr("Large floating islands"), 5);
-    maze_size_selection->setCurrentIndex(1);
+    cbMazeSize = new QComboBox(mapWidget);
+    cbMazeSize->addItem(tr("Small tunnels"), 0);
+    cbMazeSize->addItem(tr("Medium tunnels"), 1);
+    cbMazeSize->addItem(tr("Large tunnels"), 2);
+    cbMazeSize->addItem(tr("Small floating islands"), 3);
+    cbMazeSize->addItem(tr("Medium floating islands"), 4);
+    cbMazeSize->addItem(tr("Large floating islands"), 5);
+    cbMazeSize->setCurrentIndex(1);
 
-    mapLayout->addWidget(maze_size_selection, 2, 1);
-    maze_size_selection->hide();
-    connect(maze_size_selection, SIGNAL(currentIndexChanged(int)), this, SLOT(setMaze_size(int)));
+    mapLayout->addWidget(cbMazeSize, 2, 1);
+    cbMazeSize->hide();
+    connect(cbMazeSize, SIGNAL(activated(int)), this, SLOT(setMazeSize(int)));
 
     gbThemes = new IconedGroupBox(mapWidget);
     gbThemes->setTitleTextPadding(80);
@@ -278,9 +278,9 @@
         updatePreview();
         gbThemes->show();
         lblFilter->show();
-        CB_TemplateFilter->show();
+        cbTemplateFilter->show();
         maze_size_label->hide();
-        maze_size_selection->hide();
+        cbMazeSize->hide();
         emit mapChanged("+rnd+");
         emit mapgenChanged(mapgen);
         emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
@@ -290,9 +290,9 @@
         updatePreview();
         gbThemes->show();
         lblFilter->hide();
-        CB_TemplateFilter->hide();
+        cbTemplateFilter->hide();
         maze_size_label->show();
-        maze_size_selection->show();
+        cbMazeSize->show();
         emit mapChanged("+maze+");
         emit mapgenChanged(mapgen);
         emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
@@ -302,9 +302,9 @@
         updatePreview();
         gbThemes->show();
         lblFilter->hide();
-        CB_TemplateFilter->hide();
+        cbTemplateFilter->hide();
         maze_size_label->hide();
-        maze_size_selection->hide();
+        cbMazeSize->hide();
         emit mapChanged("+drawn+");
         emit mapgenChanged(mapgen);
         emit themeChanged(chooseMap->itemData(index).toList()[1].toString());
@@ -313,9 +313,9 @@
         updatePreview();
         gbThemes->hide();
         lblFilter->hide();
-        CB_TemplateFilter->hide();
+        cbTemplateFilter->hide();
         maze_size_label->hide();
-        maze_size_selection->hide();
+        cbMazeSize->hide();
         emit mapChanged(chooseMap->itemData(index).toList()[0].toString());
     }
 }
@@ -355,7 +355,7 @@
     pMap->getImage(m_seed,
                    getTemplateFilter(),
                    get_mapgen(),
-                   get_maze_size(),
+                   getMazeSize(),
                    getDrawnMapData()
             );
 }
@@ -416,7 +416,7 @@
 
 quint32 HWMapContainer::getTemplateFilter() const
 {
-    return CB_TemplateFilter->itemData(CB_TemplateFilter->currentIndex()).toInt();
+    return cbTemplateFilter->itemData(cbTemplateFilter->currentIndex()).toInt();
 }
 
 void HWMapContainer::resizeEvent ( QResizeEvent * event )
@@ -525,14 +525,15 @@
     lwThemes->setCurrentRow(themeNum);
 }
 
+void HWMapContainer::intSetTemplateFilter(int filter)
+{
+    cbTemplateFilter->setCurrentIndex(filter);
+    emit newTemplateFilter(filter);
+}
+
 void HWMapContainer::setTemplateFilter(int filter)
 {
-    CB_TemplateFilter->setCurrentIndex(filter);
-}
-
-void HWMapContainer::templateFilterChanged(int filter)
-{
-    emit newTemplateFilter(filter);
+    intSetTemplateFilter(filter);
     updatePreview();
 }
 
@@ -541,15 +542,20 @@
     return mapgen;
 }
 
-int HWMapContainer::get_maze_size(void) const
+int HWMapContainer::getMazeSize(void) const
 {
-    return maze_size_selection->currentIndex();
+    return cbMazeSize->currentIndex();
 }
 
-void HWMapContainer::setMaze_size(int size)
+void HWMapContainer::intSetMazeSize(int size)
 {
-    maze_size_selection->setCurrentIndex(size);
-    emit maze_sizeChanged(size);
+    cbMazeSize->setCurrentIndex(size);
+    emit mazeSizeChanged(size);
+}
+
+void HWMapContainer::setMazeSize(int size)
+{
+    intSetMazeSize(size);
     updatePreview();
 }
 
@@ -610,6 +616,7 @@
 
 void HWMapContainer::updatePreview()
 {
+    qDebug("updating a preview");
     int curIndex = chooseMap->currentIndex();
 
     switch(curIndex)
@@ -636,11 +643,13 @@
     }
 }
 
-void HWMapContainer::setMapMapgenSeed(const QString & map, MapGenerator m, const QString & seed)
+void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl)
 {
-    setMap(map);
-    setMapgen(m);
-    setSeed(seed);
+    intSetMap(map);
+    intSetMapgen(m);
+    intSetMazeSize(mazesize);
+    intSetSeed(seed);
+    intSetTemplateFilter(tmpl);
 
     updatePreview();
 }