From 71703af6b8aa8f3028e060be43c23458973eafc2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 3 Jul 2022 13:49:59 +0300 Subject: [PATCH 58/58] Qt: Show wonders intel information See osdn #44990 Signed-off-by: Marko Lindqvist --- client/gui-qt/plrdlg.cpp | 78 ++++++++++++++++++++++++++++++++++++++-- client/gui-qt/plrdlg.h | 6 ++++ 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/client/gui-qt/plrdlg.cpp b/client/gui-qt/plrdlg.cpp index 6824abf878..a6dbf1d257 100644 --- a/client/gui-qt/plrdlg.cpp +++ b/client/gui-qt/plrdlg.cpp @@ -454,11 +454,13 @@ void plr_widget::nation_selected(const QItemSelection &sl, struct player *me; Tech_type_id tech_id; bool global_observer = client_is_global_observer(); + QString rule; other_player = NULL; intel_str.clear(); tech_str.clear(); ally_str.clear(); + wonder_str.clear(); if (indexes.isEmpty()) { selected_player = nullptr; @@ -649,6 +651,55 @@ void plr_widget::nation_selected(const QItemSelection &sl, } } + switch (game.info.small_wonder_visibility) { + case WV_ALWAYS: + rule = _("All Wonders are known"); + break; + case WV_NEVER: + rule = _("Small Wonders not known"); + break; + case WV_EMBASSY: + rule = _("Small Wonders visible if we have an embassy"); + break; + } + + wonder_str = QString("Wonders of %1 Empire."). + arg(QString(nation_plural_for_player(pplayer)).toHtmlEscaped()); + wonder_str += nl + QString(_("Rule: ")) + rule + nl; + + improvement_iterate(impr) { + if (is_wonder(impr)) { + const char *cityname; + QString notes; + QString wonstr; + + if (wonder_is_built(pplayer, impr)) { + struct city *wcity = city_from_wonder(pplayer, impr); + + if (wcity != NULL) { + cityname = city_name_get(wcity); + } else { + cityname = _("(unknown city)"); + } + if (improvement_obsolete(pplayer, impr, NULL)) { + notes = _(" (obsolete)"); + } + } else if (wonder_is_lost(pplayer, impr)) { + cityname = _("(lost)"); + } else { + continue; + } + + if (is_great_wonder(impr)) { + wonstr = QString("") + improvement_name_translation(impr) + QString(""); + } else { + wonstr = improvement_name_translation(impr); + } + + wonder_str += wonstr + QString(" ") + cityname + notes + nl; + } + } improvement_iterate_end; + plr->update_report(false); } @@ -697,6 +748,11 @@ plr_report::plr_report():QWidget() tech_label->setFrameStyle(QFrame::StyledPanel); tech_label->setAlignment(Qt::AlignTop | Qt::AlignLeft); tech_label->setWordWrap(true); + wonder_label = new QLabel; + wonder_label->setFrameStyle(QFrame::StyledPanel); + wonder_label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + wonder_label->setWordWrap(true); + wonder_label->setTextFormat(Qt::RichText); meet_but = new QPushButton; meet_but->setText(_("Meet")); cancel_but = new QPushButton; @@ -705,6 +761,8 @@ plr_report::plr_report():QWidget() withdraw_but->setText(_("Withdraw Vision")); toggle_ai_but = new QPushButton; toggle_ai_but->setText(_("Toggle AI Mode")); + show_wonders = new QPushButton; + show_wonders->setText(_("Show Wonders")); meet_but->setDisabled(true); cancel_but->setDisabled(true); withdraw_but->setDisabled(true); @@ -713,18 +771,21 @@ plr_report::plr_report():QWidget() h_splitter->addWidget(plr_label); h_splitter->addWidget(ally_label); h_splitter->addWidget(tech_label); + h_splitter->addWidget(wonder_label); v_splitter->addWidget(h_splitter); layout->addWidget(v_splitter); hlayout->addWidget(meet_but); hlayout->addWidget(cancel_but); hlayout->addWidget(withdraw_but); hlayout->addWidget(toggle_ai_but); + hlayout->addWidget(show_wonders); hlayout->addStretch(); layout->addLayout(hlayout); connect(meet_but, &QAbstractButton::pressed, this, &plr_report::req_meeeting); connect(cancel_but, &QAbstractButton::pressed, this, &plr_report::req_caancel_threaty); connect(withdraw_but, &QAbstractButton::pressed, this, &plr_report::req_wiithdrw_vision); connect(toggle_ai_but, &QAbstractButton::pressed, this, &plr_report::toggle_ai_mode); + connect(show_wonders, &QAbstractButton::pressed, this, &plr_report::show_wonders_toggle); setLayout(layout); if (gui()->qt_settings.player_repo_sort_col != -1) { @@ -836,14 +897,26 @@ void plr_report::toggle_ai_mode() ai_menu->popup(QCursor::pos()); } +/**********************************************************************//** + Slot to enable/disable wonders display +**************************************************************************/ +void plr_report::show_wonders_toggle() +{ + if (wonder_label->isVisible()) { + wonder_label->hide(); + } else { + wonder_label->show(); + } +} + /**********************************************************************//** Handle mouse click **************************************************************************/ void plr_widget::mousePressEvent(QMouseEvent *event) { - QModelIndex index = this->indexAt(event->pos()); + QModelIndex index = this->indexAt(event->pos()); - if (index.isValid() && event->button() == Qt::RightButton + if (index.isValid() && event->button() == Qt::RightButton && can_client_issue_orders()) { plr->call_meeting(); } @@ -891,6 +964,7 @@ void plr_report::update_report(bool update_selection) plr_label->setText(plr_wdg->intel_str); ally_label->setText(plr_wdg->ally_str); tech_label->setText(plr_wdg->tech_str); + wonder_label->setText(plr_wdg->wonder_str); other_player = plr_wdg->other_player; if (other_player == NULL || !can_client_issue_orders()) { return; diff --git a/client/gui-qt/plrdlg.h b/client/gui-qt/plrdlg.h index 38028e9d8e..c9d51806e7 100644 --- a/client/gui-qt/plrdlg.h +++ b/client/gui-qt/plrdlg.h @@ -111,6 +111,7 @@ private: class plr_widget: public QTreeView { Q_OBJECT + plr_model *list_model; QSortFilterProxyModel *filter_model; plr_item_delegate *pid; @@ -126,6 +127,7 @@ public: QString intel_str; QString ally_str; QString tech_str; + QString wonder_str; struct player *other_player; public slots: void display_header_menu(const QPoint &); @@ -141,16 +143,19 @@ private: class plr_report: public QWidget { Q_OBJECT + plr_widget *plr_wdg; QLabel *plr_label; QLabel *ally_label; QLabel *tech_label; + QLabel *wonder_label; QSplitter *v_splitter; QSplitter *h_splitter; QPushButton *meet_but; QPushButton *cancel_but; QPushButton *withdraw_but; QPushButton *toggle_ai_but; + QPushButton *show_wonders; QVBoxLayout *layout; QHBoxLayout *hlayout; public: @@ -169,6 +174,7 @@ private slots: * autoconnect */ void req_wiithdrw_vision(); void toggle_ai_mode(); + void show_wonders_toggle(); }; void popup_players_dialog(bool raise); -- 2.35.1