From c5eded415c5ef9f3da06a2894bb5331606129f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sun, 26 May 2024 14:08:37 +0200 Subject: [PATCH] !OSDN:#117692:Slawomir Lach User can see counters in city dialog (Qt5) diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index 0e5deeb491..ab3122d903 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -41,6 +41,7 @@ // common #include "citizens.h" #include "city.h" +#include "counters.h" #include "game.h" //agents @@ -1873,8 +1874,8 @@ city_dialog::city_dialog(QWidget *parent): qfc_dialog(parent) gridl = new QGridLayout; slider_grid = new QGridLayout; - counterss_layout = new QHBoxLayout(); - counterss_widget = new QWidget(); + counterss_layout = new QVBoxLayout(); + counterss_widget = new QScrollArea(); counterss_widget->setLayout(counterss_layout); qpush2 @@ -2090,6 +2091,8 @@ void city_dialog::update_tabs() { if (current_tab == happiness) { happiness_button->setToolTip(_("Show city production")); + counterss_button->setToolTip(_("Show counters information")); + } else { happiness_button->setToolTip(_("Show happiness information")); @@ -2972,6 +2975,7 @@ void city_dialog::refresh() update_buy_button(); update_citizens(); update_building(); + update_counters_table(); update_improvements(); update_units(); update_nation_table(); @@ -2988,6 +2992,35 @@ void city_dialog::refresh() } +/************************************************************************//** + Updates counters table +****************************************************************************/ +void city_dialog::update_counters_table() +{ + qDeleteAll(counterss_widget->findChildren("", Qt::FindDirectChildrenOnly)); + city_counters_iterate(pcount) { + QString concatStr; + QLabel *name = new QLabel(name_translation_get(&pcount->name)); + concatStr=QString::asprintf("%s%d", _("Current value is: "), + dlgcity->counter_values[counter_index(pcount)]); + QLabel *value = new QLabel(concatStr); + concatStr=QString::asprintf("%s%d",_("Activated once value equal or higher than: "),pcount->checkpoint); + QLabel *activated = new QLabel(concatStr); + QString helptext; + if (NULL!=pcount->helptext) { + strvec_iterate(pcount->helptext, text_) { + helptext+=text_; + } strvec_iterate_end; + } + + counterss_layout->addWidget(name); + counterss_layout->addWidget(value); + counterss_layout->addWidget(activated); + counterss_layout->addWidget(new QLabel(helptext)); + + } city_counters_iterate_end; +} + /************************************************************************//** Updates nationality table in happiness tab ****************************************************************************/ diff --git a/client/gui-qt/citydlg.h b/client/gui-qt/citydlg.h index 137ce78289..9ed43a8230 100644 --- a/client/gui-qt/citydlg.h +++ b/client/gui-qt/citydlg.h @@ -443,7 +443,7 @@ class city_dialog: public qfc_dialog QHBoxLayout *single_page_layout; QHBoxLayout *happiness_layout; - QHBoxLayout *counterss_layout; + QVBoxLayout *counterss_layout; QSplitter *prod_unit_splitter; QSplitter *central_left_splitter; QSplitter *central_splitter; @@ -511,6 +511,7 @@ public: private: int current_building; void update_title(); + void update_counters_table(); void update_building(); void update_info_label(); void update_buy_button(); -- 2.42.1