Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-qt/repodlgs.cpp Source File

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);
61 extern QString get_tooltip_improvement(impr_type *building,
62 struct city *pcity, bool ext);
63 extern QString get_tooltip_unit(struct unit_type *unit, bool ext);
64
65 units_reports *units_reports::m_instance = nullptr;
66
67/****************************************************************************
68 From reqtree.c used to get tooltips
69****************************************************************************/
70 struct tree_node {
71 bool is_dummy;
72 Tech_type_id tech;
73 int nrequire;
74 struct tree_node **require;
75 int nprovide;
76 struct tree_node **provide;
77 int order, layer;
78 int node_x, node_y, node_width, node_height;
79 int number;
80};
81
82/****************************************************************************
83 From reqtree.c used to get tooltips
84****************************************************************************/
85 struct reqtree {
86 int num_nodes;
87 struct tree_node **nodes;
88 int num_layers;
89 int *layer_size;
90 struct tree_node ***layers;
91 int diagram_width, diagram_height;
92};
93
94/************************************************************************/
97unittype_item::unittype_item(QWidget *parent,
98 struct unit_type *ut): QFrame(parent)
99{
100 int isize;
101 QFont f;
102 QFontMetrics *fm;
103 QHBoxLayout *hbox;
104 QHBoxLayout *hbox_top;
105 QHBoxLayout *hbox_upkeep;
106 QImage cropped_img;
107 QImage img;
108 QLabel *lab;
109 QPixmap pix;
110 QRect crop;
111 QSizePolicy size_fixed_policy(QSizePolicy::Maximum, QSizePolicy::Maximum,
112 QSizePolicy::Slider);
113 QSpacerItem *spacer;
114 QVBoxLayout *vbox;
115 QVBoxLayout *vbox_main;
116 struct sprite *spr;
117
118 setParent(parent);
119 utype = ut;
120 init_img();
121 unit_scroll = 0;
122 setSizePolicy(size_fixed_policy);
123 f = *fc_font::instance()->get_font(fonts::default_font);
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);
142 hbox_upkeep = new QHBoxLayout;
143 hbox_upkeep->addWidget(&shield_upkeep);
144 lab = new QLabel("");
145 spr = tiles_lookup_sprite_tag_alt(tileset, LOG_VERBOSE, "upkeep.shield",
146 "citybar.shields", nullptr, "", "", false);
147 img = spr->pm->toImage();
148 crop = zealous_crop_rect(img);
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);
157 spr = get_tax_sprite(tileset, O_GOLD);
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("");
166 spr = tiles_lookup_sprite_tag_alt(tileset, LOG_VERBOSE, "citybar.food",
167 "citybar.food", nullptr, "", "", false);
168 img = spr->pm->toImage();
169 crop = zealous_crop_rect(img);
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);
175 setLayout(vbox_main);
176 entered = false;
177 delete fm;
178}
179
180/************************************************************************/
183unittype_item::~unittype_item()
184{
185}
186
187/************************************************************************/
190 void unittype_item::init_img()
191{
192 struct sprite *sp;
193
194 sp = get_unittype_sprite(get_tileset(), utype,
195 ACTIVITY_LAST, direction8_invalid());
196 label_pix.setPixmap(*sp->pm);
197}
198
199/************************************************************************/
202 void unittype_item::upgrade_units()
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;
210 const Unit_type_id type = utype_number(utype);
211
212 upgrade = can_upgrade_unittype(client_player(), utype);
213 price = unit_upgrade_price(client_player(), utype, upgrade);
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);
218 fc_snprintf(buf2, ARRAY_SIZE(buf2),
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),
223 utype_name_translation(utype),
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, [=]() {
231 dsend_packet_unit_type_upgrade(&client.conn, type);
232 });
233 ask->show();
234}
235
236/************************************************************************/
239#ifndef FC_QT5_MODE
240 void unittype_item::enterEvent(QEnterEvent *event)
241#else // FC_QT5_MODE
242void unittype_item::enterEvent(QEvent *event)
243#endif // FC_QT5_MODE
244{
245 entered = true;
246 update();
247}
248
249/************************************************************************/
252 void unittype_item::paintEvent(QPaintEvent *event)
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/************************************************************************/
269 void unittype_item::leaveEvent(QEvent *event)
270{
271 entered = false;
272 update();
273}
274
275/************************************************************************/
278 void unittype_item::wheelEvent(QWheelEvent *event)
279{
280 int unit_count = 0;
281
282 unit_list_iterate(client_player()->units, punit) {
283 if (punit->utype != utype) {
284 continue;
285 }
286 if (ACTIVITY_IDLE == punit->activity
287 || ACTIVITY_SENTRY == punit->activity) {
288 if (can_unit_do_activity_client(punit, ACTIVITY_IDLE)) {
289 unit_count++;
290 }
291 }
292 } unit_list_iterate_end;
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
307 unit_list_iterate(client_player()->units, punit) {
308 if (punit->utype != utype) {
309 continue;
310 }
311 if (ACTIVITY_IDLE == punit->activity
312 || ACTIVITY_SENTRY == punit->activity) {
313 if (can_unit_do_activity_client(punit, ACTIVITY_IDLE)) {
314 unit_count++;
315 if (unit_count == unit_scroll) {
316 unit_focus_set_and_select(punit);
317 }
318 }
319 }
320 } unit_list_iterate_end;
321 event->accept();
322}
323
324/************************************************************************/
327units_reports::units_reports() : fcwidget()
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/************************************************************************/
341units_reports::~units_reports()
342{
343 qDeleteAll(unittype_list);
344 unittype_list.clear();
345 delete cw;
346}
347
348/************************************************************************/
351 void units_reports::add_item(unittype_item *item)
352{
353 unittype_list.append(item);
354}
355
356/************************************************************************/
359 units_reports *units_reports::instance()
360{
361 if (!m_instance) {
362 m_instance = new units_reports;
363 }
364
365 return m_instance;
366}
367
368/************************************************************************/
371 void units_reports::drop()
372{
373 if (m_instance) {
374 delete m_instance;
375 m_instance = nullptr;
376 }
377}
378
379/************************************************************************/
382 void units_reports::update_menu()
383{
384 was_destroyed = true;
385 drop();
386}
387
388/************************************************************************/
391 void units_reports::init_layout()
392{
393 QSizePolicy size_fixed_policy(QSizePolicy::Maximum,
394 QSizePolicy::Maximum,
395 QSizePolicy::Slider);
396
397 scroll = new QScrollArea(this);
398 setSizePolicy(size_fixed_policy);
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);
406 setLayout(scroll_layout);
407}
408
409/************************************************************************/
412 void units_reports::paintEvent(QPaintEvent *event)
413{
414 cw->put_to_corner();
415}
416
417/************************************************************************/
420 void units_reports::update_units(bool show)
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;
434 Unit_type_id utype_id;
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) {
446 info = unit_array + utype_index(unit_type_get(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++;
453 } unit_list_iterate_end;
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
460 (void) city_production_build_units(pcity, true, &num_units);
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 }
465 } city_list_iterate_end;
466 } players_iterate_end;
467
468 unit_type_iterate(utype) {
469 utype_id = utype_index(utype);
470 info = unit_array + utype_id;
471 upgradable = client_has_player()
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);
489 } unit_type_iterate_end;
490
491 free(unit_array);
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
502 total_len = total_len + contentsMargins().left()
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();
513 updateGeometry();
514}
515
516/************************************************************************/
519 void units_reports::clear_layout()
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/************************************************************************/
545 bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
546{
547 return (q1.tech_str < q2.tech_str);
548}
549
550/************************************************************************/
553research_diagram::research_diagram(QWidget *parent): QWidget(parent)
554{
555 pcanvas = nullptr;
556 req = nullptr;
557 reset();
558 setMouseTracking(true);
559}
560
561/************************************************************************/
564research_diagram::~research_diagram()
565{
566 canvas_free(pcanvas);
567 destroy_reqtree(req);
568 qDeleteAll(tt_help);
569 tt_help.clear();
570}
571
572/************************************************************************/
575req_tooltip_help::req_tooltip_help()
576{
577 tech_id = -1;
578 tunit = nullptr;
579 timpr = nullptr;
580}
581
582/************************************************************************/
585 void research_diagram::create_tooltip_help()
586{
587 int i, j;
588 int swidth, sheight;
589 struct sprite *sprite;
590 reqtree *tree;
591 req_tooltip_help *rttp;
592
593 qDeleteAll(tt_help);
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];
604 int startx, starty, nwidth, nheight;
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(
613 research_get(client_player()), node->tech);
614 int text_w, text_h;
615 int icon_startx;
616
617 get_text_size(&text_w, &text_h, FONT_REQTREE_TEXT, text);
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
625 if (gui_options.reqtree_show_icons) {
626 unit_type_iterate(utype) {
627
628 if (!is_tech_req_for_utype(utype, advance_by_number(node->tech))) {
629 continue;
630 }
631
632 sprite = get_unittype_sprite(tileset, utype,
633 ACTIVITY_LAST, direction8_invalid());
634 get_sprite_dimensions(sprite, &swidth, &sheight);
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;
642 } unit_type_iterate_end;
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) {
649 sprite = get_building_sprite(tileset, pimprove);
650 if (sprite) {
651 get_sprite_dimensions(sprite, &swidth, &sheight);
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 }
661 } requirement_vector_iterate_end;
662 }
663 } improvement_iterate_end;
664
665 governments_iterate(gov) {
666 requirement_vector_iterate(&(gov->reqs), preq) {
667 if (VUT_ADVANCE == preq->source.kind
668 && advance_number(preq->source.value.advance) == node->tech) {
669 sprite = get_government_sprite(tileset, gov);
670 get_sprite_dimensions(sprite, &swidth, &sheight);
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 }
679 } requirement_vector_iterate_end;
680 } governments_iterate_end;
681 }
682 }
683 }
684 }
685}
686
687/************************************************************************/
690 void research_diagram::update_reqtree()
691{
692 reset();
693 draw_reqtree(req, pcanvas, 0, 0, 0, 0, width, height);
694 create_tooltip_help();
695 update();
696}
697
698/************************************************************************/
701 void research_diagram::reset()
702{
703 timer_active = false;
704 if (req != nullptr) {
705 destroy_reqtree(req);
706 }
707 if (pcanvas != nullptr) {
708 canvas_free(pcanvas);
709 }
710 req = create_reqtree(client_player(), true);
711 get_reqtree_dimensions(req, &width, &height);
712 pcanvas = qtg_canvas_create(width, height);
713 pcanvas->map_pixmap.fill(Qt::transparent);
714 resize(width, height);
715}
716
717/************************************************************************/
720 void research_diagram::mousePressEvent(QMouseEvent *event)
721{
722 QPoint pos = event->pos();
723 Tech_type_id tech = get_tech_on_reqtree(req, pos.x(), pos.y());
724 req_tooltip_help *rttp;
725 int i;
726
727 if (event->button() == Qt::LeftButton && can_client_issue_orders()) {
728 switch (research_invention_state(research_get(client_player()), tech)) {
729 case TECH_PREREQS_KNOWN:
730 dsend_packet_player_research(&client.conn, tech);
731 break;
732 case TECH_UNKNOWN:
733 dsend_packet_player_tech_goal(&client.conn, tech);
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) {
743 popup_help_dialog_typed(research_advance_name_translation(
744 research_get(client_player()),
745 rttp->tech_id), HELP_TECH);
746 } else if (rttp->timpr != nullptr) {
747 popup_help_dialog_typed(improvement_name_translation(rttp->timpr),
748 is_great_wonder(rttp->timpr) ? HELP_WONDER
749 : HELP_IMPROVEMENT);
750 } else if (rttp->tunit != nullptr) {
751 popup_help_dialog_typed(utype_name_translation(rttp->tunit),
752 HELP_UNIT);
753 } else if (rttp->tgov != nullptr) {
754 popup_help_dialog_typed(government_name_translation(rttp->tgov),
755 HELP_GOVERNMENT);
756 } else {
757 return;
758 }
759 }
760 }
761 }
762}
763
764/************************************************************************/
767 void research_diagram::mouseMoveEvent(QMouseEvent *event)
768{
769 req_tooltip_help *rttp;
770 int i;
771 QString tt_text;
772 QString def_str;
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>"
786 + QString(advance_name_translation(
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);
793 tt_text = cut_helptext(tt_text);
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);
798 tt_text = cut_helptext(tt_text);
799 } else if (rttp->tgov != nullptr) {
800 helptext_government(buffer, sizeof(buffer), pplayer,
801 buf2, rttp->tgov);
802 tt_text = QString(buffer);
803 tt_text = cut_helptext(tt_text);
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;
814 tooltip_pos = mevent_gpos(event);
815 if (!QToolTip::isVisible() && !timer_active) {
816 timer_active = true;
817 QTimer::singleShot(500, this, SLOT(show_tooltip()));
818 }
819 }
820 }
821}
822
823/************************************************************************/
826 void research_diagram::show_tooltip()
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/************************************************************************/
841 void research_diagram::paintEvent(QPaintEvent *event)
842{
843 QPainter painter;
844
845 painter.begin(this);
846 painter.drawPixmap(0, 0, width, height, pcanvas->map_pixmap);
847 painter.end();
848}
849
850/************************************************************************/
853 QSize research_diagram::size()
854{
855 QSize s;
856
857 s.setWidth(width);
858 s.setHeight(height);
859
860 return s;
861}
862
863/************************************************************************/
866science_report::science_report(): QWidget()
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();
877 researching_combo = new QComboBox();
878 sci_layout = new QGridLayout();
879 res_diag = new research_diagram();
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)),
905 SLOT(current_tech_changed(int)));
906
907 QObject::connect(goal_combo, SIGNAL(currentIndexChanged(int)),
908 SLOT(goal_tech_changed(int)));
909
910 setLayout(sci_layout);
911}
912
913/************************************************************************/
918science_report::~science_report()
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/************************************************************************/
935 void science_report::init()
936{
937 gui()->gimme_place(this, "SCI");
938 index = gui()->add_game_tab(this);
939 gui()->game_tab_widget->setCurrentIndex(index);
940 update_report();
941}
942
943/************************************************************************/
946 void science_report::redraw()
947{
948 update();
949}
950
951/************************************************************************/
954 void science_report::reset_tree()
955{
956 QSize size;
957 res_diag->reset();
958 size = res_diag->size();
959 res_diag->setMinimumSize(size);
960 update();
961}
962
963/************************************************************************/
966 void science_report::update_report()
967{
968 struct research *research = research_get(client_player());
969 const char *text;
970 int total;
971 int done = research->bulbs_researched;
972 QVariant qvar, qres;
973 double not_used;
974 QString str;
975 qlist_item item;
976 struct sprite *sp;
977 Tech_type_id ac;
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) {
990 total = research->client.researching_cost;
991 } else {
992 total = -1;
993 }
994
995 curr_list = new QList<qlist_item>;
996 goal_list = new QList<qlist_item>;
997 progress_label->setText(science_dialog_text());
998 progress_label->setAlignment(Qt::AlignHCenter);
999 info_label->setAlignment(Qt::AlignHCenter);
1000 info_label->setText(get_science_goal_text(research->tech_goal));
1001 text = get_science_target_text(&not_used);
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();
1017 advance_index_iterate_max(A_FIRST, i, ac) {
1018 if (TECH_PREREQS_KNOWN == research->inventions[i].state) {
1019 item.tech_str
1020 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1021 item.id = i;
1022 curr_list->append(item);
1023 }
1024 } advance_index_iterate_max_end;
1025
1026 // Collect all techs which are reachable in next 10 steps.
1027 advance_index_iterate_max(A_FIRST, i, ac) {
1028 if (research_invention_reachable(research, i)
1029 && TECH_KNOWN != research->inventions[i].state
1030 && (i == research->tech_goal
1031 || 10 >= research->inventions[i].num_required_techs)) {
1032 item.tech_str
1033 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1034 item.id = i;
1035 goal_list->append(item);
1036 }
1037 } advance_index_iterate_max_end;
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
1072 qres = research->researching;
1073 if (qres == A_UNSET || is_future_tech(research->researching)) {
1074 researching_combo->insertItem(0, research_advance_name_translation(
1075 research, research->researching ),
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
1088 qres = research->tech_goal;
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 }
1113 update_reqtree();
1114}
1115
1116/************************************************************************/
1119 void science_report::update_reqtree()
1120{
1121 res_diag->update_reqtree();
1122}
1123
1124/************************************************************************/
1127 void science_report::current_tech_changed(int changed_index)
1128{
1129 QVariant qvar;
1130
1131 qvar = researching_combo->itemData(changed_index);
1132
1133 if (researching_combo->hasFocus()) {
1134 if (can_client_issue_orders()) {
1135 dsend_packet_player_research(&client.conn, qvar.toInt());
1136 }
1137 }
1138}
1139
1140/************************************************************************/
1143 void science_report::goal_tech_changed(int changed_index)
1144{
1145 QVariant qvar;
1146
1147 qvar = goal_combo->itemData(changed_index);
1148
1149 if (goal_combo->hasFocus()) {
1150 if (can_client_issue_orders()) {
1151 dsend_packet_player_tech_goal(&client.conn, qvar.toInt());
1152 }
1153 }
1154}
1155
1156/************************************************************************/
1159 void qtg_real_science_report_dialog_update(void *unused)
1160{
1161 int i;
1162 int percent;
1163 science_report *sci_rep;
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) {
1175 str = research_advance_name_translation(research, research->researching);
1176 percent = 100 *research->bulbs_researched / research->client.researching_cost;
1177 str = str + "\n (" + QString::number(percent) + "%)";
1178 }
1179 if (research->researching == A_UNSET && research->tech_goal == A_UNSET
1180 && research->techs_researched < game.control.num_tech_types) {
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);
1203 sci_rep->update_report();
1204 }
1205}
1206
1207/************************************************************************/
1210eco_report::eco_report(): QWidget()
1211{
1212 QHeaderView *header;
1213 QGridLayout *eco_layout = new QGridLayout;
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;
1219 QStringList slist;
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(),
1251 SIGNAL(selectionChanged(const QItemSelection &,
1252 const QItemSelection &)),
1253 SLOT(selection_changed(const QItemSelection &,
1254 const QItemSelection &)));
1255 setLayout(eco_layout);
1256}
1257
1258/************************************************************************/
1261eco_report::~eco_report()
1262{
1263 gui()->remove_repo_dlg("ECO");
1264}
1265
1266/************************************************************************/
1269 void eco_report::init()
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/************************************************************************/
1280 void eco_report::update_report()
1281{
1282 struct improvement_entry building_entries[B_LAST];
1283 struct unit_entry unit_entries[U_LAST];
1284 int entries_used, building_total, unit_total, tax, i, j;
1285 char buf[256];
1286 QTableWidgetItem *item;
1287 QFont f = QApplication::font();
1288 int h;
1289 QFontMetrics fm(f);
1290 h = fm.height() + 6;
1291 QPixmap *pix;
1292 QPixmap pix_scaled;
1293 struct sprite *sprite;
1294
1295 eco_widget->setRowCount(0);
1296 eco_widget->clearContents();
1297 get_economy_report_data(building_entries, &entries_used,
1298 &building_total, &tax);
1299 for (i = 0; i < entries_used; i++) {
1300 struct improvement_entry *pentry = building_entries + 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;
1345 get_economy_report_units_data(unit_entries, &entries_used, &unit_total);
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;
1352 sprite = get_unittype_sprite(tileset, putype,
1353 ACTIVITY_LAST, direction8_invalid());
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);
1373 item->setText(utype_name_translation(putype));
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/************************************************************************/
1401 void eco_report::selection_changed(const QItemSelection &sl,
1402 const QItemSelection &ds)
1403{
1404 QTableWidgetItem *itm;
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/************************************************************************/
1449 void eco_report::disband_units()
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);
1458 fc_snprintf(title, ARRAY_SIZE(title),
1459 _("Do you really wish to disband every %s (%d total)?"),
1460 utype_name_translation(utype_by_number(utype)), counter);
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/************************************************************************/
1486 void eco_report::sell_buildings()
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;
1492 Impr_type_id impr_id;
1493
1494 selected = cid_decode(uid);
1495 pimpr = selected.value.building;
1496 impr_id = improvement_number(pimpr);
1497
1498 fc_snprintf(title, ARRAY_SIZE(title),
1499 _("Do you really wish to sell "
1500 "every %s (%d total)?"),
1501 improvement_name_translation(pimpr), counter);
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/************************************************************************/
1529 void eco_report::sell_redundant()
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;
1535 Impr_type_id impr_id;
1536
1537 selected = cid_decode(uid);
1538 pimpr = selected.value.building;
1539 impr_id = improvement_number(pimpr);
1540
1541 fc_snprintf(title, ARRAY_SIZE(title),
1542 _("Do you really wish to sell "
1543 "every redundant %s (%d total)?"),
1544 improvement_name_translation(pimpr), counter);
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/************************************************************************/
1572endgame_report::endgame_report(const struct packet_endgame_report *packet): QWidget()
1573{
1574 QGridLayout *end_layout = new QGridLayout;
1575 end_widget = new QTableWidget;
1576 unsigned int i;
1577 const size_t col_num = packet->category_num + 3;
1578 QStringList slist;
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);
1596 setLayout(end_layout);
1597}
1598
1599/************************************************************************/
1602endgame_report::~endgame_report()
1603{
1604 gui()->remove_repo_dlg("END");
1605}
1606
1607/************************************************************************/
1610 void endgame_report::init()
1611{
1612 gui()->gimme_place(this, "END");
1613 index = gui()->add_game_tab(this);
1614 gui()->game_tab_widget->setCurrentIndex(index);
1615}
1616
1617/************************************************************************/
1620 void endgame_report::update_report(const struct packet_endgame_player *packet)
1621{
1622 QTableWidgetItem *item;
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:
1636 pix = get_nation_flag_sprite(tileset, nation_of_player(pplayer))->pm;
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/************************************************************************/
1660 void qtg_science_report_dialog_popup(bool raise)
1661{
1662 science_report *sci_rep;
1663 int i;
1664 QWidget *w;
1665
1666 if (client_is_global_observer()) {
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/************************************************************************/
1687 void qtg_real_economy_report_dialog_update(void *unused)
1688{
1689 int i;
1690 eco_report *eco_rep;
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);
1698 eco_rep->update_report();
1699 }
1700 }
1701 gui()->update_sidebar_tooltips();
1702}
1703
1704/************************************************************************/
1707 void economy_report_dialog_popup(bool raise)
1708{
1709 int i;
1710 eco_report *eco_rep;
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);
1726 eco_rep->update_report();
1727 gui()->game_tab_widget->setCurrentWidget(eco_rep);
1728 }
1729}
1730
1731/************************************************************************/
1734 void qtg_real_units_report_dialog_update(void *unused)
1735{
1736 if (units_reports::instance()->isVisible()) {
1737 units_reports::instance()->update_units();
1738 }
1739}
1740
1741/************************************************************************/
1744 void units_report_dialog_popup(bool raise)
1745{
1746 gui()->game_tab_widget->setCurrentIndex(0);
1747 units_reports::instance()->update_units(true);
1748}
1749
1750/************************************************************************/
1753 void qtg_endgame_report_dialog_start(const struct packet_endgame_report *packet)
1754{
1755 endgame_report *end_rep;
1756
1757 end_rep = new endgame_report(packet);
1758 end_rep->init();
1759}
1760
1761/************************************************************************/
1764 void popdown_endgame_report()
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/************************************************************************/
1778 void popup_endgame_report()
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/************************************************************************/
1791 void qtg_endgame_report_dialog_player(const struct packet_endgame_player *packet)
1792{
1793 int i;
1794 endgame_report *end_rep;
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/************************************************************************/
1809 void qtg_science_report_dialog_redraw()
1810{
1811 int i;
1812 science_report *sci_rep;
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/************************************************************************/
1828 void popdown_economy_report()
1829{
1830 int i;
1831 eco_report *eco_rep;
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/************************************************************************/
1846 void popdown_science_report()
1847{
1848 int i;
1849 science_report *sci_rep;
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/************************************************************************/
1864 void popdown_units_report()
1865{
1866 units_reports::instance()->drop();
1867}
1868
1869/************************************************************************/
1872 void toggle_units_report(bool x)
1873 {
1874 Q_UNUSED(x);
1875 if (units_reports::instance()->isVisible()
1876 && gui()->game_tab_widget->currentIndex() == 0) {
1877 units_reports::instance()->drop();
1878 } else {
1879 units_report_dialog_popup(true);
1880 }
1881}
entries_used
int entries_used
Definition agents.c:77
str
#define str
Definition astring.c:76
zealous_crop_rect
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:419
qtg_canvas_create
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:36
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
city_production_build_units
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:746
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
split_text
QString split_text(QString text, bool cut)
Definition optiondlg.cpp:62
get_tooltip_improvement
QString get_tooltip_improvement(const impr_type *building, struct city *pcity, bool ext)
Definition citydlg.cpp:3862
cut_helptext
QString cut_helptext(QString text)
Definition optiondlg.cpp:105
get_tooltip_unit
QString get_tooltip_unit(const struct unit_type *utype, bool ext)
Definition citydlg.cpp:3921
close_widget
Definition mapview.h:183
close_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:502
eco_report
Definition repodlgs.h:206
eco_report::eco_report
eco_report()
Definition repodlgs.cpp:1210
eco_report::sell_button
QPushButton * sell_button
Definition repodlgs.h:209
eco_report::selection_changed
void selection_changed(const QItemSelection &sl, const QItemSelection &ds)
Definition repodlgs.cpp:1401
eco_report::sell_redun_button
QPushButton * sell_redun_button
Definition repodlgs.h:210
eco_report::disband_button
QPushButton * disband_button
Definition repodlgs.h:208
eco_report::disband_units
void disband_units()
Definition repodlgs.cpp:1449
eco_report::eco_widget
QTableWidget * eco_widget
Definition repodlgs.h:211
eco_report::index
int index
Definition repodlgs.h:221
eco_report::max_row
int max_row
Definition repodlgs.h:223
eco_report::sell_buildings
void sell_buildings()
Definition repodlgs.cpp:1486
eco_report::init
void init()
Definition repodlgs.cpp:1269
eco_report::uid
cid uid
Definition repodlgs.h:224
eco_report::~eco_report
~eco_report()
Definition repodlgs.cpp:1261
eco_report::sell_redundant
void sell_redundant()
Definition repodlgs.cpp:1529
eco_report::curr_row
int curr_row
Definition repodlgs.h:222
eco_report::update_report
void update_report()
Definition repodlgs.cpp:1280
eco_report::eco_label
QLabel * eco_label
Definition repodlgs.h:212
fc_font::instance
static fc_font * instance()
Definition fonts.cpp:41
fc_font::get_font
QFont * get_font(QString name)
Definition fonts.cpp:63
fcwidget
Definition mapview.h:172
fcwidget::was_destroyed
bool was_destroyed
Definition mapview.h:176
hud_message_box
Definition hudwidget.h:56
hud_message_box::set_text_title
int set_text_title(QString s1, QString s2, bool return_exec=false)
Definition hudwidget.cpp:126
progress_bar::set_pixmap
void set_pixmap(struct universal *target)
Definition citydlg.cpp:113
req_tooltip_help
Definition repodlgs.h:123
req_tooltip_help::tech_id
Tech_type_id tech_id
Definition repodlgs.h:127
req_tooltip_help::tunit
struct unit_type * tunit
Definition repodlgs.h:128
req_tooltip_help::timpr
struct impr_type * timpr
Definition repodlgs.h:129
req_tooltip_help::req_tooltip_help
req_tooltip_help()
Definition repodlgs.cpp:575
research_diagram
Definition repodlgs.h:137
research_diagram::show_tooltip
void show_tooltip()
Definition repodlgs.cpp:826
research_diagram::reset
void reset()
Definition repodlgs.cpp:701
research_diagram::pcanvas
struct canvas * pcanvas
Definition repodlgs.h:153
research_diagram::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition repodlgs.cpp:720
research_diagram::size
QSize size()
Definition repodlgs.cpp:853
research_diagram::timer_active
bool timer_active
Definition repodlgs.h:155
research_diagram::~research_diagram
~research_diagram()
Definition repodlgs.cpp:564
research_diagram::create_tooltip_help
void create_tooltip_help()
Definition repodlgs.cpp:585
research_diagram::req
struct reqtree * req
Definition repodlgs.h:154
research_diagram::tooltip_text
QString tooltip_text
Definition repodlgs.h:160
research_diagram::tt_help
QList< req_tooltip_help * > tt_help
Definition repodlgs.h:158
research_diagram::tooltip_rect
QRect tooltip_rect
Definition repodlgs.h:161
research_diagram::height
int height
Definition repodlgs.h:157
research_diagram::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition repodlgs.cpp:767
research_diagram::width
int width
Definition repodlgs.h:156
research_diagram::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:690
research_diagram::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:841
research_diagram::research_diagram
research_diagram(QWidget *parent=nullptr)
Definition repodlgs.cpp:553
research_diagram::tooltip_pos
QPoint tooltip_pos
Definition repodlgs.h:159
units_reports
Definition repodlgs.h:82
units_reports::m_instance
static units_reports * m_instance
Definition repodlgs.h:92
units_reports::clear_layout
void clear_layout()
Definition repodlgs.cpp:519
units_reports::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:412
units_reports::drop
static void drop()
Definition repodlgs.cpp:371
units_reports::units_reports
units_reports()
Definition repodlgs.cpp:327
units_reports::cw
close_widget * cw
Definition repodlgs.h:87
units_reports::add_item
void add_item(unittype_item *item)
Definition repodlgs.cpp:351
units_reports::instance
static units_reports * instance()
Definition repodlgs.cpp:359
units_reports::update_menu
virtual void update_menu()
Definition repodlgs.cpp:382
units_reports::update_units
void update_units(bool show=false)
Definition repodlgs.cpp:420
units_reports::layout
QHBoxLayout * layout
Definition repodlgs.h:103
units_reports::unittype_list
QList< unittype_item * > unittype_list
Definition repodlgs.h:104
units_reports::scroll_layout
QHBoxLayout * scroll_layout
Definition repodlgs.h:89
units_reports::scroll_widget
QWidget scroll_widget
Definition repodlgs.h:91
units_reports::scroll
QScrollArea * scroll
Definition repodlgs.h:90
units_reports::init_layout
void init_layout()
Definition repodlgs.cpp:391
units_reports::~units_reports
~units_reports()
Definition repodlgs.cpp:341
unittype_item
Definition repodlgs.h:45
unittype_item::label_pix
QLabel label_pix
Definition repodlgs.h:51
unittype_item::unit_scroll
int unit_scroll
Definition repodlgs.h:50
unittype_item::label_info_active
QLabel label_info_active
Definition repodlgs.h:59
unittype_item::leaveEvent
void leaveEvent(QEvent *event)
Definition repodlgs.cpp:269
unittype_item::unittype_item
unittype_item(QWidget *parent, unit_type *ut)
Definition repodlgs.cpp:97
unittype_item::gold_upkeep
QLabel gold_upkeep
Definition repodlgs.h:58
unittype_item::label_info_inbuild
QLabel label_info_inbuild
Definition repodlgs.h:60
unittype_item::shield_upkeep
QLabel shield_upkeep
Definition repodlgs.h:62
unittype_item::~unittype_item
~unittype_item()
Definition repodlgs.cpp:183
unittype_item::init_img
void init_img()
Definition repodlgs.cpp:190
unittype_item::upgrade_units
void upgrade_units()
Definition repodlgs.cpp:202
unittype_item::enterEvent
void enterEvent(QEnterEvent *event)
Definition repodlgs.cpp:240
unittype_item::entered
bool entered
Definition repodlgs.h:49
unittype_item::food_upkeep
QLabel food_upkeep
Definition repodlgs.h:57
unittype_item::label_info_unit
QLabel label_info_unit
Definition repodlgs.h:61
unittype_item::utype
unit_type * utype
Definition repodlgs.h:66
unittype_item::upgrade_button
QPushButton upgrade_button
Definition repodlgs.h:63
unittype_item::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:252
unittype_item::wheelEvent
void wheelEvent(QWheelEvent *event)
Definition repodlgs.cpp:278
client_is_global_observer
bool client_is_global_observer(void)
Definition client_main.c:1345
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1083
client
struct civclient client
Definition client_main.c:150
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1264
client_has_player
bool client_has_player(void)
Definition client_main.c:1364
client_main.h
client_player
#define client_player()
Definition client_main.h:106
cid_encode_building
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:504
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:525
cid_encode_unit
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
cid
int cid
Definition climisc.h:31
incite_cost
char * incite_cost
Definition comments.c:74
unit_focus_set_and_select
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:620
control.h
can_unit_do_activity_client
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
punit
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
id
int int id
Definition editgui_g.h:28
event
enum event_type event
Definition events.c:81
fc_client.h
Tech_type_id
int Tech_type_id
Definition fc_types.h:381
Impr_type_id
int Impr_type_id
Definition fc_types.h:380
Unit_type_id
int Unit_type_id
Definition fc_types.h:386
O_SHIELD
@ O_SHIELD
Definition fc_types.h:101
O_FOOD
@ O_FOOD
Definition fc_types.h:101
O_GOLD
@ O_GOLD
Definition fc_types.h:101
O_LAST
@ O_LAST
Definition fc_types.h:101
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
game
struct civ_game game
Definition game.c:62
government_name_translation
const char * government_name_translation(const struct government *pgovern)
Definition government.c:143
government.h
governments_iterate
#define governments_iterate(NAME_pgov)
Definition government.h:120
governments_iterate_end
#define governments_iterate_end
Definition government.h:123
get_text_size
void get_text_size(int *width, int *height, enum client_font font, const char *text)
Definition canvas.c:341
canvas_free
void canvas_free(struct canvas *store)
Definition canvas.c:44
pos
static struct tile * pos
Definition finddlg.c:53
popup_help_dialog_typed
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
title
const char * title
Definition repodlgs.c:1314
type
GType type
Definition repodlgs.c:1313
mevent_gpos
#define mevent_gpos(__ev__)
Definition gui_main.h:23
comp_less_than
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Definition repodlgs.cpp:545
show
#define show(id)
Definition widget.h:235
hide
#define hide(id)
Definition widget.h:238
citydlg.h
cityrep.h
gui_main.h
repodlgs.h
sprite.h
helptext_government
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Definition helpdata.c:4304
helptext_advance
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3263
helptext_building
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1381
helptext_unit
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype)
Definition helpdata.c:1865
helpdata.h
HELP_IMPROVEMENT
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
HELP_UNIT
@ HELP_UNIT
Definition helpdlg_g.h:20
HELP_GOVERNMENT
@ HELP_GOVERNMENT
Definition helpdlg_g.h:22
HELP_WONDER
@ HELP_WONDER
Definition helpdlg_g.h:21
HELP_TECH
@ HELP_TECH
Definition helpdlg_g.h:21
hudwidget.h
valid_improvement
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
Definition improvement.c:211
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:194
can_sell_building
bool can_sell_building(const struct impr_type *pimprove)
Definition improvement.c:1091
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:184
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:772
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:205
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:199
B_LAST
#define B_LAST
Definition improvement.h:42
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
LOG_VERBOSE
@ LOG_VERBOSE
Definition log.h:33
log_error
#define log_error(message,...)
Definition log.h:103
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
gui
static mpgui * gui
Definition mpgui_qt.cpp:52
fonts::default_font
const char *const default_font
Definition fonts.h:27
nation_of_player
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
gui_options
struct client_options gui_options
Definition options.c:71
options.h
dsend_packet_player_tech_goal
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
Definition packets_gen.c:28064
dsend_packet_player_research
int dsend_packet_player_research(struct connection *pc, int tech)
Definition packets_gen.c:27877
dsend_packet_unit_type_upgrade
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
Definition packets_gen.c:32663
science_dialog_text
const char * science_dialog_text(void)
Definition text.c:754
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:849
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:895
players_iterate_end
#define players_iterate_end
Definition player.h:539
players_iterate
#define players_iterate(_pplayer)
Definition player.h:534
qtg_real_economy_report_dialog_update
void qtg_real_economy_report_dialog_update(void *unused)
Definition repodlgs.cpp:1687
get_tooltip_improvement
QString get_tooltip_improvement(impr_type *building, struct city *pcity, bool ext)
split_text
QString split_text(QString text, bool cut)
Definition optiondlg.cpp:62
qtg_science_report_dialog_redraw
void qtg_science_report_dialog_redraw()
Definition repodlgs.cpp:1809
comp_less_than
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Definition repodlgs.cpp:545
popdown_economy_report
void popdown_economy_report()
Definition repodlgs.cpp:1828
economy_report_dialog_popup
void economy_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1707
qtg_real_units_report_dialog_update
void qtg_real_units_report_dialog_update(void *unused)
Definition repodlgs.cpp:1734
qtg_endgame_report_dialog_player
void qtg_endgame_report_dialog_player(const struct packet_endgame_player *packet)
Definition repodlgs.cpp:1791
popdown_science_report
void popdown_science_report()
Definition repodlgs.cpp:1846
units_report_dialog_popup
void units_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1744
qtg_real_science_report_dialog_update
void qtg_real_science_report_dialog_update(void *unused)
Definition repodlgs.cpp:1159
popdown_endgame_report
void popdown_endgame_report()
Definition repodlgs.cpp:1764
popdown_units_report
void popdown_units_report()
Definition repodlgs.cpp:1864
qtg_science_report_dialog_popup
void qtg_science_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1660
toggle_units_report
void toggle_units_report(bool x)
Definition repodlgs.cpp:1872
popup_endgame_report
void popup_endgame_report()
Definition repodlgs.cpp:1778
cut_helptext
QString cut_helptext(QString text)
Definition optiondlg.cpp:105
qtg_endgame_report_dialog_start
void qtg_endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.cpp:1753
get_tooltip_unit
QString get_tooltip_unit(struct unit_type *unit, bool ext)
get_economy_report_units_data
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
Definition repodlgs_common.c:105
get_economy_report_data
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
Definition repodlgs_common.c:46
sell_all_improvements
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
Definition repodlgs_common.c:160
disband_all_units
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
Definition repodlgs_common.c:200
repodlgs_common.h
draw_reqtree
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
get_reqtree_dimensions
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:878
get_tech_on_reqtree
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1185
destroy_reqtree
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:478
create_reqtree
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:847
reqtree.h
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:94
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:92
research_invention_reachable
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:128
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
research.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
MAX
#define MAX(x, y)
Definition shared.h:54
sidebar.h
size
size_t size
Definition specvec.h:72
x
struct sprite int x
Definition sprite_g.h:31
get_sprite_dimensions
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
canvas::map_pixmap
QPixmap map_pixmap
Definition canvas.h:25
city
Definition city.h:320
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::reqtree_show_icons
bool reqtree_show_icons
Definition options.h:222
color
Definition colors.h:21
counter
Definition counters.h:27
endgame_report
Definition repodlgs.c:1805
endgame_report::end_widget
QTableWidget * end_widget
Definition repodlgs.h:241
endgame_report::endgame_report
endgame_report(const struct packet_endgame_report *packet)
Definition repodlgs.cpp:1572
endgame_report::update_report
void update_report(const struct packet_endgame_player *packet)
Definition repodlgs.cpp:1620
endgame_report::players
int players
Definition repodlgs.h:251
endgame_report::~endgame_report
~endgame_report()
Definition repodlgs.cpp:1602
endgame_report::index
int index
Definition repodlgs.h:250
endgame_report::init
void init()
Definition repodlgs.cpp:1610
img
Definition mapimg.c:367
impr_type
Definition improvement.h:50
improvement_entry
Definition repodlgs_common.h:28
item
Definition climisc.h:80
packet_endgame_player
Definition packets_gen.h:95
packet_endgame_player::category_num
int category_num
Definition packets_gen.h:96
packet_endgame_player::player_id
int player_id
Definition packets_gen.h:97
packet_endgame_player::category_score
int category_score[32]
Definition packets_gen.h:99
packet_endgame_player::score
int score
Definition packets_gen.h:98
packet_endgame_report
Definition packets_gen.h:89
packet_endgame_report::category_name
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:91
packet_endgame_report::category_num
int category_num
Definition packets_gen.h:90
packet_ruleset_control::num_tech_types
int num_tech_types
Definition packets_gen.h:1462
player
Definition player.h:249
qlist_item
Definition repodlgs.h:113
reqtree
Definition repodlgs.cpp:85
reqtree::num_nodes
int num_nodes
Definition repodlgs.cpp:86
reqtree::nodes
struct tree_node ** nodes
Definition repodlgs.cpp:87
reqtree::layer_size
int * layer_size
Definition repodlgs.cpp:89
reqtree::diagram_height
int diagram_height
Definition repodlgs.cpp:91
reqtree::diagram_width
int diagram_width
Definition repodlgs.cpp:91
reqtree::layers
struct tree_node *** layers
Definition repodlgs.cpp:90
reqtree::num_layers
int num_layers
Definition repodlgs.cpp:88
research::research_invention::state
enum tech_state state
Definition research.h:71
research::research_invention::num_required_techs
int num_required_techs
Definition research.h:78
research
Definition research.h:39
research::researching
Tech_type_id researching
Definition research.h:52
research::tech_goal
Tech_type_id tech_goal
Definition research.h:83
research::client
struct research::@76::@78 client
research::inventions
struct research::research_invention inventions[A_ARRAY_SIZE]
research::techs_researched
int techs_researched
Definition research.h:42
research::researching_cost
int researching_cost
Definition research.h:96
research::bulbs_researched
int bulbs_researched
Definition research.h:53
science_report
Definition repodlgs.c:69
science_report::sci_layout
QGridLayout * sci_layout
Definition repodlgs.h:175
science_report::progress_label
QLabel * progress_label
Definition repodlgs.h:178
science_report::progress_bar
GtkProgressBar * progress_bar
Definition repodlgs.c:75
science_report::~science_report
~science_report()
Definition repodlgs.cpp:918
science_report::index
int index
Definition repodlgs.h:194
science_report::init
void init()
Definition repodlgs.cpp:935
science_report::progress
progress_bar * progress
Definition repodlgs.h:176
science_report::science_report
science_report()
Definition repodlgs.cpp:866
science_report::scroll
QScrollArea * scroll
Definition repodlgs.h:182
science_report::goal_combo
QComboBox * goal_combo
Definition repodlgs.h:173
science_report::curr_list
QList< qlist_item > * curr_list
Definition repodlgs.h:179
science_report::info_label
QLabel * info_label
Definition repodlgs.h:177
science_report::res_diag
research_diagram * res_diag
Definition repodlgs.h:181
science_report::goal_list
QList< qlist_item > * goal_list
Definition repodlgs.h:180
science_report::update_report
void update_report()
Definition repodlgs.cpp:966
science_report::redraw
void redraw()
Definition repodlgs.cpp:946
science_report::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:1119
science_report::reset_tree
void reset_tree()
Definition repodlgs.cpp:954
science_report::current_tech_changed
void current_tech_changed(int index)
Definition repodlgs.cpp:1127
science_report::goal_tech_changed
void goal_tech_changed(int index)
Definition repodlgs.cpp:1143
science_report::researching_combo
QComboBox * researching_combo
Definition repodlgs.h:174
sprite
Definition sprite.h:22
sprite::pm
QPixmap * pm
Definition sprite.h:25
tileset
Definition tilespec.c:481
tree_node
Definition repodlgs.cpp:70
tree_node::tech
Tech_type_id tech
Definition repodlgs.cpp:72
tree_node::nprovide
int nprovide
Definition repodlgs.cpp:75
tree_node::number
int number
Definition repodlgs.cpp:79
tree_node::provide
struct tree_node ** provide
Definition repodlgs.cpp:76
tree_node::node_width
int node_width
Definition repodlgs.cpp:78
tree_node::node_y
int node_y
Definition repodlgs.cpp:78
tree_node::layer
int layer
Definition repodlgs.cpp:77
tree_node::node_x
int node_x
Definition repodlgs.cpp:78
tree_node::order
int order
Definition repodlgs.cpp:77
tree_node::is_dummy
bool is_dummy
Definition repodlgs.cpp:71
tree_node::node_height
int node_height
Definition repodlgs.cpp:78
tree_node::nrequire
int nrequire
Definition repodlgs.cpp:73
tree_node::require
struct tree_node ** require
Definition repodlgs.cpp:74
unit_entry
Definition repodlgs_common.h:34
unit_type
Definition unittype.h:507
unit
Definition unit.h:140
unit::upkeep
int upkeep[O_LAST]
Definition unit.h:150
unit::activity
enum unit_activity activity
Definition unit.h:159
unit::homecity
int homecity
Definition unit.h:148
unit::utype
const struct unit_type * utype
Definition unit.h:141
universal
Definition fc_types.h:908
universal::kind
enum universals_n kind
Definition fc_types.h:910
universal::value
universals_u value
Definition fc_types.h:909
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
advance_by_number
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
is_future_tech
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:300
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
advance_index_iterate_max
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:253
advance_index_iterate_max_end
#define advance_index_iterate_max_end
Definition tech.h:259
advance_count
static Tech_type_id advance_count(void)
Definition tech.h:170
A_FIRST
#define A_FIRST
Definition tech.h:44
A_UNSET
#define A_UNSET
Definition tech.h:48
get_science_target_text
const char * get_science_target_text(double *percent)
Definition text.c:833
get_science_goal_text
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:879
text.h
get_government_sprite
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6811
get_building_sprite
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6801
get_tileset
struct tileset * get_tileset(void)
Definition tilespec.c:692
tiles_lookup_sprite_tag_alt
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:3652
get_tax_sprite
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6897
get_unittype_sprite
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6823
get_nation_flag_sprite
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6774
get_tech_sprite
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6792
tilespec.h
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:728
universals_u::building
const struct impr_type * building
Definition fc_types.h:721
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
is_tech_req_for_utype
bool is_tech_req_for_utype(const struct unit_type *ptype, struct advance *padv)
Definition unittype.c:2710
can_upgrade_unittype
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
utype_count
Unit_type_id utype_count(void)
Definition unittype.c:80
utype_by_number
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
unit_upgrade_price
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:859
U_LAST
#define U_LAST
Definition unittype.h:40
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:866