# HG changeset patch # User unc0rr # Date 1234628660 0 # Node ID c84223511ca87cd2a77eb50421ed4f8b28987682 # Parent 5e7d66230067663370e16db628ca19f902c8dcf1 frontend's part of nemo patch diff -r 5e7d66230067 -r c84223511ca8 QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Sat Feb 14 16:23:51 2009 +0000 +++ b/QTfrontend/hedgewars.qrc Sat Feb 14 16:24:20 2009 +0000 @@ -43,5 +43,6 @@ res/spin_up.png res/spin_down.png res/PlaySound.png + res/hh_small.png diff -r 5e7d66230067 -r c84223511ca8 QTfrontend/hwmap.cpp --- a/QTfrontend/hwmap.cpp Sat Feb 14 16:23:51 2009 +0000 +++ b/QTfrontend/hwmap.cpp Sat Feb 14 16:24:20 2009 +0000 @@ -17,7 +17,7 @@ #include "hwconsts.h" #include "hwmap.h" - + #include HWMap::HWMap() : TCPBase(false) { @@ -44,9 +44,14 @@ void HWMap::onClientDisconnect() { - QImage im((uchar*)(readbuffer.constData()), 256, 128, QImage::Format_Mono); - im.setNumColors(2); - emit ImageReceived(im); + if (readbuffer.size() == 128 * 32 + 1) + { + quint8 *buf = (quint8*) readbuffer.constData(); + QImage im(buf, 256, 128, QImage::Format_Mono); + im.setNumColors(2); + emit HHLimitReceived(buf[128 * 32 + 1]); + emit ImageReceived(im); + } } void HWMap::SendToClientFirst() diff -r 5e7d66230067 -r c84223511ca8 QTfrontend/hwmap.h --- a/QTfrontend/hwmap.h Sat Feb 14 16:23:51 2009 +0000 +++ b/QTfrontend/hwmap.h Sat Feb 14 16:24:20 2009 +0000 @@ -43,6 +43,7 @@ signals: void ImageReceived(const QImage newImage); + void HHLimitReceived(int hhLimit); private: std::string m_seed; diff -r 5e7d66230067 -r c84223511ca8 QTfrontend/mapContainer.cpp --- a/QTfrontend/mapContainer.cpp Sat Feb 14 16:23:51 2009 +0000 +++ b/QTfrontend/mapContainer.cpp Sat Feb 14 16:24:20 2009 +0000 @@ -39,10 +39,14 @@ mainLayout(this), pMap(0) { + hhSmall.load(":/res/hh_small.png"); + hhLimit = 18; + mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), 1, QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); + imageButt = new QPushButton(this); imageButt->setObjectName("imageButt"); imageButt->setFixedSize(256 + 6, 128 + 6); @@ -61,11 +65,20 @@ QString("%1/Maps/%2/map.cfg") .arg(datadir->absolutePath()) .arg(map)); + if (mapCfgFile.open(QFile::ReadOnly)) { QString theme; + quint32 limit = 0; + QList mapInfo; QTextStream input(&mapCfgFile); input >> theme; - chooseMap->addItem(map, theme); + input >> limit; + mapInfo.push_back(theme); + if (limit) + mapInfo.push_back(limit); + else + mapInfo.push_back(18); + chooseMap->addItem(map, mapInfo); mapCfgFile.close(); } } @@ -122,12 +135,16 @@ p.fillRect(QRect(0, 0, 256, 128), linearGrad); p.drawPixmap(QPoint(0, 0), px); - imageButt->setIcon(pxres); - imageButt->setIconSize(QSize(256, 128)); + addInfoToPreview(pxres); chooseMap->setCurrentIndex(0); pMap = 0; } +void HWMapContainer::setHHLimit(int newHHLimit) +{ + hhLimit = newHHLimit; +} + void HWMapContainer::mapChanged(int index) { if(!index) { @@ -151,20 +168,46 @@ chooseMap->setCurrentIndex(0); return; } - imageButt->setIcon(mapImage); + + hhLimit = chooseMap->itemData(index).toList()[1].toInt(); + addInfoToPreview(mapImage); +} + +// Should this add text to identify map size? +void HWMapContainer::addInfoToPreview(QPixmap image) +{ + QPixmap finalImage = QPixmap(image.size()); + finalImage.fill(QColor(0, 0, 0, 0)); + + QPainter p(&finalImage); + p.drawPixmap(image.rect(), image); + //p.setPen(QColor(0xf4,0x9e,0xe9)); + p.setPen(QColor(0xff,0xcc,0x00)); + p.setBrush(QColor(0, 0, 0)); + p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); + p.setFont(QFont("MS Shell Dlg", 10)); + p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); + p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); + + imageButt->setIcon(finalImage); + imageButt->setIconSize(image.size()); } void HWMapContainer::changeImage() { pMap = new HWMap(); connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); + connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); pMap->getImage(m_seed.toStdString()); } void HWMapContainer::themeSelected(int currentRow) { QString theme = Themes->at(currentRow); - chooseMap->setItemData(0, theme); + QList mapInfo; + mapInfo.push_back(theme); + mapInfo.push_back(18); + chooseMap->setItemData(0, mapInfo); gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme))); emit themeChanged(theme); } @@ -182,7 +225,12 @@ QString HWMapContainer::getCurrentTheme() const { - return chooseMap->itemData(chooseMap->currentIndex()).toString(); + return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); +} + +int HWMapContainer::getCurrentHHLimit() const +{ + return hhLimit; } void HWMapContainer::resizeEvent ( QResizeEvent * event ) diff -r 5e7d66230067 -r c84223511ca8 QTfrontend/mapContainer.h --- a/QTfrontend/mapContainer.h Sat Feb 14 16:23:51 2009 +0000 +++ b/QTfrontend/mapContainer.h Sat Feb 14 16:24:20 2009 +0000 @@ -42,6 +42,7 @@ QString getCurrentSeed() const; QString getCurrentMap() const; QString getCurrentTheme() const; + int getCurrentHHLimit() const; public slots: void changeImage(); @@ -57,10 +58,12 @@ private slots: void setImage(const QImage newImage); + void setHHLimit(int hhLimit); void mapChanged(int index); void setRandomSeed(); void setRandomTheme(); void themeSelected(int currentRow); + void addInfoToPreview(QPixmap image); protected: virtual void resizeEvent ( QResizeEvent * event ); @@ -73,6 +76,8 @@ QListWidget* lwThemes; HWMap* pMap; QString m_seed; + int hhLimit; + QPixmap hhSmall; void loadMap(int index); }; diff -r 5e7d66230067 -r c84223511ca8 QTfrontend/res/hh_small.png Binary file QTfrontend/res/hh_small.png has changed