Browse Source

Add seed option to rmg

nordsoft 3 years ago
parent
commit
3aa19f92a0
3 changed files with 56 additions and 12 deletions
  1. 11 1
      mapeditor/windownewmap.cpp
  2. 2 0
      mapeditor/windownewmap.h
  3. 43 11
      mapeditor/windownewmap.ui

+ 11 - 1
mapeditor/windownewmap.cpp

@@ -235,7 +235,11 @@ void WindowNewMap::on_okButtong_clicked()
 			return;
 		}
 		
-		CMapGenerator generator(mapGenOptions);
+		int seed = std::time(nullptr);
+		if(ui->checkSeed->isChecked() && !ui->lineSeed->text().isEmpty())
+			seed = ui->lineSeed->text().toInt();
+			
+		CMapGenerator generator(mapGenOptions, seed);
 		auto progressBarWnd = new GeneratorProgress(generator, this);
 		progressBarWnd->show();
 	
@@ -403,3 +407,9 @@ void WindowNewMap::updateTemplateList()
 
 	ui->templateCombo->setCurrentIndex(0);
 }
+
+void WindowNewMap::on_checkSeed_toggled(bool checked)
+{
+	ui->lineSeed->setEnabled(checked);
+}
+

+ 2 - 0
mapeditor/windownewmap.h

@@ -78,6 +78,8 @@ private slots:
 
 	void on_heightTxt_textChanged(const QString &arg1);
 
+	void on_checkSeed_toggled(bool checked);
+
 private:
 
 	void updateTemplateList();

+ 43 - 11
mapeditor/windownewmap.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>448</width>
-    <height>379</height>
+    <width>444</width>
+    <height>445</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -24,8 +24,8 @@
   </property>
   <property name="maximumSize">
    <size>
-    <width>448</width>
-    <height>379</height>
+    <width>999</width>
+    <height>999</height>
    </size>
   </property>
   <property name="windowTitle">
@@ -40,7 +40,7 @@
      <x>10</x>
      <y>20</y>
      <width>291</width>
-     <height>81</height>
+     <height>91</height>
     </rect>
    </property>
    <property name="title">
@@ -178,9 +178,9 @@
    <property name="geometry">
     <rect>
      <x>10</x>
-     <y>120</y>
+     <y>140</y>
      <width>431</width>
-     <height>251</height>
+     <height>301</height>
     </rect>
    </property>
    <property name="sizePolicy">
@@ -415,7 +415,7 @@
       <x>10</x>
       <y>170</y>
       <width>411</width>
-      <height>41</height>
+      <height>51</height>
      </rect>
     </property>
     <property name="title">
@@ -544,7 +544,7 @@
       <x>10</x>
       <y>120</y>
       <width>411</width>
-      <height>41</height>
+      <height>51</height>
      </rect>
     </property>
     <property name="sizePolicy">
@@ -671,7 +671,7 @@
     <property name="geometry">
      <rect>
       <x>10</x>
-      <y>220</y>
+      <y>230</y>
       <width>411</width>
       <height>32</height>
      </rect>
@@ -708,12 +708,44 @@
      </item>
     </layout>
    </widget>
+   <widget class="QLineEdit" name="lineSeed">
+    <property name="enabled">
+     <bool>false</bool>
+    </property>
+    <property name="geometry">
+     <rect>
+      <x>280</x>
+      <y>270</y>
+      <width>131</width>
+      <height>21</height>
+     </rect>
+    </property>
+    <property name="inputMethodHints">
+     <set>Qt::ImhDigitsOnly</set>
+    </property>
+    <property name="text">
+     <string>0</string>
+    </property>
+   </widget>
+   <widget class="QCheckBox" name="checkSeed">
+    <property name="geometry">
+     <rect>
+      <x>110</x>
+      <y>270</y>
+      <width>161</width>
+      <height>20</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Custom seed</string>
+    </property>
+   </widget>
   </widget>
   <widget class="QCheckBox" name="randomMapCheck">
    <property name="geometry">
     <rect>
      <x>10</x>
-     <y>100</y>
+     <y>120</y>
      <width>291</width>
      <height>20</height>
     </rect>