226 |
226 |
227 lblDesc = new QLabel(); |
227 lblDesc = new QLabel(); |
228 lblDesc->setWordWrap(true); |
228 lblDesc->setWordWrap(true); |
229 lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
229 lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
230 lblDesc->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
230 lblDesc->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
231 bottomLeftLayout->addWidget(lblDesc, 100); |
231 lblDesc->setStyleSheet("font: 10px;"); |
232 |
232 bottomLeftLayout->addWidget(lblDesc, 1); |
233 /* Spacing above theme chooser */ |
233 |
|
234 /* Add stretch above theme button */ |
234 |
235 |
235 bottomLeftLayout->addStretch(1); |
236 bottomLeftLayout->addStretch(1); |
236 |
237 |
237 /* Theme chooser */ |
238 /* Theme chooser */ |
238 |
239 |
239 btnTheme = new QPushButton(); |
240 btnTheme = new QPushButton(); |
240 connect(btnTheme, SIGNAL(clicked()), this, SLOT(showThemePrompt())); |
241 connect(btnTheme, SIGNAL(clicked()), this, SLOT(showThemePrompt())); |
241 m_childWidgets << btnTheme; |
242 m_childWidgets << btnTheme; |
242 bottomLeftLayout->addWidget(btnTheme, 1); |
243 bottomLeftLayout->addWidget(btnTheme, 0); |
243 |
244 |
244 /* Add everything to main layout */ |
245 /* Add everything to main layout */ |
245 |
246 |
246 mainLayout.addLayout(twoColumnLayout, 0); |
247 mainLayout.addLayout(twoColumnLayout, 0); |
247 |
248 |
252 setMazeSize(0); |
253 setMazeSize(0); |
253 setTemplateFilter(0); |
254 setTemplateFilter(0); |
254 staticMapChanged(m_staticMapModel->index(0, 0)); |
255 staticMapChanged(m_staticMapModel->index(0, 0)); |
255 missionMapChanged(m_missionMapModel->index(0, 0)); |
256 missionMapChanged(m_missionMapModel->index(0, 0)); |
256 updateTheme(m_themeModel->index(0, 0)); |
257 updateTheme(m_themeModel->index(0, 0)); |
257 mapTypeChanged(0); |
258 changeMapType(MapModel::GeneratedMap); |
258 } |
259 } |
259 |
260 |
260 void HWMapContainer::setImage(const QImage newImage) |
261 void HWMapContainer::setImage(const QImage newImage) |
261 { |
262 { |
262 QPixmap px(m_previewSize); |
263 QPixmap px(m_previewSize); |
680 setMapInfo(MapModel::MapInfoRandom); |
681 setMapInfo(MapModel::MapInfoRandom); |
681 lblMapList->setText(tr("Map size:")); |
682 lblMapList->setText(tr("Map size:")); |
682 lblMapList->show(); |
683 lblMapList->show(); |
683 generationStyles->show(); |
684 generationStyles->show(); |
684 btnRandomize->show(); |
685 btnRandomize->show(); |
685 btnTheme->show(); |
|
686 break; |
686 break; |
687 case MapModel::GeneratedMaze: |
687 case MapModel::GeneratedMaze: |
688 mapgen = MAPGEN_MAZE; |
688 mapgen = MAPGEN_MAZE; |
689 setMapInfo(MapModel::MapInfoMaze); |
689 setMapInfo(MapModel::MapInfoMaze); |
690 lblMapList->setText(tr("Maze style:")); |
690 lblMapList->setText(tr("Maze style:")); |
691 lblMapList->show(); |
691 lblMapList->show(); |
692 mazeStyles->show(); |
692 mazeStyles->show(); |
693 btnRandomize->show(); |
693 btnRandomize->show(); |
694 btnTheme->show(); |
|
695 break; |
694 break; |
696 case MapModel::HandDrawnMap: |
695 case MapModel::HandDrawnMap: |
697 mapgen = MAPGEN_DRAWN; |
696 mapgen = MAPGEN_DRAWN; |
698 setMapInfo(MapModel::MapInfoDrawn); |
697 setMapInfo(MapModel::MapInfoDrawn); |
699 btnTheme->show(); |
|
700 btnLoadMap->show(); |
698 btnLoadMap->show(); |
701 btnEditMap->show(); |
699 btnEditMap->show(); |
702 break; |
700 break; |
703 case MapModel::MissionMap: |
701 case MapModel::MissionMap: |
704 mapgen = MAPGEN_MAP; |
702 mapgen = MAPGEN_MAP; |
735 } |
736 } |
736 |
737 |
737 emit mapgenChanged(mapgen); |
738 emit mapgenChanged(mapgen); |
738 } |
739 } |
739 |
740 |
|
741 void HWMapContainer::updateThemeButtonSize() |
|
742 { |
|
743 if (m_mapInfo.type == MapModel::MissionMap) |
|
744 { |
|
745 btnTheme->setIconSize(QSize(30, 30)); |
|
746 btnTheme->setFixedHeight(30); |
|
747 } |
|
748 else |
|
749 { |
|
750 QSize iconSize = btnTheme->icon().actualSize(QSize(65535, 65535)); |
|
751 btnTheme->setIconSize(iconSize); |
|
752 btnTheme->setFixedHeight(64); |
|
753 } |
|
754 } |
|
755 |
740 void HWMapContainer::showThemePrompt() |
756 void HWMapContainer::showThemePrompt() |
741 { |
757 { |
742 ThemePrompt prompt(this); |
758 ThemePrompt prompt(this); |
743 int theme = prompt.exec() - 1; // Since 0 means canceled, so all indexes are +1'd |
759 int theme = prompt.exec() - 1; // Since 0 means canceled, so all indexes are +1'd |
744 if (theme < 0) return; |
760 if (theme < 0) return; |
745 |
761 |
746 QModelIndex current = m_themeModel->index(theme, 0); |
762 QModelIndex current = m_themeModel->index(theme, 0); |
747 updateTheme(current); |
763 updateTheme(current); |
748 |
|
749 emit themeChanged(m_theme); |
764 emit themeChanged(m_theme); |
750 } |
765 } |
751 |
766 |
752 void HWMapContainer::updateTheme(const QModelIndex & current) |
767 void HWMapContainer::updateTheme(const QModelIndex & current) |
753 { |
768 { |
754 m_theme = selectedTheme = current.data().toString(); |
769 m_theme = selectedTheme = current.data().toString(); |
755 QIcon icon = qVariantValue<QIcon>(current.data(Qt::UserRole)); |
770 QIcon icon = qVariantValue<QIcon>(current.data(Qt::UserRole)); |
756 QSize iconSize = icon.actualSize(QSize(65535, 65535)); |
771 QSize iconSize = icon.actualSize(QSize(65535, 65535)); |
757 btnTheme->setFixedHeight(iconSize.height()); |
772 btnTheme->setFixedHeight(64); |
758 btnTheme->setIconSize(iconSize); |
773 btnTheme->setIconSize(iconSize); |
759 btnTheme->setIcon(icon); |
774 btnTheme->setIcon(icon); |
760 btnTheme->setText(tr("Theme: ") + current.data(Qt::DisplayRole).toString()); |
775 btnTheme->setText(tr("Theme: ") + current.data(Qt::DisplayRole).toString()); |
761 emit themeChanged(m_theme); |
776 updateThemeButtonSize(); |
762 } |
777 } |
763 |
778 |
764 void HWMapContainer::staticMapChanged(const QModelIndex & map, const QModelIndex & old) |
779 void HWMapContainer::staticMapChanged(const QModelIndex & map, const QModelIndex & old) |
765 { |
780 { |
766 mapChanged(map, 0, old); |
781 mapChanged(map, 0, old); |
813 |
828 |
814 void HWMapContainer::setMapInfo(MapModel::MapInfo mapInfo) |
829 void HWMapContainer::setMapInfo(MapModel::MapInfo mapInfo) |
815 { |
830 { |
816 m_mapInfo = mapInfo; |
831 m_mapInfo = mapInfo; |
817 m_curMap = m_mapInfo.name; |
832 m_curMap = m_mapInfo.name; |
818 m_theme = m_mapInfo.theme; |
|
819 |
833 |
820 // the map has no pre-defined theme, so let's use the selected one |
834 // the map has no pre-defined theme, so let's use the selected one |
821 if (m_mapInfo.theme.isEmpty()) |
835 if (m_mapInfo.theme.isEmpty()) |
822 { |
836 { |
823 m_theme = selectedTheme; |
837 if (!selectedTheme.isEmpty()) |
824 emit themeChanged(m_theme); |
838 { |
|
839 setTheme(selectedTheme); |
|
840 emit themeChanged(selectedTheme); |
|
841 } |
|
842 } |
|
843 else |
|
844 { |
|
845 setTheme(m_mapInfo.theme); |
|
846 emit themeChanged(m_mapInfo.theme); |
825 } |
847 } |
826 |
848 |
827 lblDesc->setText(mapInfo.desc); |
849 lblDesc->setText(mapInfo.desc); |
828 |
850 |
829 updatePreview(); |
851 updatePreview(); |
830 emit mapChanged(m_curMap); |
852 emit mapChanged(m_curMap); |
831 } |
853 } |
832 |
854 |
833 void HWMapContainer::loadDrawing() |
855 void HWMapContainer::loadDrawing() |
834 { |
856 { |
835 |
|
836 |
|
837 QString fileName = QFileDialog::getOpenFileName(NULL, tr("Load drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)"); |
857 QString fileName = QFileDialog::getOpenFileName(NULL, tr("Load drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)"); |
838 |
858 |
839 if(fileName.isEmpty()) return; |
859 if(fileName.isEmpty()) return; |
840 |
|
841 |
|
842 |
860 |
843 QFile f(fileName); |
861 QFile f(fileName); |
844 |
862 |
845 if(!f.open(QIODevice::ReadOnly)) |
863 if(!f.open(QIODevice::ReadOnly)) |
846 { |
864 { |