Merge
authorMedo <smaxein@googlemail.com>
Sat, 02 Feb 2013 14:22:57 +0100
changeset 8469 018da0724a93
parent 8465 9114b50fed82 (current diff)
parent 8468 71159aa7172f (diff)
child 8470 01ddeb241c21
Merge
--- a/QTfrontend/model/GameStyleModel.cpp	Thu Jan 31 02:14:56 2013 +0100
+++ b/QTfrontend/model/GameStyleModel.cpp	Sat Feb 02 14:22:57 2013 +0100
@@ -25,12 +25,11 @@
 
 #include "physfs.h"
 #include "GameStyleModel.h"
+#include "hwconsts.h"
 
 
 void GameStyleModel::loadGameStyles()
 {
-    const QString appDir = QString(PHYSFS_getBaseDir());
-
     beginResetModel();
 
     // empty list, so that we can (re)fill it
@@ -81,7 +80,7 @@
 
         // detect if script is dlc
         QString scriptPath = PHYSFS_getRealDir(QString("Scripts/Multiplayer/%1.lua").arg(script).toLocal8Bit().data());
-        bool isDLC = !scriptPath.startsWith(appDir);
+        bool isDLC = !scriptPath.startsWith(datadir->absolutePath());
 
         QStandardItem * item = new QStandardItem((isDLC ? "*" : "") + name);
 
--- a/QTfrontend/model/MapModel.cpp	Thu Jan 31 02:14:56 2013 +0100
+++ b/QTfrontend/model/MapModel.cpp	Sat Feb 02 14:22:57 2013 +0100
@@ -26,6 +26,7 @@
 #include "physfs.h"
 #include "MapModel.h"
 #include "HWApplication.h"
+#include "hwconsts.h"
 
 MapModel::MapInfo MapModel::MapInfoRandom = {MapModel::GeneratedMap, "+rnd+", "", 0, "", "", ""};
 MapModel::MapInfo MapModel::MapInfoMaze = {MapModel::GeneratedMaze, "+maze+", "", 0, "", "", ""};
@@ -33,8 +34,6 @@
 
 void MapModel::loadMaps(MapType maptype)
 {
-    const QString appDir = QString(PHYSFS_getBaseDir());
-
     // this method resets the contents of this model (important to know for views).
     beginResetModel();
 
@@ -99,7 +98,7 @@
 
             // detect if map is dlc
             QString mapDir = PHYSFS_getRealDir(QString("Maps/%1/map.cfg").arg(map).toLocal8Bit().data());
-            dlc = !mapDir.startsWith(appDir);
+            dlc = !mapDir.startsWith(datadir->absolutePath());
 
             // let's use some semi-sane hedgehog limit, rather than none
             if (limit == 0)
--- a/QTfrontend/model/ThemeModel.cpp	Thu Jan 31 02:14:56 2013 +0100
+++ b/QTfrontend/model/ThemeModel.cpp	Sat Feb 02 14:22:57 2013 +0100
@@ -23,6 +23,7 @@
 
 #include "physfs.h"
 #include "ThemeModel.h"
+#include "hwconsts.h"
 
 ThemeModel::ThemeModel(QObject *parent) :
     QAbstractListModel(parent)
@@ -50,8 +51,6 @@
 
 void ThemeModel::loadThemes()
 {
-    const QString appDir = QString(PHYSFS_getBaseDir());
-
     beginResetModel();
 
     DataManager & datamgr = DataManager::instance();
@@ -77,7 +76,7 @@
 
         // detect if theme is dlc
         QString themeDir = PHYSFS_getRealDir(QString("Themes/%1/icon.png").arg(theme).toLocal8Bit().data());
-        dataset.insert(Qt::UserRole + 2, !themeDir.startsWith(appDir));
+        dataset.insert(Qt::UserRole + 2, !themeDir.startsWith(datadir->absolutePath()));
 
         // set icon path
         dataset.insert(Qt::UserRole + 1, iconpath);
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Thu Jan 31 02:14:56 2013 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Sat Feb 02 14:22:57 2013 +0100
@@ -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	Thu Jan 31 02:14:56 2013 +0100
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Sat Feb 02 14:22:57 2013 +0100
@@ -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(&centered);
+    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	Thu Jan 31 02:14:56 2013 +0100
+++ b/QTfrontend/ui/widget/mapContainer.h	Sat Feb 02 14:22:57 2013 +0100
@@ -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/hedgewars/uGearsHandlersRope.pas	Thu Jan 31 02:14:56 2013 +0100
+++ b/hedgewars/uGearsHandlersRope.pas	Sat Feb 02 14:22:57 2013 +0100
@@ -165,12 +165,12 @@
 
     if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then
         if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx))
-        or (TestCollisionYwithGear(HHGear, hwSign(ropeDy)) <> 0)) then
+        or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1, hwSign(ropeDy)))) then
             Gear^.Elasticity := Gear^.Elasticity + _1_2;
 
     if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then
         if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx))
-        or (TestCollisionYwithGear(HHGear, -hwSign(ropeDy)) <> 0)) then
+        or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1, -hwSign(ropeDy)))) then
             Gear^.Elasticity := Gear^.Elasticity - _1_2;
 
     HHGear^.X := Gear^.X + mdX * Gear^.Elasticity;
@@ -264,7 +264,7 @@
         HHGear^.dX := -_0_6 * HHGear^.dX;
         haveCollision := true
         end;
-    if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0 then
+    if TestCollisionYwithXYShift(HHGear, 0, 1, hwSign(HHGear^.dY)) then
         begin
         HHGear^.dY := -_0_6 * HHGear^.dY;
         haveCollision := true
--- a/share/hedgewars/Data/Maps/Basketball/desc.txt	Thu Jan 31 02:14:56 2013 +0100
+++ b/share/hedgewars/Data/Maps/Basketball/desc.txt	Sat Feb 02 14:22:57 2013 +0100
@@ -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	Thu Jan 31 02:14:56 2013 +0100
+++ b/share/hedgewars/Data/Maps/Control/desc.txt	Sat Feb 02 14:22:57 2013 +0100
@@ -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	Thu Jan 31 02:14:56 2013 +0100
+++ b/share/hedgewars/Data/Maps/Knockball/desc.txt	Sat Feb 02 14:22:57 2013 +0100
@@ -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	Thu Jan 31 02:14:56 2013 +0100
+++ b/share/hedgewars/Data/Maps/TrophyRace/desc.txt	Sat Feb 02 14:22:57 2013 +0100
@@ -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