Feature #457 » 0054-Ruledit-Add-unit-class-editing.patch
| tools/ruledit/edit_utype.cpp | ||
|---|---|---|
|   QHBoxLayout *main_layout = new QHBoxLayout(this); | ||
|   QGridLayout *unit_layout = new QGridLayout(); | ||
|   QLabel *label; | ||
|   QMenu *menu; | ||
|   int row = 0; | ||
|   int rowcount; | ||
|   int column; | ||
| ... | ... | |
|   setWindowTitle(QString::fromUtf8(utype_rule_name(utype))); | ||
|   label = new QLabel(QString::fromUtf8(R__("Class"))); | ||
|   label->setParent(this); | ||
|   class_button = new QToolButton(); | ||
|   class_button->setParent(this); | ||
|   class_button->setToolButtonStyle(Qt::ToolButtonTextOnly); | ||
|   class_button->setPopupMode(QToolButton::MenuButtonPopup); | ||
|   menu = new QMenu(); | ||
|   connect(menu, SIGNAL(triggered(QAction *)), this, SLOT(class_menu(QAction *))); | ||
|   unit_class_re_active_iterate(pclass) { | ||
|     menu->addAction(uclass_rule_name(pclass)); | ||
|   } unit_class_re_active_iterate_end; | ||
|   class_button->setMenu(menu); | ||
|   unit_layout->addWidget(label, row, 0); | ||
|   unit_layout->addWidget(class_button, row++, 1); | ||
|   label = new QLabel(QString::fromUtf8(R__("Build Cost"))); | ||
|   label->setParent(this); | ||
| ... | ... | |
| **************************************************************************/ | ||
| void edit_utype::refresh() | ||
| { | ||
|   class_button->setText(uclass_rule_name(utype->uclass)); | ||
|   bcost->setValue(utype->build_cost); | ||
|   attack->setValue(utype->attack_strength); | ||
|   defense->setValue(utype->defense_strength); | ||
| ... | ... | |
|   sz_strlcpy(utype->sound_fight_alt, tag_bytes); | ||
| } | ||
| /**********************************************************************//** | ||
|   User selected class | ||
| **************************************************************************/ | ||
| void edit_utype::class_menu(QAction *action) | ||
| { | ||
|   QByteArray cn_bytes; | ||
|   struct unit_class *pclass; | ||
|   cn_bytes = action->text().toUtf8(); | ||
|   pclass = unit_class_by_rule_name(cn_bytes.data()); | ||
|   utype->uclass = pclass; | ||
|   refresh(); | ||
| } | ||
| tools/ruledit/edit_utype.h | ||
|---|---|---|
|   private: | ||
|     ruledit_gui *ui; | ||
|     struct unit_type *utype; | ||
|     QToolButton *class_button; | ||
|     QSpinBox *bcost; | ||
|     QSpinBox *attack; | ||
|     QSpinBox *defense; | ||
| ... | ... | |
|     void closeEvent(QCloseEvent *cevent); | ||
|   private slots: | ||
|     void class_menu(QAction *action); | ||
|     void set_bcost_value(int value); | ||
|     void set_attack_value(int value); | ||
|     void set_defense_value(int value); | ||