Freeciv-3.2
Loading...
Searching...
No Matches
diplodlg.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 <QCloseEvent>
21#include <QGridLayout>
22#include <QHeaderView>
23#include <QLabel>
24#include <QMenu>
25#include <QSpinBox>
26#include <QPainter>
27#include <QPushButton>
28
29// common
30#include "government.h"
31#include "player.h"
32
33// client
34#include "client_main.h"
35#include "svgflag.h"
36
37// gui-qt
38#include "colors.h"
39#include "diplodlg.h"
40#include "fc_client.h"
41#include "gui_main.h"
42#include "sidebar.h"
43
44extern "C" {
45 int client_player_number(void);
46 struct player *player_by_number(const int player_id);
47}
48
50typedef city *p_city;
51
52#define FLAG_HEIGHT_DIPLDLG 150
53
54/************************************************************************/
58 struct player *they, struct player *initiator): QWidget()
59{
60 struct player *we;
61 color *colr;
62 QString text;
65 QLabel *plr1_label;
66 QLabel *plr2_label;
67 QLabel *label;
68 QLabel *label2;
69 QLabel *label3;
70 QLabel *label4;
71 QPushButton *add_clause1;
72 QPushButton *add_clause2;
74 struct sprite *sprite, *sprite2;
75 char plr_buf[4 * MAX_LEN_NAME];
76 const struct player_diplstate *state;
77 QHeaderView *header;
78 struct color *textcolors[2] = {
81 };
82 int clause_column;
83 bool svg = is_svg_flag_enabled();
84
85 if (they == initiator) {
86 we = client_player();
87 } else {
88 we = initiator;
89 }
90 p1_accept = false;
91 p2_accept = false;
92 plr1 = we;
93 plr2 = they;
94 layout = new QGridLayout;
95
99 if (state->turns_left > 0) {
100 text_tooltip = text_tooltip + " (";
101 text_tooltip = text_tooltip + QString(PL_("%1 turn left",
102 "%1 turns left",
103 state->turns_left))
104 .arg(state->turns_left);
106 }
107 label3 = new QLabel;
108 text = "<b><h3><center>"
110 .toHtmlEscaped()
111 + "</center></h3></b>";
113 text = "<style>h3{background-color: "
114 + colr->qcolor.name() + ";" + "color: " + color_best_contrast(colr,
116 + "}</style>" + text;
117 label3->setText(text);
118 label3->setMinimumWidth(300);
119 label4 = new QLabel;
120 text = "<b><h3><center>"
122 .toHtmlEscaped()
123 + "</center></h3></b></body>";
125 text = "<style>h3{background-color: "
126 + colr->qcolor.name() + ";" + "color: " + color_best_contrast(colr,
128 + "}</style>" + text;
129 label4->setMinimumWidth(300);
130 label4->setText(text);
131 layout->addWidget(label3, 0, 5);
132 layout->addWidget(label4, 5, 5);
133 plr1_label = new QLabel;
134 label = new QLabel;
137 if (sprite != NULL) {
138 if (svg) {
139 plr1_label->setPixmap(sprite->pm->scaledToHeight(FLAG_HEIGHT_DIPLDLG));
140 } else {
141 plr1_label->setPixmap(*sprite->pm);
142 }
143 } else {
144 plr1_label->setText("FLAG MISSING");
145 }
146 text = ruler_title_for_player(we, plr_buf, sizeof(plr_buf));
147 text = "<b><center>" + text.toHtmlEscaped() + "</center></b>";
148 label->setText(text);
149 plr1_accept = new QLabel;
150 layout->addWidget(plr1_label, 1, 0);
151 layout->addWidget(label, 1, 5);
152 layout->addWidget(plr1_accept, 1, 10);
153 label2 = new QLabel;
156 plr2_label = new QLabel;
157 if (sprite2 != NULL) {
158 if (svg) {
159 plr2_label->setPixmap(sprite2->pm->scaledToHeight(FLAG_HEIGHT_DIPLDLG));
160 } else {
161 plr2_label->setPixmap(*sprite2->pm);
162 }
163 } else {
164 plr2_label->setText("FLAG MISSING");
165 }
167 text2 = "<b><center>" + text2.toHtmlEscaped() + "</center></b>";
168 label2->setText(text2);
169 plr2_accept = new QLabel;
170 layout->addWidget(plr2_label, 6, 0);
171 layout->addWidget(label2, 6, 5);
172 layout->addWidget(plr2_accept, 6, 10);
173
175 QLabel *goldlab1;
176 QLabel *goldlab2;
179
180 goldlab1 = new QLabel(_("Gold:"));
181 goldlab1->setAlignment(Qt::AlignRight);
182 goldlab2 = new QLabel(_("Gold:"));
183 goldlab2->setAlignment(Qt::AlignRight);
184 gold_edit1 = new QSpinBox;
185 gold_edit2 = new QSpinBox;
186 gold_edit1->setMinimum(0);
187 gold_edit2->setMinimum(0);
188 gold_edit1->setFocusPolicy(Qt::ClickFocus);
189 gold_edit2->setFocusPolicy(Qt::ClickFocus);
190 gold_edit2->setMaximum(we->economic.gold);
191 gold_edit1->setMaximum(they->economic.gold);
192 connect(gold_edit1, SIGNAL(valueChanged(int)), SLOT(gold_changed1(int)));
193 connect(gold_edit2, SIGNAL(valueChanged(int)), SLOT(gold_changed2(int)));
194 layout->addWidget(goldlab1, 7, 4);
195 layout->addWidget(goldlab2, 3, 4);
196 layout->addWidget(gold_edit1, 7, 5);
197 layout->addWidget(gold_edit2, 3, 5);
198 clause_column = 6;
199 } else {
200 clause_column = 5;
201 }
202
203 add_clause1 = new QPushButton(style()->standardIcon(QStyle::SP_ArrowRight),
204 _("Add Clause..."));
205 add_clause2 = new QPushButton(style()->standardIcon(QStyle::SP_ArrowRight),
206 _("Add Clause..."));
207 add_clause1->setFocusPolicy(Qt::ClickFocus);
208 add_clause2->setFocusPolicy(Qt::ClickFocus);
209 connect(add_clause1, &QAbstractButton::clicked, this, &diplo_wdg::show_menu_p2);
210 connect(add_clause2, &QAbstractButton::clicked, this, &diplo_wdg::show_menu_p1);
211 layout->addWidget(add_clause1, 7, clause_column);
212 layout->addWidget(add_clause2, 3, clause_column);
213
214 text_edit = new QTableWidget();
215 text_edit->setColumnCount(1);
216 text_edit->setProperty("showGrid", "false");
217 text_edit->setProperty("selectionBehavior", "SelectRows");
218 text_edit->setEditTriggers(QAbstractItemView::NoEditTriggers);
219 text_edit->verticalHeader()->setVisible(false);
220 text_edit->horizontalHeader()->setVisible(false);
221 text_edit->setSelectionMode(QAbstractItemView::SingleSelection);
222 text_edit->setFocusPolicy(Qt::NoFocus);
223 header = text_edit->horizontalHeader();
224 header->setStretchLastSection(true);
225 connect(text_edit, &QTableWidget::itemDoubleClicked,
226 this, &diplo_wdg::dbl_click);
227 text_edit->clearContents();
228 text_edit->setRowCount(0);
229 layout->addWidget(text_edit, 9, 0, 8, 11);
231 new QPushButton(style()->standardIcon(QStyle::SP_DialogYesButton),
232 _("Accept treaty"));
234 new QPushButton(style()->standardIcon(QStyle::SP_DialogNoButton),
235 _("Cancel meeting"));
236 connect(accept_treaty, &QAbstractButton::clicked, this, &diplo_wdg::response_accept);
237 connect(cancel_treaty, &QAbstractButton::clicked, this, &diplo_wdg::response_cancel);
238 layout->addWidget(accept_treaty, 17, 5);
239 layout->addWidget(cancel_treaty, 17, 6);
240
241 if (client_player() != they) {
242 label4->setToolTip(text_tooltip);
243 plr2_label->setToolTip(text_tooltip);
244 }
245 if (client_player() != we) {
246 label3->setToolTip(text_tooltip);
247 plr1_label->setToolTip(text_tooltip);
248 }
249
250 accept_treaty->setAutoDefault(true);
251 accept_treaty->setDefault(true);
252 cancel_treaty->setAutoDefault(true);
254 update_wdg();
255}
256
257/************************************************************************/
263
264/************************************************************************/
268{
269 int i, r;
270
271 r = item->row();
272 i = 0;
274 if (i == r) {
277 player_number(pclause->from),
278 pclause->type,
279 pclause->value);
280 return;
281 }
282 i++;
284}
285
286/************************************************************************/
290{
291 if (C_S_RUNNING == client_state()) {
293 }
294 event->accept();
295}
296
297/************************************************************************/
307
308/************************************************************************/
318
319/************************************************************************/
322void diplo_wdg::show_menu(struct player *pplayer)
323{
324 struct player *other_player;
325 struct player *pgiver, *pother;
326 enum diplstate_type ds;
329 QMap <QString, int>city_list;
330 QMap <QString, int>::const_iterator city_iter;
332 QMap <QString, Tech_type_id>::const_iterator adv_iter;
333 QMenu *map_menu = nullptr;
334 QMenu *adv_menu, *city_menu, *pacts_menu;
335 QMenu *menu = new QMenu(this);
336 int id;
337
338 curr_player = pplayer;
339 if (curr_player == plr1) {
340 other_player = plr2;
341 } else {
342 other_player = plr1;
343 }
344 pgiver = pplayer;
345 pother = other_player;
346
347 // Maps
350
351 map_menu = menu->addMenu(_("Maps"));
352 world_map = new QAction(_("World-map"), this);
353 connect(world_map, &QAction::triggered, this, &diplo_wdg::world_map_clause);
354 map_menu->addAction(world_map);
355 }
356
359
360 if (map_menu == nullptr) {
361 map_menu = menu->addMenu(_("Maps"));
362 }
363
364 sea_map = new QAction(_("Sea-map"), this);
365 connect(sea_map, &QAction::triggered, this, &diplo_wdg::sea_map_clause);
366 map_menu->addAction(sea_map);
367 }
368
369 // Trading: advances
371 const struct research *gresearch = research_get(pgiver);
372 const struct research *oresearch = research_get(pother);
373
374 adv_menu = menu->addMenu(_("Advances"));
377
383 == TECH_PREREQS_KNOWN)) {
385 }
387
388 // All advances
389 all_advancs = new QAction(_("All advances"), this);
390 connect(all_advancs, &QAction::triggered, this, &diplo_wdg::all_advances);
391 adv_menu->addAction(all_advancs);
392 adv_menu->addSeparator();
393
394 // QMap is sorted by default when iterating
395 adv_iter = adv_list.constBegin();
396 if (adv_list.count() > 0) {
397 while (adv_iter != adv_list.constEnd()) {
398 id = adv_iter.value();
399 some_action = adv_menu->addAction(adv_iter.key());
400 connect(some_action, &QAction::triggered, this,
402 give_advance(id);
403 });
404 adv_iter++;
405 }
406 } else {
407 adv_menu->setDisabled(true);
408 }
409
410 }
411
412 // Trading: cities.
414 city_menu = menu->addMenu(_("Cities"));
415
416 city_list_iterate(pgiver->cities, pcity) {
417 if (!is_capital(pcity)) {
418 city_list.insert(pcity->name, pcity->id);
419 }
421 city_iter = city_list.constBegin();
422 if (city_list.count() > 0) {
423 while (city_iter != city_list.constEnd()) {
424 id = city_iter.value();
425 some_action = city_menu->addAction(city_iter.key());
426 connect(some_action, &QAction::triggered, this,
428 give_city(id);
429 });
430 city_iter++;
431 }
432 } else {
433 city_menu->setDisabled(true);
434 }
435 }
436
438 some_action = new QAction(_("Give shared vision"), this);
439 connect(some_action, &QAction::triggered, this,
441 menu->addAction(some_action);
443 some_action->setDisabled(true);
444 }
445 }
446
448 some_action = new QAction(_("Give embassy"), this);
449 connect(some_action, &QAction::triggered, this, &diplo_wdg::give_embassy);
450 menu->addAction(some_action);
452 some_action->setDisabled(true);
453 }
454 }
455
456 // Pacts
457 if (curr_player == client_player()) {
458 pacts_menu = menu->addMenu(_("Pacts"));
460
462 some_action = new QAction(Q_("?diplomatic_state:Cease-fire"), this);
463 connect(some_action, &QAction::triggered, this, &diplo_wdg::pact_ceasfire);
464 pacts_menu->addAction(some_action);
465 if (ds == DS_CEASEFIRE || ds == DS_TEAM) {
466 some_action->setDisabled(true);
467 }
468 }
469
471 some_action = new QAction(Q_("?diplomatic_state:Peace"), this);
472 connect(some_action, &QAction::triggered, this, &diplo_wdg::pact_peace);
473 pacts_menu->addAction(some_action);
474 if (ds == DS_PEACE || ds == DS_TEAM) {
475 some_action->setDisabled(true);
476 }
477 }
478
480 some_action = new QAction(Q_("?diplomatic_state:Alliance"), this);
481 connect(some_action, &QAction::triggered, this, &diplo_wdg::pact_allianze);
482 pacts_menu->addAction(some_action);
483 if (ds == DS_ALLIANCE || ds == DS_TEAM) {
484 some_action->setDisabled(true);
485 }
486 }
487 }
488
489 // Check user response for not defined responses in slots
490 menu->setAttribute(Qt::WA_DeleteOnClose);
491 menu->popup(QCursor::pos());
492}
493
494/************************************************************************/
504
505/************************************************************************/
515
516/************************************************************************/
526
527/************************************************************************/
537
538/************************************************************************/
548
549/************************************************************************/
559
560/************************************************************************/
570
571/************************************************************************/
575{
576 struct player *giver, *dest, *other;
577
578 giver = curr_player;
579 if (curr_player == plr1) {
580 dest = plr2;
581 } else {
582 dest = plr1;
583 }
584
585 if (giver == client_player()) {
586 other = dest;
587 } else {
588 other = giver;
589 }
590
592 player_number(giver),
594}
595
596/************************************************************************/
600{
601 struct player *giver, *dest, *other;
602
603 giver = curr_player;
604 if (curr_player == plr1) {
605 dest = plr2;
606 } else {
607 dest = plr1;
608 }
609
610 if (giver == client_player()) {
611 other = dest;
612 } else {
613 other = giver;
614 }
615
617 player_number(giver),
618 CLAUSE_ADVANCE, tech);
619}
620
621/************************************************************************/
625{
626 struct player *giver, *dest, *other;
627 const struct research *dresearch, *gresearch;
628
629 giver = curr_player;
630 if (curr_player == plr1) {
631 dest = plr2;
632 } else {
633 dest = plr1;
634 }
635
636 if (giver == client_player()) {
637 other = dest;
638 } else {
639 other = giver;
640 }
641
642 // All techs.
643
644 dresearch = research_get(dest);
645 gresearch = research_get(giver);
646
649
655 == TECH_PREREQS_KNOWN)) {
657 player_number(giver),
659 }
661}
662
663/************************************************************************/
670
671/************************************************************************/
678
679/************************************************************************/
683{
684 index = ind;
685}
686
687/************************************************************************/
691{
692 return index;
693}
694
695/************************************************************************/
699{
700 bool blank;
701 int i;
702 struct sprite *sprite;
703 QPixmap *pix = NULL;
705
706 blank = true;
707 text_edit->clearContents();
708 text_edit->setRowCount(0);
709 i = 0;
711 char buf[128];
712
714 text_edit->insertRow(i);
715 qitem = new QTableWidgetItem();
716 qitem->setText(buf);
717 qitem->setTextAlignment(Qt::AlignLeft);
718 text_edit->setItem(i, 0, qitem);
719 blank = false;
720 i++;
722
723 if (blank) {
724 text_edit->insertRow(0);
725 qitem = new QTableWidgetItem();
726 qitem->setText(_("--- This treaty is blank. "
727 "Please add some clauses. ---"));
728 qitem->setTextAlignment(Qt::AlignLeft);
729 text_edit->setItem(0, 0, qitem);
730 }
731
733 if (sprite != NULL) {
734 pix = sprite->pm;
735 plr1_accept->setPixmap(*pix);
736 } else {
737 plr1_accept->setText("PIXMAP MISSING");
738 }
739
741 if (sprite != NULL) {
742 pix = sprite->pm;
743 plr2_accept->setPixmap(*pix);
744 } else {
745 plr2_accept->setText("PIXMAP MISSING");
746 }
747}
748
749/************************************************************************/
753{
754 gui()->sw_diplo->set_pixmap(fc_icons::instance()->get_pixmap("nations"));
755 gui()->sw_diplo->resize_pixmap(gui()->sw_diplo->width(),
756 gui()->sw_diplo->height());
757 gui()->sw_diplo->set_custom_labels(QString());
758 gui()->sw_diplo->update_final_pixmap();
759}
760
761/************************************************************************/
770
771/************************************************************************/
780
781/************************************************************************/
785 struct player *initiator) : QTabWidget()
786{
788 setFocusPolicy(Qt::ClickFocus);
789}
790
791/************************************************************************/
795 struct player *initiator)
796{
797 diplo_wdg *dw;
798 struct sprite *sprite;
799 QPixmap *pix;
800 int i;
801
802 pix = NULL;
804 treaty_list.insert(they, dw);
806 dw->set_index(i);
809 if (sprite != NULL) {
810 pix = sprite->pm;
811 }
812 if (pix != NULL) {
813 setTabIcon(i, QIcon(*pix));
814 }
815}
816
817/************************************************************************/
821{
822 QWidget *w;
823
824 w = find_widget(party);
825 if (w == nullptr) {
826 return;
827 }
829}
830
831/************************************************************************/
835{
837 return false;
838 }
839 if (!is_human(client_player())) {
840 return false;
841 }
842 setAttribute(Qt::WA_DeleteOnClose);
843 gui()->gimme_place(this, "DDI");
844 index = gui()->add_game_tab(this);
845 gui()->game_tab_widget->setCurrentIndex(index);
846
847 return true;
848}
849
850/************************************************************************/
854{
856 diplo_wdg *dw;
857
858 while (i.hasNext()) {
859 i.next();
860 dw = i.value();
861 dw->close();
862 removeTab(dw->get_index());
863 dw->deleteLater();
864 }
865 gui()->remove_repo_dlg("DDI");
866 gui()->game_tab_widget->setCurrentIndex(0);
867}
868
869/************************************************************************/
873{
874 return treaty_list.value(they);
875}
876
877/************************************************************************/
881{
882 diplo_wdg *dw;
883
884 dw = treaty_list.take(they);
885 removeTab(dw->get_index());
886 dw->deleteLater();
887 if (treaty_list.isEmpty()) {
888 close();
889 }
890}
891
892/************************************************************************/
896{
898 diplo_wdg *dw;
899
900 while (i.hasNext()) {
901 i.next();
902 dw = i.value();
903 dw->update_wdg();
904 }
905}
906
907/************************************************************************/
911{
912 raise();
913}
914
915/************************************************************************/
920{
921 int i;
922 diplo_dlg *dd;
923 diplo_wdg *dw;
924 QWidget *w;
925
926 if (!gui()->is_repo_dlg_open("DDI")) {
927 return;
928 }
929 i = gui()->gimme_index_of("DDI");
930 fc_assert(i != -1);
931 w = gui()->game_tab_widget->widget(i);
933 dw = dd->find_widget(they);
934
935 fc_assert(dw->treaty == ptreaty);
936
937 dw->update_wdg();
938}
939
940/************************************************************************/
945 struct player *initiator)
946{
947 int i;
948 diplo_dlg *dd;
949 QPainter p;
950 QPixmap *pix, *def_pix, *pix2, *pix3, *def_pix_del;
951 QWidget *w;
952 QWidget *fw;
953 bool was_open;
954
955 if (client_is_observer()) {
956 return;
957 }
958
959 if (gui()->current_page() != PAGE_GAME) {
960 gui()->switch_page(PAGE_GAME);
961 }
962
963 pix2 = new QPixmap();
964 def_pix_del = new QPixmap();
967 *pix2 = pix->scaledToWidth(gui()->sw_diplo->width() - 2,
968 Qt::SmoothTransformation);
969 if (pix2->height() > gui()->sw_diplo->height()) {
970 *pix2 = pix->scaledToHeight(gui()->sw_diplo->height(),
971 Qt::SmoothTransformation);
972 }
973 pix3 = new QPixmap(gui()->sw_diplo->width(), gui()->sw_diplo->height());
974 pix3->fill(Qt::transparent);
975 def_pix = fc_icons::instance()->get_pixmap("nations");
976 *def_pix_del = def_pix->scaled(gui()->sw_diplo->width(),
977 gui()->sw_diplo->height(),
978 Qt::IgnoreAspectRatio,
979 Qt::SmoothTransformation);
980 p.begin(pix3);
981 p.drawPixmap(1, 1, *pix2);
982 p.drawPixmap(0, 0, *def_pix_del);
983 p.end();
984 gui()->sw_diplo->set_pixmap(pix3);
985 gui()->sw_diplo->resize_pixmap(gui()->sw_diplo->width(),
986 gui()->sw_diplo->height());
987 gui()->sw_diplo->set_custom_labels(QString(nation_plural_for_player(
988 they)));
989 gui()->sw_diplo->update_final_pixmap();
990 delete pix2;
991 delete def_pix;
992 delete def_pix_del;
993
994 was_open = gui()->is_repo_dlg_open("DDI");
995 if (!was_open) {
997
998 if (!dd->init(false)) {
999 delete dd;
1000 return;
1001 }
1002 dd->update_dlg();
1003 dd->make_active(they);
1004 }
1005 i = gui()->gimme_index_of("DDI");
1006 fc_assert(i != -1);
1007 w = gui()->game_tab_widget->widget(i);
1009
1010 if (was_open) {
1011 dd->reactivate();
1012 }
1013
1014 fw = dd->find_widget(they);
1015 if (fw == NULL) {
1016 dd->add_widget(ptreaty, they, initiator);
1017 gui()->game_tab_widget->setCurrentIndex(i);
1018 }
1019 dd->make_active(they);
1020
1021 // Bring it to front if user requested meeting
1022 if (initiator == client_player()) {
1023 gui()->game_tab_widget->setCurrentIndex(i);
1024 }
1025}
1026
1027/**********************************************************************/
1031{
1032 // Not needed
1033}
1034
1035/************************************************************************/
1039{
1040 int i;
1041 diplo_dlg *dd;
1042 diplo_wdg *dw;
1043 QWidget *w;
1044
1045 if (!gui()->is_repo_dlg_open("DDI")) {
1046 log_normal("DDI not open");
1047 return;
1048 }
1049 i = gui()->gimme_index_of("DDI");
1050 fc_assert(i != -1);
1051 w = gui()->game_tab_widget->widget(i);
1053 dw = dd->find_widget(they);
1054 fc_assert(dw->treaty == ptreaty);
1055 dw->update_wdg();
1056}
1057
1058/************************************************************************/
1063 struct player *initiator)
1064{
1065 int i;
1066 diplo_dlg *dd;
1067 QWidget *w;
1068
1069 if (!gui()->is_repo_dlg_open("DDI")) {
1070 return;
1071 }
1072 i = gui()->gimme_index_of("DDI");
1073 fc_assert(i != -1);
1074 w = gui()->game_tab_widget->widget(i);
1076 dd->close_widget(they);
1077}
1078
1079/************************************************************************/
1083{
1084 int i;
1085 diplo_dlg *dd;
1086 diplo_wdg *dw;
1087 QWidget *w;
1088
1089 if (!gui()->is_repo_dlg_open("DDI")) {
1090 return;
1091 }
1092
1093 i = gui()->gimme_index_of("DDI");
1094 fc_assert(i != -1);
1095 w = gui()->game_tab_widget->widget(i);
1097 dw = dd->find_widget(they);
1098 fc_assert(dw->treaty == ptreaty);
1099 dw->update_wdg();
1100}
1101
1102/************************************************************************/
1108{
1109 int i;
1110 diplo_dlg *dd;
1111 QWidget *w;
1112
1113 current_app()->alert(gui()->central_wdg);
1114 if (!gui()->is_repo_dlg_open("DDI")) {
1115 return;
1116 }
1117 i = gui()->gimme_index_of("DDI");
1118 fc_assert(i != -1);
1119 w = gui()->game_tab_widget->widget(i);
1121 dd->close();
1122 delete dd;
1123}
bool is_capital(const struct city *pcity)
Definition city.c:1579
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define city_list_iterate_end
Definition city.h:510
void close_widget(struct player *they)
Definition diplodlg.cpp:880
diplo_dlg(struct Treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.cpp:784
void update_dlg()
Definition diplodlg.cpp:895
QMap< struct player *, diplo_wdg * > treaty_list
Definition diplodlg.h:107
bool init(bool raise)
Definition diplodlg.cpp:834
void make_active(struct player *party)
Definition diplodlg.cpp:820
int index
Definition diplodlg.h:123
void reactivate()
Definition diplodlg.cpp:910
diplo_wdg * find_widget(struct player *they)
Definition diplodlg.cpp:872
void add_widget(struct Treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.cpp:794
struct player * curr_player
Definition diplodlg.h:95
void response_accept()
Definition diplodlg.cpp:764
void pact_ceasfire()
Definition diplodlg.cpp:530
bool p2_accept
Definition diplodlg.h:97
void show_menu_p1()
Definition diplodlg.cpp:674
void give_embassy()
Definition diplodlg.cpp:497
QLabel * plr2_accept
Definition diplodlg.h:54
void gold_changed1(int val)
Definition diplodlg.cpp:300
void world_map_clause()
Definition diplodlg.cpp:563
void show_menu(struct player *pplayer)
Definition diplodlg.cpp:322
void gold_changed2(int val)
Definition diplodlg.cpp:311
diplo_wdg(struct Treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.cpp:57
int get_index()
Definition diplodlg.cpp:690
void pact_allianze()
Definition diplodlg.cpp:519
void closeEvent(QCloseEvent *event)
Definition diplodlg.cpp:289
void all_advances()
Definition diplodlg.cpp:624
QPushButton * cancel_treaty
Definition diplodlg.h:56
struct Treaty * treaty
Definition diplodlg.h:66
void sea_map_clause()
Definition diplodlg.cpp:552
void give_shared_vision()
Definition diplodlg.cpp:508
void give_city(int city_num)
Definition diplodlg.cpp:574
void response_cancel()
Definition diplodlg.cpp:774
struct player * plr1
Definition diplodlg.h:92
void dbl_click(QTableWidgetItem *item)
Definition diplodlg.cpp:267
void show_menu_p2()
Definition diplodlg.cpp:666
void update_wdg()
Definition diplodlg.cpp:698
struct player * plr2
Definition diplodlg.h:93
int index
Definition diplodlg.h:98
void restore_pixmap()
Definition diplodlg.cpp:752
bool p1_accept
Definition diplodlg.h:96
QPushButton * accept_treaty
Definition diplodlg.h:55
void give_advance(int tech)
Definition diplodlg.cpp:599
QGridLayout * layout
Definition diplodlg.h:52
void pact_peace()
Definition diplodlg.cpp:541
void set_index(int ind)
Definition diplodlg.cpp:682
QLabel * plr1_accept
Definition diplodlg.h:53
QPixmap * get_pixmap(const QString &id)
static fc_icons * instance()
bool client_is_observer(void)
struct civclient client
enum client_states client_state(void)
bool can_client_issue_orders(void)
const char * title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
#define client_player()
@ C_S_RUNNING
Definition client_main.h:47
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
struct color * color_best_contrast(struct color *subject, struct color **candidates, int ncandidates)
struct color * get_player_color(const struct tileset *t, const struct player *pplayer)
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
char * incite_cost
Definition comments.c:75
void qtg_recv_create_clause(struct Treaty *ptreaty, struct player *they)
city * p_city
Definition diplodlg.cpp:50
void qtg_recv_accept_treaty(struct Treaty *ptreaty, struct player *they)
Definition diplodlg.cpp:919
struct player * player_by_number(const int player_id)
Definition player.c:849
void qtg_prepare_clause_updt(struct Treaty *ptreaty, struct player *they)
void qtg_init_meeting(struct Treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.cpp:944
#define FLAG_HEIGHT_DIPLDLG
Definition diplodlg.cpp:52
int client_player_number(void)
void qtg_recv_cancel_meeting(struct Treaty *ptreaty, struct player *they, struct player *initiator)
void close_all_diplomacy_dialogs(void)
advance * p_advance
Definition diplodlg.cpp:49
void qtg_recv_remove_clause(struct Treaty *ptreaty, struct player *they)
struct Treaty * ptreaty
Definition diplodlg_g.h:28
struct Treaty struct player * they
Definition diplodlg_g.h:28
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:289
#define clause_list_iterate_end
Definition diptreaty.h:70
#define clause_list_iterate(clauselist, pclause)
Definition diptreaty.h:68
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int Tech_type_id
Definition fc_types.h:377
#define MAX_LEN_NAME
Definition fc_types.h:66
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:62
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:391
static enum client_pages current_page
Definition pages.c:78
#define CAPTURE_DEFAULT_THIS
Definition gui_main.h:31
QApplication * current_app()
Definition gui_main.cpp:229
#define fc_assert(condition)
Definition log.h:176
#define log_normal(message,...)
Definition log.h:107
static mpgui * gui
Definition mpgui_qt.cpp:52
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
int player_number(const struct player *pplayer)
Definition player.c:837
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:240
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1485
#define is_human(plr)
Definition player.h:229
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
#define ARRAY_SIZE(x)
Definition shared.h:85
bool accept0
Definition diptreaty.h:80
bool accept1
Definition diptreaty.h:80
struct clause_list * clauses
Definition diptreaty.h:81
struct player * plr1
Definition diptreaty.h:79
Definition city.h:320
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
Definition colors.h:21
QColor qcolor
Definition colors.h:25
Definition climisc.h:82
bool tech_trade_allow_holes
enum diplstate_type type
Definition player.h:197
QPixmap * pm
Definition sprite.h:25
#define is_svg_flag_enabled()
Definition svgflag.h:30
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_iterate(_p)
Definition tech.h:275
#define advance_iterate_end
Definition tech.h:276
struct sprite * get_treaty_thumb_sprite(const struct tileset *t, bool on_off)
Definition tilespec.c:6909
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6756