330 addInfoToPreview(newImage); |
330 addInfoToPreview(newImage); |
331 pMap = 0; |
331 pMap = 0; |
332 |
332 |
333 cType->setEnabled(isMaster()); |
333 cType->setEnabled(isMaster()); |
334 } |
334 } |
|
335 |
|
336 void HWMapContainer::setImage(const QPixmap &newImage, bool showHHLimit) |
|
337 { |
|
338 if (showHHLimit) |
|
339 { |
|
340 addInfoToPreview(newImage); |
|
341 } |
|
342 else |
|
343 { |
|
344 QIcon mapPreviewIcon = QIcon(); |
|
345 mapPreviewIcon.addPixmap(newImage, QIcon::Normal); |
|
346 mapPreviewIcon.addPixmap(newImage, QIcon::Disabled); |
|
347 mapPreview->setIcon(mapPreviewIcon); |
|
348 mapPreview->setIconSize(newImage.size()); |
|
349 } |
|
350 |
|
351 pMap = 0; |
|
352 |
|
353 cType->setEnabled(isMaster()); |
|
354 } |
|
355 |
335 |
356 |
336 void HWMapContainer::setHHLimit(int newHHLimit) |
357 void HWMapContainer::setHHLimit(int newHHLimit) |
337 { |
358 { |
338 hhLimit = newHHLimit; |
359 hhLimit = newHHLimit; |
339 } |
360 } |
774 QIcon failIcon; |
795 QIcon failIcon; |
775 |
796 |
776 switch(m_mapInfo.type) |
797 switch(m_mapInfo.type) |
777 { |
798 { |
778 case MapModel::Invalid: |
799 case MapModel::Invalid: |
|
800 // Map error image |
779 failPixmap = QPixmap(":/res/missingMap.png"); |
801 failPixmap = QPixmap(":/res/missingMap.png"); |
780 failIcon = QIcon(); |
802 setImage(failPixmap, false); |
781 failIcon.addPixmap(failPixmap, QIcon::Normal); |
|
782 failIcon.addPixmap(failPixmap, QIcon::Disabled); |
|
783 mapPreview->setIcon(failIcon); |
|
784 mapPreview->setIconSize(failPixmap.size()); |
|
785 lblDesc->clear(); |
803 lblDesc->clear(); |
786 break; |
804 break; |
787 case MapModel::GeneratedMap: |
805 case MapModel::GeneratedMap: |
788 case MapModel::GeneratedMaze: |
806 case MapModel::GeneratedMaze: |
789 case MapModel::GeneratedPerlin: |
807 case MapModel::GeneratedPerlin: |
790 case MapModel::HandDrawnMap: |
808 case MapModel::HandDrawnMap: |
791 case MapModel::FortsMap: |
809 case MapModel::FortsMap: |
792 askForGeneratedPreview(); |
810 askForGeneratedPreview(); |
793 break; |
811 break; |
794 default: |
812 default: |
|
813 // For maps loaded from image |
795 if(m_missingMap) |
814 if(m_missingMap) |
796 { |
815 { |
|
816 // Map error image due to missing map |
797 failPixmap = QPixmap(":/res/missingMap.png"); |
817 failPixmap = QPixmap(":/res/missingMap.png"); |
798 failIcon = QIcon(); |
818 setImage(failPixmap, false); |
799 failIcon.addPixmap(failPixmap, QIcon::Normal); |
|
800 failIcon.addPixmap(failPixmap, QIcon::Disabled); |
|
801 mapPreview->setIcon(failIcon); |
|
802 mapPreview->setIconSize(failPixmap.size()); |
|
803 lblDesc->clear(); |
819 lblDesc->clear(); |
804 break; |
820 break; |
805 } |
821 } |
806 else |
822 else |
807 { |
823 { |
|
824 // Draw map preview |
808 QPixmap mapImage; |
825 QPixmap mapImage; |
809 bool success = mapImage.load("physfs://Maps/" + m_mapInfo.name + "/preview.png"); |
826 bool success = mapImage.load("physfs://Maps/" + m_mapInfo.name + "/preview.png"); |
810 |
827 |
811 if(!success) |
828 if(!success) |
812 { |
829 { |
813 mapPreview->setIcon(QIcon()); |
830 // Missing preview image |
|
831 setImage(QPixmap()); |
814 return; |
832 return; |
815 } |
833 } |
816 |
834 |
817 hhLimit = m_mapInfo.limit; |
835 setHHLimit(m_mapInfo.limit); |
818 addInfoToPreview(mapImage); |
836 setImage(mapImage); |
819 } |
837 } |
820 } |
838 } |
821 } |
839 } |
822 |
840 |
823 void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl, int featureSize) |
841 void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl, int featureSize) |