Made map preview a random/edit button again.
Changed how I fixed a bug in
r06541556df53.
Removed newline delimiters used in maps' desc.txt. The description label actually auto-wraps :)
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp Fri Feb 01 08:47:07 2013 -0500
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp Fri Feb 01 18:07:43 2013 -0500
@@ -49,6 +49,7 @@
setMaximumHeight(447);
setMinimumWidth(470);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ m_master = true;
// Easy containers for the map/game options in either stacked or tabbed mode
@@ -678,6 +679,7 @@
void GameCFGWidget::setMaster(bool master)
{
+ if (master == m_master) return;
m_master = master;
pMapContainer->setMaster(master);
--- a/QTfrontend/ui/widget/mapContainer.cpp Fri Feb 01 08:47:07 2013 -0500
+++ b/QTfrontend/ui/widget/mapContainer.cpp Fri Feb 01 18:07:43 2013 -0500
@@ -132,14 +132,15 @@
QLabel * lblMapPreviewText = new QLabel(this);
lblMapPreviewText->setText(tr("Map preview:"));
leftLayout->addWidget(lblMapPreviewText, 0);
- leftLayout->addSpacing(2);
/* Map Preview */
- mapPreview = new QLabel(this);
+ mapPreview = new QPushButton(this);
mapPreview->setObjectName("mapPreview");
mapPreview->setFixedSize(256, 128);
+ mapPreview->setContentsMargins(0, 0, 0, 0);
leftLayout->addWidget(mapPreview, 0);
+ connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked()));
/* Bottom-Left layout */
@@ -230,7 +231,7 @@
lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
lblDesc->setAlignment(Qt::AlignTop | Qt::AlignLeft);
lblDesc->setStyleSheet("font: 10px;");
- bottomLeftLayout->addWidget(lblDesc, 1);
+ bottomLeftLayout->addWidget(lblDesc, 100);
/* Add stretch above theme button */
@@ -270,7 +271,7 @@
px.setMask(bm);
p.fillRect(pxres.rect(), linearGrad);
- p.drawPixmap(QPoint(0, 0), px);
+ p.drawPixmap(0, 0, px);
addInfoToPreview(pxres);
pMap = 0;
@@ -300,7 +301,14 @@
p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text);
p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall);
- mapPreview->setPixmap(finalImage);
+ // Shrink, crop, and center preview image
+ QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6));
+ QPainter pc(¢ered);
+ pc.fillRect(centered.rect(), linearGrad);
+ pc.drawPixmap(-3, -3, finalImage);
+
+ mapPreview->setIcon(QIcon(centered));
+ mapPreview->setIconSize(centered.size());
}
void HWMapContainer::askForGeneratedPreview()
@@ -333,6 +341,19 @@
cType->setEnabled(false);
}
+void HWMapContainer::previewClicked()
+{
+ switch (m_mapInfo.type)
+ {
+ case MapModel::HandDrawnMap:
+ emit drawMapRequested();
+ break;
+ default:
+ setRandomMap();
+ break;
+ }
+}
+
QString HWMapContainer::getCurrentSeed() const
{
return m_seed;
@@ -594,7 +615,8 @@
{
case MapModel::Invalid:
failIcon = QPixmap(":/res/btnDisabled.png");
- mapPreview->setPixmap(failIcon);
+ mapPreview->setIcon(QIcon(failIcon));
+ mapPreview->setIconSize(failIcon.size());
break;
case MapModel::GeneratedMap:
askForGeneratedPreview();
@@ -611,7 +633,7 @@
if(!success)
{
- mapPreview->setPixmap(QPixmap());
+ mapPreview->setIcon(QIcon());
return;
}
@@ -730,6 +752,8 @@
}
}
+ repaint();
+
emit mapgenChanged(mapgen);
}
@@ -887,6 +911,7 @@
void HWMapContainer::setMaster(bool master)
{
+ if (master == m_master) return;
m_master = master;
foreach (QWidget *widget, m_childWidgets)
--- a/QTfrontend/ui/widget/mapContainer.h Fri Feb 01 08:47:07 2013 -0500
+++ b/QTfrontend/ui/widget/mapContainer.h Fri Feb 01 18:07:43 2013 -0500
@@ -107,13 +107,14 @@
void missionMapChanged(const QModelIndex & map, const QModelIndex & old = QModelIndex());
void loadDrawing();
void showSeedPrompt();
+ void previewClicked();
protected:
virtual void resizeEvent ( QResizeEvent * event );
private:
QVBoxLayout mainLayout;
- QLabel* mapPreview;
+ QPushButton* mapPreview;
QComboBox* chooseMap;
MapModel * m_staticMapModel;
MapModel * m_missionMapModel;
--- a/share/hedgewars/Data/Maps/Basketball/desc.txt Fri Feb 01 08:47:07 2013 -0500
+++ b/share/hedgewars/Data/Maps/Basketball/desc.txt Fri Feb 01 18:07:43 2013 -0500
@@ -1,1 +1,1 @@
-en_US=Who said hedgehogs can't|play basketball?
+en_US=Who said hedgehogs can't play basketball?
--- a/share/hedgewars/Data/Maps/Control/desc.txt Fri Feb 01 08:47:07 2013 -0500
+++ b/share/hedgewars/Data/Maps/Control/desc.txt Fri Feb 01 18:07:43 2013 -0500
@@ -1,1 +1,1 @@
-en_US=Islands scattered everywhere\, full set of|weapons.
+en_US=Islands scattered everywhere\, full set of weapons.
--- a/share/hedgewars/Data/Maps/Knockball/desc.txt Fri Feb 01 08:47:07 2013 -0500
+++ b/share/hedgewars/Data/Maps/Knockball/desc.txt Fri Feb 01 18:07:43 2013 -0500
@@ -1,1 +1,1 @@
-en_US=Knock your opponents off the platforms|using only a bat!
+en_US=Knock your opponents off the platforms using only a bat!
--- a/share/hedgewars/Data/Maps/TrophyRace/desc.txt Fri Feb 01 08:47:07 2013 -0500
+++ b/share/hedgewars/Data/Maps/TrophyRace/desc.txt Fri Feb 01 18:07:43 2013 -0500
@@ -1,1 +1,1 @@
-en_US=Ready\, set\, go! Who is going to|be the first in this|crazy race?
\ No newline at end of file
+en_US=Ready\, set\, go! Who is going to be the first in this crazy race?
\ No newline at end of file