Browse Source

Add hero limit checkbox in map editor

nordsoft 2 years ago
parent
commit
94c6c0c262
3 changed files with 48 additions and 1 deletions
  1. 12 0
      mapeditor/mapsettings.cpp
  2. 2 0
      mapeditor/mapsettings.h
  3. 34 1
      mapeditor/mapsettings.ui

+ 12 - 0
mapeditor/mapsettings.cpp

@@ -93,6 +93,8 @@ MapSettings::MapSettings(MapController & ctrl, QWidget *parent) :
 
 	ui->mapNameEdit->setText(tr(controller.map()->name.c_str()));
 	ui->mapDescriptionEdit->setPlainText(tr(controller.map()->description.c_str()));
+	ui->heroLevelLimit->setValue(controller.map()->levelLimit);
+	ui->heroLevelLimitCheck->setChecked(controller.map()->levelLimit);
 	
 	show();
 	
@@ -432,6 +434,10 @@ void MapSettings::on_pushButton_clicked()
 {
 	controller.map()->name = ui->mapNameEdit->text().toStdString();
 	controller.map()->description = ui->mapDescriptionEdit->toPlainText().toStdString();
+	if(ui->heroLevelLimitCheck->isChecked())
+		controller.map()->levelLimit = ui->heroLevelLimit->value();
+	else
+		controller.map()->levelLimit = 0;
 	controller.commitChangeWithoutRedraw();
 	
 	for(int i = 0; i < controller.map()->allowedAbilities.size(); ++i)
@@ -875,3 +881,9 @@ void MapSettings::on_loseComboBox_currentIndexChanged(int index)
 	}
 }
 
+
+void MapSettings::on_heroLevelLimitCheck_toggled(bool checked)
+{
+	ui->heroLevelLimit->setEnabled(checked);
+}
+

+ 2 - 0
mapeditor/mapsettings.h

@@ -32,6 +32,8 @@ private slots:
 
 	void on_loseComboBox_currentIndexChanged(int index);
 
+	void on_heroLevelLimitCheck_toggled(bool checked);
+
 private:
 	
 	std::string getTownName(int townObjectIdx);

+ 34 - 1
mapeditor/mapsettings.ui

@@ -10,7 +10,7 @@
     <x>0</x>
     <y>0</y>
     <width>470</width>
-    <height>480</height>
+    <height>494</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -60,6 +60,39 @@
        <item>
         <widget class="QPlainTextEdit" name="mapDescriptionEdit"/>
        </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_4">
+         <property name="topMargin">
+          <number>10</number>
+         </property>
+         <item>
+          <widget class="QSpinBox" name="heroLevelLimit">
+           <property name="enabled">
+            <bool>false</bool>
+           </property>
+           <property name="minimumSize">
+            <size>
+             <width>48</width>
+             <height>0</height>
+            </size>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="heroLevelLimitCheck">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text">
+            <string>Limit maximum heroes level</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
        <item>
         <widget class="QGroupBox" name="groupBox">
          <property name="title">