Partially hook up feature size so horrorcat has something to test.
authornemo
Sat, 08 Nov 2014 11:26:16 -0500
changeset 10472 8d04cebedb16
parent 10471 d968b1ac130c
child 10476 e40021c61cfe
Partially hook up feature size so horrorcat has something to test.
QTfrontend/net/hwmap.cpp
QTfrontend/net/hwmap.h
QTfrontend/ui/widget/gamecfgwidget.cpp
QTfrontend/ui/widget/mapContainer.cpp
QTfrontend/ui/widget/mapContainer.h
hedgewars/uCommandHandlers.pas
hedgewars/uLandGenTemplateBased.pas
hedgewars/uVariables.pas
--- a/QTfrontend/net/hwmap.cpp	Sat Nov 08 10:11:16 2014 -0500
+++ b/QTfrontend/net/hwmap.cpp	Sat Nov 08 11:26:16 2014 -0500
@@ -30,6 +30,7 @@
     templateFilter = 0;
     m_mapgen = MAPGEN_REGULAR;
     m_maze_size = 0;
+    m_feature_size = 50;
 }
 
 HWMap::~HWMap()
@@ -41,13 +42,14 @@
     return !m_hasStarted;
 }
 
-void HWMap::getImage(const QString & seed, int filter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData, QString & script)
+void HWMap::getImage(const QString & seed, int filter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData, QString & script, int feature_size)
 {
     m_seed = seed;
     m_script = script;
     templateFilter = filter;
     m_mapgen = mapgen;
-    m_maze_size = maze_size;
+    m_maze_size = maze_size; // TODO replace with feature_size
+    m_feature_size = feature_size;
     if(mapgen == MAPGEN_DRAWN) m_drawMapData = drawMapData;
     Start(true);
 }
@@ -119,6 +121,7 @@
     SendIPC(QString("eseed %1").arg(m_seed).toUtf8());
     SendIPC(QString("e$template_filter %1").arg(templateFilter).toUtf8());
     SendIPC(QString("e$mapgen %1").arg(m_mapgen).toUtf8());
+    SendIPC(QString("e$feature_size %1").arg(m_feature_size).toUtf8());
     if (!m_script.isEmpty())
     {
         SendIPC(QString("escript Scripts/Multiplayer/%1.lua").arg(m_script).toUtf8());
--- a/QTfrontend/net/hwmap.h	Sat Nov 08 10:11:16 2014 -0500
+++ b/QTfrontend/net/hwmap.h	Sat Nov 08 11:26:16 2014 -0500
@@ -42,7 +42,7 @@
     public:
         HWMap(QObject *parent = 0);
         virtual ~HWMap();
-        void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData, QString & script);
+        void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData, QString & script, int feature_size);
         bool couldBeRemoved();
 
     protected:
@@ -59,7 +59,8 @@
         QString m_script;
         int templateFilter;
         MapGenerator m_mapgen;
-        int m_maze_size;
+        int m_maze_size;  // going to try and deprecate this one
+        int m_feature_size;
         QByteArray m_drawMapData;
 
     private slots:
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Sat Nov 08 10:11:16 2014 -0500
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Sat Nov 08 11:26:16 2014 -0500
@@ -323,6 +323,7 @@
     bcfg << QString("e$getawaytime %1").arg(schemeData(40).toInt()).toUtf8();
     bcfg << QString("e$worldedge %1").arg(schemeData(41).toInt()).toUtf8();
     bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8();
+    bcfg << QString("e$feature_size %1").arg(pMapContainer->getFeatureSize()).toUtf8();
     bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8();
     if(!schemeData(42).isNull())
         bcfg << QString("e$scriptparam %1").arg(schemeData(42).toString()).toUtf8();
--- a/QTfrontend/ui/widget/mapContainer.cpp	Sat Nov 08 10:11:16 2014 -0500
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Sat Nov 08 11:26:16 2014 -0500
@@ -61,6 +61,8 @@
     m_missionsViewSetup = false;
     m_staticViewSetup = false;
     m_script = QString();
+    m_prevMapFeatureSize = 50;
+    m_mapFeatureSize = 50;
 
     hhSmall.load(":/res/hh_small.png");
     hhLimit = 18;
@@ -227,7 +229,7 @@
     mapFeatureSize->setMaximum(100);
     mapFeatureSize->setMinimum(1);
     //mapFeatureSize->setFixedWidth(259);
-    mapFeatureSize->setValue(50);
+    mapFeatureSize->setValue(m_mapFeatureSize);
     mapFeatureSize->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     bottomLeftLayout->addWidget(mapFeatureSize, 0);
     connect(mapFeatureSize, SIGNAL(valueChanged(int)), this, SLOT(mapFeatureSizeChanged(int)));
@@ -322,7 +324,8 @@
                    get_mapgen(),
                    getMazeSize(),
                    getDrawnMapData(),
-                   m_script
+                   m_script,
+		   m_mapFeatureSize
                   );
 
     setHHLimit(0);
