Kaynağa Gözat

Templateeditor: Support forced level

Laserlicht 1 ay önce
ebeveyn
işleme
ede1668395

+ 16 - 0
mapeditor/templateeditor/templateeditor.cpp

@@ -365,6 +365,14 @@ void TemplateEditor::loadZoneMenuContent(bool onlyPosition)
 		ui->comboBoxZoneOwner->setEnabled(false);
 	}
 
+	ui->comboBoxForcedLevel->clear();
+	ui->comboBoxForcedLevel->addItem(tr("Automatic"), QVariant(static_cast<int>(EZoneLevel::AUTOMATIC)));
+	ui->comboBoxForcedLevel->addItem(tr("Surface"), QVariant(static_cast<int>(EZoneLevel::SURFACE)));
+	ui->comboBoxForcedLevel->addItem(tr("Underground"), QVariant(static_cast<int>(EZoneLevel::UNDERGROUND)));
+	for (int i = 0; i < ui->comboBoxForcedLevel->count(); ++i)
+		if (ui->comboBoxForcedLevel->itemData(i).toInt() == static_cast<int>(zone->getForcedLevel()))
+			ui->comboBoxForcedLevel->setCurrentIndex(i);
+
 	ui->comboBoxMonsterStrength->clear();
 	ui->comboBoxMonsterStrength->addItem(tr("None"), QVariant(static_cast<int>(EMonsterStrength::EMonsterStrength::ZONE_NONE)));
 	ui->comboBoxMonsterStrength->addItem(tr("Random"), QVariant(static_cast<int>(EMonsterStrength::EMonsterStrength::RANDOM)));
@@ -466,10 +474,12 @@ void TemplateEditor::saveZoneMenuContent()
 
 	auto zone = templates[selectedTemplate]->getZones().at(selectedZone);
 	auto type = static_cast<ETemplateZoneType>(ui->comboBoxZoneType->currentData().toInt());
+	auto forcedLevel = static_cast<EZoneLevel>(ui->comboBoxForcedLevel->currentData().toInt());
 
 	zone->setVisiblePosition(Point(ui->spinBoxZoneVisPosX->value(), ui->spinBoxZoneVisPosY->value()));
 	zone->setVisibleSize(ui->doubleSpinBoxZoneVisSize->value());
 	zone->setType(type);
+	zone->setForcedLevel(forcedLevel);
 	zone->setSize(ui->spinBoxZoneSize->value());
 	zone->playerTowns.townCount = ui->spinBoxTownCountPlayer->value();
 	zone->playerTowns.castleCount = ui->spinBoxCastleCountPlayer->value();
@@ -829,6 +839,12 @@ void TemplateEditor::on_comboBoxZoneOwner_currentTextChanged(const QString &text
 		saveZoneMenuContent();
 }
 
+void TemplateEditor::on_comboBoxForcedLevel_currentTextChanged(const QString &text)
+{
+	if(ui->comboBoxForcedLevel->hasFocus())
+		saveZoneMenuContent();
+}
+
 void TemplateEditor::on_spinBoxZoneSize_valueChanged()
 {
 	if(ui->spinBoxZoneSize->hasFocus())

+ 1 - 0
mapeditor/templateeditor/templateeditor.h

@@ -58,6 +58,7 @@ private slots:
 	void on_doubleSpinBoxZoneVisSize_valueChanged();
 	void on_comboBoxZoneType_currentTextChanged(const QString &text);
 	void on_comboBoxZoneOwner_currentTextChanged(const QString &text);
+	void on_comboBoxForcedLevel_currentTextChanged(const QString &text);
 	void on_spinBoxZoneSize_valueChanged();
 	void on_spinBoxTownCountPlayer_valueChanged();
 	void on_spinBoxCastleCountPlayer_valueChanged();

+ 19 - 7
mapeditor/templateeditor/templateeditor.ui

@@ -206,9 +206,9 @@
         <property name="geometry">
          <rect>
           <x>0</x>
-          <y>-316</y>
-          <width>449</width>
-          <height>830</height>
+          <y>0</y>
+          <width>441</width>
+          <height>936</height>
          </rect>
         </property>
         <attribute name="label">
@@ -552,9 +552,9 @@
         <property name="geometry">
          <rect>
           <x>0</x>
-          <y>0</y>
-          <width>449</width>
-          <height>1494</height>
+          <y>-106</y>
+          <width>441</width>
+          <height>1796</height>
          </rect>
         </property>
         <attribute name="label">
@@ -723,6 +723,18 @@
            </layout>
           </widget>
          </item>
+         <item>
+          <widget class="QGroupBox" name="groupBoxForcedLevel">
+           <property name="title">
+            <string>Forced level</string>
+           </property>
+           <layout class="QVBoxLayout" name="verticalLayout_22">
+            <item>
+             <widget class="QComboBox" name="comboBoxForcedLevel"/>
+            </item>
+           </layout>
+          </widget>
+         </item>
          <item>
           <widget class="QGroupBox" name="groupBoxZoneLink">
            <property name="title">
@@ -1280,7 +1292,7 @@
           <x>0</x>
           <y>0</y>
           <width>462</width>
-          <height>514</height>
+          <height>491</height>
          </rect>
         </property>
         <attribute name="label">