From 5182f956edae97c085dd0cf1415259d9596fca07 Mon Sep 17 00:00:00 2001 From: Dino Date: Sun, 20 Jul 2025 16:08:55 -0400 Subject: [PATCH] #1604 make help -> units show all tech requirements --- client/gui-qt/helpdlg.cpp | 57 ++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index c87401297f..32e7bdf5a2 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -882,7 +882,6 @@ void help_widget::set_topic_unit(const help_item *topic, struct canvas *canvas; const struct unit_type *obsolete; struct unit_type *utype, *max_utype; - QList list; QString str; utype = unit_type_by_translated_name(title); @@ -934,26 +933,48 @@ void help_widget::set_topic_unit(const help_item *topic, add_info_separator(); - // Tech requirement - tech = utype_primary_tech_req(utype); - if (advance_number(tech) != A_NONE) { - QLabel *tb; - - tb = new QLabel(this); + // Tech requirements + // see if any reqs + if (utype->build_reqs.size == 0) { + add_info_label(_("No technology required.")); + } else { + // there is >= 1 req // TRANS: this and similar literal strings interpreted as (Qt) HTML str = _("Requires"); - str = "" + str + " " - + link_me(advance_name_translation(tech), HELP_TECH); + str = "" + str + " "; - tb->setProperty(fonts::help_label, "true"); - tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); - tb->setTextFormat(Qt::RichText); - tb->setText(str.trimmed()); - connect(tb, &QLabel::linkActivated, - this, &help_widget::anchor_clicked); - info_layout->addWidget(tb); - } else { - add_info_label(_("No technology required.")); + // iterate all the reqs + QLabel *tb; + int num_reqs_on_this_line = 0; + unit_tech_reqs_iterate(utype, padv) { + str = str + link_me(advance_name_translation(padv), HELP_TECH); + if (++num_reqs_on_this_line == 3) { + // start a new line when we get 3 on this line + tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); + tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); + tb->setTextFormat(Qt::RichText); + tb->setText(str.trimmed()); + connect(tb, &QLabel::linkActivated, + this, &help_widget::anchor_clicked); + info_layout->addWidget(tb); + + num_reqs_on_this_line = 0; + str = ""; + } + } unit_tech_reqs_iterate_end; + + // finish any leftovers on last line + if (num_reqs_on_this_line != 0) { + tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); + tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); + tb->setTextFormat(Qt::RichText); + tb->setText(str.trimmed()); + connect(tb, &QLabel::linkActivated, + this, &help_widget::anchor_clicked); + info_layout->addWidget(tb); + } } // Obsolescence -- 2.31.0