From 1952f92b7c2fa163774ae093d4c0cbce662400ba Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 8 Apr 2021 15:45:54 +0300 Subject: [PATCH 50/50] Ruledit: Add support for editing unit build cost See osdn #41950 Signed-off-by: Marko Lindqvist --- tools/ruledit/edit_utype.cpp | 19 +++++++++++++++++++ tools/ruledit/edit_utype.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/tools/ruledit/edit_utype.cpp b/tools/ruledit/edit_utype.cpp index b8db8904d5..61c3a12e2f 100644 --- a/tools/ruledit/edit_utype.cpp +++ b/tools/ruledit/edit_utype.cpp @@ -60,6 +60,16 @@ edit_utype::edit_utype(ruledit_gui *ui_in, struct unit_type *utype_in) : QDialog unit_layout->addWidget(label, 0, 0); unit_layout->addWidget(req_button, 0, 1); + label = new QLabel(QString::fromUtf8(R__("Build Cost"))); + label->setParent(this); + + bcost = new QSpinBox(this); + bcost->setRange(0, 10000); + connect(bcost, SIGNAL(valueChanged(int)), this, SLOT(set_bcost_value(int))); + + unit_layout->addWidget(label, 1, 0); + unit_layout->addWidget(bcost, 1, 1); + refresh(); main_layout->addLayout(unit_layout); @@ -73,6 +83,7 @@ edit_utype::edit_utype(ruledit_gui *ui_in, struct unit_type *utype_in) : QDialog void edit_utype::refresh() { req_button->setText(tab_tech::tech_name(utype->require_advance)); + bcost->setValue(utype->build_cost); } /**********************************************************************//** @@ -92,3 +103,11 @@ void edit_utype::req_menu(QAction *action) refresh(); } } + +/**********************************************************************//** + Read build cost value from spinbox +**************************************************************************/ +void edit_utype::set_bcost_value(int value) +{ + utype->build_cost = value; +} diff --git a/tools/ruledit/edit_utype.h b/tools/ruledit/edit_utype.h index 5ec4ff3918..3b7361041c 100644 --- a/tools/ruledit/edit_utype.h +++ b/tools/ruledit/edit_utype.h @@ -20,6 +20,7 @@ // Qt #include +#include class QToolButton; @@ -37,9 +38,11 @@ class edit_utype : public QDialog ruledit_gui *ui; struct unit_type *utype; QToolButton *req_button; + QSpinBox *bcost; private slots: void req_menu(QAction *action); + void set_bcost_value(int value); }; -- 2.30.2