- Pass map drawing data to engine
authorunc0rr
Wed, 08 Dec 2010 22:18:50 +0300
changeset 4489 c4ca9ced258b
parent 4487 dbf69c7c5e00
child 4490 f6840f7e2f60
- Pass map drawing data to engine - Hardcode one map for test purposes
QTfrontend/gamecfgwidget.cpp
QTfrontend/hwmap.cpp
QTfrontend/hwmap.h
QTfrontend/mapContainer.cpp
QTfrontend/mapContainer.h
--- a/QTfrontend/gamecfgwidget.cpp	Wed Dec 08 21:55:15 2010 +0300
+++ b/QTfrontend/gamecfgwidget.cpp	Wed Dec 08 22:18:50 2010 +0300
@@ -173,6 +173,8 @@
 QStringList GameCFGWidget::getFullConfig() const
 {
     QStringList sl;
+    int mapgen = pMapContainer->get_mapgen();
+    
     sl.append("eseed " + pMapContainer->getCurrentSeed());
     sl.append(QString("e$gmflags %1").arg(getGameFlags()));
     sl.append(QString("e$damagepct %1").arg(schemeData(24).toInt()));
@@ -189,8 +191,26 @@
     sl.append(QString("e$healthdec %1").arg(schemeData(36).toInt()));
     sl.append(QString("e$ropepct %1").arg(schemeData(37).toInt()));
     sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
-    sl.append(QString("e$mapgen %1").arg(pMapContainer->get_mapgen()));
-    sl.append(QString("e$maze_size %1").arg(pMapContainer->get_maze_size()));
+    sl.append(QString("e$mapgen %1").arg(mapgen));
+
+    switch (mapgen)
+    {
+        case MAPGEN_MAZE:
+            sl.append(QString("e$maze_size %1").arg(pMapContainer->get_maze_size()));
+
+        case MAPGEN_DRAWN:
+        {
+            QByteArray data = pMapContainer->getDrawnMapData();
+            while(data.size() > 0)
+            {
+                QByteArray tmp = data;
+                tmp.truncate(230);
+                sl << QString("edraw %1").arg(QString(tmp));
+                data.remove(0, 230);
+            }
+        }
+        default: ;
+    }
 
     QString currentMap = pMapContainer->getCurrentMap();
     if (currentMap.size() > 0)
--- a/QTfrontend/hwmap.cpp	Wed Dec 08 21:55:15 2010 +0300
+++ b/QTfrontend/hwmap.cpp	Wed Dec 08 22:18:50 2010 +0300
@@ -27,12 +27,13 @@
 {
 }
 
-void HWMap::getImage(std::string seed, int filter, MapGenerator mapgen, int maze_size)
+void HWMap::getImage(std::string seed, int filter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData)
 {
     m_seed = seed;
     templateFilter = filter;
     m_mapgen = mapgen;
     m_maze_size = maze_size;
+    m_drawMapData = drawMapData;
     Start();
 }
 
@@ -62,6 +63,25 @@
     SendIPC(QString("eseed %1").arg(m_seed.c_str()).toLatin1());
     SendIPC(QString("e$template_filter %1").arg(templateFilter).toLatin1());
     SendIPC(QString("e$mapgen %1").arg(m_mapgen).toLatin1());
-    SendIPC(QString("e$maze_size %1").arg(m_maze_size).toLatin1());
+
+    switch (m_mapgen)
+    {
+        case MAPGEN_MAZE:
+            SendIPC(QString("e$maze_size %1").arg(m_maze_size).toLatin1());
+
+        case MAPGEN_DRAWN:
+        {
+            QByteArray data = m_drawMapData;
+            while(data.size() > 0)
+            {
+                QByteArray tmp = data;
+                tmp.truncate(230);
+                SendIPC("edraw " + tmp);
+                data.remove(0, 230);
+            }
+        }
+        default: ;
+    }
+
     SendIPC("!");
 }
--- a/QTfrontend/hwmap.h	Wed Dec 08 21:55:15 2010 +0300
+++ b/QTfrontend/hwmap.h	Wed Dec 08 22:18:50 2010 +0300
@@ -42,7 +42,7 @@
  public:
   HWMap();
   virtual ~HWMap();
-  void getImage(std::string seed, int templateFilter, MapGenerator mapgen, int maze_size);
+  void getImage(std::string seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData);
 
  protected:
   virtual QStringList setArguments();
@@ -58,6 +58,7 @@
   int templateFilter;
   MapGenerator m_mapgen;
   int m_maze_size;
+  QByteArray m_drawMapData;
 
  private slots:
 };
--- a/QTfrontend/mapContainer.cpp	Wed Dec 08 21:55:15 2010 +0300
+++ b/QTfrontend/mapContainer.cpp	Wed Dec 08 22:18:50 2010 +0300
@@ -39,7 +39,9 @@
     mainLayout(this),
     pMap(0),
     mapgen(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+    )
 {
     hhSmall.load(":/res/hh_small.png");
     hhLimit = 18;
@@ -324,7 +326,7 @@
     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(), getTemplateFilter(), mapgen, maze_size);
+    pMap->getImage(m_seed.toStdString(), getTemplateFilter(), mapgen, maze_size, drawnMapData);
 }
 
 void HWMapContainer::themeSelected(int currentRow)
@@ -504,3 +506,8 @@
     emit mapgenChanged(m);
     changeImage();
 }
+
+QByteArray HWMapContainer::getDrawnMapData()
+{
+    return drawnMapData;
+}
\ No newline at end of file
--- a/QTfrontend/mapContainer.h	Wed Dec 08 21:55:15 2010 +0300
+++ b/QTfrontend/mapContainer.h	Wed Dec 08 22:18:50 2010 +0300
@@ -23,6 +23,7 @@
 #include <QGridLayout>
 #include <QComboBox>
 #include <QLabel>
+#include <QByteArray>
 
 #include "hwmap.h"
 
@@ -48,6 +49,7 @@
   MapGenerator get_mapgen(void) const;
   int get_maze_size(void) const;
   bool getCurrentIsMission() const;
+  QByteArray getDrawnMapData();
 
  public slots:
   void changeImage();
@@ -98,6 +100,7 @@
   QLabel *maze_size_label;
   QComboBox *maze_size_selection;
   MapGenerator mapgen;
+  QByteArray drawnMapData;
   int numMissions;
   int maze_size;