Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-qt/repodlgs.cpp Source File

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);
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", NULL, "", "", 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", NULL, "", "", 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 = NULL;
556 req = NULL;
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 != NULL) {
705 destroy_reqtree(req);
706 }
707 if (pcanvas != NULL) {
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
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>"
785 + QString(advance_name_translation(
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);
792 tt_text = cut_helptext(tt_text);
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);
797 tt_text = cut_helptext(tt_text);
798 } else if (rttp->tgov != nullptr) {
799 helptext_government(buffer, sizeof(buffer), client.conn.playing,
800 buf2, rttp->tgov);
801 tt_text = QString(buffer);
802 tt_text = cut_helptext(tt_text);
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;
813 tooltip_pos = mevent_gpos(event);
814 if (!QToolTip::isVisible() && !timer_active) {
815 timer_active = true;
816 QTimer::singleShot(500, this, SLOT(show_tooltip()));
817 }
818 }
819 }
820}
821
822/************************************************************************/
825 void research_diagram::show_tooltip()
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/************************************************************************/
840 void research_diagram::paintEvent(QPaintEvent *event)
841{
842 QPainter painter;
843
844 painter.begin(this);
845 painter.drawPixmap(0, 0, width, height, pcanvas->map_pixmap);
846 painter.end();
847}
848
849/************************************************************************/
852 QSize research_diagram::size()
853{
854 QSize s;
855
856 s.setWidth(width);;
857 s.setHeight(height);
858 return s;
859}
860
861/************************************************************************/
864science_report::science_report(): QWidget()
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();
875 researching_combo = new QComboBox();
876 sci_layout = new QGridLayout();
877 res_diag = new research_diagram();
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)),
903 SLOT(current_tech_changed(int)));
904
905 QObject::connect(goal_combo, SIGNAL(currentIndexChanged(int)),
906 SLOT(goal_tech_changed(int)));
907
908 setLayout(sci_layout);
909}
910
911/************************************************************************/
916science_report::~science_report()
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/************************************************************************/
933 void science_report::init()
934{
935 gui()->gimme_place(this, "SCI");
936 index = gui()->add_game_tab(this);
937 gui()->game_tab_widget->setCurrentIndex(index);
938 update_report();
939}
940
941/************************************************************************/
944 void science_report::redraw()
945{
946 update();
947}
948
949/************************************************************************/
952 void science_report::reset_tree()
953{
954 QSize size;
955 res_diag->reset();
956 size = res_diag->size();
957 res_diag->setMinimumSize(size);
958 update();
959}
960
961/************************************************************************/
964 void science_report::update_report()
965{
966 struct research *research = research_get(client_player());
967 const char *text;
968 int total;
969 int done = research->bulbs_researched;
970 QVariant qvar, qres;
971 double not_used;
972 QString str;
973 qlist_item item;
974 struct sprite *sp;
975 Tech_type_id ac;
976
977 fc_assert_ret(NULL != research);
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) {
988 total = research->client.researching_cost;
989 } else {
990 total = -1;
991 }
992
993 curr_list = new QList<qlist_item>;
994 goal_list = new QList<qlist_item>;
995 progress_label->setText(science_dialog_text());
996 progress_label->setAlignment(Qt::AlignHCenter);
997 info_label->setAlignment(Qt::AlignHCenter);
998 info_label->setText(get_science_goal_text(research->tech_goal));
999 text = get_science_target_text(&not_used);
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();
1015 advance_index_iterate_max(A_FIRST, i, ac) {
1016 if (TECH_PREREQS_KNOWN == research->inventions[i].state) {
1017 item.tech_str
1018 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1019 item.id = i;
1020 curr_list->append(item);
1021 }
1022 } advance_index_iterate_max_end;
1023
1024 // Collect all techs which are reachable in next 10 steps.
1025 advance_index_iterate_max(A_FIRST, i, ac) {
1026 if (research_invention_reachable(research, i)
1027 && TECH_KNOWN != research->inventions[i].state
1028 && (i == research->tech_goal
1029 || 10 >= research->inventions[i].num_required_techs)) {
1030 item.tech_str
1031 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1032 item.id = i;
1033 goal_list->append(item);
1034 }
1035 } advance_index_iterate_max_end;
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
1070 qres = research->researching;
1071 if (qres == A_UNSET || is_future_tech(research->researching)) {
1072 researching_combo->insertItem(0, research_advance_name_translation(
1073 research, research->researching ),
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
1086 qres = research->tech_goal;
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 }
1111 update_reqtree();
1112}
1113
1114/************************************************************************/
1117 void science_report::update_reqtree()
1118{
1119 res_diag->update_reqtree();
1120}
1121
1122/************************************************************************/
1125 void science_report::current_tech_changed(int changed_index)
1126{
1127 QVariant qvar;
1128
1129 qvar = researching_combo->itemData(changed_index);
1130
1131 if (researching_combo->hasFocus()) {
1132 if (can_client_issue_orders()) {
1133 dsend_packet_player_research(&client.conn, qvar.toInt());
1134 }
1135 }
1136}
1137
1138/************************************************************************/
1141 void science_report::goal_tech_changed(int changed_index)
1142{
1143 QVariant qvar;
1144
1145 qvar = goal_combo->itemData(changed_index);
1146
1147 if (goal_combo->hasFocus()) {
1148 if (can_client_issue_orders()) {
1149 dsend_packet_player_tech_goal(&client.conn, qvar.toInt());
1150 }
1151 }
1152}
1153
1154/************************************************************************/
1157 void real_science_report_dialog_update(void *unused)
1158{
1159 int i;
1160 int percent;
1161 science_report *sci_rep;
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) {
1173 str = research_advance_name_translation(research, research->researching);
1174 percent = 100 *research->bulbs_researched / research->client.researching_cost;
1175 str = str + "\n (" + QString::number(percent) + "%)";
1176 }
1177 if (research->researching == A_UNSET && research->tech_goal == A_UNSET
1178 && research->techs_researched < game.control.num_tech_types) {
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);
1201 sci_rep->update_report();
1202 }
1203}
1204
1205/************************************************************************/
1208eco_report::eco_report(): QWidget()
1209{
1210 QHeaderView *header;
1211 QGridLayout *eco_layout = new QGridLayout;
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;
1217 QStringList slist;
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(),
1249 SIGNAL(selectionChanged(const QItemSelection &,
1250 const QItemSelection &)),
1251 SLOT(selection_changed(const QItemSelection &,
1252 const QItemSelection &)));
1253 setLayout(eco_layout);
1254}
1255
1256/************************************************************************/
1259eco_report::~eco_report()
1260{
1261 gui()->remove_repo_dlg("ECO");
1262}
1263
1264/************************************************************************/
1267 void eco_report::init()
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/************************************************************************/
1278 void eco_report::update_report()
1279{
1280 struct improvement_entry building_entries[B_LAST];
1281 struct unit_entry unit_entries[U_LAST];
1282 int entries_used, building_total, unit_total, tax, i, j;
1283 char buf[256];
1284 QTableWidgetItem *item;
1285 QFont f = QApplication::font();
1286 int h;
1287 QFontMetrics fm(f);
1288 h = fm.height() + 6;
1289 QPixmap *pix;
1290 QPixmap pix_scaled;
1291 struct sprite *sprite;
1292
1293 eco_widget->setRowCount(0);
1294 eco_widget->clearContents();
1295 get_economy_report_data(building_entries, &entries_used,
1296 &building_total, &tax);
1297 for (i = 0; i < entries_used; i++) {
1298 struct improvement_entry *pentry = building_entries + 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;
1343 get_economy_report_units_data(unit_entries, &entries_used, &unit_total);
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;
1350 sprite = get_unittype_sprite(tileset, putype,
1351 ACTIVITY_LAST, direction8_invalid());
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);
1371 item->setText(utype_name_translation(putype));
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/************************************************************************/
1399 void eco_report::selection_changed(const QItemSelection &sl,
1400 const QItemSelection &ds)
1401{
1402 QTableWidgetItem *itm;
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/************************************************************************/
1447 void eco_report::disband_units()
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);
1456 fc_snprintf(title, ARRAY_SIZE(title),
1457 _("Do you really wish to disband every %s (%d total)?"),
1458 utype_name_translation(utype_by_number(utype)), counter);
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/************************************************************************/
1484 void eco_report::sell_buildings()
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;
1490 Impr_type_id impr_id;
1491
1492 selected = cid_decode(uid);
1493 pimpr = selected.value.building;
1494 impr_id = improvement_number(pimpr);
1495
1496 fc_snprintf(title, ARRAY_SIZE(title),
1497 _("Do you really wish to sell "
1498 "every %s (%d total)?"),
1499 improvement_name_translation(pimpr), counter);
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/************************************************************************/
1527 void eco_report::sell_redundant()
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;
1533 Impr_type_id impr_id;
1534
1535 selected = cid_decode(uid);
1536 pimpr = selected.value.building;
1537 impr_id = improvement_number(pimpr);
1538
1539 fc_snprintf(title, ARRAY_SIZE(title),
1540 _("Do you really wish to sell "
1541 "every redundant %s (%d total)?"),
1542 improvement_name_translation(pimpr), counter);
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/************************************************************************/
1570endgame_report::endgame_report(const struct packet_endgame_report *packet): QWidget()
1571{
1572 QGridLayout *end_layout = new QGridLayout;
1573 end_widget = new QTableWidget;
1574 unsigned int i;
1575 const size_t col_num = packet->category_num + 3;
1576 QStringList slist;
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);
1594 setLayout(end_layout);
1595}
1596
1597/************************************************************************/
1600endgame_report::~endgame_report()
1601{
1602 gui()->remove_repo_dlg("END");
1603}
1604
1605/************************************************************************/
1608 void endgame_report::init()
1609{
1610 gui()->gimme_place(this, "END");
1611 index = gui()->add_game_tab(this);
1612 gui()->game_tab_widget->setCurrentIndex(index);
1613}
1614
1615/************************************************************************/
1618 void endgame_report::update_report(const struct packet_endgame_player *packet)
1619{
1620 QTableWidgetItem *item;
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:
1634 pix = get_nation_flag_sprite(tileset, nation_of_player(pplayer))->pm;
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/************************************************************************/
1658 void science_report_dialog_popup(bool raise)
1659{
1660 science_report *sci_rep;
1661 int i;
1662 QWidget *w;
1663
1664 if (client_is_global_observer()) {
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/************************************************************************/
1685 void real_economy_report_dialog_update(void *unused)
1686{
1687 int i;
1688 eco_report *eco_rep;
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);
1696 eco_rep->update_report();
1697 }
1698 }
1699 gui()->update_sidebar_tooltips();
1700}
1701
1702/************************************************************************/
1705 void economy_report_dialog_popup(bool raise)
1706{
1707 int i;
1708 eco_report *eco_rep;
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);
1724 eco_rep->update_report();
1725 gui()->game_tab_widget->setCurrentWidget(eco_rep);
1726 }
1727}
1728
1729/************************************************************************/
1732 void real_units_report_dialog_update(void *unused)
1733{
1734 if (units_reports::instance()->isVisible()) {
1735 units_reports::instance()->update_units();
1736 }
1737}
1738
1739/************************************************************************/
1742 void units_report_dialog_popup(bool raise)
1743{
1744 gui()->game_tab_widget->setCurrentIndex(0);
1745 units_reports::instance()->update_units(true);
1746}
1747
1748/************************************************************************/
1751 void endgame_report_dialog_start(const struct packet_endgame_report *packet)
1752{
1753 endgame_report *end_rep;
1754
1755 end_rep = new endgame_report(packet);
1756 end_rep->init();
1757}
1758
1759/************************************************************************/
1762 void popdown_endgame_report()
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/************************************************************************/
1776 void popup_endgame_report()
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/************************************************************************/
1789 void endgame_report_dialog_player(const struct packet_endgame_player *packet)
1790{
1791 int i;
1792 endgame_report *end_rep;
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/************************************************************************/
1807 void science_report_dialog_redraw(void)
1808{
1809 int i;
1810 science_report *sci_rep;
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/************************************************************************/
1826 void popdown_economy_report()
1827{
1828 int i;
1829 eco_report *eco_rep;
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/************************************************************************/
1844 void popdown_science_report()
1845{
1846 int i;
1847 science_report *sci_rep;
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/************************************************************************/
1862 void popdown_units_report()
1863{
1864 units_reports::instance()->drop();
1865}
1866
1867/************************************************************************/
1870 void toggle_units_report(bool x)
1871 {
1872 Q_UNUSED(x);
1873 if (units_reports::instance()->isVisible()
1874 && gui()->game_tab_widget->currentIndex() == 0) {
1875 units_reports::instance()->drop();
1876 } else {
1877 units_report_dialog_popup(true);
1878 }
1879}
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:3879
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:3936
close_widget
Definition mapview.h:183
close_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:502
eco_report
Definition repodlgs.h:209
eco_report::eco_report
eco_report()
Definition repodlgs.cpp:1208
eco_report::sell_button
QPushButton * sell_button
Definition repodlgs.h:212
eco_report::selection_changed
void selection_changed(const QItemSelection &sl, const QItemSelection &ds)
Definition repodlgs.cpp:1399
eco_report::sell_redun_button
QPushButton * sell_redun_button
Definition repodlgs.h:213
eco_report::disband_button
QPushButton * disband_button
Definition repodlgs.h:211
eco_report::disband_units
void disband_units()
Definition repodlgs.cpp:1447
eco_report::eco_widget
QTableWidget * eco_widget
Definition repodlgs.h:214
eco_report::index
int index
Definition repodlgs.h:224
eco_report::max_row
int max_row
Definition repodlgs.h:226
eco_report::sell_buildings
void sell_buildings()
Definition repodlgs.cpp:1484
eco_report::init
void init()
Definition repodlgs.cpp:1267
eco_report::uid
cid uid
Definition repodlgs.h:227
eco_report::~eco_report
~eco_report()
Definition repodlgs.cpp:1259
eco_report::sell_redundant
void sell_redundant()
Definition repodlgs.cpp:1527
eco_report::curr_row
int curr_row
Definition repodlgs.h:225
eco_report::update_report
void update_report()
Definition repodlgs.cpp:1278
eco_report::eco_label
QLabel * eco_label
Definition repodlgs.h:215
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:126
req_tooltip_help::tech_id
Tech_type_id tech_id
Definition repodlgs.h:130
req_tooltip_help::tunit
struct unit_type * tunit
Definition repodlgs.h:131
req_tooltip_help::timpr
struct impr_type * timpr
Definition repodlgs.h:132
req_tooltip_help::req_tooltip_help
req_tooltip_help()
Definition repodlgs.cpp:575
research_diagram
Definition repodlgs.h:140
research_diagram::show_tooltip
void show_tooltip()
Definition repodlgs.cpp:825
research_diagram::reset
void reset()
Definition repodlgs.cpp:701
research_diagram::pcanvas
struct canvas * pcanvas
Definition repodlgs.h:156
research_diagram::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition repodlgs.cpp:720
research_diagram::size
QSize size()
Definition repodlgs.cpp:852
research_diagram::timer_active
bool timer_active
Definition repodlgs.h:158
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:157
research_diagram::tooltip_text
QString tooltip_text
Definition repodlgs.h:163
research_diagram::tt_help
QList< req_tooltip_help * > tt_help
Definition repodlgs.h:161
research_diagram::tooltip_rect
QRect tooltip_rect
Definition repodlgs.h:164
research_diagram::height
int height
Definition repodlgs.h:160
research_diagram::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition repodlgs.cpp:767
research_diagram::width
int width
Definition repodlgs.h:159
research_diagram::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:690
research_diagram::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:840
research_diagram::research_diagram
research_diagram(QWidget *parent=nullptr)
Definition repodlgs.cpp:553
research_diagram::tooltip_pos
QPoint tooltip_pos
Definition repodlgs.h:162
units_reports
Definition repodlgs.h:85
units_reports::m_instance
static units_reports * m_instance
Definition repodlgs.h:95
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:90
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:106
units_reports::unittype_list
QList< unittype_item * > unittype_list
Definition repodlgs.h:107
units_reports::scroll_layout
QHBoxLayout * scroll_layout
Definition repodlgs.h:92
units_reports::scroll_widget
QWidget scroll_widget
Definition repodlgs.h:94
units_reports::scroll
QScrollArea * scroll
Definition repodlgs.h:93
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:48
unittype_item::label_pix
QLabel label_pix
Definition repodlgs.h:54
unittype_item::unit_scroll
int unit_scroll
Definition repodlgs.h:53
unittype_item::label_info_active
QLabel label_info_active
Definition repodlgs.h:62
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:61
unittype_item::label_info_inbuild
QLabel label_info_inbuild
Definition repodlgs.h:63
unittype_item::shield_upkeep
QLabel shield_upkeep
Definition repodlgs.h:65
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:52
unittype_item::food_upkeep
QLabel food_upkeep
Definition repodlgs.h:60
unittype_item::label_info_unit
QLabel label_info_unit
Definition repodlgs.h:64
unittype_item::utype
unit_type * utype
Definition repodlgs.h:69
unittype_item::upgrade_button
QPushButton upgrade_button
Definition repodlgs.h:66
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:503
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:524
cid_encode_unit
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:491
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:380
Impr_type_id
int Impr_type_id
Definition fc_types.h:379
Unit_type_id
int Unit_type_id
Definition fc_types.h:385
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:4309
helptext_advance
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3268
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:27308
dsend_packet_player_research
int dsend_packet_player_research(struct connection *pc, int tech)
Definition packets_gen.c:27133
dsend_packet_unit_type_upgrade
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
Definition packets_gen.c:31811
science_dialog_text
const char * science_dialog_text(void)
Definition text.c:741
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:537
players_iterate
#define players_iterate(_pplayer)
Definition player.h:532
science_report_dialog_popup
void science_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1658
get_tooltip_improvement
QString get_tooltip_improvement(impr_type *building, struct city *pcity, bool ext)
endgame_report_dialog_start
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.cpp:1751
split_text
QString split_text(QString text, bool cut)
Definition optiondlg.cpp:62
real_units_report_dialog_update
void real_units_report_dialog_update(void *unused)
Definition repodlgs.cpp:1732
real_economy_report_dialog_update
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.cpp:1685
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:1826
economy_report_dialog_popup
void economy_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1705
popdown_science_report
void popdown_science_report()
Definition repodlgs.cpp:1844
units_report_dialog_popup
void units_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1742
popdown_endgame_report
void popdown_endgame_report()
Definition repodlgs.cpp:1762
science_report_dialog_redraw
void science_report_dialog_redraw(void)
Definition repodlgs.cpp:1807
popdown_units_report
void popdown_units_report()
Definition repodlgs.cpp:1862
toggle_units_report
void toggle_units_report(bool x)
Definition repodlgs.cpp:1870
popup_endgame_report
void popup_endgame_report()
Definition repodlgs.cpp:1776
cut_helptext
QString cut_helptext(QString text)
Definition optiondlg.cpp:105
get_tooltip_unit
QString get_tooltip_unit(struct unit_type *unit, bool ext)
real_science_report_dialog_update
void real_science_report_dialog_update(void *unused)
Definition repodlgs.cpp:1157
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
endgame_report_dialog_player
endgame_report_dialog_player
Definition repodlgs_g.h:33
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:1036
get_reqtree_dimensions
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:870
get_tech_on_reqtree
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1176
destroy_reqtree
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:473
create_reqtree
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:839
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:221
color
Definition colors.h:21
connection::playing
struct player * playing
Definition connection.h:151
counter
Definition counters.h:27
endgame_report
Definition repodlgs.c:1805
endgame_report::end_widget
QTableWidget * end_widget
Definition repodlgs.h:244
endgame_report::endgame_report
endgame_report(const struct packet_endgame_report *packet)
Definition repodlgs.cpp:1570
endgame_report::update_report
void update_report(const struct packet_endgame_player *packet)
Definition repodlgs.cpp:1618
endgame_report::players
int players
Definition repodlgs.h:254
endgame_report::~endgame_report
~endgame_report()
Definition repodlgs.cpp:1600
endgame_report::index
int index
Definition repodlgs.h:253
endgame_report::init
void init()
Definition repodlgs.cpp:1608
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:91
packet_endgame_player::category_num
int category_num
Definition packets_gen.h:92
packet_endgame_player::player_id
int player_id
Definition packets_gen.h:93
packet_endgame_player::category_score
int category_score[32]
Definition packets_gen.h:95
packet_endgame_player::score
int score
Definition packets_gen.h:94
packet_endgame_report
Definition packets_gen.h:85
packet_endgame_report::category_name
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:87
packet_endgame_report::category_num
int category_num
Definition packets_gen.h:86
packet_ruleset_control::num_tech_types
int num_tech_types
Definition packets_gen.h:1453
player
Definition player.h:247
qlist_item
Definition repodlgs.h:116
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:178
science_report::progress_label
QLabel * progress_label
Definition repodlgs.h:181
science_report::progress_bar
GtkProgressBar * progress_bar
Definition repodlgs.c:75
science_report::~science_report
~science_report()
Definition repodlgs.cpp:916
science_report::index
int index
Definition repodlgs.h:197
science_report::init
void init()
Definition repodlgs.cpp:933
science_report::progress
progress_bar * progress
Definition repodlgs.h:179
science_report::science_report
science_report()
Definition repodlgs.cpp:864
science_report::scroll
QScrollArea * scroll
Definition repodlgs.h:185
science_report::goal_combo
QComboBox * goal_combo
Definition repodlgs.h:176
science_report::curr_list
QList< qlist_item > * curr_list
Definition repodlgs.h:182
science_report::info_label
QLabel * info_label
Definition repodlgs.h:180
science_report::res_diag
research_diagram * res_diag
Definition repodlgs.h:184
science_report::goal_list
QList< qlist_item > * goal_list
Definition repodlgs.h:183
science_report::update_report
void update_report()
Definition repodlgs.cpp:964
science_report::redraw
void redraw()
Definition repodlgs.cpp:944
science_report::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:1117
science_report::reset_tree
void reset_tree()
Definition repodlgs.cpp:952
science_report::current_tech_changed
void current_tech_changed(int index)
Definition repodlgs.cpp:1125
science_report::goal_tech_changed
void goal_tech_changed(int index)
Definition repodlgs.cpp:1141
science_report::researching_combo
QComboBox * researching_combo
Definition repodlgs.h:177
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:500
unit
Definition unit.h:138
unit::upkeep
int upkeep[O_LAST]
Definition unit.h:148
unit::activity
enum unit_activity activity
Definition unit.h:157
unit::homecity
int homecity
Definition unit.h:146
unit::utype
const struct unit_type * utype
Definition unit.h:139
universal
Definition fc_types.h:901
universal::kind
enum universals_n kind
Definition fc_types.h:903
universal::value
universals_u value
Definition fc_types.h:902
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
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:290
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:252
advance_index_iterate_max_end
#define advance_index_iterate_max_end
Definition tech.h:258
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:820
get_science_goal_text
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
text.h
get_government_sprite
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6797
get_building_sprite
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6787
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:3643
get_tax_sprite
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6883
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:6809
get_nation_flag_sprite
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6760
get_tech_sprite
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6778
tilespec.h
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:724
universals_u::building
const struct impr_type * building
Definition fc_types.h:717
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:852
U_LAST
#define U_LAST
Definition unittype.h:40
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:859