Freeciv-3.2
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", NULL, "", "", 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", NULL, "", "", 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 = NULL;
556 req = NULL;
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 != NULL) {
706 }
707 if (pcanvas != NULL) {
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
776 buf2[0] = '\0';
777 for (i = 0; i < tt_help.count(); i++) {
778 rttp = tt_help.at(i);
779 if (rttp->rect.contains(event->pos())) {
780 if (rttp->tech_id != -1) {
781 helptext_advance(buffer, sizeof(buffer), client.conn.playing,
782 buf2, rttp->tech_id);
783 tt_text = QString(buffer);
784 def_str = "<p style='white-space:pre'><b>"
786 advance_by_number(rttp->tech_id))).toHtmlEscaped()
787 + "</b>\n";
788 } else if (rttp->timpr != nullptr) {
789 def_str = get_tooltip_improvement(rttp->timpr, nullptr);
790 tt_text = helptext_building(buffer, sizeof(buffer),
791 client.conn.playing, NULL, rttp->timpr);
793 } else if (rttp->tunit != nullptr) {
794 def_str = get_tooltip_unit(rttp->tunit);
795 tt_text += helptext_unit(buffer, sizeof(buffer), client.conn.playing,
796 buf2, rttp->tunit, TRUE);
798 } else if (rttp->tgov != nullptr) {
799 helptext_government(buffer, sizeof(buffer), client.conn.playing,
800 buf2, rttp->tgov);
801 tt_text = QString(buffer);
803 def_str = "<p style='white-space:pre'><b>"
804 + QString(government_name_translation(rttp->tgov)).toHtmlEscaped()
805 + "</b>\n";
806 } else {
807 return;
808 }
809 tt_text = split_text(tt_text, true);
810 tt_text = def_str + tt_text.toHtmlEscaped();
811 tooltip_text = tt_text.trimmed();
812 tooltip_rect = rttp->rect;
814 if (!QToolTip::isVisible() && !timer_active) {
815 timer_active = true;
816 QTimer::singleShot(500, this, SLOT(show_tooltip()));
817 }
818 }
819 }
820}
821
822/************************************************************************/
826{
827 QPoint cp;
828
829 timer_active = false;
830 cp = QCursor::pos();
831 if (qAbs(cp.x() - tooltip_pos.x()) < 4
832 && qAbs(cp.y() - tooltip_pos.y()) < 4) {
833 QToolTip::showText(cp, tooltip_text, this, tooltip_rect);
834 }
835}
836
837/************************************************************************/
841{
843
844 painter.begin(this);
845 painter.drawPixmap(0, 0, width, height, pcanvas->map_pixmap);
846 painter.end();
847}
848
849/************************************************************************/
853{
854 QSize s;
855
856 s.setWidth(width);;
857 s.setHeight(height);
858 return s;
859}
860
861/************************************************************************/
865{
866 QSize size;
867 QSizePolicy size_expanding_policy(QSizePolicy::Expanding,
868 QSizePolicy::Expanding);
869 QSizePolicy size_fixed_policy(QSizePolicy::Minimum, QSizePolicy::Minimum);
870
871 goal_combo = new QComboBox();
872 info_label = new QLabel();
873 progress = new progress_bar(this);
874 progress_label = new QLabel();
876 sci_layout = new QGridLayout();
878 scroll = new QScrollArea();
879
880 curr_list = NULL;
881 goal_list = NULL;
882 progress->setTextVisible(true);
883 progress_label->setSizePolicy(size_fixed_policy);
884 sci_layout->addWidget(progress_label, 0, 0, 1, 8);
885 sci_layout->addWidget(researching_combo, 1, 0, 1, 4);
886 researching_combo->setSizePolicy(size_fixed_policy);
887 sci_layout->addWidget(progress, 1, 5, 1, 4);
888 progress->setSizePolicy(size_fixed_policy);
889 sci_layout->addWidget(goal_combo, 2, 0, 1, 4);
890 goal_combo->setSizePolicy(size_fixed_policy);
891 sci_layout->addWidget(info_label, 2, 5, 1, 4);
892 info_label->setSizePolicy(size_fixed_policy);
893
894 size = res_diag->size();
895 res_diag->setMinimumSize(size);
896 scroll->setAutoFillBackground(true);
897 scroll->setPalette(QPalette(QColor(215,215,215)));
898 scroll->setWidget(res_diag);
899 scroll->setSizePolicy(size_expanding_policy);
900 sci_layout->addWidget(scroll, 4, 0, 1, 10);
901
902 QObject::connect(researching_combo, SIGNAL(currentIndexChanged(int)),
904
905 QObject::connect(goal_combo, SIGNAL(currentIndexChanged(int)),
906 SLOT(goal_tech_changed(int)));
907
909}
910
911/************************************************************************/
917{
918 if (curr_list) {
919 delete curr_list;
920 }
921
922 if (goal_list) {
923 delete goal_list;
924 }
925 gui()->remove_repo_dlg("SCI");
926}
927
928/************************************************************************/
934{
935 gui()->gimme_place(this, "SCI");
936 index = gui()->add_game_tab(this);
937 gui()->game_tab_widget->setCurrentIndex(index);
939}
940
941/************************************************************************/
945{
946 update();
947}
948
949/************************************************************************/
953{
954 QSize size;
955 res_diag->reset();
956 size = res_diag->size();
957 res_diag->setMinimumSize(size);
958 update();
959}
960
961/************************************************************************/
965{
967 const char *text;
968 int total;
969 int done = research->bulbs_researched;
971 double not_used;
972 QString str;
974 struct sprite *sp;
976
978
979 if (curr_list) {
980 delete curr_list;
981 }
982
983 if (goal_list) {
984 delete goal_list;
985 }
986
987 if (research->researching != A_UNSET) {
989 } else {
990 total = -1;
991 }
992
996 progress_label->setAlignment(Qt::AlignHCenter);
997 info_label->setAlignment(Qt::AlignHCenter);
1000 str = QString::fromUtf8(text);
1001 progress->setFormat(str);
1002 progress->setMinimum(0);
1003 progress->setMaximum(total);
1004 progress->set_pixmap(static_cast<int>(research->researching));
1005
1006 if (done <= total) {
1007 progress->setValue(done);
1008 } else {
1009 done = total;
1010 progress->setValue(done);
1011 }
1012
1013 // Collect all techs which are reachable in the next step.
1014 ac = advance_count();
1017 item.tech_str
1018 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1019 item.id = i;
1020 curr_list->append(item);
1021 }
1023
1024 // Collect all techs which are reachable in next 10 steps.
1028 && (i == research->tech_goal
1030 item.tech_str
1031 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1032 item.id = i;
1033 goal_list->append(item);
1034 }
1036
1037 // Sort both lists
1038 std::sort(goal_list->begin(), goal_list->end(), comp_less_than);
1039 std::sort(curr_list->begin(), curr_list->end(), comp_less_than);
1040
1041 // Fill combo boxes
1042 researching_combo->blockSignals(true);
1043 goal_combo->blockSignals(true);
1044
1045 researching_combo->clear();
1046 goal_combo->clear();
1047 for (int i = 0; i < curr_list->count(); i++) {
1048 QIcon ic;
1049
1050 sp = get_tech_sprite(tileset, curr_list->at(i).id);
1051 if (sp) {
1052 ic = QIcon(*sp->pm);
1053 }
1054 qvar = curr_list->at(i).id;
1055 researching_combo->insertItem(i, ic, curr_list->at(i).tech_str, qvar);
1056 }
1057
1058 for (int i = 0; i < goal_list->count(); i++) {
1059 QIcon ic;
1060
1061 sp = get_tech_sprite(tileset, goal_list->at(i).id);
1062 if (sp) {
1063 ic = QIcon(*sp->pm);
1064 }
1065 qvar = goal_list->at(i).id;
1066 goal_combo->insertItem(i, ic, goal_list->at(i).tech_str, qvar);
1067 }
1068
1069 // Set current tech and goal
1074 A_UNSET);
1075 researching_combo->setCurrentIndex(0);
1076 } else {
1077 for (int i = 0; i < researching_combo->count(); i++) {
1078 qvar = researching_combo->itemData(i);
1079
1080 if (qvar == qres) {
1081 researching_combo->setCurrentIndex(i);
1082 }
1083 }
1084 }
1085
1087
1088 if (qres == A_UNSET) {
1089 goal_combo->insertItem(0, Q_("?tech:None"), A_UNSET);
1090 goal_combo->setCurrentIndex(0);
1091 } else {
1092 for (int i = 0; i < goal_combo->count(); i++) {
1093 qvar = goal_combo->itemData(i);
1094
1095 if (qvar == qres) {
1096 goal_combo->setCurrentIndex(i);
1097 }
1098 }
1099 }
1100
1101 researching_combo->blockSignals(false);
1102 goal_combo->blockSignals(false);
1103
1104 if (client_is_observer()) {
1105 researching_combo->setDisabled(true);
1106 goal_combo->setDisabled(true);
1107 } else {
1108 researching_combo->setDisabled(false);
1109 goal_combo->setDisabled(false);
1110 }
1112}
1113
1114/************************************************************************/
1121
1122/************************************************************************/
1126{
1127 QVariant qvar;
1128
1130
1131 if (researching_combo->hasFocus()) {
1134 }
1135 }
1136}
1137
1138/************************************************************************/
1142{
1143 QVariant qvar;
1144
1145 qvar = goal_combo->itemData(changed_index);
1146
1147 if (goal_combo->hasFocus()) {
1150 }
1151 }
1152}
1153
1154/************************************************************************/
1158{
1159 int i;
1160 int percent;
1162 bool blk = false;
1163 QWidget *w;
1164 QString str;
1165 struct player *plr = client_player();
1166
1167 if (NULL != plr) {
1168 struct research *research = research_get(plr);
1169
1170 if (research->researching == A_UNSET) {
1171 str = QString(Q_("?tech:None"));
1172 } else if (research->client.researching_cost != 0) {
1175 str = str + "\n (" + QString::number(percent) + "%)";
1176 }
1179 blk = true;
1180 }
1181 } else {
1182 str = " ";
1183 }
1184
1185 if (blk) {
1186 gui()->sw_science->keep_blinking = true;
1187 gui()->sw_science->set_custom_labels(str);
1188 gui()->sw_science->sblink();
1189 } else {
1190 gui()->sw_science->keep_blinking = false;
1191 gui()->sw_science->set_custom_labels(str);
1192 gui()->sw_science->update_final_pixmap();
1193 }
1194 gui()->update_sidebar_tooltips();
1195
1196 if (gui()->is_repo_dlg_open("SCI")) {
1197 i = gui()->gimme_index_of("SCI");
1198 fc_assert(i != -1);
1199 w = gui()->game_tab_widget->widget(i);
1200 sci_rep = reinterpret_cast<science_report*>(w);
1202 }
1203}
1204
1205/************************************************************************/
1209{
1210 QHeaderView *header;
1212 eco_widget = new QTableWidget;
1213 disband_button = new QPushButton;
1214 sell_button = new QPushButton;
1215 sell_redun_button = new QPushButton;
1216 eco_label = new QLabel;
1218
1219 slist << _("Type") << Q_("?Building or Unit type:Name") << _("Redundant")
1220 << _("Count") << _("Cost") << _("U Total");
1221 eco_widget->setColumnCount(slist.count());
1222 eco_widget->setHorizontalHeaderLabels(slist);
1223 eco_widget->setProperty("showGrid", "false");
1224 eco_widget->setProperty("selectionBehavior", "SelectRows");
1225 eco_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
1226 eco_widget->horizontalHeader()->resizeSections(QHeaderView::Stretch);
1227 eco_widget->verticalHeader()->setVisible(false);
1228 eco_widget->setSelectionMode(QAbstractItemView::SingleSelection);
1229 eco_widget->setSortingEnabled(true);
1230 header = eco_widget->horizontalHeader();
1231 header->setSectionResizeMode(1, QHeaderView::Stretch);
1232 header->setStretchLastSection(true);
1233 disband_button->setText(_("Disband"));
1234 disband_button->setEnabled(false);
1235 sell_button->setText(_("Sell All"));
1236 sell_button->setEnabled(false);
1237 sell_redun_button->setText(_("Sell Redundant"));
1238 sell_redun_button->setEnabled(false);
1239 eco_layout->addWidget(eco_widget, 1, 0, 5, 5);
1240 eco_layout->addWidget(disband_button, 0, 0, 1, 1);
1241 eco_layout->addWidget(sell_button, 0, 1, 1, 1);
1242 eco_layout->addWidget(sell_redun_button, 0, 2, 1, 1);
1243 eco_layout->addWidget(eco_label, 6, 0, 1, 5);
1244
1245 connect(disband_button, &QAbstractButton::pressed, this, &eco_report::disband_units);
1246 connect(sell_button, &QAbstractButton::pressed, this, &eco_report::sell_buildings);
1247 connect(sell_redun_button, &QAbstractButton::pressed, this, &eco_report::sell_redundant);
1248 connect(eco_widget->selectionModel(),
1250 const QItemSelection &)),
1252 const QItemSelection &)));
1254}
1255
1256/************************************************************************/
1260{
1261 gui()->remove_repo_dlg("ECO");
1262}
1263
1264/************************************************************************/
1268{
1269 curr_row = -1;
1270 gui()->gimme_place(this, "ECO");
1271 index = gui()->add_game_tab(this);
1272 gui()->game_tab_widget->setCurrentIndex(index);
1273}
1274
1275/************************************************************************/
1279{
1282 int entries_used, building_total, unit_total, tax, i, j;
1283 char buf[256];
1285 QFont f = QApplication::font();
1286 int h;
1287 QFontMetrics fm(f);
1288 h = fm.height() + 6;
1289 QPixmap *pix;
1291 struct sprite *sprite;
1292
1293 eco_widget->setRowCount(0);
1294 eco_widget->clearContents();
1296 &building_total, &tax);
1297 for (i = 0; i < entries_used; i++) {
1299 struct impr_type *pimprove = pentry->type;
1300
1301 pix = NULL;
1302 sprite = get_building_sprite(tileset, pimprove);
1303 if (sprite != NULL) {
1304 pix = sprite->pm;
1305 }
1306 if (pix != NULL) {
1307 pix_scaled = pix->scaledToHeight(h);
1308 } else {
1309 pix_scaled.fill();
1310 }
1311 cid id = cid_encode_building(pimprove);
1312
1313 eco_widget->insertRow(i);
1314 for (j = 0; j < 6; j++) {
1315 item = new QTableWidgetItem;
1316 switch (j) {
1317 case 0:
1318 item->setData(Qt::DecorationRole, pix_scaled);
1319 item->setData(Qt::UserRole, id);
1320 break;
1321 case 1:
1322 item->setTextAlignment(Qt::AlignLeft);
1323 item->setText(improvement_name_translation(pimprove));
1324 break;
1325 case 2:
1326 item->setData(Qt::DisplayRole, pentry->redundant);
1327 break;
1328 case 3:
1329 item->setData(Qt::DisplayRole, pentry->count);
1330 break;
1331 case 4:
1332 item->setData(Qt::DisplayRole, pentry->cost);
1333 break;
1334 case 5:
1335 item->setData(Qt::DisplayRole, pentry->total_cost);
1336 break;
1337 }
1338 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
1339 eco_widget->setItem(i, j, item);
1340 }
1341 }
1342 max_row = i;
1344 for (i = 0; i < entries_used; i++) {
1345 struct unit_entry *pentry = unit_entries + i;
1346 struct unit_type *putype = pentry->type;
1347 cid id;
1348
1349 pix = NULL;
1352 if (sprite != NULL) {
1353 pix = sprite->pm;
1354 }
1355 id = cid_encode_unit(putype);
1356
1357 eco_widget->insertRow(i + max_row);
1358 for (j = 0; j < 6; j++) {
1359 item = new QTableWidgetItem;
1360 item->setTextAlignment(Qt::AlignHCenter);
1361 switch (j) {
1362 case 0:
1363 if (pix != NULL) {
1364 pix_scaled = pix->scaledToHeight(h);
1365 item->setData(Qt::DecorationRole, pix_scaled);
1366 }
1367 item->setData(Qt::UserRole, id);
1368 break;
1369 case 1:
1370 item->setTextAlignment(Qt::AlignLeft);
1372 break;
1373 case 2:
1374 item->setData(Qt::DisplayRole, 0);
1375 break;
1376 case 3:
1377 item->setData(Qt::DisplayRole, pentry->count);
1378 break;
1379 case 4:
1380 item->setData(Qt::DisplayRole, pentry->cost);
1381 break;
1382 case 5:
1383 item->setData(Qt::DisplayRole, pentry->total_cost);
1384 break;
1385 }
1386 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
1387 eco_widget->setItem(max_row + i, j, item);
1388 }
1389 }
1390 max_row = max_row + i;
1391 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
1392 tax, building_total + unit_total);
1393 eco_label->setText(buf);
1394}
1395
1396/************************************************************************/
1400 const QItemSelection &ds)
1401{
1403 int i;
1404 QVariant qvar;
1405 struct universal selected;
1406 const struct impr_type *pimprove;
1407 disband_button->setEnabled(false);
1408 sell_button->setEnabled(false);
1409 sell_redun_button->setEnabled(false);
1410
1411 if (sl.isEmpty()) {
1412 return;
1413 }
1414
1415 curr_row = sl.indexes().at(0).row();
1416 if (curr_row >= 0 && curr_row <= max_row) {
1417 itm = eco_widget->item(curr_row, 0);
1418 qvar = itm->data(Qt::UserRole);
1419 uid = qvar.toInt();
1420 selected = cid_decode(uid);
1421 switch (selected.kind) {
1422 case VUT_IMPROVEMENT:
1423 pimprove = selected.value.building;
1424 counter = eco_widget->item(curr_row, 3)->text().toInt();
1425 if (can_sell_building(pimprove)) {
1426 sell_button->setEnabled(true);
1427 }
1428 itm = eco_widget->item(curr_row, 2);
1429 i = itm->text().toInt();
1430 if (i > 0) {
1431 sell_redun_button->setEnabled(true);
1432 }
1433 break;
1434 case VUT_UTYPE:
1435 counter = eco_widget->item(curr_row, 3)->text().toInt();
1436 disband_button->setEnabled(true);
1437 break;
1438 default:
1439 log_error("Not supported type: %d.", selected.kind);
1440 }
1441 }
1442}
1443
1444/************************************************************************/
1448{
1449 struct universal selected;
1450 char title[1024];
1451 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1452 Unit_type_id utype;
1453
1454 selected = cid_decode(uid);
1455 utype = utype_number(selected.value.utype);
1457 _("Do you really wish to disband every %s (%d total)?"),
1459
1460 ask->set_text_title(title, _("Disband Units"));
1461 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1462 ask->setDefaultButton(QMessageBox::Cancel);
1463 ask->setAttribute(Qt::WA_DeleteOnClose);
1464 connect(ask, &hud_message_box::accepted, [=]() {
1465 struct unit_type *putype = utype_by_number(utype);
1466 char buf[1024];
1467 hud_message_box *result;
1468
1469 if (putype) {
1470 disband_all_units(putype, false, buf, sizeof(buf));
1471 }
1472
1473 result = new hud_message_box(gui()->central_wdg);
1474 result->set_text_title(buf, _("Disband Results"));
1475 result->setStandardButtons(QMessageBox::Ok);
1476 result->setAttribute(Qt::WA_DeleteOnClose);
1477 result->show();
1478 });
1479}
1480
1481/************************************************************************/
1485{
1486 struct universal selected;
1487 char title[1024];
1488 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1489 const struct impr_type *pimpr;
1491
1492 selected = cid_decode(uid);
1493 pimpr = selected.value.building;
1495
1497 _("Do you really wish to sell "
1498 "every %s (%d total)?"),
1500
1501 ask->set_text_title(title, _("Sell Improvements"));
1502 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1503 ask->setDefaultButton(QMessageBox::Cancel);
1504 ask->setAttribute(Qt::WA_DeleteOnClose);
1505 connect(ask, &hud_message_box::accepted, [=]() {
1506 char buf[1024];
1507 hud_message_box *result;
1508 struct impr_type *pimprove = improvement_by_number(impr_id);
1509
1510 if (!pimprove) {
1511 return;
1512 }
1513
1514 sell_all_improvements(pimprove, false, buf, sizeof(buf));
1515
1516 result = new hud_message_box(gui()->central_wdg);
1517 result->set_text_title(buf, _("Sell-Off: Results"));
1518 result->setStandardButtons(QMessageBox::Ok);
1519 result->setAttribute(Qt::WA_DeleteOnClose);
1520 result->show();
1521 });
1522}
1523
1524/************************************************************************/
1528{
1529 struct universal selected;
1530 char title[1024];
1531 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1532 const struct impr_type *pimpr;
1534
1535 selected = cid_decode(uid);
1536 pimpr = selected.value.building;
1538
1540 _("Do you really wish to sell "
1541 "every redundant %s (%d total)?"),
1543
1544 ask->set_text_title(title, _("Sell Improvements"));
1545 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1546 ask->setDefaultButton(QMessageBox::Cancel);
1547 ask->setAttribute(Qt::WA_DeleteOnClose);
1548 connect(ask, &hud_message_box::accepted, [=]() {
1549 char buf[1024];
1550 hud_message_box *result;
1551 struct impr_type *pimprove = improvement_by_number(impr_id);
1552
1553 if (!pimprove) {
1554 return;
1555 }
1556
1557 sell_all_improvements(pimprove, true, buf, sizeof(buf));
1558
1559 result = new hud_message_box(gui()->central_wdg);
1560 result->set_text_title(buf, _("Sell-Off: Results"));
1561 result->setStandardButtons(QMessageBox::Ok);
1562 result->setAttribute(Qt::WA_DeleteOnClose);
1563 result->show();
1564 });
1565}
1566
1567/************************************************************************/
1571{
1573 end_widget = new QTableWidget;
1574 unsigned int i;
1575 const size_t col_num = packet->category_num + 3;
1577
1578 players = 0;
1579
1580 slist << _("Player") << _("Nation") << _("Score");
1581 for (i = 0 ; i < col_num - 3; i++) {
1582 slist << Q_(packet->category_name[i]);
1583 }
1584 end_widget->setColumnCount(slist.count());
1585 end_widget->setHorizontalHeaderLabels(slist);
1586 end_widget->setProperty("showGrid", "false");
1587 end_widget->setProperty("selectionBehavior", "SelectRows");
1588 end_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
1589 end_widget->verticalHeader()->setVisible(false);
1590 end_widget->setSelectionMode(QAbstractItemView::SingleSelection);
1591 end_widget->horizontalHeader()->setSectionResizeMode(
1592 QHeaderView::ResizeToContents);
1593 end_layout->addWidget(end_widget, 1, 0, 5, 5);
1595}
1596
1597/************************************************************************/
1601{
1602 gui()->remove_repo_dlg("END");
1603}
1604
1605/************************************************************************/
1609{
1610 gui()->gimme_place(this, "END");
1611 index = gui()->add_game_tab(this);
1612 gui()->game_tab_widget->setCurrentIndex(index);
1613}
1614
1615/************************************************************************/
1619{
1621 QPixmap *pix;
1622 unsigned int i;
1623 const struct player *pplayer = player_by_number(packet->player_id);
1624 const size_t col_num = packet->category_num + 3;
1625
1626 end_widget->insertRow(players);
1627 for (i = 0; i < col_num; i++) {
1628 item = new QTableWidgetItem;
1629 switch (i) {
1630 case 0:
1631 item->setText(player_name(pplayer));
1632 break;
1633 case 1:
1635 if (pix != NULL) {
1636 item->setData(Qt::DecorationRole, *pix);
1637 }
1638 break;
1639 case 2:
1640 item->setText(QString::number(packet->score));
1641 item->setTextAlignment(Qt::AlignHCenter);
1642 break;
1643 default:
1644 item->setText(QString::number(packet->category_score[i-3]));
1645 item->setTextAlignment(Qt::AlignHCenter);
1646 break;
1647 }
1648 end_widget->setItem(players, i, item);
1649 }
1650 players++;
1651 end_widget->resizeRowsToContents();
1652}
1653
1654/************************************************************************/
1659{
1661 int i;
1662 QWidget *w;
1663
1665 return;
1666 }
1667 if (!gui()->is_repo_dlg_open("SCI")) {
1668 sci_rep = new science_report;
1669 sci_rep->init();
1670 } else {
1671 i = gui()->gimme_index_of("SCI");
1672 w = gui()->game_tab_widget->widget(i);
1673 sci_rep = reinterpret_cast<science_report*>(w);
1674 if (gui()->game_tab_widget->currentIndex() == i) {
1675 sci_rep->redraw();
1676 } else if (raise) {
1677 gui()->game_tab_widget->setCurrentWidget(sci_rep);
1678 }
1679 }
1680}
1681
1682/************************************************************************/
1686{
1687 int i;
1689 QWidget *w;
1690
1691 if (gui()->is_repo_dlg_open("ECO")) {
1692 i = gui()->gimme_index_of("ECO");
1693 if (gui()->game_tab_widget->currentIndex() == i) {
1694 w = gui()->game_tab_widget->widget(i);
1695 eco_rep = reinterpret_cast<eco_report*>(w);
1697 }
1698 }
1699 gui()->update_sidebar_tooltips();
1700}
1701
1702/************************************************************************/
1706{
1707 int i;
1709 QWidget *w;
1710
1711 if (!gui()->is_repo_dlg_open("ECO")) {
1712 eco_rep = new eco_report;
1713 eco_rep->init();
1714 eco_rep->update_report();
1715 } else {
1716 i = gui()->gimme_index_of("ECO");
1717 fc_assert(i != -1);
1718 w = gui()->game_tab_widget->widget(i);
1719 if (w->isVisible()) {
1720 gui()->game_tab_widget->setCurrentIndex(0);
1721 return;
1722 }
1723 eco_rep = reinterpret_cast<eco_report *>(w);
1725 gui()->game_tab_widget->setCurrentWidget(eco_rep);
1726 }
1727}
1728
1729/************************************************************************/
1738
1739/************************************************************************/
1743{
1744 gui()->game_tab_widget->setCurrentIndex(0);
1746}
1747
1748/************************************************************************/
1752{
1754
1755 end_rep = new endgame_report(packet);
1756 end_rep->init();
1757}
1758
1759/************************************************************************/
1763{
1764 int i;
1765
1766 if (gui()->is_repo_dlg_open("END")) {
1767 i = gui()->gimme_index_of("END");
1768 fc_assert(i != -1);
1769 delete gui()->game_tab_widget->widget(i);
1770 }
1771}
1772
1773/************************************************************************/
1777{
1778 int i;
1779
1780 if (gui()->is_repo_dlg_open("END")) {
1781 i = gui()->gimme_index_of("END");
1782 gui()->game_tab_widget->setCurrentIndex(i);
1783 }
1784}
1785
1786/************************************************************************/
1790{
1791 int i;
1793 QWidget *w;
1794
1795 if (gui()->is_repo_dlg_open("END")) {
1796 i = gui()->gimme_index_of("END");
1797 fc_assert(i != -1);
1798 w = gui()->game_tab_widget->widget(i);
1799 end_rep = reinterpret_cast<endgame_report*>(w);
1800 end_rep->update_report(packet);
1801 }
1802}
1803
1804/************************************************************************/
1808{
1809 int i;
1811 QWidget *w;
1812
1813 if (gui()->is_repo_dlg_open("SCI")) {
1814 i = gui()->gimme_index_of("SCI");
1815 if (gui()->game_tab_widget->currentIndex() == i) {
1816 w = gui()->game_tab_widget->widget(i);
1817 sci_rep = reinterpret_cast<science_report*>(w);
1818 sci_rep->redraw();
1819 }
1820 }
1821}
1822
1823/************************************************************************/
1827{
1828 int i;
1830 QWidget *w;
1831
1832 if (gui()->is_repo_dlg_open("ECO")) {
1833 i = gui()->gimme_index_of("ECO");
1834 fc_assert(i != -1);
1835 w = gui()->game_tab_widget->widget(i);
1836 eco_rep = reinterpret_cast<eco_report*>(w);
1837 eco_rep->deleteLater();
1838 }
1839}
1840
1841/************************************************************************/
1845{
1846 int i;
1848 QWidget *w;
1849
1850 if (gui()->is_repo_dlg_open("SCI")) {
1851 i = gui()->gimme_index_of("SCI");
1852 fc_assert(i != -1);
1853 w = gui()->game_tab_widget->widget(i);
1854 sci_rep = reinterpret_cast<science_report*>(w);
1855 sci_rep->deleteLater();
1856 }
1857}
1858
1859/************************************************************************/
1866
1867/************************************************************************/
1871 {
1872 Q_UNUSED(x);
1874 && gui()->game_tab_widget->currentIndex() == 0) {
1876 } else {
1878 }
1879}
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:508
#define city_list_iterate_end
Definition city.h:510
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:3993
QString cut_helptext(QString text)
QString get_tooltip_unit(const struct unit_type *utype, bool ext)
Definition citydlg.cpp:4050
void put_to_corner()
Definition mapview.cpp:502
QPushButton * sell_button
Definition repodlgs.h:212
void selection_changed(const QItemSelection &sl, const QItemSelection &ds)
QPushButton * sell_redun_button
Definition repodlgs.h:213
QPushButton * disband_button
Definition repodlgs.h:211
void disband_units()
QTableWidget * eco_widget
Definition repodlgs.h:214
int max_row
Definition repodlgs.h:226
void sell_buildings()
void init()
void sell_redundant()
int curr_row
Definition repodlgs.h:225
void update_report()
QLabel * eco_label
Definition repodlgs.h:215
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:130
struct unit_type * tunit
Definition repodlgs.h:131
struct impr_type * timpr
Definition repodlgs.h:132
struct canvas * pcanvas
Definition repodlgs.h:156
void mousePressEvent(QMouseEvent *event)
Definition repodlgs.cpp:720
void create_tooltip_help()
Definition repodlgs.cpp:585
struct reqtree * req
Definition repodlgs.h:157
QString tooltip_text
Definition repodlgs.h:163
QList< req_tooltip_help * > tt_help
Definition repodlgs.h:161
void mouseMoveEvent(QMouseEvent *event)
Definition repodlgs.cpp:767
void update_reqtree()
Definition repodlgs.cpp:690
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:840
research_diagram(QWidget *parent=nullptr)
Definition repodlgs.cpp:553
QPoint tooltip_pos
Definition repodlgs.h:162
static units_reports * m_instance
Definition repodlgs.h:95
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:90
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:106
QList< unittype_item * > unittype_list
Definition repodlgs.h:107
QHBoxLayout * scroll_layout
Definition repodlgs.h:92
QWidget scroll_widget
Definition repodlgs.h:94
QScrollArea * scroll
Definition repodlgs.h:93
void init_layout()
Definition repodlgs.cpp:391
QLabel label_pix
Definition repodlgs.h:54
int unit_scroll
Definition repodlgs.h:53
QLabel label_info_active
Definition repodlgs.h:62
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:61
QLabel label_info_inbuild
Definition repodlgs.h:63
QLabel shield_upkeep
Definition repodlgs.h:65
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:60
QLabel label_info_unit
Definition repodlgs.h:64
unit_type * utype
Definition repodlgs.h:69
QPushButton upgrade_button
Definition repodlgs.h:66
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:504
struct universal cid_decode(cid id)
Definition climisc.c:525
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
int cid
Definition climisc.h:31
char * incite_cost
Definition comments.c:75
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
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int Tech_type_id
Definition fc_types.h:377
int Impr_type_id
Definition fc_types.h:376
int Unit_type_id
Definition fc_types.h:382
@ 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:62
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:4340
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3299
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:191
#define fc_assert(condition)
Definition log.h:176
@ LOG_VERBOSE
Definition log.h:33
#define log_error(message,...)
Definition log.h:103
#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:741
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:537
#define players_iterate(_pplayer)
Definition player.h:532
void science_report_dialog_popup(bool raise)
QString get_tooltip_improvement(impr_type *building, struct city *pcity, bool ext)
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
QString split_text(QString text, bool cut)
Definition optiondlg.cpp:62
void real_units_report_dialog_update(void *unused)
void real_economy_report_dialog_update(void *unused)
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 popdown_science_report()
void units_report_dialog_popup(bool raise)
void popdown_endgame_report()
void science_report_dialog_redraw(void)
void popdown_units_report()
void toggle_units_report(bool x)
void popup_endgame_report()
QString cut_helptext(QString text)
QString get_tooltip_unit(struct unit_type *unit, bool ext)
void real_science_report_dialog_update(void *unused)
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)
endgame_report_dialog_player
Definition repodlgs_g.h:33
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:1036
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:870
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1176
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:473
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:839
#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:320
struct packet_ruleset_control control
Definition game.h:83
struct connection conn
Definition client_main.h:96
bool reqtree_show_icons
Definition options.h:221
Definition colors.h:21
struct player * playing
Definition connection.h:151
QTableWidget * end_widget
Definition repodlgs.h:244
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:85
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::@76::@78 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:178
QLabel * progress_label
Definition repodlgs.h:181
GtkProgressBar * progress_bar
Definition repodlgs.c:75
progress_bar * progress
Definition repodlgs.h:179
QScrollArea * scroll
Definition repodlgs.h:185
QComboBox * goal_combo
Definition repodlgs.h:176
QList< qlist_item > * curr_list
Definition repodlgs.h:182
QLabel * info_label
Definition repodlgs.h:180
research_diagram * res_diag
Definition repodlgs.h:184
QList< qlist_item > * goal_list
Definition repodlgs.h:183
void update_report()
Definition repodlgs.cpp:964
void update_reqtree()
void reset_tree()
Definition repodlgs.cpp:952
void current_tech_changed(int index)
void goal_tech_changed(int index)
QComboBox * researching_combo
Definition repodlgs.h:177
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:138
int upkeep[O_LAST]
Definition unit.h:148
enum unit_activity activity
Definition unit.h:157
int homecity
Definition unit.h:146
const struct unit_type * utype
Definition unit.h:139
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#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:290
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
#define advance_index_iterate_max_end
Definition tech.h:258
static Tech_type_id advance_count(void)
Definition tech.h:170
#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:820
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6793
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6783
struct tileset * get_tileset(void)
Definition tilespec.c:692
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:3639
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6879
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6805
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6756
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6774
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
#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:2724
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
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:1560
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
#define unit_type_iterate(_p)
Definition unittype.h:855
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:862