exposing seed for editing and viewing
authorHenek
Mon, 13 Dec 2010 19:26:20 +0100
changeset 4519 aee36896d46b
parent 4518 ce95df0398fb
child 4520 e7882bd1a894
exposing seed for editing and viewing
QTfrontend/mapContainer.cpp
QTfrontend/mapContainer.h
--- a/QTfrontend/mapContainer.cpp	Mon Dec 13 20:54:18 2010 +0300
+++ b/QTfrontend/mapContainer.cpp	Mon Dec 13 19:26:20 2010 +0100
@@ -29,6 +29,7 @@
 #include <QListWidget>
 #include <QVBoxLayout>
 #include <QIcon>
+#include <QLineEdit>
 
 #include "hwconsts.h"
 #include "mapContainer.h"
@@ -211,6 +212,12 @@
     gbTLayout->addWidget(lwThemes);
     lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
 
+    QLabel* seedLabel = new QLabel(tr("Seed"), this);
+    mainLayout.addWidget(seedLabel, 3, 0);
+    seedEdit = new QLineEdit(this);
+    mainLayout.addWidget(seedEdit, 3, 1, 1, 2);
+    connect(seedEdit, SIGNAL(textChanged(const QString&)), this, SLOT(seedEdited(const QString&)));
+
     mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
 
     setRandomSeed();
@@ -408,6 +415,8 @@
 void HWMapContainer::setSeed(const QString & seed)
 {
     m_seed = seed;
+    if (seed != seedEdit->text())
+        seedEdit->setText(seed);
     if (chooseMap->currentIndex() < MAPGEN_LAST)
         changeImage();
 }
@@ -483,6 +492,7 @@
 void HWMapContainer::setRandomSeed()
 {
     m_seed = QUuid::createUuid().toString();
+    seedEdit->setText(m_seed);
     emit seedChanged(m_seed);
     if (chooseMap->currentIndex() < MAPGEN_LAST)
         changeImage();
@@ -535,3 +545,14 @@
 {
     return drawnMapData;
 }
+
+void HWMapContainer::seedEdited(const QString & seed)
+{
+    if (seed.isEmpty() || seed.size() > 54)
+        seedEdit->setText(m_seed);
+    else
+    {
+        setSeed(seed);
+        emit seedChanged(seed);
+    }
+}
--- a/QTfrontend/mapContainer.h	Mon Dec 13 20:54:18 2010 +0300
+++ b/QTfrontend/mapContainer.h	Mon Dec 13 19:26:20 2010 +0100
@@ -24,6 +24,7 @@
 #include <QComboBox>
 #include <QLabel>
 #include <QByteArray>
+#include <QLineEdit>
 
 #include "hwmap.h"
 
@@ -83,6 +84,7 @@
   void themeSelected(int currentRow);
   void addInfoToPreview(QPixmap image);
   void templateFilterChanged(int filter);
+  void seedEdited(const QString & seed);
 
  protected:
   virtual void resizeEvent ( QResizeEvent * event );
@@ -95,6 +97,7 @@
   QListWidget* lwThemes;
   HWMap* pMap;
   QString m_seed;
+  QLineEdit* seedEdit;
   int hhLimit;
   int templateFilter;
   QPixmap hhSmall;