Freeciv-3.3
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/* SDL2 */
19#ifdef SDL2_PLAIN_INCLUDE
20#include <SDL.h>
21#else /* SDL2_PLAIN_INCLUDE */
22#include <SDL2/SDL.h>
23#endif /* SDL2_PLAIN_INCLUDE */
24
25/* utility */
26#include "fcintl.h"
27#include "log.h"
28
29/* common */
30#include "diptreaty.h"
31#include "game.h"
32#include "research.h"
33
34/* client */
35#include "client_main.h"
36#include "climisc.h"
37#include "packhand.h"
38
39/* gui-sdl2 */
40#include "chatline.h"
41#include "colors.h"
42#include "dialogs.h"
43#include "graphics.h"
44#include "gui_id.h"
45#include "gui_main.h"
46#include "gui_tilespec.h"
47#include "mapview.h"
48#include "themespec.h"
49#include "widget.h"
50
51#include "diplodlg.h"
52
59
60#define SPECLIST_TAG dialog
61#define SPECLIST_TYPE struct diplomacy_dialog
62#include "speclist.h"
63
64#define dialog_list_iterate(dialoglist, pdialog) \
65 TYPED_LIST_ITERATE(struct diplomacy_dialog, dialoglist, pdialog)
66#define dialog_list_iterate_end LIST_ITERATE_END
67
68static struct dialog_list *dialog_list;
69
70static void update_diplomacy_dialog(struct diplomacy_dialog *pdialog);
71static void update_acceptance_icons(struct diplomacy_dialog *pdialog);
72static void update_clauses_list(struct diplomacy_dialog *pdialog);
74 struct player *giver,
75 enum clause_type type, int value);
76static void popdown_diplomacy_dialog(struct diplomacy_dialog *pdialog);
77static void popdown_diplomacy_dialogs(void);
78static void popdown_sdip_dialog(void);
79
80/**********************************************************************/
87
88/**********************************************************************/
95
96/**********************************************************************/
100{
101 struct player *we = client_player();
102
104 if ((pdialog->treaty->plr0 == we && pdialog->treaty->plr1 == they)
105 || (pdialog->treaty->plr0 == they && pdialog->treaty->plr1 == we)) {
106 return pdialog;
107 }
109
110 return NULL;
111}
112
113/**********************************************************************/
118{
120
121 if (!pdialog) {
122 return;
123 }
124
125 fc_assert(pdialog->treaty == ptreaty);
126
128}
129
130/**********************************************************************/
145
146/* ----------------------------------------------------------------------- */
147
148/**********************************************************************/
151static int remove_clause_callback(struct widget *pwidget)
152{
155
158 }
159
161 player_number(pdialog->treaty->plr1),
162 pwidget->data.cont->id0,
163 (enum clause_type) ((pwidget->data.
164 cont->value >> 16) & 0xFFFF),
165 pwidget->data.cont->value & 0xFFFF);
166 }
167
168 return -1;
169}
170
171/**********************************************************************/
175{
177
178 if (!pdialog) {
179 return;
180 }
181
182 fc_assert(pdialog->treaty == ptreaty);
183
184 clause_list_iterate(pdialog->treaty->clauses, pclause) {
186 pclause->from,
187 pclause->type,
188 pclause->value);
190}
191
192/**********************************************************************/
196{
198
199 if (!pdialog) {
200 return;
201 }
202
203 fc_assert(pdialog->treaty == ptreaty);
204
207}
208
209/**********************************************************************/
213{
215
216 if (!pdialog) {
217 return;
218 }
219
222}
223
224/* ================================================================= */
225
226/**********************************************************************/
229static int cancel_meeting_callback(struct widget *pwidget)
230{
233 pwidget->data.cont->id1);
234 }
235
236 return -1;
237}
238
239/**********************************************************************/
242static int accept_treaty_callback(struct widget *pwidget)
243{
246 pwidget->data.cont->id1);
247 }
248
249 return -1;
250}
251
252/* ------------------------------------------------------------------------ */
253
254/**********************************************************************/
257static int pact_callback(struct widget *pwidget)
258{
260 int clause_type;
262
265 }
266
267 switch (MAX_ID - pwidget->id) {
268 case 2:
270 break;
271 case 1:
273 break;
274 default:
276 break;
277 }
278
280 player_number(pdialog->treaty->plr1),
281 pwidget->data.cont->id0,
282 clause_type, 0);
283 }
284
285 return -1;
286}
287
288/**********************************************************************/
291static int vision_callback(struct widget *pwidget)
292{
295
298 }
299
301 player_number(pdialog->treaty->plr1),
302 pwidget->data.cont->id0,
303 CLAUSE_VISION, 0);
304 }
305
306 return -1;
307}
308
309/**********************************************************************/
312static int embassy_callback(struct widget *pwidget)
313{
316
319 }
320
322 player_number(pdialog->treaty->plr1),
323 pwidget->data.cont->id0,
324 CLAUSE_EMBASSY, 0);
325 }
326
327 return -1;
328}
329
330/**********************************************************************/
333static int shared_tiles_callback(struct widget *pwidget)
334{
337
340 }
341
343 player_number(pdialog->treaty->plr1),
344 pwidget->data.cont->id0,
346 }
347
348 return -1;
349}
350
351/**********************************************************************/
354static int maps_callback(struct widget *pwidget)
355{
357 int clause_type;
359
362 }
363
364 switch (MAX_ID - pwidget->id) {
365 case 1:
367 break;
368 default:
370 break;
371 }
372
374 player_number(pdialog->treaty->plr1),
375 pwidget->data.cont->id0,
376 clause_type, 0);
377 }
378
379 return -1;
380}
381
382/**********************************************************************/
385static int techs_callback(struct widget *pwidget)
386{
389
392 }
393
395 player_number(pdialog->treaty->plr1),
396 pwidget->data.cont->id0,
398 (MAX_ID - pwidget->id));
399 }
400
401 return -1;
402}
403
404/**********************************************************************/
407static int gold_callback(struct widget *pwidget)
408{
409 int amount;
411
414 }
415
416 if (pwidget->string_utf8->text != NULL) {
417 sscanf(pwidget->string_utf8->text, "%d", &amount);
418
419 if (amount > pwidget->data.cont->value) {
420 /* Max player gold */
421 amount = pwidget->data.cont->value;
422 }
423
424 } else {
425 amount = 0;
426 }
427
428 if (amount > 0) {
430 player_number(pdialog->treaty->plr1),
431 pwidget->data.cont->id0,
433 } else {
435 _("Invalid amount of gold specified."));
436 }
437
438 if (amount || pwidget->string_utf8->text == NULL) {
439 copy_chars_to_utf8_str(pwidget->string_utf8, "0");
440 widget_redraw(pwidget);
441 widget_flush(pwidget);
442 }
443
444 return -1;
445}
446
447/**********************************************************************/
450static int cities_callback(struct widget *pwidget)
451{
454
457 }
458
460 player_number(pdialog->treaty->plr1),
461 pwidget->data.cont->id0,
463 (MAX_ID - pwidget->id));
464 }
465
466 return -1;
467}
468
469/**********************************************************************/
472static int dipomatic_window_callback(struct widget *pwindow)
473{
474 return -1;
475}
476
477/**********************************************************************/
482 struct player *pplayer1,
483 struct widget *main_window,
484 bool L_R)
485{
486 struct advanced_dialog *dlg = fc_calloc(1, sizeof(struct advanced_dialog));
487 struct container *cont = fc_calloc(1, sizeof(struct container));
488 unsigned width, height;
489 unsigned count = 0;
490 unsigned scroll_w = 0;
491 char cbuf[128];
492 struct widget *buf = NULL, *pwindow;
493 utf8_str *pstr;
494 unsigned window_x = 0, window_y = 0;
498
501
504 pstr->style |= TTF_STYLE_BOLD;
505
507
508 pwindow->action = dipomatic_window_callback;
509 set_wstate(pwindow, FC_WS_NORMAL);
510
511 dlg->end_widget_list = pwindow;
512 pwindow->data.cont = cont;
513 add_to_gui_list(ID_WINDOW, pwindow);
514
515 area = pwindow->area;
516
517 /* ============================================================= */
518 width = 0;
519 height = 0;
520
521 /* Pacts. */
522 if (pplayer0 == client_player() && DS_ALLIANCE != type) {
524 && type != DS_CEASEFIRE && type != DS_TEAM;
526 && type != DS_PEACE && type != DS_TEAM;
529
530 if (ceasefire || peace || alliance) {
532 _("Pacts"), FONTO_ATTENTION,
535 width = buf->size.w;
536 height = buf->size.h;
538 count++;
539 }
540
541 if (ceasefire) {
542 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Cease-fire"));
547 width = MAX(width, buf->size.w);
548 height = MAX(height, buf->size.h);
549 buf->action = pact_callback;
550 buf->data.cont = cont;
553 count++;
554 }
555
556 if (peace) {
557 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Peace"));
558
563 width = MAX(width, buf->size.w);
564 height = MAX(height, buf->size.h);
565 buf->action = pact_callback;
566 buf->data.cont = cont;
569 count++;
570 }
571
572 if (alliance) {
573 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Alliance"));
574
579 width = MAX(width, buf->size.w);
580 height = MAX(height, buf->size.h);
581 buf->action = pact_callback;
582 buf->data.cont = cont;
585 count++;
586 }
587 }
588
589 /* ---------------------------- */
590 /* You can't give maps if you give shared vision */
592 bool full_map, sea_map;
593
596 _("Give shared vision"),
600 width = MAX(width, buf->size.w);
601 height = MAX(height, buf->size.h);
602 buf->action = vision_callback;
603 buf->data.cont = cont;
606 count++;
607 }
608
611
612 if (full_map || sea_map) {
614 _("Maps"), FONTO_ATTENTION,
616 buf->string_utf8->fgcol
618 width = MAX(width, buf->size.w);
619 height = MAX(height, buf->size.h);
621 count++;
622 }
623
624 if (full_map) {
625 fc_snprintf(cbuf, sizeof(cbuf), " %s", _("World map"));
626
630 buf->string_utf8->fgcol
632 width = MAX(width, buf->size.w);
633 height = MAX(height, buf->size.h);
634 buf->action = maps_callback;
635 buf->data.cont = cont;
638 count++;
639 }
640
641 if (sea_map) {
642 fc_snprintf(cbuf, sizeof(cbuf), " %s", _("Sea map"));
643
647 buf->string_utf8->fgcol
649 width = MAX(width, buf->size.w);
650 height = MAX(height, buf->size.h);
651 buf->action = maps_callback;
652 buf->data.cont = cont;
655 count++;
656 }
657 }
658
659 /* Don't take in account the embassy effects. */
663 _("Give embassy"), FONTO_ATTENTION,
665 buf->string_utf8->fgcol
667 width = MAX(width, buf->size.w);
668 height = MAX(height, buf->size.h);
669 buf->action = embassy_callback;
670 buf->data.cont = cont;
673 count++;
674 }
675
678 _("Share tiles"), FONTO_ATTENTION,
680 buf->string_utf8->fgcol
682 width = MAX(width, buf->size.w);
683 height = MAX(height, buf->size.h);
684 buf->action = shared_tiles_callback;
685 buf->data.cont = cont;
688 count++;
689 }
690
691 /* ---------------------------- */
692
693 if (clause_enabled(CLAUSE_GOLD) && pplayer0->economic.gold > 0) {
694 cont->value = pplayer0->economic.gold;
695
696 fc_snprintf(cbuf, sizeof(cbuf), _("Gold(max %d)"), pplayer0->economic.gold);
700 buf->string_utf8->fgcol
702 width = MAX(width, buf->size.w);
703 height = MAX(height, buf->size.h);
705 count++;
706
707 buf = create_edit(NULL, pwindow->dst,
710 buf->data.cont = cont;
711 buf->action = gold_callback;
713 width = MAX(width, buf->size.w);
714 height = MAX(height, buf->size.h);
716 count++;
717 }
718
719 /* ---------------------------- */
720
721 /* Trading: advances */
723 const struct research *presearch0 = research_get(pplayer0);
724 const struct research *presearch1 = research_get(pplayer1);
725 int flag = A_NONE;
727
734 == TECH_PREREQS_KNOWN)) {
735
737 _("Advances"), FONTO_ATTENTION,
739 buf->string_utf8->fgcol
741 width = MAX(width, buf->size.w);
742 height = MAX(height, buf->size.h);
744 count++;
745
746 fc_snprintf(cbuf, sizeof(cbuf), " %s",
748
752 buf->string_utf8->fgcol
754 width = MAX(width, buf->size.w);
755 height = MAX(height, buf->size.h);
756 buf->action = techs_callback;
758 buf->data.cont = cont;
760 count++;
761 flag = ++i;
762 break;
763 }
765
766 if (flag > A_NONE) {
773 == TECH_PREREQS_KNOWN)) {
774
775 fc_snprintf(cbuf, sizeof(cbuf), " %s",
777
781 buf->string_utf8->fgcol
783 width = MAX(width, buf->size.w);
784 height = MAX(height, buf->size.h);
785 buf->action = techs_callback;
787 buf->data.cont = cont;
789 count++;
790 }
791 }
793 } /* Advances */
794
795 /* Trading: cities */
796 /****************************************************************
797 Creates a sorted list of pplayer0's cities, excluding the capital and
798 any cities not visible to pplayer1. This means that you can only trade
799 cities visible to requesting player.
800
801 - Kris Bubendorfer
802 *****************************************************************/
804 int i = 0, j = 0, n = city_list_size(pplayer0->cities);
805 struct city **city_list_ptrs;
806
807 if (n > 0) {
808 city_list_ptrs = fc_calloc(1, sizeof(struct city *) * n);
810 if (!is_capital(pcity)) {
812 i++;
813 }
815 } else {
817 }
818
819 if (i > 0) {
821 _("Cities"), FONTO_ATTENTION,
823 buf->string_utf8->fgcol
825 buf->string_utf8->style &= ~SF_CENTER;
826 width = MAX(width, buf->size.w);
827 height = MAX(height, buf->size.h);
829 count++;
830
831 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
832
833 for (j = 0; j < i; j++) {
834 fc_snprintf(cbuf, sizeof(cbuf), " %s", city_name_get(city_list_ptrs[j]));
835
839 buf->string_utf8->fgcol
841 width = MAX(width, buf->size.w);
842 height = MAX(height, buf->size.h);
843 buf->data.cont = cont;
844 buf->action = cities_callback;
846 /* MAX_ID is unigned short type range and city id must be in this range */
849 count++;
850 }
851 }
853 } /* Cities */
854
855 dlg->begin_widget_list = buf;
858 dlg->scroll = NULL;
859
860 area.h = (main_window_height() - adj_size(100) - (pwindow->size.h - pwindow->area.h));
861
862 if (area.h < (count * height)) {
864 count = area.h / height;
865 scroll_w = create_vertical_scrollbar(dlg, 1, count, TRUE, TRUE);
866 buf = pwindow;
867 /* Hide not seen widgets */
868 do {
869 buf = buf->prev;
870 if (count) {
871 count--;
872 } else {
874 }
875 } while (buf != dlg->begin_active_widget_list);
876 }
877
878 area.w = MAX(width + adj_size(4) + scroll_w, adj_size(150) - (pwindow->size.w - pwindow->area.w));
879
881 (pwindow->size.w - pwindow->area.w) + area.w,
882 (pwindow->size.h - pwindow->area.h) + area.h);
883
884 area = pwindow->area;
885
886 if (L_R) {
887 window_x = main_window->dst->dest_rect.x + main_window->size.w + adj_size(20);
888 } else {
889 window_x = main_window->dst->dest_rect.x - adj_size(20) - pwindow->size.w;
890 }
891 window_y = (main_window_height() - pwindow->size.h) / 2;
892
894
896 area.x + adj_size(2), area.y + 1,
899
900 if (dlg->scroll) {
902 area.x + area.w,
903 area.y,
904 area.h, TRUE);
905 }
906
907 return dlg;
908}
909
910/**********************************************************************/
914 struct player *plr0,
915 struct player *plr1)
916{
917 struct diplomacy_dialog *pdialog = fc_calloc(1, sizeof(struct diplomacy_dialog));
918
919 pdialog->treaty = ptreaty;
920
921 pdialog->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
922
924
925 return pdialog;
926}
927
928/**********************************************************************/
932{
933 SDL_Color bg_color = {255, 255, 255, 136};
934 struct player *pplayer0, *pplayer1;
935 struct container *cont = fc_calloc(1, sizeof(struct container));
936 char cbuf[128];
937 struct widget *buf = NULL, *pwindow;
938 utf8_str *pstr;
941
942 if (pdialog) {
943 /* delete old content */
944 if (pdialog->pdialog->end_widget_list) {
946 pdialog->poffers->end_widget_list);
947 FC_FREE(pdialog->poffers->scroll);
948 FC_FREE(pdialog->poffers);
949
951 pdialog->pwants->end_widget_list);
952 FC_FREE(pdialog->pwants->scroll);
953 FC_FREE(pdialog->pwants);
954
956 pdialog->pdialog->end_widget_list);
957 }
958
959 pplayer0 = pdialog->treaty->plr0;
960 pplayer1 = pdialog->treaty->plr1;
961
964
965 fc_snprintf(cbuf, sizeof(cbuf), _("Diplomacy meeting"));
966
968 pstr->style |= TTF_STYLE_BOLD;
969
970 pwindow = create_window_skeleton(NULL, pstr, 0);
971
972 pwindow->action = dipomatic_window_callback;
973 set_wstate(pwindow, FC_WS_NORMAL);
974 pwindow->data.cont = cont;
975 pdialog->pdialog->end_widget_list = pwindow;
976
977 add_to_gui_list(ID_WINDOW, pwindow);
978
979 /* ============================================================= */
980
983 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
985
987 pwindow->dst, pstr,
990
991 buf->private_data.cbox = fc_calloc(1, sizeof(struct checkbox));
992 buf->private_data.cbox->state = FALSE;
993 buf->private_data.cbox->true_theme = current_theme->ok_pact_icon;
994 buf->private_data.cbox->false_theme = current_theme->cancel_pact_icon;
995
997
1000 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1002
1004 pwindow->dst, pstr,
1007 buf->private_data.cbox = fc_calloc(1, sizeof(struct checkbox));
1008 buf->private_data.cbox->state = FALSE;
1009 buf->private_data.cbox->true_theme = current_theme->ok_pact_icon;
1010 buf->private_data.cbox->false_theme = current_theme->cancel_pact_icon;
1012 /* ============================================================= */
1013
1014 buf = create_themeicon(current_theme->cancel_pact_icon, pwindow->dst,
1017 buf->info_label = create_utf8_from_char_fonto(_("Cancel meeting"),
1019 buf->action = cancel_meeting_callback;
1020 buf->data.cont = cont;
1022
1024
1025 buf = create_themeicon(current_theme->ok_pact_icon, pwindow->dst,
1028 buf->info_label = create_utf8_from_char_fonto(_("Accept treaty"),
1030 buf->action = accept_treaty_callback;
1031 buf->data.cont = cont;
1033
1035 /* ============================================================= */
1036
1037 pdialog->pdialog->begin_widget_list = buf;
1038
1039 create_vertical_scrollbar(pdialog->pdialog, 1, 7, TRUE, TRUE);
1040 hide_scrollbar(pdialog->pdialog->scroll);
1041
1042 /* ============================================================= */
1043
1045 adj_size(250), adj_size(300));
1046
1047 area = pwindow->area;
1048
1049 widget_set_position(pwindow,
1050 (main_window_width() - pwindow->size.w) / 2,
1051 (main_window_height() - pwindow->size.h) / 2);
1052
1053 buf = pwindow->prev;
1054 buf->size.x = area.x + adj_size(17);
1055 buf->size.y = area.y + adj_size(6);
1056
1057 dst.y = area.y + adj_size(6) + buf->size.h + adj_size(10);
1058 dst.x = adj_size(10);
1059 dst.w = area.w - adj_size(14);
1060
1061 buf = buf->prev;
1062 buf->size.x = area.x + area.w - buf->size.w - adj_size(20);
1063 buf->size.y = area.y + adj_size(6);
1064
1065 buf = buf->prev;
1066 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(40))) / 2;
1067 buf->size.y = area.y + area.h - buf->size.w - adj_size(17);
1068
1069 buf = buf->prev;
1070 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(40);
1071 buf->size.y = area.y + area.h - buf->size.w - adj_size(17);
1072
1073 dst.h = area.h - buf->size.w - adj_size(3) - dst.y;
1074 /* ============================================================= */
1075
1076 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
1077
1078 /* ============================================================= */
1080 area.x + dst.x + dst.w,
1081 dst.y,
1082 dst.h, TRUE);
1083 /* ============================================================= */
1085 FALSE);
1086
1087 pdialog->pwants = popup_diplomatic_objects(pplayer1, pplayer0, pwindow,
1088 TRUE);
1089 /* ============================================================= */
1090 /* redraw */
1091 redraw_group(pdialog->pdialog->begin_widget_list, pwindow, 0);
1092 widget_mark_dirty(pwindow);
1093
1095 pdialog->poffers->end_widget_list, 0);
1097
1099 pdialog->pwants->end_widget_list, 0);
1101
1102 flush_dirty();
1103 }
1104}
1105
1106/**********************************************************************/
1109static void update_acceptance_icons(struct diplomacy_dialog *pdialog)
1110{
1111 struct widget *label;
1113 SDL_Rect src = {0, 0, 0, 0};
1114
1115 /* updates your own acceptance status */
1116 label = pdialog->pdialog->end_widget_list->prev;
1117
1118 label->private_data.cbox->state = pdialog->treaty->accept0;
1119 if (label->private_data.cbox->state) {
1120 thm = label->private_data.cbox->true_theme;
1121 } else {
1122 thm = label->private_data.cbox->false_theme;
1123 }
1124
1125 src.w = thm->w / 4;
1126 src.h = thm->h;
1127
1128 alphablit(thm, &src, label->theme, NULL, 255);
1130
1131 widget_redraw(label);
1132 widget_flush(label);
1133
1134 /* updates other player's acceptance status */
1135 label = pdialog->pdialog->end_widget_list->prev->prev;
1136
1137 label->private_data.cbox->state = pdialog->treaty->accept1;
1138 if (label->private_data.cbox->state) {
1139 thm = label->private_data.cbox->true_theme;
1140 } else {
1141 thm = label->private_data.cbox->false_theme;
1142 }
1143
1144 src.w = thm->w / 4;
1145 src.h = thm->h;
1146
1147 alphablit(thm, &src, label->theme, NULL, 255);
1148
1149 widget_redraw(label);
1150 widget_flush(label);
1151}
1152
1153/**********************************************************************/
1156static void update_clauses_list(struct diplomacy_dialog *pdialog)
1157{
1158 utf8_str *pstr;
1159 struct widget *pbuf, *pwindow = pdialog->pdialog->end_widget_list;
1160 char cbuf[128];
1161 bool redraw_all, scroll = (pdialog->pdialog->active_widget_list != NULL);
1162 int len = pdialog->pdialog->scroll->up_left_button->size.w;
1163
1166
1168 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
1170
1171 if (pclause->from != client_player()) {
1172 pbuf->string_utf8->style |= SF_CENTER_RIGHT;
1173 }
1174
1175 pbuf->data.cont = fc_calloc(1, sizeof(struct container));
1176 pbuf->data.cont->id0 = player_number(pclause->from);
1177 pbuf->data.cont->id1 = player_number(pdialog->treaty->plr1);
1178 pbuf->data.cont->value = ((int)pclause->type << 16) + pclause->value;
1179
1180 pbuf->action = remove_clause_callback;
1182
1183 pbuf->size.w = pwindow->size.w - adj_size(24) - (scroll ? len : 0);
1184
1186 pbuf, pdialog->pdialog->begin_widget_list,
1187 FALSE,
1188 pwindow->size.x + adj_size(12),
1189 pdialog->pdialog->scroll->up_left_button->size.y + adj_size(2));
1190
1191 if (!scroll && (pdialog->pdialog->active_widget_list != NULL)) {
1192 /* -> the scrollbar has been activated */
1194 do {
1195 pbuf = pbuf->prev;
1196 pbuf->size.w -= len;
1197 /* we need to save a new background because the width has changed */
1198 FREESURFACE(pbuf->gfx);
1199 } while (pbuf != pdialog->pdialog->begin_active_widget_list);
1200 scroll = TRUE;
1201 }
1202
1203 /* redraw */
1204 if (redraw_all) {
1205 redraw_group(pdialog->pdialog->begin_widget_list, pwindow, 0);
1206 widget_mark_dirty(pwindow);
1207 } else {
1210 }
1212
1213 flush_dirty();
1214}
1215
1216/**********************************************************************/
1220 struct player *giver,
1221 enum clause_type type, int value)
1222{
1223 struct widget *buf;
1224 SDL_Rect src = {0, 0, 0, 0};
1225 bool scroll;
1227
1228 /* Find widget with clause */
1230
1231 do {
1232 buf = buf->prev;
1233 } while (!((buf->data.cont->id0 == player_number(giver))
1234 && (((buf->data.cont->value >> 16) & 0xFFFF) == (int)type)
1235 && ((buf->data.cont->value & 0xFFFF) == value))
1236 && (buf != pdialog->pdialog->begin_active_widget_list));
1237
1238 if (!(buf->data.cont->id0 == player_number(giver)
1239 && ((buf->data.cont->value >> 16) & 0xFFFF) == (int)type
1240 && (buf->data.cont->value & 0xFFFF) == value)) {
1241 return;
1242 }
1243
1244 scroll = (pdialog->pdialog->active_widget_list != NULL);
1246
1247 if (scroll && (pdialog->pdialog->active_widget_list == NULL)) {
1248 /* -> the scrollbar has been deactivated */
1249 int len = pdialog->pdialog->scroll->up_left_button->size.w;
1250
1252 do {
1253 buf = buf->prev;
1255 buf->size.w += len;
1256 /* We need to save a new background because the width has changed */
1257 FREESURFACE(buf->gfx);
1258 } while (buf != pdialog->pdialog->begin_active_widget_list);
1259 }
1260
1261 /* Update state icons */
1262 buf = pdialog->pdialog->end_widget_list->prev;
1263
1264 if (buf->private_data.cbox->state) {
1266 src.w = buf->private_data.cbox->false_theme->w / 4;
1267 src.h = buf->private_data.cbox->false_theme->h;
1268
1269 alphablit(buf->private_data.cbox->false_theme, &src, buf->theme, NULL, 255);
1270 }
1271}
1272
1273/**********************************************************************/
1278 struct player *initiator)
1279{
1280 struct diplomacy_dialog *pdialog;
1281
1282 if (!can_client_issue_orders()) {
1283 return;
1284 }
1285
1286 if (!is_human(client_player())) {
1287 return; /* Don't show if we are not under human control. */
1288 }
1289
1290 if (!(pdialog = get_diplomacy_dialog(they))) {
1292 } else {
1293 /* bring existing dialog to front */
1295 pdialog->pdialog->end_widget_list);
1296 }
1297
1299}
1300
1301/**********************************************************************/
1305{
1306 if (pdialog != NULL) {
1308 pdialog->poffers->end_widget_list);
1309 FC_FREE(pdialog->poffers->scroll);
1310 FC_FREE(pdialog->poffers);
1311
1313 pdialog->pwants->end_widget_list);
1314 FC_FREE(pdialog->pwants->scroll);
1315 FC_FREE(pdialog->pwants);
1316
1318 pdialog->pdialog->end_widget_list);
1319
1320 FC_FREE(pdialog->pdialog->scroll);
1321 FC_FREE(pdialog->pdialog);
1323 }
1324}
1325
1326/**********************************************************************/
1337
1338/**********************************************************************/
1346
1347/* ================================================================= */
1348/* ========================== Small Diplomat Dialog ================ */
1349/* ================================================================= */
1350static struct small_dialog *spy_dlg = NULL;
1351
1352/**********************************************************************/
1355static void popdown_sdip_dialog(void)
1356{
1357 if (spy_dlg) {
1361 }
1362}
1363
1364/**********************************************************************/
1367static int sdip_window_callback(struct widget *pwindow)
1368{
1371 }
1372
1373 return -1;
1374}
1375
1376/**********************************************************************/
1379static int withdraw_vision_dlg_callback(struct widget *pwidget)
1380{
1383 player_number(pwidget->data.player),
1385
1387 flush_dirty();
1388 }
1389
1390 return -1;
1391}
1392
1393/**********************************************************************/
1396static int cancel_pact_dlg_callback(struct widget *pwidget)
1397{
1400 player_number(pwidget->data.player),
1402
1404 flush_dirty();
1405 }
1406
1407 return -1;
1408}
1409
1410/**********************************************************************/
1413static int call_meeting_dlg_callback(struct widget *pwidget)
1414{
1416 if (can_meet_with_player(pwidget->data.player)) {
1419 (pwidget->data.player));
1420 }
1421
1423 flush_dirty();
1424 }
1425
1426 return -1;
1427}
1428
1429/**********************************************************************/
1432static int cancel_sdip_dlg_callback(struct widget *pwidget)
1433{
1436 flush_dirty();
1437 }
1438
1439 return -1;
1440}
1441
1442/**********************************************************************/
1445static void popup_war_dialog(struct player *pplayer)
1446{
1447 char cbuf[128];
1448 struct widget *buf = NULL, *pwindow;
1449 utf8_str *pstr;
1450 SDL_Surface *text;
1451 SDL_Rect dst;
1452 SDL_Rect area;
1453
1454 if (spy_dlg) {
1455 return;
1456 }
1457
1458 spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
1459
1460 fc_snprintf(cbuf, sizeof(cbuf),
1461 /* TRANS: "Polish incident !" FIXME!!! */
1462 _("%s incident !"),
1465 pstr->style |= TTF_STYLE_BOLD;
1466
1467 pwindow = create_window_skeleton(NULL, pstr, 0);
1468
1469 pwindow->action = sdip_window_callback;
1470 set_wstate(pwindow, FC_WS_NORMAL);
1471
1472 add_to_gui_list(ID_WINDOW, pwindow);
1473
1474 spy_dlg->end_widget_list = pwindow;
1475
1476 area = pwindow->area;
1477
1478 /* ============================================================= */
1479 /* Label */
1480 fc_snprintf(cbuf, sizeof(cbuf), _("Shall we declare WAR on them?"));
1481
1483 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1485
1488 area.w = MAX(area.w, text->w);
1489 area.h += text->h + adj_size(10);
1490
1492 pwindow->dst, _("No"),
1493 FONTO_ATTENTION, 0);
1494
1495 buf->action = cancel_sdip_dlg_callback;
1497 buf->key = SDLK_ESCAPE;
1498 area.h += buf->size.h;
1499
1501
1503 pwindow->dst,
1504 _("Yes"),
1505 FONTO_ATTENTION, 0);
1506
1507 buf->action = cancel_pact_dlg_callback;
1509 buf->data.player = pplayer;
1510 buf->key = SDLK_RETURN;
1512 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1513 buf->next->size.w = buf->size.w;
1514 area.w = MAX(area.w , 2 * buf->size.w + adj_size(20));
1515
1517
1518 /* Setup window size and start position */
1519 area.w += adj_size(10);
1520 area.h += adj_size(5);
1521
1523 (pwindow->size.w - pwindow->area.w) + area.w,
1524 (pwindow->size.h - pwindow->area.h) + area.h);
1525
1526 area = pwindow->area;
1527
1528 widget_set_position(pwindow,
1529 (main_window_width() - pwindow->size.w) / 2,
1530 (main_window_height() - pwindow->size.h) / 2);
1531
1532 /* Setup rest of widgets */
1533 /* Label */
1534 dst.x = area.x + (area.w - text->w) / 2;
1535 dst.y = area.y + 1;
1536 alphablit(text, NULL, pwindow->theme, &dst, 255);
1537 dst.y += text->h + adj_size(5);
1538 FREESURFACE(text);
1539
1540 /* No */
1541 buf = pwindow->prev;
1542 buf->size.y = dst.y;
1543
1544 /* Yes */
1545 buf = buf->prev;
1546 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(20))) / 2;
1547 buf->size.y = dst.y;
1548
1549 /* No */
1550 buf->next->size.x = buf->size.x + buf->size.w + adj_size(20);
1551
1552 /* ================================================== */
1553 /* Redraw */
1555 widget_mark_dirty(pwindow);
1556 flush_dirty();
1557}
1558
1559/* ===================================================================== */
1560
1561/**********************************************************************/
1564void popup_diplomacy_dialog(struct player *pplayer)
1565{
1566 enum diplstate_type type =
1568
1569 if (!can_meet_with_player(pplayer)) {
1570 if (DS_WAR == type || pplayer == client.conn.playing) {
1571 flush_dirty();
1572
1573 return;
1574 } else {
1575 popup_war_dialog(pplayer);
1576
1577 return;
1578 }
1579 } else {
1580 int button_w = 0, button_h = 0;
1581 char cbuf[128];
1582 struct widget *buf = NULL, *pwindow;
1583 utf8_str *pstr;
1584 SDL_Surface *text;
1585 SDL_Rect dst;
1586 bool shared;
1587 SDL_Rect area;
1588 int buttons = 0;
1589 bool can_toward_war;
1590
1591 if (spy_dlg) {
1592 return;
1593 }
1594
1595 spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
1596
1597 fc_snprintf(cbuf, sizeof(cbuf), _("Foreign Minister"));
1599 pstr->style |= TTF_STYLE_BOLD;
1600
1601 pwindow = create_window_skeleton(NULL, pstr, 0);
1602
1603 pwindow->action = sdip_window_callback;
1604 set_wstate(pwindow, FC_WS_NORMAL);
1605 spy_dlg->end_widget_list = pwindow;
1606
1607 add_to_gui_list(ID_WINDOW, pwindow);
1608
1609 area = pwindow->area;
1610
1611 /* ============================================================= */
1612 /* Label */
1614 fc_snprintf(cbuf, sizeof(cbuf), _("Sir!, the %s ambassador has arrived\n"
1615 "What are your wishes?"),
1617 } else {
1618 fc_snprintf(cbuf, sizeof(cbuf), _("Ma'am!, the %s ambassador has arrived\n"
1619 "What are your wishes?"),
1621 }
1622
1624 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1626
1629 area.w = MAX(area.w , text->w);
1630 area.h += text->h + adj_size(15);
1631
1634
1635 if (can_toward_war) {
1636 if (type == DS_ARMISTICE) {
1637 fc_snprintf(cbuf, sizeof(cbuf), _("Declare WAR"));
1638 } else {
1639 fc_snprintf(cbuf, sizeof(cbuf), _("Cancel Treaty"));
1640 }
1641
1642 /* Cancel treaty */
1644 pwindow->dst, cbuf,
1645 FONTO_ATTENTION, 0);
1646
1647 buf->action = cancel_pact_dlg_callback;
1649 buf->string_utf8->fgcol
1651 buf->data.player = pplayer;
1652 buf->key = SDLK_c;
1654 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1655 buf->next->size.w = buf->size.w;
1656 button_w = MAX(button_w, buf->size.w);
1657 button_h = MAX(button_h, buf->size.h);
1658 buttons++;
1659 }
1660
1662
1663 if (shared) {
1664 /* Shared vision */
1666 pwindow->dst,
1667 _("Withdraw vision"),
1668 FONTO_ATTENTION, 0);
1669
1672 buf->data.player = pplayer;
1673 buf->key = SDLK_w;
1674 buf->string_utf8->fgcol
1677 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1678 buf->next->size.w = buf->size.w;
1679 button_w = MAX(button_w , buf->size.w);
1680 button_h = MAX(button_h , buf->size.h);
1681 buttons++;
1682 }
1683
1684 /* Meet */
1686 pwindow->dst,
1687 _("Call Diplomatic Meeting"),
1688 FONTO_ATTENTION, 0);
1689
1692 buf->data.player = pplayer;
1693 buf->key = SDLK_m;
1696 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1697 buf->next->size.w = buf->size.w;
1698 button_w = MAX(button_w , buf->size.w);
1699 button_h = MAX(button_h , buf->size.h);
1700 buttons++;
1701
1703 pwindow->dst,
1704 _("Send them back"),
1705 FONTO_ATTENTION, 0);
1706
1707 buf->action = cancel_sdip_dlg_callback;
1710 buf->key = SDLK_ESCAPE;
1711 button_w = MAX(button_w , buf->size.w);
1712 button_h = MAX(button_h , buf->size.h);
1713 buttons++;
1714
1715 button_h += adj_size(4);
1716 area.w = MAX(area.w, button_w + adj_size(20));
1717
1718 area.h += buttons * (button_h + adj_size(10));
1719
1721
1723
1724 /* Setup window size and start position */
1725 area.w += adj_size(10);
1726 area.h += adj_size(2);
1727
1729 (pwindow->size.w - pwindow->area.w) + area.w,
1730 (pwindow->size.h - pwindow->area.h) + area.h);
1731
1732 area = pwindow->area;
1733
1734 widget_set_position(pwindow,
1735 (main_window_width() - pwindow->size.w) / 2,
1736 (main_window_height() - pwindow->size.h) / 2);
1737
1738 /* Setup rest of widgets */
1739 /* Label */
1740 dst.x = area.x + (area.w - text->w) / 2;
1741 dst.y = area.y + 1;
1742 alphablit(text, NULL, pwindow->theme, &dst, 255);
1743 dst.y += text->h + adj_size(15);
1744 FREESURFACE(text);
1745
1746 buf = pwindow;
1747
1748 /* War: meet, peace: cancel treaty */
1749 buf = buf->prev;
1750 buf->size.w = button_w;
1751 buf->size.h = button_h;
1752 buf->size.x = area.x + (area.w - (buf->size.w)) / 2;
1753 buf->size.y = dst.y;
1754
1755 if (shared) {
1756 /* Vision */
1757 buf = buf->prev;
1758 buf->size.w = button_w;
1759 buf->size.h = button_h;
1760 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1761 buf->size.x = buf->next->size.x;
1762 }
1763
1764 if (type != DS_WAR) {
1765 /* Meet */
1766 buf = buf->prev;
1767 buf->size.w = button_w;
1768 buf->size.h = button_h;
1769 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1770 buf->size.x = buf->next->size.x;
1771 }
1772
1773 /* Cancel */
1774 if (can_toward_war) {
1775 buf = buf->prev;
1776 buf->size.w = button_w;
1777 buf->size.h = button_h;
1778 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1779 buf->size.x = buf->next->size.x;
1780 }
1781
1782 /* ================================================== */
1783 /* Redraw */
1785 widget_mark_dirty(pwindow);
1786
1787 flush_dirty();
1788 }
1789}
#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:505
#define city_list_iterate_end
Definition city.h:507
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:76
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct treaty * ptreaty
Definition diplodlg_g.h:28
struct treaty struct player struct player *initiator gui_recv_create_clause
Definition diplodlg_g.h:32
gui_recv_cancel_meeting
Definition diplodlg_g.h:27
struct treaty struct player * they
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
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:305
#define clause_list_iterate_end
Definition diptreaty.h:73
#define clause_list_iterate(clauselist, pclause)
Definition diptreaty.h:71
QString current_theme
Definition fc_client.cpp:64
int Tech_type_id
Definition fc_types.h:236
#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:61
void gui_init_meeting(struct treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.c:137
static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:976
void diplomacy_dialog_init(void)
Definition diplodlg.c:1206
static struct Diplomacy_dialog * create_diplomacy_dialog(struct treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diplodlg.c:689
#define dialog_list_iterate_end
Definition diplodlg.c:83
void gui_recv_remove_clause(struct treaty *ptreaty, struct player *they)
Definition diplodlg.c:188
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1260
#define dialog_list_iterate(dialoglist, pdialog)
Definition diplodlg.c:81
static struct dialog_list * dialog_list
Definition diplodlg.c:85
void gui_prepare_clause_updt(struct treaty *ptreaty, struct player *they)
Definition diplodlg.c:163
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 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:24
@ COLOR_THEME_DIPLODLG_MEETING_TEXT
Definition themecolors.h:82
@ COLOR_THEME_WARDLG_TEXT
@ COLOR_THEME_DIPLODLG_MEETING_HEADING_TEXT
Definition themecolors.h:81
@ COLOR_THEME_DIPLODLG_TEXT
Definition themecolors.h:83
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:177
#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:1489
@ DIPL_OK
Definition player.h:193
#define is_human(plr)
Definition player.h:231
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 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:317
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:199
bool is_male
Definition player.h:257
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
struct player * plr1
Definition diptreaty.h:82
struct clause_list * clauses
Definition diptreaty.h:84
bool accept1
Definition diptreaty.h:83
struct player * plr0
Definition diptreaty.h:82
bool accept0
Definition diptreaty.h:83
char * text
Definition gui_string.h:60
struct checkbox * cbox
Definition widget.h:137
SDL_Surface * theme
Definition widget.h:118
struct player * player
Definition widget.h:130
union widget::@223 data
struct widget * prev
Definition widget.h:114
union widget::@224 private_data
struct gui_layer * dst
Definition widget.h:116
struct container * cont
Definition widget.h:127
utf8_str * string_utf8
Definition widget.h:121
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:960
#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:300
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:248
#define advance_index_iterate_max_end
Definition tech.h:254
static Tech_type_id advance_count(void)
Definition tech.h:165
#define A_FIRST
Definition tech.h:44
#define A_NONE
Definition tech.h:43