@@ -403,6 +406,11 @@
     return generationStyles->currentRow();
 }
 
+quint32 HWMapContainer::getFeatureSize() const
+{
+    return m_mapFeatureSize;
+}
+
 void HWMapContainer::resizeEvent ( QResizeEvent * event )
 {
     Q_UNUSED(event);
@@ -811,8 +819,15 @@
     emit mapgenChanged(mapgen);
 }
 
-void HWMapContainer::mapFeatureSizeChanged(int index)
+void HWMapContainer::mapFeatureSizeChanged(int val)
 {
+    // needs to be per map type, scales will be different
+    m_mapFeatureSize = val;
+    if (qAbs(m_prevMapFeatureSize-m_mapFeatureSize) > 8)
+    {
+	m_prevMapFeatureSize = m_mapFeatureSize;
+	updatePreview();
+    }
 }
 
 // unused because I needed the space for the slider
--- a/QTfrontend/ui/widget/mapContainer.h	Sat Nov 08 10:11:16 2014 -0500
+++ b/QTfrontend/ui/widget/mapContainer.h	Sat Nov 08 11:26:16 2014 -0500
@@ -60,6 +60,7 @@
         QString getCurrentScheme() const;
         QString getCurrentWeapons() const;
         quint32 getTemplateFilter() const;
+        quint32 getFeatureSize() const;
         MapGenerator get_mapgen(void) const;
         int getMazeSize(void) const;
         bool getCurrentIsMission() const;
@@ -175,6 +176,8 @@
 
         MapModel::MapInfo m_mapInfo;
         int m_themeID;
+        int m_prevMapFeatureSize;
+        int m_mapFeatureSize;
         QString m_theme;
         QString m_curMap;
 
--- a/hedgewars/uCommandHandlers.pas	Sat Nov 08 10:11:16 2014 -0500
+++ b/hedgewars/uCommandHandlers.pas	Sat Nov 08 11:26:16 2014 -0500
@@ -674,6 +674,11 @@
 cTemplateFilter:= StrToInt(s)
 end;
 
+procedure chFeatureSize(var s: shortstring);
+begin
+cFeatureSize:= StrToInt(s)
+end;
+
 procedure chInactDelay(var s: shortstring);
 begin
 cInactDelay:= StrToInt(s)
@@ -814,6 +819,7 @@
     RegisterVariable('template_filter', @chTemplateFilter, false);
     RegisterVariable('mapgen'  , @chMapGen        , false);
     RegisterVariable('maze_size',@chTemplateFilter, false);
+    RegisterVariable('feature_size',@chFeatureSize, false);
     RegisterVariable('delay'   , @chInactDelay    , false);
     RegisterVariable('ready'   , @chReadyDelay    , false);
     RegisterVariable('casefreq', @chCaseFactor    , false);
--- a/hedgewars/uLandGenTemplateBased.pas	Sat Nov 08 10:11:16 2014 -0500
+++ b/hedgewars/uLandGenTemplateBased.pas	Sat Nov 08 11:26:16 2014 -0500
@@ -9,6 +9,7 @@
 implementation
 uses uVariables, uConsts, uFloat, uLandUtils, uRandom, SDLh, math;
 
+var minDistance: LongInt; // different details size
 
 procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray);
 var i: LongInt;
@@ -97,7 +98,6 @@
 
 procedure FindPoint(si: LongInt; fillPointsCount: LongWord; var newPoint: TPoint; var pa: TPixAr);
 const mapBorderMargin = 40;
-    minDistance = 32; // adjust/parametrize this for different details size
 var p1, p2, p4, fp, mp: TPoint;
     i, t1, t2, iy, ix, aqpb: LongInt;
     a, b, p, q: LongInt;
@@ -336,7 +336,8 @@
     for y:= 0 to LAND_HEIGHT - 1 do
         for x:= 0 to LAND_WIDTH - 1 do
             Land[y, x]:= lfBasic;
-            
+    
+    minDistance:= max(cFeatureSize,12);
     MaxHedgehogs:= Template.MaxHedgehogs;
     hasGirders:= Template.hasGirders;
     playHeight:= Template.TemplateHeight;
--- a/hedgewars/uVariables.pas	Sat Nov 08 10:11:16 2014 -0500
+++ b/hedgewars/uVariables.pas	Sat Nov 08 11:26:16 2014 -0500
@@ -97,6 +97,7 @@
     cDamagePercent  : LongInt;
     cMineDudPercent : LongWord;
     cTemplateFilter : LongInt;
+    cFeatureSize    : LongInt;
     cMapGen         : LongInt;
     cRopePercent    : LongWord;
     cGetAwayTime    : LongWord;
@@ -2559,6 +2560,7 @@
     cGetAwayTime        := 100;
     cMineDudPercent     := 0;
     cTemplateFilter     := 0;
+    cFeatureSize        := 50;
     cMapGen             := 0;   // MAPGEN_REGULAR
     cHedgehogTurnTime   := 45000;
     cMinesTime          := 3000;