From cbd7e3720179e8f8b7346fed75a9c62bafbae6ef Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 23 Apr 2023 03:10:02 +0300 Subject: [PATCH 10/10] Ruledit: Add effects count to stats See osdn #47906 Signed-off-by: Marko Lindqvist --- tools/ruledit/tab_misc.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/ruledit/tab_misc.cpp b/tools/ruledit/tab_misc.cpp index c11dc5afdf..c6408308b7 100644 --- a/tools/ruledit/tab_misc.cpp +++ b/tools/ruledit/tab_misc.cpp @@ -217,6 +217,10 @@ tab_misc::tab_misc(ruledit_gui *ui_in) : QWidget() stats->setItem(5, 6, item); item = new QTableWidgetItem("-"); stats->setItem(5, 7, item); + item = new QTableWidgetItem(QString::fromUtf8(RQ_("?stat:Effects"))); + stats->setItem(6, 6, item); + item = new QTableWidgetItem("-"); + stats->setItem(6, 7, item); stats->verticalHeader()->setVisible(false); stats->horizontalHeader()->setVisible(false); stats->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -306,6 +310,16 @@ void tab_misc::save_now() ui->display_msg(R__("Ruleset saved")); } +/************************************************************************** + Callback to count number of effects +**************************************************************************/ +static bool effect_counter(struct effect *peff, void *data) +{ + (*(int *)data)++; + + return TRUE; +} + /************************************************************************** Recalculate stats **************************************************************************/ @@ -423,6 +437,10 @@ void tab_misc::refresh_stats() } multipliers_active_iterate_end; stats->item(row++, 7)->setText(QString::number(count)); + count = 0; + iterate_effect_cache(effect_counter, &count); + stats->item(row++, 7)->setText(QString::number(count)); + stats->resizeColumnsToContents(); } -- 2.39.2