Freeciv-3.2
Loading...
Searching...
No Matches
diplodlg.c
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/* SDL3 */
19#include <SDL3/SDL.h>
20
21/* utility */
22#include "fcintl.h"
23#include "log.h"
24
25/* common */
26#include "diptreaty.h"
27#include "game.h"
28#include "research.h"
29
30/* client */
31#include "client_main.h"
32#include "climisc.h"
33#include "packhand.h"
34
35/* gui-sdl3 */
36#include "chatline.h"
37#include "colors.h"
38#include "dialogs.h"
39#include "graphics.h"
40#include "gui_id.h"
41#include "gui_main.h"
42#include "gui_tilespec.h"
43#include "mapview.h"
44#include "themespec.h"
45#include "widget.h"
46
47#include "diplodlg.h"
48
49struct diplomacy_dialog {
50 struct Treaty *treaty;
52 struct advanced_dialog *pwants;
54};
55
56#define SPECLIST_TAG dialog
57#define SPECLIST_TYPE struct diplomacy_dialog
58#include "speclist.h"
59
60#define dialog_list_iterate(dialoglist, pdialog) \
61 TYPED_LIST_ITERATE(struct diplomacy_dialog, dialoglist, pdialog)
62#define dialog_list_iterate_end LIST_ITERATE_END
63
64static struct dialog_list *dialog_list;
65
66static void update_diplomacy_dialog(struct diplomacy_dialog *pdialog);
67static void update_acceptance_icons(struct diplomacy_dialog *pdialog);
68static void update_clauses_list(struct diplomacy_dialog *pdialog);
70 struct player *giver,
71 enum clause_type type, int value);
72static void popdown_diplomacy_dialog(struct diplomacy_dialog *pdialog);
73static void popdown_diplomacy_dialogs(void);
74static void popdown_sdip_dialog(void);
75
76/**********************************************************************/
83
84/**********************************************************************/
91
92/**********************************************************************/
96{
97 struct player *we = client_player();
98
100 if ((pdialog->treaty->plr0 == we && pdialog->treaty->plr1 == they)
101 || (pdialog->treaty->plr0 == they && pdialog->treaty->plr1 == we)) {
102 return pdialog;
103 }
105
106 return NULL;
107}
108
109/**********************************************************************/
114{
116
117 if (!pdialog) {
118 return;
119 }
120
121 fc_assert(pdialog->treaty == ptreaty);
122
124}
125
126/**********************************************************************/
141
142/* ----------------------------------------------------------------------- */
143
144/**********************************************************************/
147static int remove_clause_callback(struct widget *pwidget)
148{
151
154 }
155
157 player_number(pdialog->treaty->plr1),
158 pwidget->data.cont->id0,
159 (enum clause_type) ((pwidget->data.
160 cont->value >> 16) & 0xFFFF),
161 pwidget->data.cont->value & 0xFFFF);
162 }
163
164 return -1;
165}
166
167/**********************************************************************/
171{
173
174 if (!pdialog) {
175 return;
176 }
177
178 fc_assert(pdialog->treaty == ptreaty);
179
180 clause_list_iterate(pdialog->treaty->clauses, pclause) {
182 pclause->from,
183 pclause->type,
184 pclause->value);
186}
187
188/**********************************************************************/
192{
194
195 if (!pdialog) {
196 return;
197 }
198
199 fc_assert(pdialog->treaty == ptreaty);
200
203}
204
205/**********************************************************************/
209{
211
212 if (!pdialog) {
213 return;
214 }
215
218}
219
220/* ================================================================= */
221
222/**********************************************************************/
225static int cancel_meeting_callback(struct widget *pwidget)
226{
229 pwidget->data.cont->id1);
230 }
231
232 return -1;
233}
234
235/**********************************************************************/
238static int accept_treaty_callback(struct widget *pwidget)
239{
242 pwidget->data.cont->id1);
243 }
244
245 return -1;
246}
247
248/* ------------------------------------------------------------------------ */
249
250/**********************************************************************/
253static int pact_callback(struct widget *pwidget)
254{
256 int clause_type;
258
261 }
262
263 switch (MAX_ID - pwidget->id) {
264 case 2:
266 break;
267 case 1:
269 break;
270 default:
272 break;
273 }
274
276 player_number(pdialog->treaty->plr1),
277 pwidget->data.cont->id0,
278 clause_type, 0);
279 }
280
281 return -1;
282}
283
284/**********************************************************************/
287static int vision_callback(struct widget *pwidget)
288{
291
294 }
295
297 player_number(pdialog->treaty->plr1),
298 pwidget->data.cont->id0,
299 CLAUSE_VISION, 0);
300 }
301
302 return -1;
303}
304
305/**********************************************************************/
308static int embassy_callback(struct widget *pwidget)
309{
312
315 }
316
318 player_number(pdialog->treaty->plr1),
319 pwidget->data.cont->id0,
320 CLAUSE_EMBASSY, 0);
321 }
322
323 return -1;
324}
325
326/**********************************************************************/
329static int shared_tiles_callback(struct widget *pwidget)
330{
333
336 }
337
339 player_number(pdialog->treaty->plr1),
340 pwidget->data.cont->id0,
342 }
343
344 return -1;
345}
346
347/**********************************************************************/
350static int maps_callback(struct widget *pwidget)
351{
353 int clause_type;
355
358 }
359
360 switch (MAX_ID - pwidget->id) {
361 case 1:
363 break;
364 default:
366 break;
367 }
368
370 player_number(pdialog->treaty->plr1),
371 pwidget->data.cont->id0,
372 clause_type, 0);
373 }
374
375 return -1;
376}
377
378/**********************************************************************/
381static int techs_callback(struct widget *pwidget)
382{
385
388 }
389
391 player_number(pdialog->treaty->plr1),
392 pwidget->data.cont->id0,
394 (MAX_ID - pwidget->id));
395 }
396
397 return -1;
398}
399
400/**********************************************************************/
403static int gold_callback(struct widget *pwidget)
404{
405 int amount;
407
410 }
411
412 if (pwidget->string_utf8->text != NULL) {
413 sscanf(pwidget->string_utf8->text, "%d", &amount);
414
415 if (amount > pwidget->data.cont->value) {
416 /* Max player gold */
417 amount = pwidget->data.cont->value;
418 }
419
420 } else {
421 amount = 0;
422 }
423
424 if (amount > 0) {
426 player_number(pdialog->treaty->plr1),
427 pwidget->data.cont->id0,
429 } else {
431 _("Invalid amount of gold specified."));
432 }
433
434 if (amount || pwidget->string_utf8->text == NULL) {
435 copy_chars_to_utf8_str(pwidget->string_utf8, "0");
436 widget_redraw(pwidget);
437 widget_flush(pwidget);
438 }
439
440 return -1;
441}
442
443/**********************************************************************/
446static int cities_callback(struct widget *pwidget)
447{
450
453 }
454
456 player_number(pdialog->treaty->plr1),
457 pwidget->data.cont->id0,
459 (MAX_ID - pwidget->id));
460 }
461
462 return -1;
463}
464
465/**********************************************************************/
468static int dipomatic_window_callback(struct widget *pwindow)
469{
470 return -1;
471}
472
473/**********************************************************************/
478 struct player *pplayer1,
479 struct widget *main_window,
480 bool L_R)
481{
482 struct advanced_dialog *dlg = fc_calloc(1, sizeof(struct advanced_dialog));
483 struct container *cont = fc_calloc(1, sizeof(struct container));
484 unsigned width, height;
485 unsigned count = 0;
486 unsigned scroll_w = 0;
487 char cbuf[128];
488 struct widget *buf = NULL, *pwindow;
489 utf8_str *pstr;
490 unsigned window_x = 0, window_y = 0;
494
497
500 pstr->style |= TTF_STYLE_BOLD;
501
503
504 pwindow->action = dipomatic_window_callback;
505 set_wstate(pwindow, FC_WS_NORMAL);
506
507 dlg->end_widget_list = pwindow;
508 pwindow->data.cont = cont;
509 add_to_gui_list(ID_WINDOW, pwindow);
510
511 area = pwindow->area;
512
513 /* ============================================================= */
514 width = 0;
515 height = 0;
516
517 /* Pacts. */
518 if (pplayer0 == client_player() && DS_ALLIANCE != type) {
520 && type != DS_CEASEFIRE && type != DS_TEAM;
522 && type != DS_PEACE && type != DS_TEAM;
525
526 if (ceasefire || peace || alliance) {
528 _("Pacts"), FONTO_ATTENTION,
531 width = buf->size.w;
532 height = buf->size.h;
534 count++;
535 }
536
537 if (ceasefire) {
538 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Cease-fire"));
543 width = MAX(width, buf->size.w);
544 height = MAX(height, buf->size.h);
545 buf->action = pact_callback;
546 buf->data.cont = cont;
549 count++;
550 }
551
552 if (peace) {
553 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Peace"));
554
559 width = MAX(width, buf->size.w);
560 height = MAX(height, buf->size.h);
561 buf->action = pact_callback;
562 buf->data.cont = cont;
565 count++;
566 }
567
568 if (alliance) {
569 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Alliance"));
570
575 width = MAX(width, buf->size.w);
576 height = MAX(height, buf->size.h);
577 buf->action = pact_callback;
578 buf->data.cont = cont;
581 count++;
582 }
583 }
584
585 /* ---------------------------- */
586 /* You can't give maps if you give shared vision */
588 bool full_map, sea_map;
589
592 _("Give shared vision"),
596 width = MAX(width, buf->size.w);
597 height = MAX(height, buf->size.h);
598 buf->action = vision_callback;
599 buf->data.cont = cont;
602 count++;
603 }
604
607
608 if (full_map || sea_map) {
610 _("Maps"), FONTO_ATTENTION,
612 buf->string_utf8->fgcol
614 width = MAX(width, buf->size.w);
615 height = MAX(height, buf->size.h);
617 count++;
618 }
619
620 if (full_map) {
621 fc_snprintf(cbuf, sizeof(cbuf), " %s", _("World map"));
622
626 buf->string_utf8->fgcol
628 width = MAX(width, buf->size.w);
629 height = MAX(height, buf->size.h);
630 buf->action = maps_callback;
631 buf->data.cont = cont;
634 count++;
635 }
636
637 if (sea_map) {
638 fc_snprintf(cbuf, sizeof(cbuf), " %s", _("Sea map"));
639
643 buf->string_utf8->fgcol
645 width = MAX(width, buf->size.w);
646 height = MAX(height, buf->size.h);
647 buf->action = maps_callback;
648 buf->data.cont = cont;
651 count++;
652 }
653 }
654
655 /* Don't take in account the embassy effects. */
659 _("Give embassy"), FONTO_ATTENTION,
661 buf->string_utf8->fgcol
663 width = MAX(width, buf->size.w);
664 height = MAX(height, buf->size.h);
665 buf->action = embassy_callback;
666 buf->data.cont = cont;
669 count++;
670 }
671
674 _("Share tiles"), FONTO_ATTENTION,
676 buf->string_utf8->fgcol
678 width = MAX(width, buf->size.w);
679 height = MAX(height, buf->size.h);
680 buf->action = shared_tiles_callback;
681 buf->data.cont = cont;
684 count++;
685 }
686
687 /* ---------------------------- */
688
689 if (clause_enabled(CLAUSE_GOLD) && pplayer0->economic.gold > 0) {
690 cont->value = pplayer0->economic.gold;
691
692 fc_snprintf(cbuf, sizeof(cbuf), _("Gold(max %d)"), pplayer0->economic.gold);
696 buf->string_utf8->fgcol
698 width = MAX(width, buf->size.w);
699 height = MAX(height, buf->size.h);
701 count++;
702
703 buf = create_edit(NULL, pwindow->dst,
706 buf->data.cont = cont;
707 buf->action = gold_callback;
709 width = MAX(width, buf->size.w);
710 height = MAX(height, buf->size.h);
712 count++;
713 }
714
715 /* ---------------------------- */
716
717 /* Trading: advances */
719 const struct research *presearch0 = research_get(pplayer0);
720 const struct research *presearch1 = research_get(pplayer1);
721 int flag = A_NONE;
723
730 == TECH_PREREQS_KNOWN)) {
731
733 _("Advances"), FONTO_ATTENTION,
735 buf->string_utf8->fgcol
737 width = MAX(width, buf->size.w);
738 height = MAX(height, buf->size.h);
740 count++;
741
742 fc_snprintf(cbuf, sizeof(cbuf), " %s",
744
748 buf->string_utf8->fgcol
750 width = MAX(width, buf->size.w);
751 height = MAX(height, buf->size.h);
752 buf->action = techs_callback;
754 buf->data.cont = cont;
756 count++;
757 flag = ++i;
758 break;
759 }
761
762 if (flag > A_NONE) {
769 == TECH_PREREQS_KNOWN)) {
770
771 fc_snprintf(cbuf, sizeof(cbuf), " %s",
773
777 buf->string_utf8->fgcol
779 width = MAX(width, buf->size.w);
780 height = MAX(height, buf->size.h);
781 buf->action = techs_callback;
783 buf->data.cont = cont;
785 count++;
786 }
787 }
789 } /* Advances */
790
791 /* Trading: cities */
792 /****************************************************************
793 Creates a sorted list of pplayer0's cities, excluding the capital and
794 any cities not visible to pplayer1. This means that you can only trade
795 cities visible to requesting player.
796
797 - Kris Bubendorfer
798 *****************************************************************/
800 int i = 0, j = 0, n = city_list_size(pplayer0->cities);
801 struct city **city_list_ptrs;
802
803 if (n > 0) {
804 city_list_ptrs = fc_calloc(1, sizeof(struct city *) * n);
805 city_list_iterate(pplayer0->cities, pcity) {
806 if (!is_capital(pcity)) {
807 city_list_ptrs[i] = pcity;
808 i++;
809 }
811 } else {
813 }
814
815 if (i > 0) {
817 _("Cities"), FONTO_ATTENTION,
819 buf->string_utf8->fgcol
821 buf->string_utf8->style &= ~SF_CENTER;
822 width = MAX(width, buf->size.w);
823 height = MAX(height, buf->size.h);
825 count++;
826
827 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
828
829 for (j = 0; j < i; j++) {
830 fc_snprintf(cbuf, sizeof(cbuf), " %s", city_name_get(city_list_ptrs[j]));
831
835 buf->string_utf8->fgcol
837 width = MAX(width, buf->size.w);
838 height = MAX(height, buf->size.h);
839 buf->data.cont = cont;
840 buf->action = cities_callback;
842 /* MAX_ID is unigned short type range and city id must be in this range */
845 count++;
846 }
847 }
849 } /* Cities */
850
851 dlg->begin_widget_list = buf;
854 dlg->scroll = NULL;
855
856 area.h = (main_window_height() - adj_size(100) - (pwindow->size.h - pwindow->area.h));
857
858 if (area.h < (count * height)) {
860 count = area.h / height;
861 scroll_w = create_vertical_scrollbar(dlg, 1, count, TRUE, TRUE);
862 buf = pwindow;
863 /* Hide not seen widgets */
864 do {
865 buf = buf->prev;
866 if (count) {
867 count--;
868 } else {
870 }
871 } while (buf != dlg->begin_active_widget_list);
872 }
873
874 area.w = MAX(width + adj_size(4) + scroll_w, adj_size(150) - (pwindow->size.w - pwindow->area.w));
875
877 (pwindow->size.w - pwindow->area.w) + area.w,
878 (pwindow->size.h - pwindow->area.h) + area.h);
879
880 area = pwindow->area;
881
882 if (L_R) {
883 window_x = main_window->dst->dest_rect.x + main_window->size.w + adj_size(20);
884 } else {
885 window_x = main_window->dst->dest_rect.x - adj_size(20) - pwindow->size.w;
886 }
887 window_y = (main_window_height() - pwindow->size.h) / 2;
888
890
892 area.x + adj_size(2), area.y + 1,
895
896 if (dlg->scroll) {
898 area.x + area.w,
899 area.y,
900 area.h, TRUE);
901 }
902
903 return dlg;
904}
905
906/**********************************************************************/
910 struct player *plr0,
911 struct player *plr1)
912{
913 struct diplomacy_dialog *pdialog = fc_calloc(1, sizeof(struct diplomacy_dialog));
914
915 pdialog->treaty = ptreaty;
916
917 pdialog->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
918
920
921 return pdialog;
922}
923
924/**********************************************************************/
928{
929 SDL_Color bg_color = {255, 255, 255, 136};
930 struct player *pplayer0, *pplayer1;
931 struct container *cont = fc_calloc(1, sizeof(struct container));
932 char cbuf[128];
933 struct widget *buf = NULL, *pwindow;
934 utf8_str *pstr;
937
938 if (pdialog) {
939 /* delete old content */
940 if (pdialog->pdialog->end_widget_list) {
942 pdialog->poffers->end_widget_list);
943 FC_FREE(pdialog->poffers->scroll);
944 FC_FREE(pdialog->poffers);
945
947 pdialog->pwants->end_widget_list);
948 FC_FREE(pdialog->pwants->scroll);
949 FC_FREE(pdialog->pwants);
950
952 pdialog->pdialog->end_widget_list);
953 }
954
955 pplayer0 = pdialog->treaty->plr0;
956 pplayer1 = pdialog->treaty->plr1;
957
960
961 fc_snprintf(cbuf, sizeof(cbuf), _("Diplomacy meeting"));
962
964 pstr->style |= TTF_STYLE_BOLD;
965
966 pwindow = create_window_skeleton(NULL, pstr, 0);
967
968 pwindow->action = dipomatic_window_callback;
969 set_wstate(pwindow, FC_WS_NORMAL);
970 pwindow->data.cont = cont;
971 pdialog->pdialog->end_widget_list = pwindow;
972
973 add_to_gui_list(ID_WINDOW, pwindow);
974
975 /* ============================================================= */
976
979 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
981
983 pwindow->dst, pstr,
986
987 buf->private_data.cbox = fc_calloc(1, sizeof(struct checkbox));
988 buf->private_data.cbox->state = FALSE;
989 buf->private_data.cbox->true_theme = current_theme->ok_pact_icon;
990 buf->private_data.cbox->false_theme = current_theme->cancel_pact_icon;
991
993
996 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
998
1000 pwindow->dst, pstr,
1003 buf->private_data.cbox = fc_calloc(1, sizeof(struct checkbox));
1004 buf->private_data.cbox->state = FALSE;
1005 buf->private_data.cbox->true_theme = current_theme->ok_pact_icon;
1006 buf->private_data.cbox->false_theme = current_theme->cancel_pact_icon;
1008 /* ============================================================= */
1009
1010 buf = create_themeicon(current_theme->cancel_pact_icon, pwindow->dst,
1013 buf->info_label = create_utf8_from_char_fonto(_("Cancel meeting"),
1015 buf->action = cancel_meeting_callback;
1016 buf->data.cont = cont;
1018
1020
1021 buf = create_themeicon(current_theme->ok_pact_icon, pwindow->dst,
1024 buf->info_label = create_utf8_from_char_fonto(_("Accept treaty"),
1026 buf->action = accept_treaty_callback;
1027 buf->data.cont = cont;
1029
1031 /* ============================================================= */
1032
1033 pdialog->pdialog->begin_widget_list = buf;
1034
1035 create_vertical_scrollbar(pdialog->pdialog, 1, 7, TRUE, TRUE);
1036 hide_scrollbar(pdialog->pdialog->scroll);
1037
1038 /* ============================================================= */
1039
1041 adj_size(250), adj_size(300));
1042
1043 area = pwindow->area;
1044
1045 widget_set_position(pwindow,
1046 (main_window_width() - pwindow->size.w) / 2,
1047 (main_window_height() - pwindow->size.h) / 2);
1048
1049 buf = pwindow->prev;
1050 buf->size.x = area.x + adj_size(17);
1051 buf->size.y = area.y + adj_size(6);
1052
1053 dst.y = area.y + adj_size(6) + buf->size.h + adj_size(10);
1054 dst.x = adj_size(10);
1055 dst.w = area.w - adj_size(14);
1056
1057 buf = buf->prev;
1058 buf->size.x = area.x + area.w - buf->size.w - adj_size(20);
1059 buf->size.y = area.y + adj_size(6);
1060
1061 buf = buf->prev;
1062 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(40))) / 2;
1063 buf->size.y = area.y + area.h - buf->size.w - adj_size(17);
1064
1065 buf = buf->prev;
1066 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(40);
1067 buf->size.y = area.y + area.h - buf->size.w - adj_size(17);
1068
1069 dst.h = area.h - buf->size.w - adj_size(3) - dst.y;
1070 /* ============================================================= */
1071
1072 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
1073
1074 /* ============================================================= */
1076 area.x + dst.x + dst.w,
1077 dst.y,
1078 dst.h, TRUE);
1079 /* ============================================================= */
1081 FALSE);
1082
1083 pdialog->pwants = popup_diplomatic_objects(pplayer1, pplayer0, pwindow,
1084 TRUE);
1085 /* ============================================================= */
1086 /* redraw */
1087 redraw_group(pdialog->pdialog->begin_widget_list, pwindow, 0);
1088 widget_mark_dirty(pwindow);
1089
1091 pdialog->poffers->end_widget_list, 0);
1093
1095 pdialog->pwants->end_widget_list, 0);
1097
1098 flush_dirty();
1099 }
1100}
1101
1102/**********************************************************************/
1105static void update_acceptance_icons(struct diplomacy_dialog *pdialog)
1106{
1107 struct widget *label;
1109 SDL_Rect src = {0, 0, 0, 0};
1110
1111 /* updates your own acceptance status */
1112 label = pdialog->pdialog->end_widget_list->prev;
1113
1114 label->private_data.cbox->state = pdialog->treaty->accept0;
1115 if (label->private_data.cbox->state) {
1116 thm = label->private_data.cbox->true_theme;
1117 } else {
1118 thm = label->private_data.cbox->false_theme;
1119 }
1120
1121 src.w = thm->w / 4;
1122 src.h = thm->h;
1123
1124 alphablit(thm, &src, label->theme, NULL, 255);
1126
1127 widget_redraw(label);
1128 widget_flush(label);
1129
1130 /* updates other player's acceptance status */
1131 label = pdialog->pdialog->end_widget_list->prev->prev;
1132
1133 label->private_data.cbox->state = pdialog->treaty->accept1;
1134 if (label->private_data.cbox->state) {
1135 thm = label->private_data.cbox->true_theme;
1136 } else {
1137 thm = label->private_data.cbox->false_theme;
1138 }
1139
1140 src.w = thm->w / 4;
1141 src.h = thm->h;
1142
1143 alphablit(thm, &src, label->theme, NULL, 255);
1144
1145 widget_redraw(label);
1146 widget_flush(label);
1147}
1148
1149/**********************************************************************/
1152static void update_clauses_list(struct diplomacy_dialog *pdialog)
1153{
1154 utf8_str *pstr;
1155 struct widget *pbuf, *pwindow = pdialog->pdialog->end_widget_list;
1156 char cbuf[128];
1157 bool redraw_all, scroll = (pdialog->pdialog->active_widget_list != NULL);
1158 int len = pdialog->pdialog->scroll->up_left_button->size.w;
1159
1162
1164 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
1166
1167 if (pclause->from != client_player()) {
1168 pbuf->string_utf8->style |= SF_CENTER_RIGHT;
1169 }
1170
1171 pbuf->data.cont = fc_calloc(1, sizeof(struct container));
1172 pbuf->data.cont->id0 = player_number(pclause->from);
1173 pbuf->data.cont->id1 = player_number(pdialog->treaty->plr1);
1174 pbuf->data.cont->value = ((int)pclause->type << 16) + pclause->value;
1175
1176 pbuf->action = remove_clause_callback;
1178
1179 pbuf->size.w = pwindow->size.w - adj_size(24) - (scroll ? len : 0);
1180
1182 pbuf, pdialog->pdialog->begin_widget_list,
1183 FALSE,
1184 pwindow->size.x + adj_size(12),
1185 pdialog->pdialog->scroll->up_left_button->size.y + adj_size(2));
1186
1187 if (!scroll && (pdialog->pdialog->active_widget_list != NULL)) {
1188 /* -> the scrollbar has been activated */
1190 do {
1191 pbuf = pbuf->prev;
1192 pbuf->size.w -= len;
1193 /* we need to save a new background because the width has changed */
1194 FREESURFACE(pbuf->gfx);
1195 } while (pbuf != pdialog->pdialog->begin_active_widget_list);
1196 scroll = TRUE;
1197 }
1198
1199 /* redraw */
1200 if (redraw_all) {
1201 redraw_group(pdialog->pdialog->begin_widget_list, pwindow, 0);
1202 widget_mark_dirty(pwindow);
1203 } else {
1206 }
1208
1209 flush_dirty();
1210}
1211
1212/**********************************************************************/
1216 struct player *giver,
1217 enum clause_type type, int value)
1218{
1219 struct widget *buf;
1220 SDL_Rect src = {0, 0, 0, 0};
1221 bool scroll;
1223
1224 /* Find widget with clause */
1226
1227 do {
1228 buf = buf->prev;
1229 } while (!((buf->data.cont->id0 == player_number(giver))
1230 && (((buf->data.cont->value >> 16) & 0xFFFF) == (int)type)
1231 && ((buf->data.cont->value & 0xFFFF) == value))
1232 && (buf != pdialog->pdialog->begin_active_widget_list));
1233
1234 if (!(buf->data.cont->id0 == player_number(giver)
1235 && ((buf->data.cont->value >> 16) & 0xFFFF) == (int)type
1236 && (buf->data.cont->value & 0xFFFF) == value)) {
1237 return;
1238 }
1239
1240 scroll = (pdialog->pdialog->active_widget_list != NULL);
1242
1243 if (scroll && (pdialog->pdialog->active_widget_list == NULL)) {
1244 /* -> the scrollbar has been deactivated */
1245 int len = pdialog->pdialog->scroll->up_left_button->size.w;
1246
1248 do {
1249 buf = buf->prev;
1251 buf->size.w += len;
1252 /* We need to save a new background because the width has changed */
1253 FREESURFACE(buf->gfx);
1254 } while (buf != pdialog->pdialog->begin_active_widget_list);
1255 }
1256
1257 /* Update state icons */
1258 buf = pdialog->pdialog->end_widget_list->prev;
1259
1260 if (buf->private_data.cbox->state) {
1262 src.w = buf->private_data.cbox->false_theme->w / 4;
1263 src.h = buf->private_data.cbox->false_theme->h;
1264
1265 alphablit(buf->private_data.cbox->false_theme, &src, buf->theme, NULL, 255);
1266 }
1267}
1268
1269/**********************************************************************/
1274 struct player *initiator)
1275{
1276 struct diplomacy_dialog *pdialog;
1277
1278 if (!can_client_issue_orders()) {
1279 return;
1280 }
1281
1282 if (!is_human(client_player())) {
1283 return; /* Don't show if we are not under human control. */
1284 }
1285
1286 if (!(pdialog = get_diplomacy_dialog(they))) {
1288 } else {
1289 /* bring existing dialog to front */
1291 pdialog->pdialog->end_widget_list);
1292 }
1293
1295}
1296
1297/**********************************************************************/
1301{
1302 if (pdialog != NULL) {
1304 pdialog->poffers->end_widget_list);
1305 FC_FREE(pdialog->poffers->scroll);
1306 FC_FREE(pdialog->poffers);
1307
1309 pdialog->pwants->end_widget_list);
1310 FC_FREE(pdialog->pwants->scroll);
1311 FC_FREE(pdialog->pwants);
1312
1314 pdialog->pdialog->end_widget_list);
1315
1316 FC_FREE(pdialog->pdialog->scroll);
1317 FC_FREE(pdialog->pdialog);
1319 }
1320}
1321
1322/**********************************************************************/
1333
1334/**********************************************************************/
1342
1343/* ================================================================= */
1344/* ========================== Small Diplomat Dialog ================ */
1345/* ================================================================= */
1346static struct small_dialog *spy_dlg = NULL;
1347
1348/**********************************************************************/
1351static void popdown_sdip_dialog(void)
1352{
1353 if (spy_dlg) {
1357 }
1358}
1359
1360/**********************************************************************/
1363static int sdip_window_callback(struct widget *pwindow)
1364{
1367 }
1368
1369 return -1;
1370}
1371
1372/**********************************************************************/
1375static int withdraw_vision_dlg_callback(struct widget *pwidget)
1376{
1379 player_number(pwidget->data.player),
1381
1383 flush_dirty();
1384 }
1385
1386 return -1;
1387}
1388
1389/**********************************************************************/
1392static int cancel_pact_dlg_callback(struct widget *pwidget)
1393{
1396 player_number(pwidget->data.player),
1398
1400 flush_dirty();
1401 }
1402
1403 return -1;
1404}
1405
1406/**********************************************************************/
1409static int call_meeting_dlg_callback(struct widget *pwidget)
1410{
1412 if (can_meet_with_player(pwidget->data.player)) {
1415 (pwidget->data.player));
1416 }
1417
1419 flush_dirty();
1420 }
1421
1422 return -1;
1423}
1424
1425/**********************************************************************/
1428static int cancel_sdip_dlg_callback(struct widget *pwidget)
1429{
1432 flush_dirty();
1433 }
1434
1435 return -1;
1436}
1437
1438/**********************************************************************/
1441static void popup_war_dialog(struct player *pplayer)
1442{
1443 char cbuf[128];
1444 struct widget *buf = NULL, *pwindow;
1445 utf8_str *pstr;
1446 SDL_Surface *text;
1447 SDL_Rect dst;
1448 SDL_Rect area;
1449
1450 if (spy_dlg) {
1451 return;
1452 }
1453
1454 spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
1455
1456 fc_snprintf(cbuf, sizeof(cbuf),
1457 /* TRANS: "Polish incident !" FIXME!!! */
1458 _("%s incident !"),
1461 pstr->style |= TTF_STYLE_BOLD;
1462
1463 pwindow = create_window_skeleton(NULL, pstr, 0);
1464
1465 pwindow->action = sdip_window_callback;
1466 set_wstate(pwindow, FC_WS_NORMAL);
1467
1468 add_to_gui_list(ID_WINDOW, pwindow);
1469
1470 spy_dlg->end_widget_list = pwindow;
1471
1472 area = pwindow->area;
1473
1474 /* ============================================================= */
1475 /* Label */
1476 fc_snprintf(cbuf, sizeof(cbuf), _("Shall we declare WAR on them?"));
1477
1479 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1481
1484 area.w = MAX(area.w, text->w);
1485 area.h += text->h + adj_size(10);
1486
1488 pwindow->dst, _("No"),
1489 FONTO_ATTENTION, 0);
1490
1491 buf->action = cancel_sdip_dlg_callback;
1493 buf->key = SDLK_ESCAPE;
1494 area.h += buf->size.h;
1495
1497
1499 pwindow->dst,
1500 _("Yes"),
1501 FONTO_ATTENTION, 0);
1502
1503 buf->action = cancel_pact_dlg_callback;
1505 buf->data.player = pplayer;
1506 buf->key = SDLK_RETURN;
1508 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1509 buf->next->size.w = buf->size.w;
1510 area.w = MAX(area.w , 2 * buf->size.w + adj_size(20));
1511
1513
1514 /* Setup window size and start position */
1515 area.w += adj_size(10);
1516 area.h += adj_size(5);
1517
1519 (pwindow->size.w - pwindow->area.w) + area.w,
1520 (pwindow->size.h - pwindow->area.h) + area.h);
1521
1522 area = pwindow->area;
1523
1524 widget_set_position(pwindow,
1525 (main_window_width() - pwindow->size.w) / 2,
1526 (main_window_height() - pwindow->size.h) / 2);
1527
1528 /* Setup rest of widgets */
1529 /* Label */
1530 dst.x = area.x + (area.w - text->w) / 2;
1531 dst.y = area.y + 1;
1532 alphablit(text, NULL, pwindow->theme, &dst, 255);
1533 dst.y += text->h + adj_size(5);
1534 FREESURFACE(text);
1535
1536 /* No */
1537 buf = pwindow->prev;
1538 buf->size.y = dst.y;
1539
1540 /* Yes */
1541 buf = buf->prev;
1542 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(20))) / 2;
1543 buf->size.y = dst.y;
1544
1545 /* No */
1546 buf->next->size.x = buf->size.x + buf->size.w + adj_size(20);
1547
1548 /* ================================================== */
1549 /* Redraw */
1551 widget_mark_dirty(pwindow);
1552 flush_dirty();
1553}
1554
1555/* ===================================================================== */
1556
1557/**********************************************************************/
1560void popup_diplomacy_dialog(struct player *pplayer)
1561{
1562 enum diplstate_type type =
1564
1565 if (!can_meet_with_player(pplayer)) {
1566 if (DS_WAR == type || pplayer == client.conn.playing) {
1567 flush_dirty();
1568
1569 return;
1570 } else {
1571 popup_war_dialog(pplayer);
1572
1573 return;
1574 }
1575 } else {
1576 int button_w = 0, button_h = 0;
1577 char cbuf[128];
1578 struct widget *buf = NULL, *pwindow;
1579 utf8_str *pstr;
1580 SDL_Surface *text;
1581 SDL_Rect dst;
1582 bool shared;
1583 SDL_Rect area;
1584 int buttons = 0;
1585 bool can_toward_war;
1586
1587 if (spy_dlg) {
1588 return;
1589 }
1590
1591 spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
1592
1593 fc_snprintf(cbuf, sizeof(cbuf), _("Foreign Minister"));
1595 pstr->style |= TTF_STYLE_BOLD;
1596
1597 pwindow = create_window_skeleton(NULL, pstr, 0);
1598
1599 pwindow->action = sdip_window_callback;
1600 set_wstate(pwindow, FC_WS_NORMAL);
1601 spy_dlg->end_widget_list = pwindow;
1602
1603 add_to_gui_list(ID_WINDOW, pwindow);
1604
1605 area = pwindow->area;
1606
1607 /* ============================================================= */
1608 /* Label */
1610 fc_snprintf(cbuf, sizeof(cbuf), _("Sir!, the %s ambassador has arrived\n"
1611 "What are your wishes?"),
1613 } else {
1614 fc_snprintf(cbuf, sizeof(cbuf), _("Ma'am!, the %s ambassador has arrived\n"
1615 "What are your wishes?"),
1617 }
1618
1620 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1622
1625 area.w = MAX(area.w , text->w);
1626 area.h += text->h + adj_size(15);
1627
1630
1631 if (can_toward_war) {
1632 if (type == DS_ARMISTICE) {
1633 fc_snprintf(cbuf, sizeof(cbuf), _("Declare WAR"));
1634 } else {
1635 fc_snprintf(cbuf, sizeof(cbuf), _("Cancel Treaty"));
1636 }
1637
1638 /* Cancel treaty */
1640 pwindow->dst, cbuf,
1641 FONTO_ATTENTION, 0);
1642
1643 buf->action = cancel_pact_dlg_callback;
1645 buf->string_utf8->fgcol
1647 buf->data.player = pplayer;
1648 buf->key = SDLK_C;
1650 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1651 buf->next->size.w = buf->size.w;
1652 button_w = MAX(button_w, buf->size.w);
1653 button_h = MAX(button_h, buf->size.h);
1654 buttons++;
1655 }
1656
1658
1659 if (shared) {
1660 /* Shared vision */
1662 pwindow->dst,
1663 _("Withdraw vision"),
1664 FONTO_ATTENTION, 0);
1665
1668 buf->data.player = pplayer;
1669 buf->key = SDLK_W;
1670 buf->string_utf8->fgcol
1673 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1674 buf->next->size.w = buf->size.w;
1675 button_w = MAX(button_w , buf->size.w);
1676 button_h = MAX(button_h , buf->size.h);
1677 buttons++;
1678 }
1679
1680 /* Meet */
1682 pwindow->dst,
1683 _("Call Diplomatic Meeting"),
1684 FONTO_ATTENTION, 0);
1685
1688 buf->data.player = pplayer;
1689 buf->key = SDLK_M;
1692 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1693 buf->next->size.w = buf->size.w;
1694 button_w = MAX(button_w , buf->size.w);
1695 button_h = MAX(button_h , buf->size.h);
1696 buttons++;
1697
1699 pwindow->dst,
1700 _("Send them back"),
1701 FONTO_ATTENTION, 0);
1702
1703 buf->action = cancel_sdip_dlg_callback;
1706 buf->key = SDLK_ESCAPE;
1707 button_w = MAX(button_w , buf->size.w);
1708 button_h = MAX(button_h , buf->size.h);
1709 buttons++;
1710
1711 button_h += adj_size(4);
1712 area.w = MAX(area.w, button_w + adj_size(20));
1713
1714 area.h += buttons * (button_h + adj_size(10));
1715
1717
1719
1720 /* Setup window size and start position */
1721 area.w += adj_size(10);
1722 area.h += adj_size(2);
1723
1725 (pwindow->size.w - pwindow->area.w) + area.w,
1726 (pwindow->size.h - pwindow->area.h) + area.h);
1727
1728 area = pwindow->area;
1729
1730 widget_set_position(pwindow,
1731 (main_window_width() - pwindow->size.w) / 2,
1732 (main_window_height() - pwindow->size.h) / 2);
1733
1734 /* Setup rest of widgets */
1735 /* Label */
1736 dst.x = area.x + (area.w - text->w) / 2;
1737 dst.y = area.y + 1;
1738 alphablit(text, NULL, pwindow->theme, &dst, 255);
1739 dst.y += text->h + adj_size(15);
1740 FREESURFACE(text);
1741
1742 buf = pwindow;
1743
1744 /* War: meet, peace: cancel treaty */
1745 buf = buf->prev;
1746 buf->size.w = button_w;
1747 buf->size.h = button_h;
1748 buf->size.x = area.x + (area.w - (buf->size.w)) / 2;
1749 buf->size.y = dst.y;
1750
1751 if (shared) {
1752 /* Vision */
1753 buf = buf->prev;
1754 buf->size.w = button_w;
1755 buf->size.h = button_h;
1756 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1757 buf->size.x = buf->next->size.x;
1758 }
1759
1760 if (type != DS_WAR) {
1761 /* Meet */
1762 buf = buf->prev;
1763 buf->size.w = button_w;
1764 buf->size.h = button_h;
1765 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1766 buf->size.x = buf->next->size.x;
1767 }
1768
1769 /* Cancel */
1770 if (can_toward_war) {
1771 buf = buf->prev;
1772 buf->size.w = button_w;
1773 buf->size.h = button_h;
1774 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1775 buf->size.x = buf->next->size.x;
1776 }
1777
1778 /* ================================================== */
1779 /* Redraw */
1781 widget_mark_dirty(pwindow);
1782
1783 flush_dirty();
1784 }
1785}
#define n
Definition astring.c:77
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
bool is_capital(const struct city *pcity)
Definition city.c:1579
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
int city_name_compare(const void *p1, const void *p2)
Definition city.c:1711
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define city_list_iterate_end
Definition city.h:510
bool can_meet_with_player(const struct player *pplayer)
struct civclient client
bool can_client_issue_orders(void)
#define client_player()
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
char * incite_cost
Definition comments.c:75
struct Treaty struct player struct player *initiator gui_recv_create_clause
Definition diplodlg_g.h:32
struct Treaty * ptreaty
Definition diplodlg_g.h:28
struct Treaty struct player struct player *initiator struct Treaty struct player *they gui_recv_accept_treaty
Definition diplodlg_g.h:36
struct Treaty struct player * they
Definition diplodlg_g.h:28
gui_recv_cancel_meeting
Definition diplodlg_g.h:27
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
QString current_theme
Definition fc_client.cpp:65
int Tech_type_id
Definition fc_types.h:377
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:976
static struct Diplomacy_dialog * create_diplomacy_dialog(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diplodlg.c:689
void gui_init_meeting(struct Treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.c:137
void diplomacy_dialog_init(void)
Definition diplodlg.c:1206
#define dialog_list_iterate_end
Definition diplodlg.c:83
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1260
void gui_recv_remove_clause(struct Treaty *ptreaty, struct player *they)
Definition diplodlg.c:188
#define dialog_list_iterate(dialoglist, pdialog)
Definition diplodlg.c:81
static struct dialog_list * dialog_list
Definition diplodlg.c:85
void diplomacy_dialog_done(void)
Definition diplodlg.c:1215
static void popup_diplomacy_dialog(struct Treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.c:205
void gui_prepare_clause_updt(struct Treaty *ptreaty, struct player *they)
Definition diplodlg.c:163
void flush_dirty(void)
Definition mapview.c:468
GType type
Definition repodlgs.c:1313
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
static int dipomatic_window_callback(struct widget *pwindow)
Definition diplodlg.c:472
static int shared_tiles_callback(struct widget *pwidget)
Definition diplodlg.c:333
static int accept_treaty_callback(struct widget *pwidget)
Definition diplodlg.c:242
static void update_clauses_list(struct diplomacy_dialog *pdialog)
Definition diplodlg.c:1156
static int remove_clause_callback(struct widget *pwidget)
Definition diplodlg.c:151
static int cancel_pact_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1396
static void popdown_sdip_dialog(void)
Definition diplodlg.c:1355
static int sdip_window_callback(struct widget *pwindow)
Definition diplodlg.c:1367
static int withdraw_vision_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1379
static int cities_callback(struct widget *pwidget)
Definition diplodlg.c:450
static int maps_callback(struct widget *pwidget)
Definition diplodlg.c:354
static int cancel_meeting_callback(struct widget *pwidget)
Definition diplodlg.c:229
static int embassy_callback(struct widget *pwidget)
Definition diplodlg.c:312
static int gold_callback(struct widget *pwidget)
Definition diplodlg.c:407
static void update_acceptance_icons(struct diplomacy_dialog *pdialog)
Definition diplodlg.c:1109
static void popdown_diplomacy_dialogs(void)
Definition diplodlg.c:1329
static void popdown_diplomacy_dialog(struct diplomacy_dialog *pdialog)
Definition diplodlg.c:1304
static int vision_callback(struct widget *pwidget)
Definition diplodlg.c:291
static int techs_callback(struct widget *pwidget)
Definition diplodlg.c:385
static int pact_callback(struct widget *pwidget)
Definition diplodlg.c:257
static struct advanced_dialog * popup_diplomatic_objects(struct player *pplayer0, struct player *pplayer1, struct widget *main_window, bool L_R)
Definition diplodlg.c:481
static struct diplomacy_dialog * get_diplomacy_dialog(struct player *they)
Definition diplodlg.c:99
static int cancel_sdip_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1432
static int call_meeting_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1413
static void popup_war_dialog(struct player *pplayer)
Definition diplodlg.c:1445
static struct small_dialog * spy_dlg
Definition diplodlg.c:1350
static void remove_clause_widget_from_list(struct player *they, struct player *giver, enum clause_type type, int value)
Definition diplodlg.c:1219
int main_window_width(void)
Definition graphics.c:685
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct sdl2_data main_data
Definition graphics.c:57
int main_window_height(void)
Definition graphics.c:693
#define FREESURFACE(ptr)
Definition graphics.h:322
@ ID_BUTTON
Definition gui_id.h:29
@ ID_ICON
Definition gui_id.h:33
@ ID_LABEL
Definition gui_id.h:27
@ ID_WINDOW
Definition gui_id.h:30
#define adj_size(size)
Definition gui_main.h:141
#define PRESSED_EVENT(event)
Definition gui_main.h:71
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
Definition gui_string.c:251
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
#define FREEUTF8STR(pstr)
Definition gui_string.h:93
#define SF_CENTER
Definition gui_string.h:40
#define SF_CENTER_RIGHT
Definition gui_string.h:41
@ FONTO_HEADING
Definition gui_string.h:69
@ FONTO_DEFAULT
Definition gui_string.h:65
@ FONTO_ATTENTION
Definition gui_string.h:67
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:108
@ COLOR_THEME_BACKGROUND
Definition themecolors.h:23
@ COLOR_THEME_DIPLODLG_MEETING_TEXT
Definition themecolors.h:81
@ COLOR_THEME_WARDLG_TEXT
@ COLOR_THEME_DIPLODLG_MEETING_HEADING_TEXT
Definition themecolors.h:80
@ COLOR_THEME_DIPLODLG_TEXT
Definition themecolors.h:82
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:586
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:998
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1051
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:720
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:983
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1039
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
#define MAX_ID
Definition widget.h:38
@ FC_WS_NORMAL
Definition widget.h:96
bool add_widget_to_vertical_scroll_widget_list(struct advanced_dialog *dlg, struct widget *new_widget, struct widget *add_dock, bool dir, Sint16 start_x, Sint16 start_y) fc__attribute((nonnull(2)))
bool del_widget_from_vertical_scroll_widget_list(struct advanced_dialog *dlg, struct widget *pwidget) fc__attribute((nonnull(2)))
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_ICON_ABOVE_TEXT
Definition widget.h:81
@ WF_FREE_DATA
Definition widget.h:78
@ WF_FREE_PRIVATE_DATA
Definition widget.h:80
@ WF_FREE_STRING
Definition widget.h:76
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
@ WF_HIDDEN
Definition widget.h:68
@ WF_FREE_THEME
Definition widget.h:72
@ WF_DRAW_TEXT_LABEL_WITH_SPACE
Definition widget.h:87
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, char_string, fonto, flags)
struct widget * create_edit(SDL_Surface *background, struct gui_layer *pdest, utf8_str *pstr, int length, Uint32 flags)
struct widget * create_themeicon(SDL_Surface *icon_theme, struct gui_layer *pdest, Uint32 flags)
SDL_Surface * create_icon_from_theme(SDL_Surface *icon_theme, Uint8 state)
struct widget * create_iconlabel(SDL_Surface *icon, struct gui_layer *pdest, utf8_str *pstr, Uint32 flags)
#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags)
void setup_vertical_scrollbar_area(struct scroll_bar *scroll, Sint16 start_x, Sint16 start_y, Uint16 height, bool swap_start_x)
Uint32 create_vertical_scrollbar(struct advanced_dialog *dlg, Uint8 step, Uint8 active, bool create_scrollbar, bool create_buttons)
#define hide_scrollbar(scrollbar)
bool resize_window(struct widget *pwindow, SDL_Surface *bcgd, SDL_Color *pcolor, Uint16 new_w, Uint16 new_h)
struct widget * create_window_skeleton(struct gui_layer *pdest, utf8_str *title, Uint32 flags)
#define fc_assert(condition)
Definition log.h:176
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
const char * nation_adjective_for_player(const struct player *pplayer)
Definition nation.c:169
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_pact(struct connection *pc, int other_player_id, enum clause_type clause)
int dsend_packet_diplomacy_init_meeting_req(struct connection *pc, int counterpart)
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 len
Definition packhand.c:127
struct player * player_by_number(const int player_id)
Definition player.c:849
int player_number(const struct player *pplayer)
Definition player.c:837
enum dipl_reason pplayer_can_make_treaty(const struct player *p1, const struct player *p2, enum diplstate_type treaty)
Definition player.c:159
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:240
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, const struct player *p2)
Definition player.c:98
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
@ DIPL_OK
Definition player.h:191
#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 MAX(x, y)
Definition shared.h:54
struct player * plr0
Definition diptreaty.h:79
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
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_widget_list
Definition widget.h:182
struct widget * end_active_widget_list
Definition widget.h:185
struct widget * active_widget_list
Definition widget.h:186
struct scroll_bar * scroll
Definition widget.h:187
struct widget * begin_widget_list
Definition widget.h:181
SDL_Surface * false_theme
SDL_Surface * true_theme
Definition city.h:320
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
int id1
Definition widget.h:104
int id0
Definition widget.h:103
int value
Definition widget.h:105
struct advanced_dialog * pdialog
Definition diplodlg.c:55
struct Treaty * treaty
Definition diplodlg.c:54
struct advanced_dialog * poffers
Definition diplodlg.c:57
struct advanced_dialog * pwants
Definition diplodlg.c:56
bool tech_trade_allow_holes
enum diplstate_type type
Definition player.h:197
bool is_male
Definition player.h:255
struct widget * up_left_button
SDL_Event event
Definition graphics.h:217
struct widget * begin_widget_list
Definition widget.h:175
struct widget * end_widget_list
Definition widget.h:176
char * text
Definition gui_string.h:60
union widget::@194 data
struct checkbox * cbox
Definition widget.h:137
SDL_Surface * theme
Definition widget.h:118
struct player * player
Definition widget.h:130
struct widget * prev
Definition widget.h:114
struct gui_layer * dst
Definition widget.h:116
struct container * cont
Definition widget.h:127
utf8_str * string_utf8
Definition widget.h:121
union widget::@195 private_data
SDL_Rect area
Definition widget.h:149
struct widget * next
Definition widget.h:113
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
#define advance_index_iterate_max_end
Definition tech.h:258
static Tech_type_id advance_count(void)
Definition tech.h:170
#define A_FIRST
Definition tech.h:44
#define A_NONE
Definition tech.h:43