Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/repodlgs.cpp Source File

Freeciv-3.1

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 "helpdata.h"
42#include "options.h"
43#include "repodlgs_common.h"
44#include "reqtree.h"
45#include "sprite.h"
46#include "text.h"
47#include "tilespec.h"
48
49// gui-qt
50#include "citydlg.h"
51#include "cityrep.h"
52#include "fc_client.h"
53#include "hudwidget.h"
54#include "sidebar.h"
55
56#include "repodlgs.h"
57
58extern QString split_text(QString text, bool cut);
59extern QString cut_helptext(QString text);
60 extern QString get_tooltip_improvement(impr_type *building,
61 struct city *pcity, bool ext);
62 extern QString get_tooltip_unit(struct unit_type *unit, bool ext);
63
64 units_reports* units_reports::m_instance = 0;
65
66/****************************************************************************
67 From reqtree.c used to get tooltips
68****************************************************************************/
69 struct tree_node {
70 bool is_dummy;
71 Tech_type_id tech;
72 int nrequire;
73 struct tree_node **require;
74 int nprovide;
75 struct tree_node **provide;
76 int order, layer;
77 int node_x, node_y, node_width, node_height;
78 int number;
79};
80
81/****************************************************************************
82 From reqtree.c used to get tooltips
83****************************************************************************/
84 struct reqtree {
85 int num_nodes;
86 struct tree_node **nodes;
87 int num_layers;
88 int *layer_size;
89 struct tree_node ***layers;
90 int diagram_width, diagram_height;
91};
92
93/************************************************************************/
96unittype_item::unittype_item(QWidget *parent,
97 struct unit_type *ut): QFrame(parent)
98{
99 int isize;
100 QFont f;
101 QFontMetrics *fm;
102 QHBoxLayout *hbox;
103 QHBoxLayout *hbox_top;
104 QHBoxLayout *hbox_upkeep;
105 QImage cropped_img;
106 QImage img;
107 QLabel *lab;
108 QPixmap pix;
109 QRect crop;
110 QSizePolicy size_fixed_policy(QSizePolicy::Maximum, QSizePolicy::Maximum,
111 QSizePolicy::Slider);
112 QSpacerItem *spacer;
113 QVBoxLayout *vbox;
114 QVBoxLayout *vbox_main;
115 struct sprite *spr;
116
117 setParent(parent);
118 utype = ut;
119 init_img();
120 unit_scroll = 0;
121 setSizePolicy(size_fixed_policy);
122 f = *fc_font::instance()->get_font(fonts::default_font);
123 fm = new QFontMetrics(f);
124 isize = fm->height() * 2 / 3;
125 vbox_main = new QVBoxLayout();
126 hbox = new QHBoxLayout();
127 vbox = new QVBoxLayout();
128 hbox_top = new QHBoxLayout();
129 upgrade_button.setText("★");
130 upgrade_button.setVisible(false);
131 connect(&upgrade_button, &QAbstractButton::pressed, this, &unittype_item::upgrade_units);
132 hbox_top->addWidget(&upgrade_button, 0, Qt::AlignLeft);
133 label_info_unit.setTextFormat(Qt::PlainText);
134 hbox_top->addWidget(&label_info_unit);
135 vbox_main->addLayout(hbox_top);
136 vbox->addWidget(&label_info_active);
137 vbox->addWidget(&label_info_inbuild);
138 hbox->addWidget(&label_pix);
139 hbox->addLayout(vbox);
140 vbox_main->addLayout(hbox);
141 hbox_upkeep = new QHBoxLayout;
142 hbox_upkeep->addWidget(&shield_upkeep);
143 lab = new QLabel("");
144 spr = tiles_lookup_sprite_tag_alt(tileset, LOG_VERBOSE, "upkeep.shield",
145 "citybar.shields", "", "", false);
146 img = spr->pm->toImage();
147 crop = zealous_crop_rect(img);
148 cropped_img = img.copy(crop);
149 pix = QPixmap::fromImage(cropped_img);
150 lab->setPixmap(pix.scaledToHeight(isize));
151 hbox_upkeep->addWidget(lab);
152 spacer = new QSpacerItem(0, isize, QSizePolicy::Expanding,
153 QSizePolicy::Minimum);
154 hbox_upkeep->addSpacerItem(spacer);
155 hbox_upkeep->addWidget(&gold_upkeep);
156 spr = get_tax_sprite(tileset, O_GOLD);
157 lab = new QLabel("");
158 lab->setPixmap(spr->pm->scaledToHeight(isize));
159 hbox_upkeep->addWidget(lab);
160 spacer = new QSpacerItem(0, isize, QSizePolicy::Expanding,
161 QSizePolicy::Minimum);
162 hbox_upkeep->addSpacerItem(spacer);
163 hbox_upkeep->addWidget(&food_upkeep);
164 lab = new QLabel("");
165 spr = tiles_lookup_sprite_tag_alt(tileset, LOG_VERBOSE, "citybar.food",
166 "citybar.food", "", "", false);
167 img = spr->pm->toImage();
168 crop = zealous_crop_rect(img);
169 cropped_img = img.copy(crop);
170 pix = QPixmap::fromImage(cropped_img);
171 lab->setPixmap(pix.scaledToHeight(isize));
172 hbox_upkeep->addWidget(lab);
173 vbox_main->addLayout(hbox_upkeep);
174 setLayout(vbox_main);
175 entered = false;
176 delete fm;
177}
178
179/************************************************************************/
182unittype_item::~unittype_item()
183{
184
185}
186
187/************************************************************************/
190 void unittype_item::init_img()
191{
192 struct sprite *sp;
193
194 sp = get_unittype_sprite(get_tileset(), utype, direction8_invalid());
195 label_pix.setPixmap(*sp->pm);
196}
197
198/************************************************************************/
201 void unittype_item::upgrade_units()
202{
203 char buf[1024];
204 char buf2[2048];
205 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
206 int price;
207 QString s2;
208 const struct unit_type *upgrade;
209 const Unit_type_id type = utype_number(utype);
210
211 upgrade = can_upgrade_unittype(client_player(), utype);
212 price = unit_upgrade_price(client_player(), utype, upgrade);
213 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
214 "Treasury contains %d gold.",
215 client_player()->economic.gold),
216 client_player()->economic.gold);
217 fc_snprintf(buf2, ARRAY_SIZE(buf2),
218 PL_("Upgrade as many %s to %s as possible "
219 "for %d gold each?\n%s",
220 "Upgrade as many %s to %s as possible "
221 "for %d gold each?\n%s", price),
222 utype_name_translation(utype),
223 utype_name_translation(upgrade), price, buf);
224 s2 = QString(buf2);
225 ask->set_text_title(s2, _("Upgrade Obsolete Units"));
226 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
227 ask->setDefaultButton(QMessageBox::Cancel);
228 ask->setAttribute(Qt::WA_DeleteOnClose);
229 connect(ask, &hud_message_box::accepted, [=]() {
230 dsend_packet_unit_type_upgrade(&client.conn, type);
231 });
232 ask->show();
233}
234
235/************************************************************************/
238#ifndef FC_QT5_MODE
239 void unittype_item::enterEvent(QEnterEvent *event)
240#else // FC_QT5_MODE
241void unittype_item::enterEvent(QEvent *event)
242#endif // FC_QT5_MODE
243{
244 entered = true;
245 update();
246}
247
248/************************************************************************/
251 void unittype_item::paintEvent(QPaintEvent *event)
252{
253 QRect rfull;
254 QPainter p;
255
256 if (entered) {
257 rfull = QRect(1 , 1, width() - 2 , height() - 2);
258 p.begin(this);
259 p.setPen(QColor(palette().color(QPalette::Highlight)));
260 p.drawRect(rfull);
261 p.end();
262 }
263}
264
265/************************************************************************/
268 void unittype_item::leaveEvent(QEvent *event)
269{
270 entered = false;
271 update();
272}
273
274/************************************************************************/
277 void unittype_item::wheelEvent(QWheelEvent *event)
278{
279 int unit_count = 0;
280
281 unit_list_iterate(client_player()->units, punit) {
282 if (punit->utype != utype) {
283 continue;
284 }
285 if (ACTIVITY_IDLE == punit->activity
286 || ACTIVITY_SENTRY == punit->activity) {
287 if (can_unit_do_activity_client(punit, ACTIVITY_IDLE)) {
288 unit_count++;
289 }
290 }
291 } unit_list_iterate_end;
292
293 if (event->angleDelta().y() < 0) {
294 unit_scroll--;
295 } else {
296 unit_scroll++;
297 }
298 if (unit_scroll < 0) {
299 unit_scroll = unit_count;
300 } else if (unit_scroll > unit_count) {
301 unit_scroll = 0;
302 }
303
304 unit_count = 0;
305
306 unit_list_iterate(client_player()->units, punit) {
307 if (punit->utype != utype) {
308 continue;
309 }
310 if (ACTIVITY_IDLE == punit->activity
311 || ACTIVITY_SENTRY == punit->activity) {
312 if (can_unit_do_activity_client(punit, ACTIVITY_IDLE)) {
313 unit_count++;
314 if (unit_count == unit_scroll) {
315 unit_focus_set_and_select(punit);
316 }
317 }
318 }
319 } unit_list_iterate_end;
320 event->accept();
321}
322
323/************************************************************************/
326units_reports::units_reports() : fcwidget()
327{
328 layout = new QHBoxLayout;
329 scroll_layout = new QHBoxLayout(this);
330 init_layout();
331 setParent(gui()->mapview_wdg);
332 cw = new close_widget(this);
333 cw->setFixedSize(12, 12);
334 setVisible(false);
335}
336
337/************************************************************************/
340units_reports::~units_reports()
341{
342 qDeleteAll(unittype_list);
343 unittype_list.clear();
344 delete cw;
345}
346
347/************************************************************************/
350 void units_reports::add_item(unittype_item *item)
351{
352 unittype_list.append(item);
353}
354
355/************************************************************************/
358 units_reports *units_reports::instance()
359{
360 if (!m_instance)
361 m_instance = new units_reports;
362 return m_instance;
363}
364
365/************************************************************************/
368 void units_reports::drop()
369{
370 if (m_instance) {
371 delete m_instance;
372 m_instance = 0;
373 }
374}
375
376/************************************************************************/
379 void units_reports::update_menu()
380{
381 was_destroyed = true;
382 drop();
383}
384
385/************************************************************************/
388 void units_reports::init_layout()
389{
390 QSizePolicy size_fixed_policy(QSizePolicy::Maximum,
391 QSizePolicy::Maximum,
392 QSizePolicy::Slider);
393
394 scroll = new QScrollArea(this);
395 setSizePolicy(size_fixed_policy);
396 scroll->setWidgetResizable(true);
397 scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
398 scroll_widget.setLayout(layout);
399 scroll->setWidget(&scroll_widget);
400 scroll->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
401 scroll->setProperty("city_scroll", true);
402 scroll_layout->addWidget(scroll);
403 setLayout(scroll_layout);
404}
405
406/************************************************************************/
409 void units_reports::paintEvent(QPaintEvent *event)
410{
411 cw->put_to_corner();
412}
413
414/************************************************************************/
417 void units_reports::update_units(bool show)
418{
419 struct urd_info {
420 int active_count;
421 int building_count;
422 int upkeep[O_LAST];
423 };
424 bool upgradable;
425 int i, j;
426 int output;
427 int total_len = 0;
428 struct urd_info *info;
429 struct urd_info *unit_array = (struct urd_info *)fc_calloc(sizeof(struct urd_info), utype_count());
430 struct urd_info unit_totals;
431 Unit_type_id utype_id;
432 unittype_item *ui = nullptr;
433
434 clear_layout();
435 memset(&unit_totals, '\0', sizeof(unit_totals));
436 /* Count units. */
437 players_iterate(pplayer) {
438 if (client_has_player() && pplayer != client_player()) {
439 continue;
440 }
441 unit_list_iterate(pplayer->units, punit) {
442 info = unit_array + utype_index(unit_type_get(punit));
443 if (0 != punit->homecity) {
444 for (output = 0; output < O_LAST; output++) {
445 info->upkeep[output] += punit->upkeep[output];
446 }
447 }
448 info->active_count++;
449 } unit_list_iterate_end;
450 city_list_iterate(pplayer->cities, pcity) {
451 if (VUT_UTYPE == pcity->production.kind) {
452 int num_units;
453 info = unit_array + utype_index(pcity->production.value.utype);
454 /* Account for build slots in city */
455 (void) city_production_build_units(pcity, true, &num_units);
456 /* Unit is in progress even if it won't be done this turn */
457 num_units = MAX(num_units, 1);
458 info->building_count += num_units;
459 }
460 } city_list_iterate_end;
461 } players_iterate_end;
462
463 unit_type_iterate(utype) {
464 utype_id = utype_index(utype);
465 info = unit_array + utype_id;
466 upgradable = client_has_player()
467 && nullptr != can_upgrade_unittype(client_player(), utype);
468 if (0 == info->active_count && 0 == info->building_count) {
469 continue; /* We don't need a row for this type. */
470 }
471 ui = new unittype_item(this, utype);
472 ui->label_info_active.setText("⚔:" + QString::number(info->active_count));
473 ui->label_info_inbuild.setText("⚒:" + QString::number(info->building_count));
474 ui->label_info_unit.setText(utype_name_translation(utype));
475 if (upgradable) {
476 ui->upgrade_button.setVisible(true);
477 } else {
478 ui->upgrade_button.setVisible(false);
479 }
480 ui->shield_upkeep.setText(QString::number(info->upkeep[O_SHIELD]));
481 ui->food_upkeep.setText(QString::number(info->upkeep[O_FOOD]));
482 ui->gold_upkeep.setText(QString::number(info->upkeep[O_GOLD]));
483 add_item(ui);
484 } unit_type_iterate_end;
485
486 free(unit_array);
487
488 setUpdatesEnabled(false);
489 hide();
490 i = unittype_list.count();
491 for (j = 0; j < i; j++) {
492 ui = unittype_list[j];
493 layout->addWidget(ui, 0, Qt::AlignVCenter);
494 total_len = total_len + ui->sizeHint().width() + 18;
495 }
496
497 total_len = total_len + contentsMargins().left()
498 + contentsMargins().right();
499 if (show) {
500 setVisible(true);
501 }
502 setUpdatesEnabled(true);
503 setFixedWidth(qMin(total_len, gui()->mapview_wdg->width()));
504 if (ui != nullptr) {
505 setFixedHeight(ui->height() + 60);
506 }
507 layout->update();
508 updateGeometry();
509}
510
511/************************************************************************/
514 void units_reports::clear_layout()
515{
516 int i = unittype_list.count();
517 unittype_item *ui;
518 int j;
519
520 setUpdatesEnabled(false);
521 setMouseTracking(false);
522
523 for (j = 0; j < i; j++) {
524 ui = unittype_list[j];
525 layout->removeWidget(ui);
526 delete ui;
527 }
528
529 while (!unittype_list.empty()) {
530 unittype_list.removeFirst();
531 }
532
533 setMouseTracking(true);
534 setUpdatesEnabled(true);
535}
536
537/************************************************************************/
540 bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
541{
542 return (q1.tech_str < q2.tech_str);
543}
544
545/************************************************************************/
548research_diagram::research_diagram(QWidget *parent): QWidget(parent)
549{
550 pcanvas = NULL;
551 req = NULL;
552 reset();
553 setMouseTracking(true);
554}
555
556/************************************************************************/
559research_diagram::~research_diagram()
560{
561 canvas_free(pcanvas);
562 destroy_reqtree(req);
563 qDeleteAll(tt_help);
564 tt_help.clear();
565}
566
567/************************************************************************/
570req_tooltip_help::req_tooltip_help()
571{
572 tech_id = -1;
573 tunit = nullptr;
574 timpr = nullptr;
575}
576
577/************************************************************************/
580 void research_diagram::create_tooltip_help()
581{
582 int i, j;
583 int swidth, sheight;
584 struct sprite *sprite;
585 reqtree *tree;
586 req_tooltip_help *rttp;
587
588 qDeleteAll(tt_help);
589 tt_help.clear();
590 if (req == nullptr) {
591 return;
592 } else {
593 tree = req;
594 }
595
596 for (i = 0; i < tree->num_layers; i++) {
597 for (j = 0; j < tree->layer_size[i]; j++) {
598 struct tree_node *node = tree->layers[i][j];
599 int startx, starty, nwidth, nheight;
600
601 startx = node->node_x;
602 starty = node->node_y;
603 nwidth = node->node_width;
604 nheight = node->node_height;
605
606 if (!node->is_dummy) {
607 const char *text = research_advance_name_translation(
608 research_get(client_player()), node->tech);
609 int text_w, text_h;
610 int icon_startx;
611
612 get_text_size(&text_w, &text_h, FONT_REQTREE_TEXT, text);
613 rttp = new req_tooltip_help();
614 rttp->rect = QRect(startx + (nwidth - text_w) / 2, starty + 4,
615 text_w, text_h);
616 rttp->tech_id = node->tech;
617 tt_help.append(rttp);
618 icon_startx = startx + 5;
619
620 if (gui_options.reqtree_show_icons) {
621 unit_type_iterate(unit) {
622 if (advance_number(unit->require_advance) != node->tech) {
623 continue;
624 }
625 sprite = get_unittype_sprite(tileset, unit, direction8_invalid());
626 get_sprite_dimensions(sprite, &swidth, &sheight);
627 rttp = new req_tooltip_help();
628 rttp->rect = QRect(icon_startx, starty + text_h + 4
629 + (nheight - text_h - 4 - sheight) / 2,
630 swidth, sheight);
631 rttp->tunit = unit;
632 tt_help.append(rttp);
633 icon_startx += swidth + 2;
634 } unit_type_iterate_end;
635
636 improvement_iterate(pimprove) {
637 if (valid_improvement(pimprove)) {
638 requirement_vector_iterate(&(pimprove->reqs), preq) {
639 if (VUT_ADVANCE == preq->source.kind
640 && advance_number(preq->source.value.advance) == node->tech) {
641 sprite = get_building_sprite(tileset, pimprove);
642 if (sprite) {
643 get_sprite_dimensions(sprite, &swidth, &sheight);
644 rttp = new req_tooltip_help();
645 rttp->rect = QRect(icon_startx, starty + text_h + 4
646 + (nheight - text_h - 4 - sheight) / 2,
647 swidth, sheight);
648 rttp->timpr = pimprove;
649 tt_help.append(rttp);
650 icon_startx += swidth + 2;
651 }
652 }
653 } requirement_vector_iterate_end;
654 }
655 } improvement_iterate_end;
656
657 governments_iterate(gov) {
658 requirement_vector_iterate(&(gov->reqs), preq) {
659 if (VUT_ADVANCE == preq->source.kind
660 && advance_number(preq->source.value.advance) == node->tech) {
661 sprite = get_government_sprite(tileset, gov);
662 get_sprite_dimensions(sprite, &swidth, &sheight);
663 rttp = new req_tooltip_help();
664 rttp->rect = QRect(icon_startx, starty + text_h + 4
665 + (nheight - text_h - 4 - sheight) / 2,
666 swidth, sheight);
667 rttp->tgov = gov;
668 tt_help.append(rttp);
669 icon_startx += swidth + 2;
670 }
671 } requirement_vector_iterate_end;
672 } governments_iterate_end;
673 }
674 }
675 }
676 }
677}
678
679/************************************************************************/
682 void research_diagram::update_reqtree()
683{
684 reset();
685 draw_reqtree(req, pcanvas, 0, 0, 0, 0, width, height);
686 create_tooltip_help();
687 update();
688}
689
690/************************************************************************/
693 void research_diagram::reset()
694{
695 timer_active = false;
696 if (req != NULL) {
697 destroy_reqtree(req);
698 }
699 if (pcanvas != NULL) {
700 canvas_free(pcanvas);
701 }
702 req = create_reqtree(client_player(), true);
703 get_reqtree_dimensions(req, &width, &height);
704 pcanvas = qtg_canvas_create(width, height);
705 pcanvas->map_pixmap.fill(Qt::transparent);
706 resize(width, height);
707}
708
709
710/************************************************************************/
713 void research_diagram::mousePressEvent(QMouseEvent *event)
714{
715 QPoint pos = event->pos();
716 Tech_type_id tech = get_tech_on_reqtree(req, pos.x(), pos.y());
717 req_tooltip_help *rttp;
718 int i;
719
720 if (event->button() == Qt::LeftButton && can_client_issue_orders()) {
721 switch (research_invention_state(research_get(client_player()), tech)) {
722 case TECH_PREREQS_KNOWN:
723 dsend_packet_player_research(&client.conn, tech);
724 break;
725 case TECH_UNKNOWN:
726 dsend_packet_player_tech_goal(&client.conn, tech);
727 break;
728 case TECH_KNOWN:
729 break;
730 }
731 } else if (event->button() == Qt::RightButton) {
732 for (i = 0; i < tt_help.count(); i++) {
733 rttp = tt_help.at(i);
734 if (rttp->rect.contains(event->pos())) {
735 if (rttp->tech_id != -1) {
736 popup_help_dialog_typed(research_advance_name_translation(
737 research_get(client_player()),
738 rttp->tech_id), HELP_TECH);
739 } else if (rttp->timpr != nullptr) {
740 popup_help_dialog_typed(improvement_name_translation(rttp->timpr),
741 is_great_wonder(rttp->timpr) ? HELP_WONDER
742 : HELP_IMPROVEMENT);
743 } else if (rttp->tunit != nullptr) {
744 popup_help_dialog_typed(utype_name_translation(rttp->tunit),
745 HELP_UNIT);
746 } else if (rttp->tgov != nullptr) {
747 popup_help_dialog_typed(government_name_translation(rttp->tgov),
748 HELP_GOVERNMENT);
749 } else {
750 return;
751 }
752 }
753 }
754 }
755}
756
757/************************************************************************/
760 void research_diagram::mouseMoveEvent(QMouseEvent *event)
761{
762 req_tooltip_help *rttp;
763 int i;
764 QString tt_text;
765 QString def_str;
766 char buffer[8192];
767 char buf2[1];
768
769 buf2[0] = '\0';
770 for (i = 0; i < tt_help.count(); i++) {
771 rttp = tt_help.at(i);
772 if (rttp->rect.contains(event->pos())) {
773 if (rttp->tech_id != -1) {
774 helptext_advance(buffer, sizeof(buffer), client.conn.playing,
775 buf2, rttp->tech_id);
776 tt_text = QString(buffer);
777 def_str = "<p style='white-space:pre'><b>"
778 + QString(advance_name_translation(
779 advance_by_number(rttp->tech_id))).toHtmlEscaped()
780 + "</b>\n";
781 } else if (rttp->timpr != nullptr) {
782 def_str = get_tooltip_improvement(rttp->timpr, nullptr);
783 tt_text = helptext_building(buffer, sizeof(buffer),
784 client.conn.playing, NULL, rttp->timpr);
785 tt_text = cut_helptext(tt_text);
786 } else if (rttp->tunit != nullptr) {
787 def_str = get_tooltip_unit(rttp->tunit);
788 tt_text += helptext_unit(buffer, sizeof(buffer), client.conn.playing,
789 buf2, rttp->tunit);
790 tt_text = cut_helptext(tt_text);
791 } else if (rttp->tgov != nullptr) {
792 helptext_government(buffer, sizeof(buffer), client.conn.playing,
793 buf2, rttp->tgov);
794 tt_text = QString(buffer);
795 tt_text = cut_helptext(tt_text);
796 def_str = "<p style='white-space:pre'><b>"
797 + QString(government_name_translation(rttp->tgov)).toHtmlEscaped()
798 + "</b>\n";
799 } else {
800 return;
801 }
802 tt_text = split_text(tt_text, true);
803 tt_text = def_str + tt_text.toHtmlEscaped();
804 tooltip_text = tt_text.trimmed();
805 tooltip_rect = rttp->rect;
806 tooltip_pos = event->globalPos();
807 if (!QToolTip::isVisible() && !timer_active) {
808 timer_active = true;
809 QTimer::singleShot(500, this, SLOT(show_tooltip()));
810 }
811 }
812 }
813}
814
815/************************************************************************/
818 void research_diagram::show_tooltip()
819{
820 QPoint cp;
821
822 timer_active = false;
823 cp = QCursor::pos();
824 if (qAbs(cp.x() - tooltip_pos.x()) < 4
825 && qAbs(cp.y() - tooltip_pos.y()) < 4) {
826 QToolTip::showText(cp, tooltip_text, this, tooltip_rect);
827 }
828}
829
830/************************************************************************/
833 void research_diagram::paintEvent(QPaintEvent *event)
834{
835 QPainter painter;
836
837 painter.begin(this);
838 painter.drawPixmap(0, 0, width, height, pcanvas->map_pixmap);
839 painter.end();
840}
841
842/************************************************************************/
845QSize research_diagram::size()
846{
847 QSize s;
848
849 s.setWidth(width);;
850 s.setHeight(height);
851 return s;
852}
853
854/************************************************************************/
857science_report::science_report(): QWidget()
858{
859 QSize size;
860 QSizePolicy size_expanding_policy(QSizePolicy::Expanding,
861 QSizePolicy::Expanding);
862 QSizePolicy size_fixed_policy(QSizePolicy::Minimum, QSizePolicy::Minimum);
863
864 goal_combo = new QComboBox();
865 info_label = new QLabel();
866 progress = new progress_bar(this);
867 progress_label = new QLabel();
868 researching_combo = new QComboBox();
869 sci_layout = new QGridLayout();
870 res_diag = new research_diagram();
871 scroll = new QScrollArea();
872
873 curr_list = NULL;
874 goal_list = NULL;
875 progress->setTextVisible(true);
876 progress_label->setSizePolicy(size_fixed_policy);
877 sci_layout->addWidget(progress_label, 0, 0, 1, 8);
878 sci_layout->addWidget(researching_combo, 1, 0, 1, 4);
879 researching_combo->setSizePolicy(size_fixed_policy);
880 sci_layout->addWidget(progress, 1, 5, 1, 4);
881 progress->setSizePolicy(size_fixed_policy);
882 sci_layout->addWidget(goal_combo, 2, 0, 1, 4);
883 goal_combo->setSizePolicy(size_fixed_policy);
884 sci_layout->addWidget(info_label, 2, 5, 1, 4);
885 info_label->setSizePolicy(size_fixed_policy);
886
887 size = res_diag->size();
888 res_diag->setMinimumSize(size);
889 scroll->setAutoFillBackground(true);
890 scroll->setPalette(QPalette(QColor(215,215,215)));
891 scroll->setWidget(res_diag);
892 scroll->setSizePolicy(size_expanding_policy);
893 sci_layout->addWidget(scroll, 4, 0, 1, 10);
894
895 QObject::connect(researching_combo, SIGNAL(currentIndexChanged(int)),
896 SLOT(current_tech_changed(int)));
897
898 QObject::connect(goal_combo, SIGNAL(currentIndexChanged(int)),
899 SLOT(goal_tech_changed(int)));
900
901 setLayout(sci_layout);
902
903}
904
905/************************************************************************/
910science_report::~science_report()
911{
912 if (curr_list) {
913 delete curr_list;
914 }
915
916 if (goal_list) {
917 delete goal_list;
918 }
919 gui()->remove_repo_dlg("SCI");
920}
921
922/************************************************************************/
927 void science_report::init()
928{
929 gui()->gimme_place(this, "SCI");
930 index = gui()->add_game_tab(this);
931 gui()->game_tab_widget->setCurrentIndex(index);
932 update_report();
933}
934
935/************************************************************************/
938 void science_report::redraw()
939{
940 update();
941}
942
943/************************************************************************/
946 void science_report::reset_tree()
947{
948 QSize size;
949 res_diag->reset();
950 size = res_diag->size();
951 res_diag->setMinimumSize(size);
952 update();
953}
954
955/************************************************************************/
958 void science_report::update_report()
959{
960
961 struct research *research = research_get(client_player());
962 const char *text;
963 int total;
964 int done = research->bulbs_researched;
965 QVariant qvar, qres;
966 double not_used;
967 QString str;
968 qlist_item item;
969 struct sprite *sp;
970
971 fc_assert_ret(NULL != research);
972
973 if (curr_list) {
974 delete curr_list;
975 }
976
977 if (goal_list) {
978 delete goal_list;
979 }
980
981 if (research->researching != A_UNSET) {
982 total = research->client.researching_cost;
983 } else {
984 total = -1;
985 }
986
987 curr_list = new QList<qlist_item>;
988 goal_list = new QList<qlist_item>;
989 progress_label->setText(science_dialog_text());
990 progress_label->setAlignment(Qt::AlignHCenter);
991 info_label->setAlignment(Qt::AlignHCenter);
992 info_label->setText(get_science_goal_text(research->tech_goal));
993 text = get_science_target_text(&not_used);
994 str = QString::fromUtf8(text);
995 progress->setFormat(str);
996 progress->setMinimum(0);
997 progress->setMaximum(total);
998 progress->set_pixmap(static_cast<int>(research->researching));
999
1000 if (done <= total) {
1001 progress->setValue(done);
1002 } else {
1003 done = total;
1004 progress->setValue(done);
1005 }
1006
1008 advance_index_iterate(A_FIRST, i) {
1009 if (TECH_PREREQS_KNOWN == research->inventions[i].state) {
1010 item.tech_str
1011 =
1012 QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1013 item.id = i;
1014 curr_list->append(item);
1015 }
1016 } advance_index_iterate_end;
1017
1018
1020 advance_index_iterate(A_FIRST, i) {
1021 if (research_invention_reachable(research, i)
1022 && TECH_KNOWN != research->inventions[i].state
1023 && (i == research->tech_goal
1024 || 10 >= research->inventions[i].num_required_techs)) {
1025 item.tech_str
1026 = QString::fromUtf8(advance_name_translation(advance_by_number(i)));
1027 item.id = i;
1028 goal_list->append(item);
1029 }
1030 } advance_index_iterate_end;
1031
1033 std::sort(goal_list->begin(), goal_list->end(), comp_less_than);
1034 std::sort(curr_list->begin(), curr_list->end(), comp_less_than);
1035
1037 researching_combo->blockSignals(true);
1038 goal_combo->blockSignals(true);
1039
1040 researching_combo->clear();
1041 goal_combo->clear();
1042 for (int i = 0; i < curr_list->count(); i++) {
1043 QIcon ic;
1044
1045 sp = get_tech_sprite(tileset, curr_list->at(i).id);
1046 if (sp) {
1047 ic = QIcon(*sp->pm);
1048 }
1049 qvar = curr_list->at(i).id;
1050 researching_combo->insertItem(i, ic, curr_list->at(i).tech_str, qvar);
1051 }
1052
1053 for (int i = 0; i < goal_list->count(); i++) {
1054 QIcon ic;
1055
1056 sp = get_tech_sprite(tileset, goal_list->at(i).id);
1057 if (sp) {
1058 ic = QIcon(*sp->pm);
1059 }
1060 qvar = goal_list->at(i).id;
1061 goal_combo->insertItem(i, ic, goal_list->at(i).tech_str, qvar);
1062 }
1063
1065 qres = research->researching;
1066 if (qres == A_UNSET || is_future_tech(research->researching)) {
1067 researching_combo->insertItem(0, research_advance_name_translation(
1068 research, research->researching ),
1069 A_UNSET);
1070 researching_combo->setCurrentIndex(0);
1071 } else {
1072 for (int i = 0; i < researching_combo->count(); i++) {
1073 qvar = researching_combo->itemData(i);
1074
1075 if (qvar == qres) {
1076 researching_combo->setCurrentIndex(i);
1077 }
1078 }
1079 }
1080
1081 qres = research->tech_goal;
1082
1083 if (qres == A_UNSET) {
1084 goal_combo->insertItem(0, Q_("?tech:None"), A_UNSET);
1085 goal_combo->setCurrentIndex(0);
1086 } else {
1087 for (int i = 0; i < goal_combo->count(); i++) {
1088 qvar = goal_combo->itemData(i);
1089
1090 if (qvar == qres) {
1091 goal_combo->setCurrentIndex(i);
1092 }
1093 }
1094 }
1095
1096 researching_combo->blockSignals(false);
1097 goal_combo->blockSignals(false);
1098
1099 if (client_is_observer()) {
1100 researching_combo->setDisabled(true);
1101 goal_combo->setDisabled(true);
1102 } else {
1103 researching_combo->setDisabled(false);
1104 goal_combo->setDisabled(false);
1105 }
1106 update_reqtree();
1107}
1108
1109/************************************************************************/
1112 void science_report::update_reqtree()
1113{
1114 res_diag->update_reqtree();
1115}
1116
1117/************************************************************************/
1120 void science_report::current_tech_changed(int changed_index)
1121{
1122 QVariant qvar;
1123
1124 qvar = researching_combo->itemData(changed_index);
1125
1126 if (researching_combo->hasFocus()) {
1127 if (can_client_issue_orders()) {
1128 dsend_packet_player_research(&client.conn, qvar.toInt());
1129 }
1130 }
1131}
1132
1133/************************************************************************/
1136 void science_report::goal_tech_changed(int changed_index)
1137{
1138 QVariant qvar;
1139
1140 qvar = goal_combo->itemData(changed_index);
1141
1142 if (goal_combo->hasFocus()) {
1143 if (can_client_issue_orders()) {
1144 dsend_packet_player_tech_goal(&client.conn, qvar.toInt());
1145 }
1146 }
1147}
1148
1149/************************************************************************/
1152 void real_science_report_dialog_update(void *unused)
1153{
1154 int i;
1155 int percent;
1156 science_report *sci_rep;
1157 bool blk = false;
1158 QWidget *w;
1159 QString str;
1160 struct player *plr = client_player();
1161
1162 if (NULL != plr) {
1163 struct research *research = research_get(plr);
1164
1165 if (research->researching == A_UNSET) {
1166 str = QString(Q_("?tech:None"));
1167 } else if (research->client.researching_cost != 0) {
1168 str = research_advance_name_translation(research,research->researching);
1169 percent = 100 *research->bulbs_researched / research->client.researching_cost;
1170 str = str + "\n (" + QString::number(percent) + "%)";
1171 }
1172 if (research->researching == A_UNSET && research->tech_goal == A_UNSET
1173 && research->techs_researched < game.control.num_tech_types) {
1174 blk = true;
1175 }
1176 } else {
1177 str = " ";
1178 }
1179
1180 if (blk) {
1181 gui()->sw_science->keep_blinking = true;
1182 gui()->sw_science->set_custom_labels(str);
1183 gui()->sw_science->sblink();
1184 } else {
1185 gui()->sw_science->keep_blinking = false;
1186 gui()->sw_science->set_custom_labels(str);
1187 gui()->sw_science->update_final_pixmap();
1188 }
1189 gui()->update_sidebar_tooltips();
1190
1191 if (gui()->is_repo_dlg_open("SCI")) {
1192 i = gui()->gimme_index_of("SCI");
1193 fc_assert(i != -1);
1194 w = gui()->game_tab_widget->widget(i);
1195 sci_rep = reinterpret_cast< science_report*>(w);
1196 sci_rep->update_report();
1197 }
1198}
1199
1200/************************************************************************/
1203eco_report::eco_report(): QWidget()
1204{
1205 QHeaderView *header;
1206 QGridLayout *eco_layout = new QGridLayout;
1207 eco_widget = new QTableWidget;
1208 disband_button = new QPushButton;
1209 sell_button = new QPushButton;
1210 sell_redun_button = new QPushButton;
1211 eco_label = new QLabel;
1212
1213 QStringList slist;
1214 slist << _("Type") << Q_("?Building or Unit type:Name") << _("Redundant")
1215 << _("Count") << _("Cost") << _("U Total");
1216 eco_widget->setColumnCount(slist.count());
1217 eco_widget->setHorizontalHeaderLabels(slist);
1218 eco_widget->setProperty("showGrid", "false");
1219 eco_widget->setProperty("selectionBehavior", "SelectRows");
1220 eco_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
1221 eco_widget->horizontalHeader()->resizeSections(QHeaderView::Stretch);
1222 eco_widget->verticalHeader()->setVisible(false);
1223 eco_widget->setSelectionMode(QAbstractItemView::SingleSelection);
1224 eco_widget->setSortingEnabled(true);
1225 header = eco_widget->horizontalHeader();
1226 header->setSectionResizeMode(1, QHeaderView::Stretch);
1227 header->setStretchLastSection(true);
1228 disband_button->setText(_("Disband"));
1229 disband_button->setEnabled(false);
1230 sell_button->setText(_("Sell All"));
1231 sell_button->setEnabled(false);
1232 sell_redun_button->setText(_("Sell Redundant"));
1233 sell_redun_button->setEnabled(false);
1234 eco_layout->addWidget(eco_widget, 1, 0, 5, 5);
1235 eco_layout->addWidget(disband_button, 0, 0, 1, 1);
1236 eco_layout->addWidget(sell_button, 0, 1, 1, 1);
1237 eco_layout->addWidget(sell_redun_button, 0, 2, 1, 1);
1238 eco_layout->addWidget(eco_label, 6, 0, 1, 5);
1239
1240 connect(disband_button, &QAbstractButton::pressed, this, &eco_report::disband_units);
1241 connect(sell_button, &QAbstractButton::pressed, this, &eco_report::sell_buildings);
1242 connect(sell_redun_button, &QAbstractButton::pressed, this, &eco_report::sell_redundant);
1243 connect(eco_widget->selectionModel(),
1244 SIGNAL(selectionChanged(const QItemSelection &,
1245 const QItemSelection &)),
1246 SLOT(selection_changed(const QItemSelection &,
1247 const QItemSelection &)));
1248 setLayout(eco_layout);
1249}
1250
1251/************************************************************************/
1254eco_report::~eco_report()
1255{
1256 gui()->remove_repo_dlg("ECO");
1257}
1258
1259/************************************************************************/
1262 void eco_report::init()
1263{
1264 curr_row = -1;
1265 gui()->gimme_place(this, "ECO");
1266 index = gui()->add_game_tab(this);
1267 gui()->game_tab_widget->setCurrentIndex(index);
1268}
1269
1270/************************************************************************/
1273 void eco_report::update_report()
1274{
1275 struct improvement_entry building_entries[B_LAST];
1276 struct unit_entry unit_entries[U_LAST];
1277 int entries_used, building_total, unit_total, tax, i, j;
1278 char buf[256];
1279 QTableWidgetItem *item;
1280 QFont f = QApplication::font();
1281 int h;
1282 QFontMetrics fm(f);
1283 h = fm.height() + 6;
1284 QPixmap *pix;
1285 QPixmap pix_scaled;
1286 struct sprite *sprite;
1287
1288 eco_widget->setRowCount(0);
1289 eco_widget->clearContents();
1290 get_economy_report_data(building_entries, &entries_used,
1291 &building_total, &tax);
1292 for (i = 0; i < entries_used; i++) {
1293 struct improvement_entry *pentry = building_entries + i;
1294 struct impr_type *pimprove = pentry->type;
1295
1296 pix = NULL;
1297 sprite = get_building_sprite(tileset, pimprove);
1298 if (sprite != NULL) {
1299 pix = sprite->pm;
1300 }
1301 if (pix != NULL) {
1302 pix_scaled = pix->scaledToHeight(h);
1303 } else {
1304 pix_scaled.fill();
1305 }
1306 cid id = cid_encode_building(pimprove);
1307
1308 eco_widget->insertRow(i);
1309 for (j = 0; j < 6; j++) {
1310 item = new QTableWidgetItem;
1311 switch (j) {
1312 case 0:
1313 item->setData(Qt::DecorationRole, pix_scaled);
1314 item->setData(Qt::UserRole, id);
1315 break;
1316 case 1:
1317 item->setTextAlignment(Qt::AlignLeft);
1318 item->setText(improvement_name_translation(pimprove));
1319 break;
1320 case 2:
1321 item->setData(Qt::DisplayRole, pentry->redundant);
1322 break;
1323 case 3:
1324 item->setData(Qt::DisplayRole, pentry->count);
1325 break;
1326 case 4:
1327 item->setData(Qt::DisplayRole, pentry->cost);
1328 break;
1329 case 5:
1330 item->setData(Qt::DisplayRole, pentry->total_cost);
1331 break;
1332 }
1333 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
1334 eco_widget->setItem(i, j, item);
1335 }
1336 }
1337 max_row = i;
1338 get_economy_report_units_data(unit_entries, &entries_used, &unit_total);
1339 for (i = 0; i < entries_used; i++) {
1340 struct unit_entry *pentry = unit_entries + i;
1341 struct unit_type *putype = pentry->type;
1342 cid id;
1343
1344 pix = NULL;
1345 sprite = get_unittype_sprite(tileset, putype, direction8_invalid());
1346 if (sprite != NULL) {
1347 pix = sprite->pm;
1348 }
1349 id = cid_encode_unit(putype);
1350
1351 eco_widget->insertRow(i + max_row);
1352 for (j = 0; j < 6; j++) {
1353 item = new QTableWidgetItem;
1354 item->setTextAlignment(Qt::AlignHCenter);
1355 switch (j) {
1356 case 0:
1357 if (pix != NULL) {
1358 pix_scaled = pix->scaledToHeight(h);
1359 item->setData(Qt::DecorationRole, pix_scaled);
1360 }
1361 item->setData(Qt::UserRole, id);
1362 break;
1363 case 1:
1364 item->setTextAlignment(Qt::AlignLeft);
1365 item->setText(utype_name_translation(putype));
1366 break;
1367 case 2:
1368 item->setData(Qt::DisplayRole, 0);
1369 break;
1370 case 3:
1371 item->setData(Qt::DisplayRole, pentry->count);
1372 break;
1373 case 4:
1374 item->setData(Qt::DisplayRole, pentry->cost);
1375 break;
1376 case 5:
1377 item->setData(Qt::DisplayRole, pentry->total_cost);
1378 break;
1379 }
1380 item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
1381 eco_widget->setItem(max_row + i, j, item);
1382 }
1383 }
1384 max_row = max_row + i;
1385 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
1386 tax, building_total + unit_total);
1387 eco_label->setText(buf);
1388}
1389
1390/************************************************************************/
1393 void eco_report::selection_changed(const QItemSelection & sl,
1394 const QItemSelection & ds)
1395{
1396 QTableWidgetItem *itm;
1397 int i;
1398 QVariant qvar;
1399 struct universal selected;
1400 const struct impr_type *pimprove;
1401 disband_button->setEnabled(false);
1402 sell_button->setEnabled(false);
1403 sell_redun_button->setEnabled(false);
1404
1405 if (sl.isEmpty()) {
1406 return;
1407 }
1408
1409 curr_row = sl.indexes().at(0).row();
1410 if (curr_row >= 0 && curr_row <= max_row) {
1411 itm = eco_widget->item(curr_row, 0);
1412 qvar = itm->data(Qt::UserRole);
1413 uid = qvar.toInt();
1414 selected = cid_decode(uid);
1415 switch (selected.kind) {
1416 case VUT_IMPROVEMENT:
1417 pimprove = selected.value.building;
1418 counter = eco_widget->item(curr_row, 3)->text().toInt();
1419 if (can_sell_building(pimprove)) {
1420 sell_button->setEnabled(true);
1421 }
1422 itm = eco_widget->item(curr_row, 2);
1423 i = itm->text().toInt();
1424 if (i > 0) {
1425 sell_redun_button->setEnabled(true);
1426 }
1427 break;
1428 case VUT_UTYPE:
1429 counter = eco_widget->item(curr_row, 3)->text().toInt();
1430 disband_button->setEnabled(true);
1431 break;
1432 default:
1433 log_error("Not supported type: %d.", selected.kind);
1434 }
1435 }
1436}
1437
1438/************************************************************************/
1441 void eco_report::disband_units()
1442{
1443 struct universal selected;
1444 char title[1024];
1445 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1446 Unit_type_id utype;
1447
1448 selected = cid_decode(uid);
1449 utype = utype_number(selected.value.utype);
1450 fc_snprintf(title, ARRAY_SIZE(title),
1451 _("Do you really wish to disband every %s (%d total)?"),
1452 utype_name_translation(utype_by_number(utype)), counter);
1453
1454 ask->set_text_title(title, _("Disband Units"));
1455 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1456 ask->setDefaultButton(QMessageBox::Cancel);
1457 ask->setAttribute(Qt::WA_DeleteOnClose);
1458 connect(ask, &hud_message_box::accepted, [=]() {
1459 struct unit_type *putype = utype_by_number(utype);
1460 char buf[1024];
1461 hud_message_box *result;
1462
1463 if (putype) {
1464 disband_all_units(putype, false, buf, sizeof(buf));
1465 }
1466
1467 result = new hud_message_box(gui()->central_wdg);
1468 result->set_text_title(buf, _("Disband Results"));
1469 result->setStandardButtons(QMessageBox::Ok);
1470 result->setAttribute(Qt::WA_DeleteOnClose);
1471 result->show();
1472 });
1473}
1474
1475/************************************************************************/
1478 void eco_report::sell_buildings()
1479{
1480 struct universal selected;
1481 char title[1024];
1482 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1483 const struct impr_type *pimpr;
1484 Impr_type_id impr_id;
1485
1486 selected = cid_decode(uid);
1487 pimpr = selected.value.building;
1488 impr_id = improvement_number(pimpr);
1489
1490 fc_snprintf(title, ARRAY_SIZE(title),
1491 _("Do you really wish to sell "
1492 "every %s (%d total)?"),
1493 improvement_name_translation(pimpr), counter);
1494
1495 ask->set_text_title(title, _("Sell Improvements"));
1496 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1497 ask->setDefaultButton(QMessageBox::Cancel);
1498 ask->setAttribute(Qt::WA_DeleteOnClose);
1499 connect(ask, &hud_message_box::accepted, [=]() {
1500 char buf[1024];
1501 hud_message_box *result;
1502 struct impr_type *pimprove = improvement_by_number(impr_id);
1503
1504 if (!pimprove) {
1505 return;
1506 }
1507
1508 sell_all_improvements(pimprove, false, buf, sizeof(buf));
1509
1510 result = new hud_message_box(gui()->central_wdg);
1511 result->set_text_title(buf, _("Sell-Off: Results"));
1512 result->setStandardButtons(QMessageBox::Ok);
1513 result->setAttribute(Qt::WA_DeleteOnClose);
1514 result->show();
1515 });
1516}
1517
1518
1519/************************************************************************/
1522 void eco_report::sell_redundant()
1523{
1524 struct universal selected;
1525 char title[1024];
1526 hud_message_box *ask = new hud_message_box(gui()->central_wdg);
1527 const struct impr_type *pimpr;
1528 Impr_type_id impr_id;
1529
1530 selected = cid_decode(uid);
1531 pimpr = selected.value.building;
1532 impr_id = improvement_number(pimpr);
1533
1534 fc_snprintf(title, ARRAY_SIZE(title),
1535 _("Do you really wish to sell "
1536 "every redundant %s (%d total)?"),
1537 improvement_name_translation(pimpr), counter);
1538
1539 ask->set_text_title(title, _("Sell Improvements"));
1540 ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok);
1541 ask->setDefaultButton(QMessageBox::Cancel);
1542 ask->setAttribute(Qt::WA_DeleteOnClose);
1543 connect(ask, &hud_message_box::accepted, [=]() {
1544 char buf[1024];
1545 hud_message_box *result;
1546 struct impr_type *pimprove = improvement_by_number(impr_id);
1547
1548 if (!pimprove) {
1549 return;
1550 }
1551
1552 sell_all_improvements(pimprove, true, buf, sizeof(buf));
1553
1554 result = new hud_message_box(gui()->central_wdg);
1555 result->set_text_title(buf, _("Sell-Off: Results"));
1556 result->setStandardButtons(QMessageBox::Ok);
1557 result->setAttribute(Qt::WA_DeleteOnClose);
1558 result->show();
1559 });
1560}
1561
1562/************************************************************************/
1565endgame_report::endgame_report(const struct packet_endgame_report *packet): QWidget()
1566{
1567 QGridLayout *end_layout = new QGridLayout;
1568 end_widget = new QTableWidget;
1569 unsigned int i;
1570
1571 players = 0;
1572 const size_t col_num = packet->category_num + 3;
1573 QStringList slist;
1574 slist << _("Player") << _("Nation") << _("Score");
1575 for (i = 0 ; i < col_num - 3; i++) {
1576 slist << Q_(packet->category_name[i]);
1577 }
1578 end_widget->setColumnCount(slist.count());
1579 end_widget->setHorizontalHeaderLabels(slist);
1580 end_widget->setProperty("showGrid", "false");
1581 end_widget->setProperty("selectionBehavior", "SelectRows");
1582 end_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
1583 end_widget->verticalHeader()->setVisible(false);
1584 end_widget->setSelectionMode(QAbstractItemView::SingleSelection);
1585 end_widget->horizontalHeader()->setSectionResizeMode(
1586 QHeaderView::ResizeToContents);
1587 end_layout->addWidget(end_widget, 1, 0, 5, 5);
1588 setLayout(end_layout);
1589
1590}
1591
1592/************************************************************************/
1595endgame_report::~endgame_report()
1596{
1597 gui()->remove_repo_dlg("END");
1598}
1599
1600/************************************************************************/
1603 void endgame_report::init()
1604{
1605 gui()->gimme_place(this, "END");
1606 index = gui()->add_game_tab(this);
1607 gui()->game_tab_widget->setCurrentIndex(index);
1608}
1609
1610/************************************************************************/
1613 void endgame_report::update_report(const struct packet_endgame_player *packet)
1614{
1615 QTableWidgetItem *item;
1616 QPixmap *pix;
1617 unsigned int i;
1618 const struct player *pplayer = player_by_number(packet->player_id);
1619 const size_t col_num = packet->category_num + 3;
1620 end_widget->insertRow(players);
1621 for (i = 0; i < col_num; i++) {
1622 item = new QTableWidgetItem;
1623 switch (i) {
1624 case 0:
1625 item->setText(player_name(pplayer));
1626 break;
1627 case 1:
1628 pix = get_nation_flag_sprite(tileset, nation_of_player(pplayer))->pm;
1629 if (pix != NULL) {
1630 item->setData(Qt::DecorationRole, *pix);
1631 }
1632 break;
1633 case 2:
1634 item->setText(QString::number(packet->score));
1635 item->setTextAlignment(Qt::AlignHCenter);
1636 break;
1637 default:
1638 item->setText(QString::number(packet->category_score[i-3]));
1639 item->setTextAlignment(Qt::AlignHCenter);
1640 break;
1641 }
1642 end_widget->setItem(players, i, item);
1643 }
1644 players++;
1645 end_widget->resizeRowsToContents();
1646}
1647
1648/************************************************************************/
1652 void science_report_dialog_popup(bool raise)
1653{
1654 science_report *sci_rep;
1655 int i;
1656 QWidget *w;
1657
1658 if (client_is_global_observer()) {
1659 return;
1660 }
1661 if (!gui()->is_repo_dlg_open("SCI")) {
1662 sci_rep = new science_report;
1663 sci_rep->init();
1664 } else {
1665 i = gui()->gimme_index_of("SCI");
1666 w = gui()->game_tab_widget->widget(i);
1667 sci_rep = reinterpret_cast< science_report*>(w);
1668 if (gui()->game_tab_widget->currentIndex() == i) {
1669 sci_rep->redraw();
1670 } else if (raise) {
1671 gui()->game_tab_widget->setCurrentWidget(sci_rep);
1672 }
1673 }
1674}
1675
1676/************************************************************************/
1679 void real_economy_report_dialog_update(void *unused)
1680{
1681 int i;
1682 eco_report *eco_rep;
1683 QWidget *w;
1684
1685 if (gui()->is_repo_dlg_open("ECO")) {
1686 i = gui()->gimme_index_of("ECO");
1687 if (gui()->game_tab_widget->currentIndex() == i) {
1688 w = gui()->game_tab_widget->widget(i);
1689 eco_rep = reinterpret_cast< eco_report*>(w);
1690 eco_rep->update_report();
1691 }
1692 }
1693 gui()->update_sidebar_tooltips();
1694}
1695
1696/************************************************************************/
1699 void economy_report_dialog_popup(bool raise)
1700{
1701 int i;
1702 eco_report *eco_rep;
1703 QWidget *w;
1704
1705 if (!gui()->is_repo_dlg_open("ECO")) {
1706 eco_rep = new eco_report;
1707 eco_rep->init();
1708 eco_rep->update_report();
1709 } else {
1710 i = gui()->gimme_index_of("ECO");
1711 fc_assert(i != -1);
1712 w = gui()->game_tab_widget->widget(i);
1713 if (w->isVisible()) {
1714 gui()->game_tab_widget->setCurrentIndex(0);
1715 return;
1716 }
1717 eco_rep = reinterpret_cast< eco_report *>(w);
1718 eco_rep->update_report();
1719 gui()->game_tab_widget->setCurrentWidget(eco_rep);
1720 }
1721}
1722
1723/************************************************************************/
1726 void real_units_report_dialog_update(void *unused)
1727{
1728 if (units_reports::instance()->isVisible()) {
1729 units_reports::instance()->update_units();
1730 }
1731}
1732
1733/************************************************************************/
1736 void units_report_dialog_popup(bool raise)
1737{
1738 gui()->game_tab_widget->setCurrentIndex(0);
1739 units_reports::instance()->update_units(true);
1740}
1741
1742/************************************************************************/
1745 void endgame_report_dialog_start(const struct packet_endgame_report *packet)
1746{
1747 endgame_report *end_rep;
1748 end_rep = new endgame_report(packet);
1749 end_rep->init();
1750}
1751
1752/************************************************************************/
1755 void popdown_endgame_report()
1756{
1757 int i;
1758 if (gui()->is_repo_dlg_open("END")) {
1759 i = gui()->gimme_index_of("END");
1760 fc_assert(i != -1);
1761 delete gui()->game_tab_widget->widget(i);
1762 }
1763}
1764
1765/************************************************************************/
1768 void popup_endgame_report()
1769{
1770 int i;
1771 if (gui()->is_repo_dlg_open("END")) {
1772 i = gui()->gimme_index_of("END");
1773 gui()->game_tab_widget->setCurrentIndex(i);
1774 }
1775}
1776
1777/************************************************************************/
1780 void endgame_report_dialog_player(const struct packet_endgame_player *packet)
1781{
1782 int i;
1783 endgame_report *end_rep;
1784 QWidget *w;
1785
1786 if (gui()->is_repo_dlg_open("END")) {
1787 i = gui()->gimme_index_of("END");
1788 fc_assert(i != -1);
1789 w = gui()->game_tab_widget->widget(i);
1790 end_rep = reinterpret_cast< endgame_report*>(w);
1791 end_rep->update_report(packet);
1792 }
1793}
1794
1795/************************************************************************/
1798 void science_report_dialog_redraw(void)
1799{
1800 int i;
1801 science_report *sci_rep;
1802 QWidget *w;
1803
1804 if (gui()->is_repo_dlg_open("SCI")) {
1805 i = gui()->gimme_index_of("SCI");
1806 if (gui()->game_tab_widget->currentIndex() == i) {
1807 w = gui()->game_tab_widget->widget(i);
1808 sci_rep = reinterpret_cast< science_report*>(w);
1809 sci_rep->redraw();
1810 }
1811 }
1812}
1813
1814/************************************************************************/
1817 void popdown_economy_report()
1818{
1819 int i;
1820 eco_report *eco_rep;
1821 QWidget *w;
1822
1823 if (gui()->is_repo_dlg_open("ECO")) {
1824 i = gui()->gimme_index_of("ECO");
1825 fc_assert(i != -1);
1826 w = gui()->game_tab_widget->widget(i);
1827 eco_rep = reinterpret_cast< eco_report*>(w);
1828 eco_rep->deleteLater();
1829 }
1830}
1831
1832/************************************************************************/
1835 void popdown_science_report()
1836{
1837 int i;
1838 science_report *sci_rep;
1839 QWidget *w;
1840
1841 if (gui()->is_repo_dlg_open("SCI")) {
1842 i = gui()->gimme_index_of("SCI");
1843 fc_assert(i != -1);
1844 w = gui()->game_tab_widget->widget(i);
1845 sci_rep = reinterpret_cast< science_report*>(w);
1846 sci_rep->deleteLater();
1847 }
1848}
1849
1850/************************************************************************/
1853 void popdown_units_report()
1854{
1855 units_reports::instance()->drop();
1856}
1857
1858/************************************************************************/
1861 void toggle_units_report(bool x)
1862 {
1863 Q_UNUSED(x);
1864 if (units_reports::instance()->isVisible()
1865 && gui()->game_tab_widget->currentIndex() == 0) {
1866 units_reports::instance()->drop();
1867 } else {
1868 units_report_dialog_popup(true);
1869 }
1870}
entries_used
int entries_used
Definition agents.c:74
str
#define str
Definition astring.c:76
zealous_crop_rect
QRect zealous_crop_rect(QImage &p)
Definition canvas.cpp:399
qtg_canvas_create
struct canvas * qtg_canvas_create(int width, int height)
Definition canvas.cpp:35
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
FONT_REQTREE_TEXT
FONT_REQTREE_TEXT
Definition canvas_g.h:72
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:731
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:488
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:490
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:3875
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:3932
close_widget
Definition mapview.h:183
close_widget::put_to_corner
void put_to_corner()
Definition mapview.cpp:500
eco_report
Definition repodlgs.h:209
eco_report::eco_report
eco_report()
Definition repodlgs.cpp:1203
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:1393
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:1441
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:1478
eco_report::init
void init()
Definition repodlgs.cpp:1262
eco_report::uid
cid uid
Definition repodlgs.h:227
eco_report::~eco_report
~eco_report()
Definition repodlgs.cpp:1254
eco_report::sell_redundant
void sell_redundant()
Definition repodlgs.cpp:1522
eco_report::curr_row
int curr_row
Definition repodlgs.h:225
eco_report::update_report
void update_report()
Definition repodlgs.cpp:1273
eco_report::eco_label
QLabel * eco_label
Definition repodlgs.h:215
eco_report::counter
int counter
Definition repodlgs.h:228
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::rect
QRect rect
Definition repodlgs.h:129
req_tooltip_help::tgov
struct government * tgov
Definition repodlgs.h:133
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:570
research_diagram
Definition repodlgs.h:139
research_diagram::show_tooltip
void show_tooltip()
Definition repodlgs.cpp:818
research_diagram::reset
void reset()
Definition repodlgs.cpp:693
research_diagram::pcanvas
struct canvas * pcanvas
Definition repodlgs.h:155
research_diagram::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition repodlgs.cpp:713
research_diagram::size
QSize size()
Definition repodlgs.cpp:845
research_diagram::timer_active
bool timer_active
Definition repodlgs.h:157
research_diagram::~research_diagram
~research_diagram()
Definition repodlgs.cpp:559
research_diagram::create_tooltip_help
void create_tooltip_help()
Definition repodlgs.cpp:580
research_diagram::req
struct reqtree * req
Definition repodlgs.h:156
research_diagram::tooltip_text
QString tooltip_text
Definition repodlgs.h:162
research_diagram::tt_help
QList< req_tooltip_help * > tt_help
Definition repodlgs.h:160
research_diagram::tooltip_rect
QRect tooltip_rect
Definition repodlgs.h:163
research_diagram::research_diagram
research_diagram(QWidget *parent=0)
Definition repodlgs.cpp:548
research_diagram::height
int height
Definition repodlgs.h:159
research_diagram::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition repodlgs.cpp:760
research_diagram::width
int width
Definition repodlgs.h:158
research_diagram::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:682
research_diagram::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:833
research_diagram::tooltip_pos
QPoint tooltip_pos
Definition repodlgs.h:161
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:514
units_reports::paintEvent
void paintEvent(QPaintEvent *event)
Definition repodlgs.cpp:409
units_reports::drop
static void drop()
Definition repodlgs.cpp:368
units_reports::units_reports
units_reports()
Definition repodlgs.cpp:326
units_reports::cw
close_widget * cw
Definition repodlgs.h:90
units_reports::add_item
void add_item(unittype_item *item)
Definition repodlgs.cpp:350
units_reports::instance
static units_reports * instance()
Definition repodlgs.cpp:358
units_reports::update_menu
virtual void update_menu()
Definition repodlgs.cpp:379
units_reports::update_units
void update_units(bool show=false)
Definition repodlgs.cpp:417
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:388
units_reports::~units_reports
~units_reports()
Definition repodlgs.cpp:340
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:268
unittype_item::unittype_item
unittype_item(QWidget *parent, unit_type *ut)
Definition repodlgs.cpp:96
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:182
unittype_item::init_img
void init_img()
Definition repodlgs.cpp:190
unittype_item::upgrade_units
void upgrade_units()
Definition repodlgs.cpp:201
unittype_item::enterEvent
void enterEvent(QEnterEvent *event)
Definition repodlgs.cpp:239
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:251
unittype_item::wheelEvent
void wheelEvent(QWheelEvent *event)
Definition repodlgs.cpp:277
client_is_global_observer
bool client_is_global_observer(void)
Definition client_main.c:1346
client_is_observer
bool client_is_observer(void)
Definition client_main.c:1086
client
struct civclient client
Definition client_main.c:149
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_has_player
bool client_has_player(void)
Definition client_main.c:1365
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:497
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:518
cid_encode_unit
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:485
cid
int cid
Definition climisc.h:31
unit_focus_set_and_select
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:621
control.h
can_unit_do_activity_client
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:40
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:73
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:347
Impr_type_id
int Impr_type_id
Definition fc_types.h:346
Unit_type_id
int Unit_type_id
Definition fc_types.h:352
O_SHIELD
@ O_SHIELD
Definition fc_types.h:91
O_FOOD
@ O_FOOD
Definition fc_types.h:91
O_GOLD
@ O_GOLD
Definition fc_types.h:91
O_LAST
@ O_LAST
Definition fc_types.h:91
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:57
government_name_translation
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
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:347
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:195
title
const char * title
Definition repodlgs.c:1313
type
GType type
Definition repodlgs.c:1312
get_sprite_dimensions
void get_sprite_dimensions(struct sprite *sprite, int *width, int *height)
Definition sprite.c:107
comp_less_than
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Definition repodlgs.cpp:540
citydlg.h
cityrep.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:4175
helptext_advance
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3115
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:1316
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:1763
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:209
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:192
can_sell_building
bool can_sell_building(const struct impr_type *pimprove)
Definition improvement.c:1064
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:182
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:767
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:241
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:211
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:205
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:443
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:37651
dsend_packet_player_research
int dsend_packet_player_research(struct connection *pc, int tech)
Definition packets_gen.c:37488
dsend_packet_unit_type_upgrade
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
Definition packets_gen.c:45036
science_dialog_text
const char * science_dialog_text(void)
Definition text.c:774
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:840
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:886
players_iterate_end
#define players_iterate_end
Definition player.h:535
players_iterate
#define players_iterate(_pplayer)
Definition player.h:530
science_report_dialog_popup
void science_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1652
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:1745
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:1726
real_economy_report_dialog_update
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.cpp:1679
comp_less_than
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Definition repodlgs.cpp:540
popdown_economy_report
void popdown_economy_report()
Definition repodlgs.cpp:1817
economy_report_dialog_popup
void economy_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1699
popdown_science_report
void popdown_science_report()
Definition repodlgs.cpp:1835
units_report_dialog_popup
void units_report_dialog_popup(bool raise)
Definition repodlgs.cpp:1736
popdown_endgame_report
void popdown_endgame_report()
Definition repodlgs.cpp:1755
science_report_dialog_redraw
void science_report_dialog_redraw(void)
Definition repodlgs.cpp:1798
popdown_units_report
void popdown_units_report()
Definition repodlgs.cpp:1853
toggle_units_report
void toggle_units_report(bool x)
Definition repodlgs.cpp:1861
popup_endgame_report
void popup_endgame_report()
Definition repodlgs.cpp:1768
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:1152
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:1033
get_reqtree_dimensions
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:867
get_tech_on_reqtree
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1170
destroy_reqtree
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:470
create_reqtree
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:836
reqtree.h
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:93
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:91
research_invention_reachable
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:665
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
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
canvas::map_pixmap
QPixmap map_pixmap
Definition canvas.h:25
city
Definition city.h:309
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:213
color
Definition colors.h:20
connection::playing
struct player * playing
Definition connection.h:156
endgame_report
Definition repodlgs.c:1802
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:1565
endgame_report::update_report
void update_report(const struct packet_endgame_player *packet)
Definition repodlgs.cpp:1613
endgame_report::players
int players
Definition repodlgs.h:254
endgame_report::~endgame_report
~endgame_report()
Definition repodlgs.cpp:1595
endgame_report::index
int index
Definition repodlgs.h:253
endgame_report::init
void init()
Definition repodlgs.cpp:1603
img
Definition mapimg.c:367
impr_type
Definition improvement.h:68
improvement_entry
Definition repodlgs_common.h:28
improvement_entry::cost
int cost
Definition repodlgs_common.h:30
improvement_entry::type
struct impr_type * type
Definition repodlgs_common.h:29
improvement_entry::total_cost
int total_cost
Definition repodlgs_common.h:30
improvement_entry::count
int count
Definition repodlgs_common.h:30
improvement_entry::redundant
int redundant
Definition repodlgs_common.h:30
item
Definition climisc.h:80
packet_endgame_player
Definition packets_gen.h:94
packet_endgame_player::category_num
int category_num
Definition packets_gen.h:95
packet_endgame_player::player_id
int player_id
Definition packets_gen.h:96
packet_endgame_player::category_score
int category_score[32]
Definition packets_gen.h:98
packet_endgame_player::score
int score
Definition packets_gen.h:97
packet_endgame_report
Definition packets_gen.h:88
packet_endgame_report::category_name
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:90
packet_endgame_report::category_num
int category_num
Definition packets_gen.h:89
packet_ruleset_control::num_tech_types
int num_tech_types
Definition packets_gen.h:1459
player
Definition player.h:249
qlist_item
Definition repodlgs.h:116
qlist_item::tech_str
QString tech_str
Definition repodlgs.h:117
reqtree
Definition repodlgs.cpp:84
reqtree::num_nodes
int num_nodes
Definition repodlgs.cpp:85
reqtree::nodes
struct tree_node ** nodes
Definition repodlgs.cpp:86
reqtree::layer_size
int * layer_size
Definition repodlgs.cpp:88
reqtree::diagram_height
int diagram_height
Definition repodlgs.cpp:90
reqtree::diagram_width
int diagram_width
Definition repodlgs.cpp:90
reqtree::layers
struct tree_node *** layers
Definition repodlgs.cpp:89
reqtree::num_layers
int num_layers
Definition repodlgs.cpp:87
research::research_invention::state
enum tech_state state
Definition research.h:73
research::research_invention::num_required_techs
int num_required_techs
Definition research.h:80
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:85
research::client
struct research::@75::@77 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:98
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:910
science_report::index
int index
Definition repodlgs.h:197
science_report::init
void init()
Definition repodlgs.cpp:927
science_report::progress
progress_bar * progress
Definition repodlgs.h:179
science_report::science_report
science_report()
Definition repodlgs.cpp:857
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:958
science_report::redraw
void redraw()
Definition repodlgs.cpp:938
science_report::update_reqtree
void update_reqtree()
Definition repodlgs.cpp:1112
science_report::reset_tree
void reset_tree()
Definition repodlgs.cpp:946
science_report::current_tech_changed
void current_tech_changed(int index)
Definition repodlgs.cpp:1120
science_report::goal_tech_changed
void goal_tech_changed(int index)
Definition repodlgs.cpp:1136
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:459
tree_node
Definition repodlgs.cpp:69
tree_node::tech
Tech_type_id tech
Definition repodlgs.cpp:71
tree_node::nprovide
int nprovide
Definition repodlgs.cpp:74
tree_node::number
int number
Definition repodlgs.cpp:78
tree_node::provide
struct tree_node ** provide
Definition repodlgs.cpp:75
tree_node::node_width
int node_width
Definition repodlgs.cpp:77
tree_node::node_y
int node_y
Definition repodlgs.cpp:77
tree_node::layer
int layer
Definition repodlgs.cpp:76
tree_node::node_x
int node_x
Definition repodlgs.cpp:77
tree_node::order
int order
Definition repodlgs.cpp:76
tree_node::is_dummy
bool is_dummy
Definition repodlgs.cpp:70
tree_node::node_height
int node_height
Definition repodlgs.cpp:77
tree_node::nrequire
int nrequire
Definition repodlgs.cpp:72
tree_node::require
struct tree_node ** require
Definition repodlgs.cpp:73
unit_entry
Definition repodlgs_common.h:34
unit_entry::total_cost
int total_cost
Definition repodlgs_common.h:36
unit_entry::type
struct unit_type * type
Definition repodlgs_common.h:35
unit_entry::count
int count
Definition repodlgs_common.h:36
unit_entry::cost
int cost
Definition repodlgs_common.h:36
unit_type
Definition unittype.h:481
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:756
universal::kind
enum universals_n kind
Definition fc_types.h:758
universal::value
universals_u value
Definition fc_types.h:757
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
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_end
#define advance_index_iterate_end
Definition tech.h:248
A_FIRST
#define A_FIRST
Definition tech.h:44
A_UNSET
#define A_UNSET
Definition tech.h:48
advance_index_iterate
#define advance_index_iterate(_start, _index)
Definition tech.h:244
get_science_target_text
const char * get_science_target_text(double *percent)
Definition text.c:853
get_science_goal_text
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:899
text.h
get_government_sprite
struct sprite * get_government_sprite(const struct tileset *t, const struct government *gov)
Definition tilespec.c:6508
get_building_sprite
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6498
get_tileset
struct tileset * get_tileset(void)
Definition tilespec.c:655
get_unittype_sprite
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6520
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 *what, const char *name, bool scale)
Definition tilespec.c:3462
get_tax_sprite
struct sprite * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Definition tilespec.c:6579
get_nation_flag_sprite
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6471
get_tech_sprite
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6489
tilespec.h
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:604
universals_u::building
const struct impr_type * building
Definition fc_types.h:598
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
can_upgrade_unittype
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1755
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:1612
unit_upgrade_price
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1783
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
U_LAST
#define U_LAST
Definition unittype.h:40
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845
show
#define show(id)
Definition widget.h:235
hide
#define hide(id)
Definition widget.h:238