# HG changeset patch # User sheepluva # Date 1336041188 -7200 # Node ID c0b32404ef74b254e3e3968eaff844758ca3fe7b # Parent 54db061b57107ff7c2c529ec7ff817f5fff6910f + display lack of map in a nice way, don't generate bogus preview in the background * improve map selection behavior in online mode, so that players can load a missing map and have it correctly selected after pressing F5 without any rejoin, map-reselection. also doesn't cause "different maps generated" anymore if map is missing, instead the person lacking the map gets "invalid genmap" and drops out of game immediatly diff -r 54db061b5710 -r c0b32404ef74 QTfrontend/ui/widget/mapContainer.cpp --- a/QTfrontend/ui/widget/mapContainer.cpp Thu May 03 12:21:16 2012 +0400 +++ b/QTfrontend/ui/widget/mapContainer.cpp Thu May 03 12:33:08 2012 +0200 @@ -211,6 +211,9 @@ void HWMapContainer::mapChanged(int index) { + if (index < 0) + return; + Q_ASSERT(chooseMap->itemData(index, Qt::UserRole + 1).canConvert()); m_mapInfo = chooseMap->itemData(index, Qt::UserRole + 1).value(); m_curMap = chooseMap->currentText(); @@ -379,15 +382,19 @@ { int id = m_mapModel->indexOf(map); - if(id >= 0) + if (pMap) { - if (pMap) - { - disconnect(pMap, 0, this, SLOT(setImage(const QImage))); - disconnect(pMap, 0, this, SLOT(setHHLimit(int))); - pMap = 0; - } - chooseMap->setCurrentIndex(id); + disconnect(pMap, 0, this, SLOT(setImage(const QImage))); + disconnect(pMap, 0, this, SLOT(setHHLimit(int))); + pMap = 0; + } + + chooseMap->setCurrentIndex(id); + + if(id < 0) + { + m_mapInfo.type = MapModel::Invalid; + m_curMap = map; } } @@ -426,7 +433,7 @@ chooseMap->setCurrentIndex(idx); break; case MapModel::Invalid: - Q_ASSERT(false); + chooseMap->setCurrentIndex(0); } } @@ -538,8 +545,15 @@ void HWMapContainer::updatePreview() { + QPixmap failIcon; + switch(m_mapInfo.type) { + case MapModel::Invalid: + failIcon = QPixmap(":/res/btnDisabled.png"); + imageButt->setIcon(failIcon); + imageButt->setIconSize(failIcon.size()); + break; case MapModel::GeneratedMap: askForGeneratedPreview(); break; @@ -594,13 +608,7 @@ // restore map selection if (!m_curMap.isEmpty()) - { - int idx = chooseMap->findText(m_curMap); - if (idx >= 0) - chooseMap->setCurrentIndex(idx); - else - chooseMap->setCurrentIndex(0); - } + setMap(m_curMap); }