# HG changeset patch # User smaxx # Date 1284495239 -7200 # Node ID e3f778c95d1c437cac2dd9269e6e12593e82f768 # Parent d3d39bbb05f2a586693a5004d5a0e123bba3b57c Frontend: * Updated random map selection: Clicking on the map preview will now create a new random seed and pick another map of the current type selected (random map, random maze, mission or static map) diff -r d3d39bbb05f2 -r e3f778c95d1c QTfrontend/mapContainer.cpp --- a/QTfrontend/mapContainer.cpp Tue Sep 14 21:07:06 2010 +0200 +++ b/QTfrontend/mapContainer.cpp Tue Sep 14 22:13:59 2010 +0200 @@ -56,8 +56,9 @@ imageButt->setFlat(true); imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); mainLayout.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(setRandomSeed())); + //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); + connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); chooseMap = new QComboBox(this); chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); @@ -66,6 +67,7 @@ chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions int missionindex = chooseMap->count(); + numMissions = 0; for (int i = 0; i < mapList->size(); ++i) { QString map = (*mapList)[i]; QFile mapCfgFile( @@ -92,7 +94,10 @@ mapInfo.push_back(18); mapInfo.push_back(mapLuaFile.exists()); if(mapLuaFile.exists()) + { chooseMap->insertItem(missionindex++, QIcon(":/res/mapMission.png"), QComboBox::tr("Mission") + ": " + map, mapInfo); + numMissions++; + } else chooseMap->addItem(QIcon(":/res/mapCustom.png"), map, mapInfo); mapCfgFile.close(); @@ -390,6 +395,36 @@ if(items.size()) lwThemes->setCurrentItem(items.at(0)); } +#include +void HWMapContainer::setRandomMap() +{ + switch(chooseMap->currentIndex()) + { + case MAPGEN_REGULAR: + case MAPGEN_MAZE: + setRandomSeed(); + setRandomTheme(); + break; + default: + if(chooseMap->currentIndex() < numMissions + 3) + setRandomMission(); + else + setRandomStatic(); + break; + } +} + +void HWMapContainer::setRandomStatic() +{ + chooseMap->setCurrentIndex(4 + numMissions + rand() % (chooseMap->count() - 4 - numMissions)); + m_seed = QUuid::createUuid().toString(); +} + +void HWMapContainer::setRandomMission() +{ + chooseMap->setCurrentIndex(3 + rand() % numMissions); + m_seed = QUuid::createUuid().toString(); +} void HWMapContainer::setRandomSeed() { diff -r d3d39bbb05f2 -r e3f778c95d1c QTfrontend/mapContainer.h --- a/QTfrontend/mapContainer.h Tue Sep 14 21:07:06 2010 +0200 +++ b/QTfrontend/mapContainer.h Tue Sep 14 22:13:59 2010 +0200 @@ -72,6 +72,9 @@ void mapChanged(int index); void setRandomSeed(); void setRandomTheme(); + void setRandomMap(); + void setRandomStatic(); + void setRandomMission(); void themeSelected(int currentRow); void addInfoToPreview(QPixmap image); void templateFilterChanged(int filter); @@ -95,6 +98,7 @@ QLabel *maze_size_label; QComboBox *maze_size_selection; MapGenerator mapgen; + int numMissions; int maze_size; void loadMap(int index);