From 99b83f6f0dc18dc0fd90f3269bedbac8d87a4073 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 2 Oct 2023 21:11:50 +0300 Subject: [PATCH 35/35] Ruledit: Add unit sound tag editing See osdn #48791 Signed-off-by: Marko Lindqvist --- tools/ruledit/edit_utype.cpp | 88 ++++++++++++++++++++++++++++++++++++ tools/ruledit/edit_utype.h | 8 ++++ 2 files changed, 96 insertions(+) diff --git a/tools/ruledit/edit_utype.cpp b/tools/ruledit/edit_utype.cpp index d88d79598f..187a22c184 100644 --- a/tools/ruledit/edit_utype.cpp +++ b/tools/ruledit/edit_utype.cpp @@ -122,6 +122,46 @@ edit_utype::edit_utype(ruledit_gui *ui_in, struct unit_type *utype_in) : QDialog unit_layout->addWidget(label, row, 0); unit_layout->addWidget(gfx_tag_alt, row++, 1); + label = new QLabel(QString::fromUtf8(R__("Move sound tag"))); + label->setParent(this); + + sound_move_tag = new QLineEdit(this); + connect(sound_move_tag, SIGNAL(returnPressed()), this, + SLOT(sound_move_tag_given())); + + unit_layout->addWidget(label, row, 0); + unit_layout->addWidget(sound_move_tag, row++, 1); + + label = new QLabel(QString::fromUtf8(R__("Alt move sound tag"))); + label->setParent(this); + + sound_move_tag_alt = new QLineEdit(this); + connect(sound_move_tag_alt, SIGNAL(returnPressed()), this, + SLOT(sound_move_tag_alt_given())); + + unit_layout->addWidget(label, row, 0); + unit_layout->addWidget(sound_move_tag_alt, row++, 1); + + label = new QLabel(QString::fromUtf8(R__("Fight sound tag"))); + label->setParent(this); + + sound_fight_tag = new QLineEdit(this); + connect(sound_fight_tag, SIGNAL(returnPressed()), this, + SLOT(sound_fight_tag_given())); + + unit_layout->addWidget(label, row, 0); + unit_layout->addWidget(sound_fight_tag, row++, 1); + + label = new QLabel(QString::fromUtf8(R__("Alt fight sound tag"))); + label->setParent(this); + + sound_fight_tag_alt = new QLineEdit(this); + connect(sound_fight_tag_alt, SIGNAL(returnPressed()), this, + SLOT(sound_fight_tag_alt_given())); + + unit_layout->addWidget(label, row, 0); + unit_layout->addWidget(sound_fight_tag_alt, row++, 1); + refresh(); main_layout->addLayout(unit_layout); @@ -137,6 +177,10 @@ void edit_utype::closeEvent(QCloseEvent *cevent) // Save values from text fields. gfx_tag_given(); gfx_tag_alt_given(); + sound_move_tag_given(); + sound_move_tag_alt_given(); + sound_fight_tag_given(); + sound_fight_tag_alt_given(); utype->ruledit_dlg = nullptr; } @@ -153,6 +197,10 @@ void edit_utype::refresh() move_rate->setValue(utype->move_rate); gfx_tag->setText(utype->graphic_str); gfx_tag_alt->setText(utype->graphic_alt); + sound_move_tag->setText(utype->sound_move); + sound_move_tag_alt->setText(utype->sound_move_alt); + sound_fight_tag->setText(utype->sound_fight); + sound_fight_tag_alt->setText(utype->sound_fight_alt); } /**********************************************************************//** @@ -224,3 +272,43 @@ void edit_utype::gfx_tag_alt_given() sz_strlcpy(utype->graphic_alt, tag_bytes); } + +/**********************************************************************//** + User entered new move sound tag. +**************************************************************************/ +void edit_utype::sound_move_tag_given() +{ + QByteArray tag_bytes = sound_move_tag->text().toUtf8(); + + sz_strlcpy(utype->sound_move, tag_bytes); +} + +/**********************************************************************//** + User entered new alternative move sound tag. +**************************************************************************/ +void edit_utype::sound_move_tag_alt_given() +{ + QByteArray tag_bytes = sound_move_tag_alt->text().toUtf8(); + + sz_strlcpy(utype->sound_move_alt, tag_bytes); +} + +/**********************************************************************//** + User entered new move fight tag. +**************************************************************************/ +void edit_utype::sound_fight_tag_given() +{ + QByteArray tag_bytes = sound_fight_tag->text().toUtf8(); + + sz_strlcpy(utype->sound_fight, tag_bytes); +} + +/**********************************************************************//** + User entered new alternative fight sound tag. +**************************************************************************/ +void edit_utype::sound_fight_tag_alt_given() +{ + QByteArray tag_bytes = sound_fight_tag_alt->text().toUtf8(); + + sz_strlcpy(utype->sound_fight_alt, tag_bytes); +} diff --git a/tools/ruledit/edit_utype.h b/tools/ruledit/edit_utype.h index 294afd1c7c..ff6b7452d7 100644 --- a/tools/ruledit/edit_utype.h +++ b/tools/ruledit/edit_utype.h @@ -45,6 +45,10 @@ class edit_utype : public QDialog QSpinBox *move_rate; QLineEdit *gfx_tag; QLineEdit *gfx_tag_alt; + QLineEdit *sound_move_tag; + QLineEdit *sound_move_tag_alt; + QLineEdit *sound_fight_tag; + QLineEdit *sound_fight_tag_alt; protected: void closeEvent(QCloseEvent *cevent); @@ -57,6 +61,10 @@ class edit_utype : public QDialog void set_move_rate(int value); void gfx_tag_given(); void gfx_tag_alt_given(); + void sound_move_tag_given(); + void sound_move_tag_alt_given(); + void sound_fight_tag_given(); + void sound_fight_tag_alt_given(); }; #endif // FC__EDIT_UTYPE_H -- 2.40.1