From ea3efffbb033855ecd5237623f091738ceb37b55 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 9 Jan 2024 02:18:36 +0200
Subject: [PATCH 46/46] Ruledit: Add unit type hitpoints and firepower editing

See RM #157

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 tools/ruledit/edit_utype.cpp | 40 +++++++++++++++++++++++++++++++++++-
 tools/ruledit/edit_utype.h   |  4 ++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/tools/ruledit/edit_utype.cpp b/tools/ruledit/edit_utype.cpp
index e7f9e378a5..e2e016ef5d 100644
--- a/tools/ruledit/edit_utype.cpp
+++ b/tools/ruledit/edit_utype.cpp
@@ -78,6 +78,26 @@ edit_utype::edit_utype(ruledit_gui *ui_in, struct unit_type *utype_in) : QDialog
   unit_layout->addWidget(label, row, 0);
   unit_layout->addWidget(defense, row++, 1);
 
+  label = new QLabel(QString::fromUtf8(R__("Hitpoints")));
+  label->setParent(this);
+
+  hitpoints = new QSpinBox(this);
+  hitpoints->setRange(0, 1000);
+  connect(hitpoints, SIGNAL(valueChanged(int)), this, SLOT(set_hitpoints(int)));
+
+  unit_layout->addWidget(label, row, 0);
+  unit_layout->addWidget(hitpoints, row++, 1);
+
+  label = new QLabel(QString::fromUtf8(R__("Firepower")));
+  label->setParent(this);
+
+  firepower = new QSpinBox(this);
+  firepower->setRange(0, 200);
+  connect(firepower, SIGNAL(valueChanged(int)), this, SLOT(set_firepower(int)));
+
+  unit_layout->addWidget(label, row, 0);
+  unit_layout->addWidget(firepower, row++, 1);
+
   label = new QLabel(QString::fromUtf8(R__("Move Rate")));
   label->setParent(this);
 
@@ -187,6 +207,8 @@ void edit_utype::refresh()
   bcost->setValue(utype->build_cost);
   attack->setValue(utype->attack_strength);
   defense->setValue(utype->defense_strength);
+  hitpoints->setValue(utype->hp);
+  firepower->setValue(utype->firepower);
   move_rate->setValue(utype->move_rate);
   gfx_tag->setText(utype->graphic_str);
   gfx_tag_alt->setText(utype->graphic_alt);
@@ -222,7 +244,23 @@ void edit_utype::set_defense_value(int value)
 }
 
 /**********************************************************************//**
-  Read move rater from spinbox
+  Read hitpoints from spinbox
+**************************************************************************/
+void edit_utype::set_hitpoints(int value)
+{
+  utype->hp = value;
+}
+
+/**********************************************************************//**
+  Read firepower from spinbox
+**************************************************************************/
+void edit_utype::set_firepower(int value)
+{
+  utype->firepower = value;
+}
+
+/**********************************************************************//**
+  Read move rate from spinbox
 **************************************************************************/
 void edit_utype::set_move_rate(int value)
 {
diff --git a/tools/ruledit/edit_utype.h b/tools/ruledit/edit_utype.h
index 34ef298157..c4484e7bd8 100644
--- a/tools/ruledit/edit_utype.h
+++ b/tools/ruledit/edit_utype.h
@@ -41,6 +41,8 @@ class edit_utype : public QDialog
     QSpinBox *bcost;
     QSpinBox *attack;
     QSpinBox *defense;
+    QSpinBox *hitpoints;
+    QSpinBox *firepower;
     QSpinBox *move_rate;
     QLineEdit *gfx_tag;
     QLineEdit *gfx_tag_alt;
@@ -57,6 +59,8 @@ class edit_utype : public QDialog
     void set_bcost_value(int value);
     void set_attack_value(int value);
     void set_defense_value(int value);
+    void set_hitpoints(int value);
+    void set_firepower(int value);
     void set_move_rate(int value);
     void gfx_tag_given();
     void gfx_tag_alt_given();
-- 
2.43.0

