144 /* Map Preview */ |
144 /* Map Preview */ |
145 |
145 |
146 mapPreview = new QPushButton(this); |
146 mapPreview = new QPushButton(this); |
147 mapPreview->setObjectName("mapPreview"); |
147 mapPreview->setObjectName("mapPreview"); |
148 mapPreview->setFlat(true); |
148 mapPreview->setFlat(true); |
149 mapPreview->setFixedSize(256, 128); |
149 mapPreview->setFixedSize(256 + 6, 128 + 6); |
150 mapPreview->setContentsMargins(0, 0, 0, 0); |
150 mapPreview->setContentsMargins(0, 0, 0, 0); |
151 leftLayout->addWidget(mapPreview, 0); |
151 leftLayout->addWidget(mapPreview, 0); |
152 connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked())); |
152 connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked())); |
153 |
153 |
154 /* Bottom-Left layout */ |
154 /* Bottom-Left layout */ |
253 staticMapChanged(m_staticMapModel->index(0, 0)); |
253 staticMapChanged(m_staticMapModel->index(0, 0)); |
254 missionMapChanged(m_missionMapModel->index(0, 0)); |
254 missionMapChanged(m_missionMapModel->index(0, 0)); |
255 changeMapType(MapModel::GeneratedMap); |
255 changeMapType(MapModel::GeneratedMap); |
256 } |
256 } |
257 |
257 |
258 void HWMapContainer::setImage(const QImage newImage) |
258 void HWMapContainer::setImage(const QPixmap &newImage) |
259 { |
259 { |
260 QPixmap px(m_previewSize); |
260 addInfoToPreview(newImage); |
261 QPixmap pxres(px.size()); |
|
262 QPainter p(&pxres); |
|
263 |
|
264 px.fill(Qt::yellow); |
|
265 QBitmap bm = QBitmap::fromImage(newImage); |
|
266 px.setMask(bm); |
|
267 |
|
268 p.fillRect(pxres.rect(), linearGrad); |
|
269 p.drawPixmap(0, 0, px); |
|
270 |
|
271 addInfoToPreview(pxres); |
|
272 pMap = 0; |
261 pMap = 0; |
273 |
262 |
274 cType->setEnabled(isMaster()); |
263 cType->setEnabled(isMaster()); |
275 } |
264 } |
276 |
265 |
278 { |
267 { |
279 hhLimit = newHHLimit; |
268 hhLimit = newHHLimit; |
280 } |
269 } |
281 |
270 |
282 // Should this add text to identify map size? |
271 // Should this add text to identify map size? |
283 void HWMapContainer::addInfoToPreview(QPixmap image) |
272 void HWMapContainer::addInfoToPreview(const QPixmap &image) |
284 { |
273 { |
285 QPixmap finalImage = QPixmap(image.size()); |
274 QPixmap finalImage = QPixmap(image.size()); |
286 finalImage.fill(QColor(0, 0, 0, 0)); |
275 //finalImage.fill(QColor(0, 0, 0, 0)); |
287 |
276 |
288 QPainter p(&finalImage); |
277 QPainter p(&finalImage); |
289 p.drawPixmap(image.rect(), image); |
278 p.fillRect(finalImage.rect(), linearGrad); |
|
279 p.drawPixmap(finalImage.rect(), image); |
290 //p.setPen(QColor(0xf4,0x9e,0xe9)); |
280 //p.setPen(QColor(0xf4,0x9e,0xe9)); |
291 p.setPen(QColor(0xff,0xcc,0x00)); |
281 p.setPen(QColor(0xff,0xcc,0x00)); |
292 p.setBrush(QColor(0, 0, 0)); |
282 p.setBrush(QColor(0, 0, 0)); |
293 p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
283 p.drawRect(finalImage.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
294 p.setFont(QFont("MS Shell Dlg", 10)); |
284 p.setFont(QFont("MS Shell Dlg", 10)); |
295 QString text = (hhLimit > 0) ? QString::number(hhLimit) : "?"; |
285 QString text = (hhLimit > 0) ? QString::number(hhLimit) : "?"; |
296 p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text); |
286 p.drawText(finalImage.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text); |
297 p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
287 p.drawPixmap(finalImage.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
298 |
288 |
299 // Shrink, crop, and center preview image |
289 // Shrink, crop, and center preview image |
300 QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6)); |
290 /*QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6)); |
301 QPainter pc(¢ered); |
291 QPainter pc(¢ered); |
302 pc.fillRect(centered.rect(), linearGrad); |
292 pc.fillRect(centered.rect(), linearGrad); |
303 pc.drawPixmap(-3, -3, finalImage); |
293 pc.drawPixmap(-3, -3, finalImage);*/ |
304 |
294 |
305 mapPreview->setIcon(QIcon(centered)); |
295 mapPreview->setIcon(QIcon(finalImage)); |
306 mapPreview->setIconSize(centered.size()); |
296 mapPreview->setIconSize(finalImage.size()); |
307 } |
297 } |
308 |
298 |
309 void HWMapContainer::askForGeneratedPreview() |
299 void HWMapContainer::askForGeneratedPreview() |
310 { |
300 { |
311 pMap = new HWMap(this); |
301 pMap = new HWMap(this); |
312 connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
302 connect(pMap, SIGNAL(ImageReceived(QPixmap)), this, SLOT(setImage(QPixmap))); |
313 connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
303 connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
314 connect(pMap, SIGNAL(destroyed(QObject *)), this, SLOT(onPreviewMapDestroyed(QObject *))); |
304 connect(pMap, SIGNAL(destroyed(QObject *)), this, SLOT(onPreviewMapDestroyed(QObject *))); |
315 pMap->getImage(m_seed, |
305 pMap->getImage(m_seed, |
316 getTemplateFilter(), |
306 getTemplateFilter(), |
317 get_mapgen(), |
307 get_mapgen(), |