Freeciv-3.3
Loading...
Searching...
No Matches
repodlgs.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QComboBox>
21#include <QElapsedTimer>
22#include <QGridLayout>
23#include <QGroupBox>
24#include <QHeaderView>
25#include <QMessageBox>
26#include <QMouseEvent>
27#include <QPainter>
28#include <QRadioButton>
29#include <QScrollArea>
30#include <QTableWidget>
31#include <QtMath>
32#include <QToolTip>
33
34// common
35#include "control.h"
36#include "government.h"
37#include "research.h"
38
39// client
40#include "client_main.h"
41#include "gui_main.h"
42#include "helpdata.h"
43#include "options.h"
44#include "repodlgs_common.h"
45#include "reqtree.h"
46#include "sprite.h"
47#include "text.h"
48#include "tilespec.h"
49
50// gui-qt
51#include "citydlg.h"
52#include "cityrep.h"
53#include "fc_client.h"
54#include "hudwidget.h"
55#include "sidebar.h"
56
57#include "repodlgs.h"
58
59extern QString split_text(QString text, bool cut);
60extern QString cut_helptext(QString text);
62 struct city *pcity, bool ext);
64
66
67/****************************************************************************
68 From reqtree.c used to get tooltips
69****************************************************************************/
81
82/****************************************************************************
83 From reqtree.c used to get tooltips
84****************************************************************************/
93
94/************************************************************************/
98 struct unit_type *ut): QFrame(parent)
99{
100 int isize;
101 QFont f;
107 QImage img;
108 QLabel *lab;
109 QPixmap pix;
110 QRect crop;
111 QSizePolicy size_fixed_policy(QSizePolicy::Maximum, QSizePolicy::Maximum,
112 QSizePolicy::Slider);
114 QVBoxLayout *vbox;
116 struct sprite *spr;
117
119 utype = ut;
120 init_img();
121 unit_scroll = 0;
124 fm = new QFontMetrics(f);
125 isize = fm->height() * 2 / 3;
126 vbox_main = new QVBoxLayout();
127 hbox = new QHBoxLayout();
128 vbox = new QVBoxLayout();
129 hbox_top = new QHBoxLayout();
130 upgrade_button.setText("★");
131 upgrade_button.setVisible(false);
132 connect(&upgrade_button, &QAbstractButton::pressed, this, &unittype_item::upgrade_units);
133 hbox_top->addWidget(&upgrade_button, 0, Qt::AlignLeft);
134 label_info_unit.setTextFormat(Qt::PlainText);
135 hbox_top->addWidget(&label_info_unit);
136 vbox_main->addLayout(hbox_top);
137 vbox->addWidget(&label_info_active);
138 vbox->addWidget(&label_info_inbuild);
139 hbox->addWidget(&label_pix);
140 hbox->addLayout(vbox);
141 vbox_main->addLayout(hbox);
143 hbox_upkeep->addWidget(&shield_upkeep);
144 lab = new QLabel("");
146 "citybar.shields", nullptr, "", "", false);
147 img = spr->pm->toImage();
149 cropped_img = img.copy(crop);
150 pix = QPixmap::fromImage(cropped_img);
151 lab->setPixmap(pix.scaledToHeight(isize));
152 hbox_upkeep->addWidget(lab);
153 spacer = new QSpacerItem(0, isize, QSizePolicy::Expanding,
154 QSizePolicy::Minimum);
155 hbox_upkeep->addSpacerItem(spacer);
156 hbox_upkeep->addWidget(&gold_upkeep);
158 lab = new QLabel("");
159 lab->setPixmap(spr->pm->scaledToHeight(isize));
160 hbox_upkeep->addWidget(lab);
161 spacer = new QSpacerItem(0, isize, QSizePolicy::Expanding,
162 QSizePolicy::Minimum);
163 hbox_upkeep->addSpacerItem(spacer);
164 hbox_upkeep->addWidget(&food_upkeep);
165 lab = new QLabel("");
167 "citybar.food", nullptr, "", "", false);
168 img = spr->pm->toImage();
170 cropped_img = img.copy(crop);
171 pix = QPixmap::fromImage(cropped_img);
172 lab->setPixmap(pix.scaledToHeight(isize));
173 hbox_upkeep->addWidget(lab);
174 vbox_main->addLayout(hbox_upkeep);
176 entered = false;
177 delete fm;
178}
179
180/************************************************************************/
186
187/************************************************************************/
191{
192 struct sprite *sp;
193
196 label_pix.setPixmap(*sp->pm);
197}
198
199/************************************************************************/
203{
204 char buf[1024];
205 char buf2[2048];
206 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
207 int price;
208 QString s2;
209 const struct unit_type *upgrade;
211
214 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
215 "Treasury contains %d gold.",
216 client_player()->economic.gold),
217 client_player()->economic.gold);
219 PL_("Upgrade as many %s to %s as possible "
220 "for %d gold each?\n%s",
221 "Upgrade as many %s to %s as possible "
222 "for %d gold each?\n%s", price),
224 utype_name_translation(upgrade), price, buf);
225 s2 = QString(buf2);
226 ask->set_text_title(s2, _("Upgrade Obsolete Units"));
227 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
228 ask->setDefaultButton(QMessageBox::Cancel);
229 ask->setAttribute(Qt::WA_DeleteOnClose);
230 connect(ask, &hud_message_box::accepted, [=]() {
232 });
233 ask->show();
234}
235
236/************************************************************************/
239#ifndef FC_QT5_MODE
241#else // FC_QT5_MODE
243#endif // FC_QT5_MODE
244{
245 entered = true;
246 update();
247}
248
249/************************************************************************/
253{
254 QRect rfull;
255 QPainter p;
256
257 if (entered) {
258 rfull = QRect(1 , 1, width() - 2 , height() - 2);
259 p.begin(this);
260 p.setPen(QColor(palette().color(QPalette::Highlight)));
261 p.drawRect(rfull);
262 p.end();
263 }
264}
265
266/************************************************************************/
270{
271 entered = false;
272 update();
273}
274
275/************************************************************************/
279{
280 int unit_count = 0;
281
283 if (punit->utype != utype) {
284 continue;
285 }
289 unit_count++;
290 }
291 }
293
294 if (event->angleDelta().y() < 0) {
295 unit_scroll--;
296 } else {
297 unit_scroll++;
298 }
299 if (unit_scroll < 0) {
300 unit_scroll = unit_count;
301 } else if (unit_scroll > unit_count) {
302 unit_scroll = 0;
303 }
304
305 unit_count = 0;
306
308 if (punit->utype != utype) {
309 continue;
310 }
314 unit_count++;
315 if (unit_count == unit_scroll) {
317 }
318 }
319 }
321 event->accept();
322}
323
324/************************************************************************/
328{
329 layout = new QHBoxLayout;
330 scroll_layout = new QHBoxLayout(this);
331 init_layout();
332 setParent(gui()->mapview_wdg);
333 cw = new close_widget(this);
334 cw->setFixedSize(12, 12);
335 setVisible(false);
336}
337
338/************************************************************************/
342{
344 unittype_list.clear();
345 delete cw;
346}
347
348/************************************************************************/
355
356/************************************************************************/
360{
361 if (!m_instance) {
363 }
364
365 return m_instance;
366}
367
368/************************************************************************/
372{
373 if (m_instance) {
374 delete m_instance;
375 m_instance = nullptr;
376 }
377}
378
379/************************************************************************/
383{
384 was_destroyed = true;
385 drop();
386}
387
388/************************************************************************/
392{
393 QSizePolicy size_fixed_policy(QSizePolicy::Maximum,
394 QSizePolicy::Maximum,
395 QSizePolicy::Slider);
396
397 scroll = new QScrollArea(this);
399 scroll->setWidgetResizable(true);
400 scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
401 scroll_widget.setLayout(layout);
402 scroll->setWidget(&scroll_widget);
403 scroll->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
404 scroll->setProperty("city_scroll", true);
405 scroll_layout->addWidget(scroll);
407}
408
409/************************************************************************/
416
417/************************************************************************/
421{
422 struct urd_info {
423 int active_count;
424 int building_count;
425 int upkeep[O_LAST];
426 };
427 bool upgradable;
428 int i, j;
429 int output;
430 int total_len = 0;
431 struct urd_info *info;
432 struct urd_info *unit_array = (struct urd_info *)fc_calloc(sizeof(struct urd_info), utype_count());
433 struct urd_info unit_totals;
435 unittype_item *ui = nullptr;
436
437 clear_layout();
438 memset(&unit_totals, '\0', sizeof(unit_totals));
439
440 // Count units.
441 players_iterate(pplayer) {
442 if (client_has_player() && pplayer != client_player()) {
443 continue;
444 }
445 unit_list_iterate(pplayer->units, punit) {
447 if (0 != punit->homecity) {
448 for (output = 0; output < O_LAST; output++) {
449 info->upkeep[output] += punit->upkeep[output];
450 }
451 }
452 info->active_count++;
454 city_list_iterate(pplayer->cities, pcity) {
455 if (VUT_UTYPE == pcity->production.kind) {
456 int num_units;
457
458 info = unit_array + utype_index(pcity->production.value.utype);
459 // Account for build slots in city
461 // Unit is in progress even if it won't be done this turn
462 num_units = MAX(num_units, 1);
463 info->building_count += num_units;
464 }
467
468 unit_type_iterate(utype) {
469 utype_id = utype_index(utype);
470 info = unit_array + utype_id;
472 && nullptr != can_upgrade_unittype(client_player(), utype);
473 if (0 == info->active_count && 0 == info->building_count) {
474 continue; // We don't need a row for this type.
475 }
476 ui = new unittype_item(this, utype);
477 ui->label_info_active.setText("⚔:" + QString::number(info->active_count));
478 ui->label_info_inbuild.setText("⚒:" + QString::number(info->building_count));
479 ui->label_info_unit.setText(utype_name_translation(utype));
480 if (upgradable) {
481 ui->upgrade_button.setVisible(true);
482 } else {
483 ui->upgrade_button.setVisible(false);
484 }
485 ui->shield_upkeep.setText(QString::number(info->upkeep[O_SHIELD]));
486 ui->food_upkeep.setText(QString::number(info->upkeep[O_FOOD]));
487 ui->gold_upkeep.setText(QString::number(info->upkeep[O_GOLD]));
488 add_item(ui);
490
492
493 setUpdatesEnabled(false);
494 hide();
495 i = unittype_list.count();
496 for (j = 0; j < i; j++) {
497 ui = unittype_list[j];
498 layout->addWidget(ui, 0, Qt::AlignVCenter);
499 total_len = total_len + ui->sizeHint().width() + 18;
500 }
501
503 + contentsMargins().right();
504 if (show) {
505 setVisible(true);
506 }
507 setUpdatesEnabled(true);
508 setFixedWidth(qMin(total_len, gui()->mapview_wdg->width()));
509 if (ui != nullptr) {
510 setFixedHeight(ui->height() + 60);
511 }
512 layout->update();
514}
515
516/************************************************************************/
520{
521 int i = unittype_list.count();
522 unittype_item *ui;
523 int j;
524
525 setUpdatesEnabled(false);
526 setMouseTracking(false);
527
528 for (j = 0; j < i; j++) {
529 ui = unittype_list[j];
530 layout->removeWidget(ui);
531 delete ui;
532 }
533
534 while (!unittype_list.empty()) {
535 unittype_list.removeFirst();
536 }
537
538 setMouseTracking(true);
539 setUpdatesEnabled(true);
540}
541
542/************************************************************************/
546{
547 return (q1.tech_str < q2.tech_str);
548}
549
550/************************************************************************/
554{
555 pcanvas = nullptr;
556 req = nullptr;
557 reset();
558 setMouseTracking(true);
559}
560
561/************************************************************************/
571
572/************************************************************************/
576{
577 tech_id = -1;
578 tunit = nullptr;
579 timpr = nullptr;
580}
581
582/************************************************************************/
586{
587 int i, j;
588 int swidth, sheight;
589 struct sprite *sprite;
590 reqtree *tree;
592
594 tt_help.clear();
595 if (req == nullptr) {
596 return;
597 } else {
598 tree = req;
599 }
600
601 for (i = 0; i < tree->num_layers; i++) {
602 for (j = 0; j < tree->layer_size[i]; j++) {
603 struct tree_node *node = tree->layers[i][j];
605
606 startx = node->node_x;
607 starty = node->node_y;
608 nwidth = node->node_width;
609 nheight = node->node_height;
610
611 if (!node->is_dummy) {
612 const char *text = research_advance_name_translation(
614 int text_w, text_h;
615 int icon_startx;
616
618 rttp = new req_tooltip_help();
619 rttp->rect = QRect(startx + (nwidth - text_w) / 2, starty + 4,
620 text_w, text_h);
621 rttp->tech_id = node->tech;
622 tt_help.append(rttp);
623 icon_startx = startx + 5;
624
626 unit_type_iterate(utype) {
627
628 if (!is_tech_req_for_utype(utype, advance_by_number(node->tech))) {
629 continue;
630 }
631
635 rttp = new req_tooltip_help();
636 rttp->rect = QRect(icon_startx, starty + text_h + 4
637 + (nheight - text_h - 4 - sheight) / 2,
638 swidth, sheight);
639 rttp->tunit = utype;
640 tt_help.append(rttp);
641 icon_startx += swidth + 2;
643
644 improvement_iterate(pimprove) {
645 if (valid_improvement(pimprove)) {
646 requirement_vector_iterate(&(pimprove->reqs), preq) {
647 if (VUT_ADVANCE == preq->source.kind
648 && advance_number(preq->source.value.advance) == node->tech) {
650 if (sprite) {
652 rttp = new req_tooltip_help();
653 rttp->rect = QRect(icon_startx, starty + text_h + 4
654 + (nheight - text_h - 4 - sheight) / 2,
655 swidth, sheight);
656 rttp->timpr = pimprove;
657 tt_help.append(rttp);
658 icon_startx += swidth + 2;
659 }
660 }
662 }
664
666 requirement_vector_iterate(&(gov->reqs), preq) {
667 if (VUT_ADVANCE == preq->source.kind
668 && advance_number(preq->source.value.advance) == node->tech) {
671 rttp = new req_tooltip_help();
672 rttp->rect = QRect(icon_startx, starty + text_h + 4
673 + (nheight - text_h - 4 - sheight) / 2,
674 swidth, sheight);
675 rttp->tgov = gov;
676 tt_help.append(rttp);
677 icon_startx += swidth + 2;
678 }
681 }
682 }
683 }
684 }
685}
686
687/************************************************************************/
691{
692 reset();
693 draw_reqtree(req, pcanvas, 0, 0, 0, 0, width, height);
695 update();
696}
697
698/************************************************************************/
702{
703 timer_active = false;
704 if (req != nullptr) {
706 }
707 if (pcanvas != nullptr) {
709 }
713 pcanvas->map_pixmap.fill(Qt::transparent);
714 resize(width, height);
715}
716
717/************************************************************************/
721{
722 QPoint pos = event->pos();
723 Tech_type_id tech = get_tech_on_reqtree(req, pos.x(), pos.y());
725 int i;
726
727 if (event->button() == Qt::LeftButton && can_client_issue_orders()) {
731 break;
732 case TECH_UNKNOWN:
734 break;
735 case TECH_KNOWN:
736 break;
737 }
738 } else if (event->button() == Qt::RightButton) {
739 for (i = 0; i < tt_help.count(); i++) {
740 rttp = tt_help.at(i);
741 if (rttp->rect.contains(event->pos())) {
742 if (rttp->tech_id != -1) {
745 rttp->tech_id), HELP_TECH);
746 } else if (rttp->timpr != nullptr) {
750 } else if (rttp->tunit != nullptr) {
752 HELP_UNIT);
753 } else if (rttp->tgov != nullptr) {
756 } else {
757 return;
758 }
759 }
760 }
761 }
762}
763
764/************************************************************************/
768{
770 int i;
773 char buffer[8192];
774 char buf2[1];
775 struct player *pplayer = client_player();
776
777 buf2[0] = '\0';
778 for (i = 0; i < tt_help.count(); i++) {
779 rttp = tt_help.at(i);
780 if (rttp->rect.contains(event->pos())) {
781 if (rttp->tech_id != -1) {
782 helptext_advance(buffer, sizeof(buffer), pplayer,
783 buf2, rttp->tech_id);
784 tt_text = QString(buffer);
785 def_str = "<p style='white-space:pre'><b>"
787 advance_by_number(rttp->tech_id))).toHtmlEscaped()
788 + "</b>\n";
789 } else if (rttp->timpr != nullptr) {
790 def_str = get_tooltip_improvement(rttp->timpr, nullptr);
791 tt_text = helptext_building(buffer, sizeof(buffer),
792 pplayer, nullptr, rttp->timpr);
794 } else if (rttp->tunit != nullptr) {
795 def_str = get_tooltip_unit(rttp->tunit);
796 tt_text += helptext_unit(buffer, sizeof(buffer), pplayer,
797 buf2, rttp->tunit, TRUE);
799 } else if (rttp->tgov != nullptr) {
800 helptext_government(buffer, sizeof(buffer), pplayer,
801 buf2, rttp->tgov);
802 tt_text = QString(buffer);
804 def_str = "<p style='white-space:pre'><b>"
805 + QString(government_name_translation(rttp->tgov)).toHtmlEscaped()
806 + "</b>\n";
807 } else {
808 return;
809 }
810 tt_text = split_text(tt_text, true);
811 tt_text = def_str + tt_text.toHtmlEscaped();
812 tooltip_text = tt_text.trimmed();
813 tooltip_rect = rttp->rect;
815 if (!QToolTip::isVisible() && !timer_active) {
816 timer_active = true;
817 QTimer::singleShot(500, this, SLOT(show_tooltip()));
818 }
819 }
820 }
821}
822
823/************************************************************************/
827{
828 QPoint cp;
829
830 timer_active = false;
831 cp = QCursor::pos();
832 if (qAbs(cp.x() - tooltip_pos.x()) < 4
833 && qAbs(cp.y() - tooltip_pos.y()) < 4) {
834 QToolTip::showText(cp, tooltip_text, this, tooltip_rect);
835 }
836}
837
838/************************************************************************/
842{
844
845 painter.begin(this);
846 painter.drawPixmap(0, 0, width, height, pcanvas->map_pixmap);
847 painter.end();
848}
849
850/************************************************************************/
854{
855 QSize s;
856
857 s.setWidth(width);
858 s.setHeight(height);
859
860 return s;
861}
862
863/************************************************************************/
867{
868 QSize size;
869 QSizePolicy size_expanding_policy(QSizePolicy::Expanding,
870 QSizePolicy::Expanding);
871 QSizePolicy size_fixed_policy(QSizePolicy::Minimum, QSizePolicy::Minimum);
872
873 goal_combo = new QComboBox();
874 info_label = new QLabel();
875 progress = new progress_bar(this);
876 progress_label = new QLabel();
878 sci_layout = new QGridLayout();
880 scroll = new QScrollArea();
881
882 curr_list = nullptr;
883 goal_list = nullptr;
884 progress->setTextVisible(true);
885 progress_label->setSizePolicy(size_fixed_policy);
886 sci_layout->addWidget(progress_label, 0, 0, 1, 8);
887 sci_layout->addWidget(researching_combo, 1, 0, 1, 4);
888 researching_combo->setSizePolicy(size_fixed_policy);
889 sci_layout->addWidget(progress, 1, 5, 1, 4);
890 progress->setSizePolicy(size_fixed_policy);
891 sci_layout->addWidget(goal_combo, 2, 0, 1, 4);
892 goal_combo->setSizePolicy(size_fixed_policy);
893 sci_layout->addWidget(info_label, 2, 5, 1, 4);
894 info_label->setSizePolicy(size_fixed_policy);
895
896 size = res_diag->size();
897 res_diag->setMinimumSize(size);
898 scroll->setAutoFillBackground(true);
899 scroll->setPalette(QPalette(QColor(215,215,215)));
900 scroll->setWidget(res_diag);
901 scroll->setSizePolicy(size_expanding_policy);
902 sci_layout->addWidget(scroll, 4, 0, 1, 10);
903
904 QObject::connect(researching_combo, SIGNAL(currentIndexChanged(int)),
906
907 QObject::connect(goal_combo, SIGNAL(currentIndexChanged(int)),
908 SLOT(goal_tech_changed(int)));
909
911}
912
913/************************************************************************/
919{
920 if (curr_list) {
921 delete curr_list;
922 }
923
924 if (goal_list) {
925 delete goal_list;
926 }
927 gui()->remove_repo_dlg("SCI");
928}
929
930/************************************************************************/
936{
937 gui()->gimme_place(this, "SCI");
938 index = gui()->add_game_tab(this);
939 gui()->game_tab_widget->setCurrentIndex(index);
941}
942
943/************************************************************************/
947{
948 update();
949}
950
951/************************************************************************/
955{
956 QSize size;
957 res_diag->reset();
958 size = res_diag->size();
959 res_diag->setMinimumSize(size);
960 update();
961}
962
963/************************************************************************/
967{
969 const char *text;
970 int total;
971 int done = research->bulbs_researched;
973 double not_used;
974 QString str;
976 struct sprite *sp;
978
979 fc_assert_ret(research != nullptr);
980
981 if (curr_list) {
982 delete curr_list;
983 }
984
985 if (goal_list) {
986 delete goal_list;
987 }
988
989 if (research->researching != A_UNSET) {
991 } else {
992 total = -1;
993 }
994
998 progress_label->setAlignment(Qt::AlignHCenter);
999 info_label->setAlignment(Qt::AlignHCenter);
1002 str = QString::fromUtf8(text);
1003 progress->setFormat(str);
1004 progress->setMinimum(0);
1005 progress->setMaximum(total);
1006 progress->set_pixmap(static_cast<int>(research->researching));
1007
1008 if (done <= total) {
1009 progress->setValue(done);
1010 } else {
1011 done = total;
1012 progress->setValue(done);
1013 }
1014
1015 // Collect all techs which are reachable in the next step.
1016 ac = advance_count();
1019 item.tech_str
1020 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1021 item.id = i;
1022 curr_list->append(item);
1023 }
1025
1026 // Collect all techs which are reachable in next 10 steps.
1030 && (i == research->tech_goal
1032 item.tech_str
1033 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1034 item.id = i;
1035 goal_list->append(item);
1036 }
1038
1039 // Sort both lists
1040 std::sort(goal_list->begin(), goal_list->end(), comp_less_than);
1041 std::sort(curr_list->begin(), curr_list->end(), comp_less_than);
1042
1043 // Fill combo boxes
1044 researching_combo->blockSignals(true);
1045 goal_combo->blockSignals(true);
1046
1047 researching_combo->clear();
1048 goal_combo->clear();
1049 for (int i = 0; i < curr_list->count(); i++) {
1050 QIcon ic;
1051
1052 sp = get_tech_sprite(tileset, curr_list->at(i).id);
1053 if (sp) {
1054 ic = QIcon(*sp->pm);
1055 }
1056 qvar = curr_list->at(i).id;
1057 researching_combo->insertItem(i, ic, curr_list->at(i).tech_str, qvar);
1058 }
1059
1060 for (int i = 0; i < goal_list->count(); i++) {
1061 QIcon ic;
1062
1063 sp = get_tech_sprite(tileset, goal_list->at(i).id);
1064 if (sp) {
1065 ic = QIcon(*sp->pm);
1066 }
1067 qvar = goal_list->at(i).id;
1068 goal_combo->insertItem(i, ic, goal_list->at(i).tech_str, qvar);
1069 }
1070
1071 // Set current tech and goal
1076 A_UNSET);
1077 researching_combo->setCurrentIndex(0);
1078 } else {
1079 for (int i = 0; i < researching_combo->count(); i++) {
1080 qvar = researching_combo->itemData(i);
1081
1082 if (qvar == qres) {
1083 researching_combo->setCurrentIndex(i);
1084 }
1085 }
1086 }
1087
1089
1090 if (qres == A_UNSET) {
1091 goal_combo->insertItem(0, Q_("?tech:None"), A_UNSET);
1092 goal_combo->setCurrentIndex(0);
1093 } else {
1094 for (int i = 0; i < goal_combo->count(); i++) {
1095 qvar = goal_combo->itemData(i);
1096
1097 if (qvar == qres) {
1098 goal_combo->setCurrentIndex(i);
1099 }
1100 }
1101 }
1102
1103 researching_combo->blockSignals(false);
1104 goal_combo->blockSignals(false);
1105
1106 if (client_is_observer()) {
1107 researching_combo->setDisabled(true);
1108 goal_combo->setDisabled(true);
1109 } else {
1110 researching_combo->setDisabled(false);
1111 goal_combo->setDisabled(false);
1112 }
1114}
1115
1116/************************************************************************/
1123
1124/************************************************************************/
1128{
1129 QVariant qvar;
1130
1132
1133 if (researching_combo->hasFocus()) {
1136 }
1137 }
1138}
1139
1140/************************************************************************/
1144{
1145 QVariant qvar;
1146
1147 qvar = goal_combo->itemData(changed_index);
1148
1149 if (goal_combo->hasFocus()) {
1152 }
1153 }
1154}
1155
1156/************************************************************************/
1160{
1161 int i;
1162 int percent;
1164 bool blk = false;
1165 QWidget *w;
1166 QString str;
1167 struct player *plr = client_player();
1168
1169 if (plr != nullptr) {
1170 struct research *research = research_get(plr);
1171
1172 if (research->researching == A_UNSET) {
1173 str = QString(Q_("?tech:None"));
1174 } else if (research->client.researching_cost != 0) {
1177 str = str + "\n (" + QString::number(percent) + "%)";
1178 }
1181 blk = true;
1182 }
1183 } else {
1184 str = " ";
1185 }
1186
1187 if (blk) {
1188 gui()->sw_science->keep_blinking = true;
1189 gui()->sw_science->set_custom_labels(str);
1190 gui()->sw_science->sblink();
1191 } else {
1192 gui()->sw_science->keep_blinking = false;
1193 gui()->sw_science->set_custom_labels(str);
1194 gui()->sw_science->update_final_pixmap();
1195 }
1196 gui()->update_sidebar_tooltips();
1197
1198 if (gui()->is_repo_dlg_open("SCI")) {
1199 i = gui()->gimme_index_of("SCI");
1200 fc_assert(i != -1);
1201 w = gui()->game_tab_widget->widget(i);
1202 sci_rep = reinterpret_cast<science_report*>(w);
1204 }
1205}
1206
1207/************************************************************************/
1211{
1212 QHeaderView *header;
1214 eco_widget = new QTableWidget;
1215 disband_button = new QPushButton;
1216 sell_button = new QPushButton;
1217 sell_redun_button = new QPushButton;
1218 eco_label = new QLabel;
1220
1221 slist << _("Type") << Q_("?Building or Unit type:Name") << _("Redundant")
1222 << _("Count") << _("Cost") << _("U Total");
1223 eco_widget->setColumnCount(slist.count());
1224 eco_widget->setHorizontalHeaderLabels(slist);
1225 eco_widget->setProperty("showGrid", "false");
1226 eco_widget->setProperty("selectionBehavior", "SelectRows");
1227 eco_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
1228 eco_widget->horizontalHeader()->resizeSections(QHeaderView::Stretch);
1229 eco_widget->verticalHeader()->setVisible(false);
1230 eco_widget->setSelectionMode(QAbstractItemView::SingleSelection);
1231 eco_widget->setSortingEnabled(true);
1232 header = eco_widget->horizontalHeader();
1233 header->setSectionResizeMode(1, QHeaderView::Stretch);
1234 header->setStretchLastSection(true);
1235 disband_button->setText(_("Disband"));
1236 disband_button->setEnabled(false);
1237 sell_button->setText(_("Sell All"));
1238 sell_button->setEnabled(false);
1239 sell_redun_button->setText(_("Sell Redundant"));
1240 sell_redun_button->setEnabled(false);
1241 eco_layout->addWidget(eco_widget, 1, 0, 5, 5);
1242 eco_layout->addWidget(disband_button, 0, 0, 1, 1);
1243 eco_layout->addWidget(sell_button, 0, 1, 1, 1);
1244 eco_layout->addWidget(sell_redun_button, 0, 2, 1, 1);
1245 eco_layout->addWidget(eco_label, 6, 0, 1, 5);
1246
1247 connect(disband_button, &QAbstractButton::pressed, this, &eco_report::disband_units);
1248 connect(sell_button, &QAbstractButton::pressed, this, &eco_report::sell_buildings);
1249 connect(sell_redun_button, &QAbstractButton::pressed, this, &eco_report::sell_redundant);
1250 connect(eco_widget->selectionModel(),
1252 const QItemSelection &)),
1254 const QItemSelection &)));
1256}
1257
1258/************************************************************************/
1262{
1263 gui()->remove_repo_dlg("ECO");
1264}
1265
1266/************************************************************************/
1270{
1271 curr_row = -1;
1272 gui()->gimme_place(this, "ECO");
1273 index = gui()->add_game_tab(this);
1274 gui()->game_tab_widget->setCurrentIndex(index);
1275}
1276
1277/************************************************************************/
1281{
1284 int entries_used, building_total, unit_total, tax, i, j;
1285 char buf[256];
1287 QFont f = QApplication::font();
1288 int h;
1289 QFontMetrics fm(f);
1290 h = fm.height() + 6;
1291 QPixmap *pix;
1293 struct sprite *sprite;
1294
1295 eco_widget->setRowCount(0);
1296 eco_widget->clearContents();
1298 &building_total, &tax);
1299 for (i = 0; i < entries_used; i++) {
1301 struct impr_type *pimprove = pentry->type;
1302
1303 pix = nullptr;
1304 sprite = get_building_sprite(tileset, pimprove);
1305 if (sprite != nullptr) {
1306 pix = sprite->pm;
1307 }
1308 if (pix != nullptr) {
1309 pix_scaled = pix->scaledToHeight(h);
1310 } else {
1311 pix_scaled.fill();
1312 }
1313 cid id = cid_encode_building(pimprove);
1314
1315 eco_widget->insertRow(i);
1316 for (j = 0; j < 6; j++) {
1317 item = new QTableWidgetItem;
1318 switch (j) {
1319 case 0:
1320 item->setData(Qt::DecorationRole, pix_scaled);
1321 item->setData(Qt::UserRole, id);
1322 break;
1323 case 1:
1324 item->setTextAlignment(Qt::AlignLeft);
1325 item->setText(improvement_name_translation(pimprove));
1326 break;
1327 case 2:
1328 item->setData(Qt::DisplayRole, pentry->redundant);
1329 break;
1330 case 3:
1331 item->setData(Qt::DisplayRole, pentry->count);
1332 break;
1333 case 4:
1334 item->setData(Qt::DisplayRole, pentry->cost);
1335 break;
1336 case 5:
1337 item->setData(Qt::DisplayRole, pentry->total_cost);
1338 break;
1339 }
1340 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
1341 eco_widget->setItem(i, j, item);
1342 }
1343 }
1344 max_row = i;
1346 for (i = 0; i < entries_used; i++) {
1347 struct unit_entry *pentry = unit_entries + i;
1348 struct unit_type *putype = pentry->type;
1349 cid id;
1350
1351 pix = nullptr;
1354 if (sprite != nullptr) {
1355 pix = sprite->pm;
1356 }
1357 id = cid_encode_unit(putype);
1358
1359 eco_widget->insertRow(i + max_row);
1360 for (j = 0; j < 6; j++) {
1361 item = new QTableWidgetItem;
1362 item->setTextAlignment(Qt::AlignHCenter);
1363 switch (j) {
1364 case 0:
1365 if (pix != nullptr) {
1366 pix_scaled = pix->scaledToHeight(h);
1367 item->setData(Qt::DecorationRole, pix_scaled);
1368 }
1369 item->setData(Qt::UserRole, id);
1370 break;
1371 case 1:
1372 item->setTextAlignment(Qt::AlignLeft);
1374 break;
1375 case 2:
1376 item->setData(Qt::DisplayRole, 0);
1377 break;
1378 case 3:
1379 item->setData(Qt::DisplayRole, pentry->count);
1380 break;
1381 case 4:
1382 item->setData(Qt::DisplayRole, pentry->cost);
1383 break;
1384 case 5:
1385 item->setData(Qt::DisplayRole, pentry->total_cost);
1386 break;
1387 }
1388 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
1389 eco_widget->setItem(max_row + i, j, item);
1390 }
1391 }
1392 max_row = max_row + i;
1393 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
1394 tax, building_total + unit_total);
1395 eco_label->setText(buf);
1396}
1397
1398/************************************************************************/
1402 const QItemSelection &ds)
1403{
1405 int i;
1406 QVariant qvar;
1407 struct universal selected;
1408 const struct impr_type *pimprove;
1409 disband_button->setEnabled(false);
1410 sell_button->setEnabled(false);
1411 sell_redun_button->setEnabled(false);
1412
1413 if (sl.isEmpty()) {
1414 return;
1415 }
1416
1417 curr_row = sl.indexes().at(0).row();
1418 if (curr_row >= 0 && curr_row <= max_row) {
1419 itm = eco_widget->item(curr_row, 0);
1420 qvar = itm->data(Qt::UserRole);
1421 uid = qvar.toInt();
1422 selected = cid_decode(uid);
1423 switch (selected.kind) {
1424 case VUT_IMPROVEMENT:
1425 pimprove = selected.value.building;
1426 counter = eco_widget->item(curr_row, 3)->text().toInt();
1427 if (can_sell_building(pimprove)) {
1428 sell_button->setEnabled(true);
1429 }
1430 itm = eco_widget->item(curr_row, 2);
1431 i = itm->text().toInt();
1432 if (i > 0) {
1433 sell_redun_button->setEnabled(true);
1434 }
1435 break;
1436 case VUT_UTYPE:
1437 counter = eco_widget->item(curr_row, 3)->text().toInt();
1438 disband_button->setEnabled(true);
1439 break;
1440 default:
1441 log_error("Not supported type: %d.", selected.kind);
1442 }
1443 }
1444}
1445
1446/************************************************************************/
1450{
1451 struct universal selected;
1452 char title[1024];
1453 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1454 Unit_type_id utype;
1455
1456 selected = cid_decode(uid);
1457 utype = utype_number(selected.value.utype);
1459 _("Do you really wish to disband every %s (%d total)?"),
1461
1462 ask->set_text_title(title, _("Disband Units"));
1463 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1464 ask->setDefaultButton(QMessageBox::Cancel);
1465 ask->setAttribute(Qt::WA_DeleteOnClose);
1466 connect(ask, &hud_message_box::accepted, [=]() {
1467 struct unit_type *putype = utype_by_number(utype);
1468 char buf[1024];
1469 hud_message_box *result;
1470
1471 if (putype) {
1472 disband_all_units(putype, false, buf, sizeof(buf));
1473 }
1474
1475 result = new hud_message_box(gui()->central_wdg);
1476 result->set_text_title(buf, _("Disband Results"));
1477 result->setStandardButtons(QMessageBox::Ok);
1478 result->setAttribute(Qt::WA_DeleteOnClose);
1479 result->show();
1480 });
1481}
1482
1483/************************************************************************/
1487{
1488 struct universal selected;
1489 char title[1024];
1490 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1491 const struct impr_type *pimpr;
1493
1494 selected = cid_decode(uid);
1495 pimpr = selected.value.building;
1497
1499 _("Do you really wish to sell "
1500 "every %s (%d total)?"),
1502
1503 ask->set_text_title(title, _("Sell Improvements"));
1504 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1505 ask->setDefaultButton(QMessageBox::Cancel);
1506 ask->setAttribute(Qt::WA_DeleteOnClose);
1507 connect(ask, &hud_message_box::accepted, [=]() {
1508 char buf[1024];
1509 hud_message_box *result;
1510 struct impr_type *pimprove = improvement_by_number(impr_id);
1511
1512 if (!pimprove) {
1513 return;
1514 }
1515
1516 sell_all_improvements(pimprove, false, buf, sizeof(buf));
1517
1518 result = new hud_message_box(gui()->central_wdg);
1519 result->set_text_title(buf, _("Sell-Off: Results"));
1520 result->setStandardButtons(QMessageBox::Ok);
1521 result->setAttribute(Qt::WA_DeleteOnClose);
1522 result->show();
1523 });
1524}
1525
1526/************************************************************************/
1530{
1531 struct universal selected;
1532 char title[1024];
1533 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1534 const struct impr_type *pimpr;
1536
1537 selected = cid_decode(uid);
1538 pimpr = selected.value.building;
1540
1542 _("Do you really wish to sell "
1543 "every redundant %s (%d total)?"),
1545
1546 ask->set_text_title(title, _("Sell Improvements"));
1547 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1548 ask->setDefaultButton(QMessageBox::Cancel);
1549 ask->setAttribute(Qt::WA_DeleteOnClose);
1550 connect(ask, &hud_message_box::accepted, [=]() {
1551 char buf[1024];
1552 hud_message_box *result;
1553 struct impr_type *pimprove = improvement_by_number(impr_id);
1554
1555 if (!pimprove) {
1556 return;
1557 }
1558
1559 sell_all_improvements(pimprove, true, buf, sizeof(buf));
1560
1561 result = new hud_message_box(gui()->central_wdg);
1562 result->set_text_title(buf, _("Sell-Off: Results"));
1563 result->setStandardButtons(QMessageBox::Ok);
1564 result->setAttribute(Qt::WA_DeleteOnClose);
1565 result->show();
1566 });
1567}
1568
1569/************************************************************************/
1573{
1575 end_widget = new QTableWidget;
1576 unsigned int i;
1577 const size_t col_num = packet->category_num + 3;
1579
1580 players = 0;
1581
1582 slist << _("Player") << _("Nation") << _("Score");
1583 for (i = 0 ; i < col_num - 3; i++) {
1584 slist << Q_(packet->category_name[i]);
1585 }
1586 end_widget->setColumnCount(slist.count());
1587 end_widget->setHorizontalHeaderLabels(slist);
1588 end_widget->setProperty("showGrid", "false");
1589 end_widget->setProperty("selectionBehavior", "SelectRows");
1590 end_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
1591 end_widget->verticalHeader()->setVisible(false);
1592 end_widget->setSelectionMode(QAbstractItemView::SingleSelection);
1593 end_widget->horizontalHeader()->setSectionResizeMode(
1594 QHeaderView::ResizeToContents);
1595 end_layout->addWidget(end_widget, 1, 0, 5, 5);
1597}
1598
1599/************************************************************************/
1603{
1604 gui()->remove_repo_dlg("END");
1605}
1606
1607/************************************************************************/
1611{
1612 gui()->gimme_place(this, "END");
1613 index = gui()->add_game_tab(this);
1614 gui()->game_tab_widget->setCurrentIndex(index);
1615}
1616
1617/************************************************************************/
1621{
1623 QPixmap *pix;
1624 unsigned int i;
1625 const struct player *pplayer = player_by_number(packet->player_id);
1626 const size_t col_num = packet->category_num + 3;
1627
1628 end_widget->insertRow(players);
1629 for (i = 0; i < col_num; i++) {
1630 item = new QTableWidgetItem;
1631 switch (i) {
1632 case 0:
1633 item->setText(player_name(pplayer));
1634 break;
1635 case 1:
1637 if (pix != nullptr) {
1638 item->setData(Qt::DecorationRole, *pix);
1639 }
1640 break;
1641 case 2:
1642 item->setText(QString::number(packet->score));
1643 item->setTextAlignment(Qt::AlignHCenter);
1644 break;
1645 default:
1646 item->setText(QString::number(packet->category_score[i-3]));
1647 item->setTextAlignment(Qt::AlignHCenter);
1648 break;
1649 }
1650 end_widget->setItem(players, i, item);
1651 }
1652 players++;
1653 end_widget->resizeRowsToContents();
1654}
1655
1656/************************************************************************/
1661{
1663 int i;
1664 QWidget *w;
1665
1667 return;
1668 }
1669 if (!gui()->is_repo_dlg_open("SCI")) {
1670 sci_rep = new science_report;
1671 sci_rep->init();
1672 } else {
1673 i = gui()->gimme_index_of("SCI");
1674 w = gui()->game_tab_widget->widget(i);
1675 sci_rep = reinterpret_cast<science_report*>(w);
1676 if (gui()->game_tab_widget->currentIndex() == i) {
1677 sci_rep->redraw();
1678 } else if (raise) {
1679 gui()->game_tab_widget->setCurrentWidget(sci_rep);
1680 }
1681 }
1682}
1683
1684/************************************************************************/
1688{
1689 int i;
1691 QWidget *w;
1692
1693 if (gui()->is_repo_dlg_open("ECO")) {
1694 i = gui()->gimme_index_of("ECO");
1695 if (gui()->game_tab_widget->currentIndex() == i) {
1696 w = gui()->game_tab_widget->widget(i);
1697 eco_rep = reinterpret_cast<eco_report*>(w);
1699 }
1700 }
1701 gui()->update_sidebar_tooltips();
1702}
1703
1704/************************************************************************/
1708{
1709 int i;
1711 QWidget *w;
1712
1713 if (!gui()->is_repo_dlg_open("ECO")) {
1714 eco_rep = new eco_report;
1715 eco_rep->init();
1716 eco_rep->update_report();
1717 } else {
1718 i = gui()->gimme_index_of("ECO");
1719 fc_assert(i != -1);
1720 w = gui()->game_tab_widget->widget(i);
1721 if (w->isVisible()) {
1722 gui()->game_tab_widget->setCurrentIndex(0);
1723 return;
1724 }
1725 eco_rep = reinterpret_cast<eco_report *>(w);
1727 gui()->game_tab_widget->setCurrentWidget(eco_rep);
1728 }
1729}
1730
1731/************************************************************************/
1740
1741/************************************************************************/
1745{
1746 gui()->game_tab_widget->setCurrentIndex(0);
1748}
1749
1750/************************************************************************/
1754{
1756
1757 end_rep = new endgame_report(packet);
1758 end_rep->init();
1759}
1760
1761/************************************************************************/
1765{
1766 int i;
1767
1768 if (gui()->is_repo_dlg_open("END")) {
1769 i = gui()->gimme_index_of("END");
1770 fc_assert(i != -1);
1771 delete gui()->game_tab_widget->widget(i);
1772 }
1773}
1774
1775/************************************************************************/
1779{
1780 int i;
1781
1782 if (gui()->is_repo_dlg_open("END")) {
1783 i = gui()->gimme_index_of("END");
1784 gui()->game_tab_widget->setCurrentIndex(i);
1785 }
1786}
1787
1788/************************************************************************/
1792{
1793 int i;
1795 QWidget *w;
1796
1797 if (gui()->is_repo_dlg_open("END")) {
1798 i = gui()->gimme_index_of("END");
1799 fc_assert(i != -1);
1800 w = gui()->game_tab_widget->widget(i);
1801 end_rep = reinterpret_cast<endgame_report*>(w);
1802 end_rep->update_report(packet);
1803 }
1804}
1805
1806/************************************************************************/
1810{
1811 int i;
1813 QWidget *w;
1814
1815 if (gui()->is_repo_dlg_open("SCI")) {
1816 i = gui()->gimme_index_of("SCI");
1817 if (gui()->game_tab_widget->currentIndex() == i) {
1818 w = gui()->game_tab_widget->widget(i);
1819 sci_rep = reinterpret_cast<science_report*>(w);
1820 sci_rep->redraw();
1821 }
1822 }
1823}
1824
1825/************************************************************************/
1829{
1830 int i;
1832 QWidget *w;
1833
1834 if (gui()->is_repo_dlg_open("ECO")) {
1835 i = gui()->gimme_index_of("ECO");
1836 fc_assert(i != -1);
1837 w = gui()->game_tab_widget->widget(i);
1838 eco_rep = reinterpret_cast<eco_report*>(w);
1839 eco_rep->deleteLater();
1840 }
1841}
1842
1843/************************************************************************/
1847{
1848 int i;
1850 QWidget *w;
1851
1852 if (gui()->is_repo_dlg_open("SCI")) {
1853 i = gui()->gimme_index_of("SCI");
1854 fc_assert(i != -1);
1855 w = gui()->game_tab_widget->widget(i);
1856 sci_rep = reinterpret_cast<science_report*>(w);
1857 sci_rep->deleteLater();
1858 }
1859}
1860
1861/************************************************************************/
1868
1869/************************************************************************/
1873 {
1874 Q_UNUSED(x);
1876 && gui()->game_tab_widget->currentIndex() == 0) {
1878 } else {
1880 }
1881}
int entries_used
Definition agents.c:77
#define str
Definition astring.c:76
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:747
#define city_list_iterate(citylist, pcity)
Definition city.h:505
#define city_list_iterate_end
Definition city.h:507
QString split_text(QString text, bool cut)
Definition optiondlg.cpp:62
QString get_tooltip_improvement(const impr_type *building, struct city *pcity, bool ext)
Definition citydlg.cpp:3997
QString cut_helptext(QString text)
QString get_tooltip_unit(const struct unit_type *utype, bool ext)
Definition citydlg.cpp:4056
void put_to_corner()
Definition mapview.cpp:502
QPushButton * sell_button
Definition repodlgs.h:209
void selection_changed(const QItemSelection &sl, const QItemSelection &ds)
QPushButton * sell_redun_button
Definition repodlgs.h:210
QPushButton * disband_button
Definition repodlgs.h:208
void disband_units()
QTableWidget * eco_widget
Definition repodlgs.h:211
int max_row
Definition repodlgs.h:223
void sell_buildings()
void init()
void sell_redundant()
int curr_row
Definition repodlgs.h:222
void update_report()
QLabel * eco_label
Definition repodlgs.h:212
static fc_font * instance()
Definition fonts.cpp:41
QFont * get_font(QString name)
Definition fonts.cpp:63
bool was_destroyed
Definition mapview.h:176
int set_text_title(QString s1, QString s2, bool return_exec=false)
void set_pixmap(struct universal *target)
Definition citydlg.cpp:114
Tech_type_id tech_id
Definition repodlgs.h:127
struct unit_type * tunit
Definition repodlgs.h:128
struct impr_type * timpr
Definition repodlgs.h:129
struct canvas * pcanvas
Definition repodlgs.h:153
void mousePressEvent(QMouseEvent *event)
Definition repodlgs.cpp:720
void create_tooltip_help()
Definition repodlgs.cpp:585
struct reqtree * req
Definition repodlgs.h:154
QString tooltip_text
Definition repodlgs.h:160
QList< req_tooltip_help * > tt_help
Definition repodlgs.h:158
void mouseMoveEvent(QMouseEvent *event)
Definition repodlgs.cpp:767
void update_reqtree()
Definition repodlgs.cpp:690
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:841
research_diagram(QWidget *parent=nullptr)
Definition repodlgs.cpp:553
QPoint tooltip_pos
Definition repodlgs.h:159
static units_reports * m_instance
Definition repodlgs.h:92
void clear_layout()
Definition repodlgs.cpp:519
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:412
static void drop()
Definition repodlgs.cpp:371
close_widget * cw
Definition repodlgs.h:87
void add_item(unittype_item *item)
Definition repodlgs.cpp:351
static units_reports * instance()
Definition repodlgs.cpp:359
virtual void update_menu()
Definition repodlgs.cpp:382
void update_units(bool show=false)
Definition repodlgs.cpp:420
QHBoxLayout * layout
Definition repodlgs.h:103
QList< unittype_item * > unittype_list
Definition repodlgs.h:104
QHBoxLayout * scroll_layout
Definition repodlgs.h:89
QWidget scroll_widget
Definition repodlgs.h:91
QScrollArea * scroll
Definition repodlgs.h:90
void init_layout()
Definition repodlgs.cpp:391
QLabel label_pix
Definition repodlgs.h:51
int unit_scroll
Definition repodlgs.h:50
QLabel label_info_active
Definition repodlgs.h:59
void leaveEvent(QEvent *event)
Definition repodlgs.cpp:269
unittype_item(QWidget *parent, unit_type *ut)
Definition repodlgs.cpp:97
QLabel gold_upkeep
Definition repodlgs.h:58
QLabel label_info_inbuild
Definition repodlgs.h:60
QLabel shield_upkeep
Definition repodlgs.h:62
void init_img()
Definition repodlgs.cpp:190
void upgrade_units()
Definition repodlgs.cpp:202
void enterEvent(QEnterEvent *event)
Definition repodlgs.cpp:240
QLabel food_upkeep
Definition repodlgs.h:57
QLabel label_info_unit
Definition repodlgs.h:61
unit_type * utype
Definition repodlgs.h:66
QPushButton upgrade_button
Definition repodlgs.h:63
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:252
void wheelEvent(QWheelEvent *event)
Definition repodlgs.cpp:278
bool client_is_global_observer(void)
bool client_is_observer(void)
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:505
struct universal cid_decode(cid id)
Definition climisc.c:526
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:493
int cid
Definition climisc.h:31
char * incite_cost
Definition comments.c:76
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:636
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int Tech_type_id
Definition fc_types.h:236
int Impr_type_id
Definition fc_types.h:235
int Unit_type_id
Definition fc_types.h:241
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
@ O_LAST
Definition fc_types.h:101
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:61
const char * government_name_translation(const struct government *pgovern)
Definition government.c:143
#define governments_iterate(NAME_pgov)
Definition government.h:124
#define governments_iterate_end
Definition government.h:127
void get_text_size(int *width, int *height, enum client_font font, const char *text)
Definition canvas.c:341
void canvas_free(struct canvas *store)
Definition canvas.c:44
static struct tile * pos
Definition finddlg.c:53
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
const char * title
Definition repodlgs.c:1314
GType type
Definition repodlgs.c:1313
#define mevent_gpos(__ev__)
Definition gui_main.h:23
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Definition repodlgs.cpp:545
#define show(id)
Definition widget.h:235
#define hide(id)
Definition widget.h:238
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Definition helpdata.c:4335
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3294
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype, bool class_help)
Definition helpdata.c:1932
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1381
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
@ HELP_UNIT
Definition helpdlg_g.h:20
@ HELP_GOVERNMENT
Definition helpdlg_g.h:22
@ HELP_WONDER
Definition helpdlg_g.h:21
@ HELP_TECH
Definition helpdlg_g.h:21
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
struct impr_type * improvement_by_number(const Impr_type_id id)
bool can_sell_building(const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define B_LAST
Definition improvement.h:42
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert(condition)
Definition log.h:177
@ LOG_VERBOSE
Definition log.h:34
#define log_error(message,...)
Definition log.h:104
#define fc_calloc(n, esz)
Definition mem.h:38
static mpgui * gui
Definition mpgui_qt.cpp:52
const char *const default_font
Definition fonts.h:27
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
struct client_options gui_options
Definition options.c:71
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
int dsend_packet_player_research(struct connection *pc, int tech)
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
const char * science_dialog_text(void)
Definition text.c:788
struct player * player_by_number(const int player_id)
Definition player.c:849
const char * player_name(const struct player *pplayer)
Definition player.c:895
#define players_iterate_end
Definition player.h:542
#define players_iterate(_pplayer)
Definition player.h:537
void qtg_real_economy_report_dialog_update(void *unused)
QString get_tooltip_improvement(impr_type *building, struct city *pcity, bool ext)
QString split_text(QString text, bool cut)
Definition optiondlg.cpp:62
void qtg_science_report_dialog_redraw()
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Definition repodlgs.cpp:545
void popdown_economy_report()
void economy_report_dialog_popup(bool raise)
void qtg_real_units_report_dialog_update(void *unused)
void qtg_endgame_report_dialog_player(const struct packet_endgame_player *packet)
void popdown_science_report()
void units_report_dialog_popup(bool raise)
void qtg_real_science_report_dialog_update(void *unused)
void popdown_endgame_report()
void popdown_units_report()
void qtg_science_report_dialog_popup(bool raise)
void toggle_units_report(bool x)
void popup_endgame_report()
QString cut_helptext(QString text)
void qtg_endgame_report_dialog_start(const struct packet_endgame_report *packet)
QString get_tooltip_unit(struct unit_type *unit, bool ext)
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
void draw_reqtree(struct reqtree *tree, struct canvas *pcanvas, int canvas_x, int canvas_y, int tt_x, int tt_y, int w, int h)
Definition reqtree.c:1045
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:878
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1185
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:478
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:847
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MAX(x, y)
Definition shared.h:54
size_t size
Definition specvec.h:72
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
QPixmap map_pixmap
Definition canvas.h:25
Definition city.h:317
struct packet_ruleset_control control
Definition game.h:83
struct connection conn
Definition client_main.h:96
bool reqtree_show_icons
Definition options.h:222
Definition colors.h:21
QTableWidget * end_widget
Definition repodlgs.h:241
endgame_report(const struct packet_endgame_report *packet)
void update_report(const struct packet_endgame_player *packet)
Definition mapimg.c:367
Definition climisc.h:82
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:89
int num_nodes
Definition repodlgs.cpp:86
struct tree_node ** nodes
Definition repodlgs.cpp:87
int * layer_size
Definition repodlgs.cpp:89
int diagram_height
Definition repodlgs.cpp:91
int diagram_width
Definition repodlgs.cpp:91
struct tree_node *** layers
Definition repodlgs.cpp:90
int num_layers
Definition repodlgs.cpp:88
enum tech_state state
Definition research.h:71
Tech_type_id researching
Definition research.h:52
Tech_type_id tech_goal
Definition research.h:83
struct research::@79::@81 client
struct research::research_invention inventions[A_ARRAY_SIZE]
int techs_researched
Definition research.h:42
int researching_cost
Definition research.h:96
int bulbs_researched
Definition research.h:53
QGridLayout * sci_layout
Definition repodlgs.h:175
QLabel * progress_label
Definition repodlgs.h:178
GtkProgressBar * progress_bar
Definition repodlgs.c:75
progress_bar * progress
Definition repodlgs.h:176
QScrollArea * scroll
Definition repodlgs.h:182
QComboBox * goal_combo
Definition repodlgs.h:173
QList< qlist_item > * curr_list
Definition repodlgs.h:179
QLabel * info_label
Definition repodlgs.h:177
research_diagram * res_diag
Definition repodlgs.h:181
QList< qlist_item > * goal_list
Definition repodlgs.h:180
void update_report()
Definition repodlgs.cpp:966
void update_reqtree()
void reset_tree()
Definition repodlgs.cpp:954
void current_tech_changed(int index)
void goal_tech_changed(int index)
QComboBox * researching_combo
Definition repodlgs.h:174
QPixmap * pm
Definition sprite.h:25
Tech_type_id tech
Definition repodlgs.cpp:72
int nprovide
Definition repodlgs.cpp:75
struct tree_node ** provide
Definition repodlgs.cpp:76
int node_width
Definition repodlgs.cpp:78
bool is_dummy
Definition repodlgs.cpp:71
int node_height
Definition repodlgs.cpp:78
int nrequire
Definition repodlgs.cpp:73
struct tree_node ** require
Definition repodlgs.cpp:74
Definition unit.h:140
int upkeep[O_LAST]
Definition unit.h:150
enum unit_activity activity
Definition unit.h:159
int homecity
Definition unit.h:148
const struct unit_type * utype
Definition unit.h:141
enum universals_n kind
Definition fc_types.h:608
universals_u value
Definition fc_types.h:607
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:300
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:248
#define advance_index_iterate_max_end
Definition tech.h:254
static Tech_type_id advance_count(void)
Definition tech.h:165
#define A_FIRST
Definition tech.h:44
#define A_UNSET
Definition tech.h:48
const char * get_science_target_text(double *percent)
Definition text.c:867
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:913
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:7017
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:7007
struct tileset * get_tileset(void)
Definition tilespec.c:718
struct sprite * tiles_lookup_sprite_tag_alt(struct tileset *t, enum log_level level, const char *tag, const char *alt, const char *alt2, const char *what, const char *name, bool scale)
Definition tilespec.c:3815
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:7103
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:7029
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6980
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6998
const struct unit_type * utype
Definition fc_types.h:553
const struct impr_type * building
Definition fc_types.h:546
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
bool is_tech_req_for_utype(const struct unit_type *ptype, struct advance *padv)
Definition unittype.c:2730
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1709
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1566
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1737
#define unit_type_iterate(_p)
Definition unittype.h:862
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:869