Freeciv-3.1
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 enum clause_type type, int value);
75static void popdown_diplomacy_dialog(struct diplomacy_dialog *pdialog);
76static void popdown_diplomacy_dialogs(void);
77static void popdown_sdip_dialog(void);
78
79/**********************************************************************/
83{
84 dialog_list = dialog_list_new();
85}
86
87/**********************************************************************/
91{
92 dialog_list_destroy(dialog_list);
93}
94
95/**********************************************************************/
98static struct diplomacy_dialog *get_diplomacy_dialog(int other_player_id)
99{
100 struct player *plr0 = client.conn.playing;
101 struct player *plr1 = player_by_number(other_player_id);
102
104 if ((pdialog->treaty.plr0 == plr0 && pdialog->treaty.plr1 == plr1)
105 || (pdialog->treaty.plr0 == plr1 && pdialog->treaty.plr1 == plr0)) {
106 return pdialog;
107 }
109
110 return NULL;
111}
112
113/**********************************************************************/
118 bool other_accepted)
119{
121
122 if (!pdialog) {
123 return;
124 }
125
126 pdialog->treaty.accept0 = I_accepted;
127 pdialog->treaty.accept1 = other_accepted;
128
130}
131
132/**********************************************************************/
136void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
137{
139
140 if (pdialog != NULL) {
141 dialog_list_remove(dialog_list, pdialog);
143 flush_dirty();
144 }
145}
146
147/* ----------------------------------------------------------------------- */
148
149/**********************************************************************/
152static int remove_clause_callback(struct widget *pwidget)
153{
156
157 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
159 }
160
162 player_number(pdialog->treaty.plr1),
163 pwidget->data.cont->id0,
164 (enum clause_type) ((pwidget->data.
165 cont->value >> 16) & 0xFFFF),
166 pwidget->data.cont->value & 0xFFFF);
167 }
168
169 return -1;
170}
171
172/**********************************************************************/
176 enum clause_type type, int value)
177{
179
180 if (!pdialog) {
181 return;
182 }
183
184 clause_list_iterate(pdialog->treaty.clauses, pclause) {
186 player_number(pclause->from),
187 pclause->type,
188 pclause->value);
190
191 add_clause(&pdialog->treaty, player_by_number(giver), type, value,
192 client_player());
193
196}
197
198/**********************************************************************/
202 enum clause_type type, int value)
203{
205
206 if (!pdialog) {
207 return;
208 }
209
210 clause_list_iterate(pdialog->treaty.clauses, pclause) {
212 player_number(pclause->from),
213 pclause->type,
214 pclause->value);
216
217 remove_clause(&pdialog->treaty, player_by_number(giver), type, value);
218
221}
222
223/* ================================================================= */
224
225/**********************************************************************/
228static int cancel_meeting_callback(struct widget *pwidget)
229{
232 pwidget->data.cont->id1);
233 }
234
235 return -1;
236}
237
238/**********************************************************************/
241static int accept_treaty_callback(struct widget *pwidget)
242{
245 pwidget->data.cont->id1);
246 }
247
248 return -1;
249}
250
251/* ------------------------------------------------------------------------ */
252
253/**********************************************************************/
256static int pact_callback(struct widget *pwidget)
257{
259 int clause_type;
261
262 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
264 }
265
266 switch (MAX_ID - pwidget->id) {
267 case 2:
268 clause_type = CLAUSE_CEASEFIRE;
269 break;
270 case 1:
271 clause_type = CLAUSE_PEACE;
272 break;
273 default:
274 clause_type = CLAUSE_ALLIANCE;
275 break;
276 }
277
279 player_number(pdialog->treaty.plr1),
280 pwidget->data.cont->id0,
281 clause_type, 0);
282 }
283
284 return -1;
285}
286
287/**********************************************************************/
290static int vision_callback(struct widget *pwidget)
291{
294
295 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
297 }
298
300 player_number(pdialog->treaty.plr1),
301 pwidget->data.cont->id0,
302 CLAUSE_VISION, 0);
303 }
304
305 return -1;
306}
307
308/**********************************************************************/
311static int embassy_callback(struct widget *pwidget)
312{
315
316 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
318 }
319
321 player_number(pdialog->treaty.plr1),
322 pwidget->data.cont->id0,
323 CLAUSE_EMBASSY, 0);
324 }
325
326 return -1;
327}
328
329/**********************************************************************/
332static int maps_callback(struct widget *pwidget)
333{
335 int clause_type;
337
338 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
340 }
341
342 switch (MAX_ID - pwidget->id) {
343 case 1:
344 clause_type = CLAUSE_MAP;
345 break;
346 default:
347 clause_type = CLAUSE_SEAMAP;
348 break;
349 }
350
352 player_number(pdialog->treaty.plr1),
353 pwidget->data.cont->id0,
354 clause_type, 0);
355 }
356
357 return -1;
358}
359
360/**********************************************************************/
363static int techs_callback(struct widget *pwidget)
364{
367
368 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
370 }
371
373 player_number(pdialog->treaty.plr1),
374 pwidget->data.cont->id0,
375 CLAUSE_ADVANCE,
376 (MAX_ID - pwidget->id));
377 }
378
379 return -1;
380}
381
382/**********************************************************************/
385static int gold_callback(struct widget *pwidget)
386{
387 int amount;
389
390 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
392 }
393
394 if (pwidget->string_utf8->text != NULL) {
395 sscanf(pwidget->string_utf8->text, "%d", &amount);
396
397 if (amount > pwidget->data.cont->value) {
398 /* max player gold */
399 amount = pwidget->data.cont->value;
400 }
401
402 } else {
403 amount = 0;
404 }
405
406 if (amount > 0) {
408 player_number(pdialog->treaty.plr1),
409 pwidget->data.cont->id0,
410 CLAUSE_GOLD, amount);
411
412 } else {
414 _("Invalid amount of gold specified."));
415 }
416
417 if (amount || pwidget->string_utf8->text == NULL) {
418 copy_chars_to_utf8_str(pwidget->string_utf8, "0");
419 widget_redraw(pwidget);
420 widget_flush(pwidget);
421 }
422
423 return -1;
424}
425
426/**********************************************************************/
429static int cities_callback(struct widget *pwidget)
430{
433
434 if (!(pdialog = get_diplomacy_dialog(pwidget->data.cont->id1))) {
436 }
437
439 player_number(pdialog->treaty.plr1),
440 pwidget->data.cont->id0,
441 CLAUSE_CITY,
442 (MAX_ID - pwidget->id));
443 }
444
445 return -1;
446}
447
448/**********************************************************************/
451static int dipomatic_window_callback(struct widget *pwindow)
452{
453 return -1;
454}
455
456/**********************************************************************/
460static struct advanced_dialog *popup_diplomatic_objects(struct player *pplayer0,
461 struct player *pplayer1,
462 struct widget *main_window,
463 bool L_R)
464{
465 struct advanced_dialog *dlg = fc_calloc(1, sizeof(struct advanced_dialog));
466 struct container *cont = fc_calloc(1, sizeof(struct container));
467 unsigned width, height;
468 unsigned count = 0;
469 unsigned scroll_w = 0;
470 char cbuf[128];
471 struct widget *buf = NULL, *pwindow;
472 utf8_str *pstr;
473 unsigned window_x = 0, window_y = 0;
477
480
483 pstr->style |= TTF_STYLE_BOLD;
484
486
487 pwindow->action = dipomatic_window_callback;
488 set_wstate(pwindow, FC_WS_NORMAL);
489
490 dlg->end_widget_list = pwindow;
491 pwindow->data.cont = cont;
492 add_to_gui_list(ID_WINDOW, pwindow);
493
494 area = pwindow->area;
495
496 /* ============================================================= */
497 width = 0;
498 height = 0;
499
500 /* Pacts. */
501 if (pplayer0 == client_player() && DS_ALLIANCE != type) {
503 && type != DS_CEASEFIRE && type != DS_TEAM;
505 && type != DS_PEACE && type != DS_TEAM;
508
509 if (ceasefire || peace || alliance) {
511 _("Pacts"), FONTO_ATTENTION,
514 width = buf->size.w;
515 height = buf->size.h;
517 count++;
518 }
519
520 if (ceasefire) {
521 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Cease-fire"));
526 width = MAX(width, buf->size.w);
527 height = MAX(height, buf->size.h);
528 buf->action = pact_callback;
529 buf->data.cont = cont;
532 count++;
533 }
534
535 if (peace) {
536 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Peace"));
537
542 width = MAX(width, buf->size.w);
543 height = MAX(height, buf->size.h);
544 buf->action = pact_callback;
545 buf->data.cont = cont;
548 count++;
549 }
550
551 if (alliance) {
552 fc_snprintf(cbuf, sizeof(cbuf), " %s", Q_("?diplomatic_state:Alliance"));
553
558 width = MAX(width, buf->size.w);
559 height = MAX(height, buf->size.h);
560 buf->action = pact_callback;
561 buf->data.cont = cont;
564 count++;
565 }
566 }
567
568 /* ---------------------------- */
569 /* You can't give maps if you give shared vision */
571 bool full_map, sea_map;
572
575 _("Give shared vision"),
579 width = MAX(width, buf->size.w);
580 height = MAX(height, buf->size.h);
581 buf->action = vision_callback;
582 buf->data.cont = cont;
585 count++;
586 }
587
590
591 if (full_map || sea_map) {
593 _("Maps"), FONTO_ATTENTION,
595 buf->string_utf8->fgcol
597 width = MAX(width, buf->size.w);
598 height = MAX(height, buf->size.h);
600 count++;
601 }
602
603 if (full_map) {
604 fc_snprintf(cbuf, sizeof(cbuf), " %s", _("World map"));
605
609 buf->string_utf8->fgcol
611 width = MAX(width, buf->size.w);
612 height = MAX(height, buf->size.h);
613 buf->action = maps_callback;
614 buf->data.cont = cont;
617 count++;
618 }
619
620 if (sea_map) {
621 fc_snprintf(cbuf, sizeof(cbuf), " %s", _("Sea 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
638 /* Don't take in account the embassy effects. */
642 _("Give embassy"), FONTO_ATTENTION,
644 buf->string_utf8->fgcol
646 width = MAX(width, buf->size.w);
647 height = MAX(height, buf->size.h);
648 buf->action = embassy_callback;
649 buf->data.cont = cont;
652 count++;
653 }
654
655 /* ---------------------------- */
656 if (clause_enabled(CLAUSE_GOLD) && pplayer0->economic.gold > 0) {
657 cont->value = pplayer0->economic.gold;
658
659 fc_snprintf(cbuf, sizeof(cbuf), _("Gold(max %d)"), pplayer0->economic.gold);
663 buf->string_utf8->fgcol
665 width = MAX(width, buf->size.w);
666 height = MAX(height, buf->size.h);
668 count++;
669
670 buf = create_edit(NULL, pwindow->dst,
673 buf->data.cont = cont;
674 buf->action = gold_callback;
676 width = MAX(width, buf->size.w);
677 height = MAX(height, buf->size.h);
679 count++;
680 }
681 /* ---------------------------- */
682
683 /* Trading: advances */
685 const struct research *presearch0 = research_get(pplayer0);
686 const struct research *presearch1 = research_get(pplayer1);
687 int flag = A_NONE;
688
690 if (research_invention_state(presearch0, i) == TECH_KNOWN
691 && research_invention_gettable(presearch1, i,
693 && (research_invention_state(presearch1, i) == TECH_UNKNOWN
694 || research_invention_state(presearch1, i)
695 == TECH_PREREQS_KNOWN)) {
696
697 buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst,
698 _("Advances"), FONTO_ATTENTION,
700 buf->string_utf8->fgcol
702 width = MAX(width, buf->size.w);
703 height = MAX(height, buf->size.h);
705 count++;
706
707 fc_snprintf(cbuf, sizeof(cbuf), " %s",
709
710 buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, cbuf,
713 buf->string_utf8->fgcol
715 width = MAX(width, buf->size.w);
716 height = MAX(height, buf->size.h);
717 buf->action = techs_callback;
719 buf->data.cont = cont;
720 add_to_gui_list(MAX_ID - i, buf);
721 count++;
722 flag = ++i;
723 break;
724 }
726
727 if (flag > A_NONE) {
728 advance_index_iterate(flag, i) {
729 if (research_invention_state(presearch0, i) == TECH_KNOWN
730 && research_invention_gettable(presearch1, i,
732 && (research_invention_state(presearch1, i) == TECH_UNKNOWN
733 || research_invention_state(presearch1, i)
734 == TECH_PREREQS_KNOWN)) {
735
736 fc_snprintf(cbuf, sizeof(cbuf), " %s",
738
739 buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, cbuf,
742 buf->string_utf8->fgcol
744 width = MAX(width, buf->size.w);
745 height = MAX(height, buf->size.h);
746 buf->action = techs_callback;
748 buf->data.cont = cont;
749 add_to_gui_list(MAX_ID - i, buf);
750 count++;
751 }
752 }
754 } /* Advances */
755
756 /* Trading: cities */
757 /****************************************************************
758 Creates a sorted list of pplayer0's cities, excluding the capital and
759 any cities not visible to pplayer1. This means that you can only trade
760 cities visible to requesting player.
761
762 - Kris Bubendorfer
763 *****************************************************************/
764 if (clause_enabled(CLAUSE_CITY)) {
765 int i = 0, j = 0, n = city_list_size(pplayer0->cities);
766 struct city **city_list_ptrs;
767
768 if (n > 0) {
769 city_list_ptrs = fc_calloc(1, sizeof(struct city *) * n);
770 city_list_iterate(pplayer0->cities, pcity) {
771 if (!is_capital(pcity)) {
772 city_list_ptrs[i] = pcity;
773 i++;
774 }
776 } else {
777 city_list_ptrs = NULL;
778 }
779
780 if (i > 0) {
781 buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst,
782 _("Cities"), FONTO_ATTENTION,
784 buf->string_utf8->fgcol
786 buf->string_utf8->style &= ~SF_CENTER;
787 width = MAX(width, buf->size.w);
788 height = MAX(height, buf->size.h);
790 count++;
791
792 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
793
794 for (j = 0; j < i; j++) {
795 fc_snprintf(cbuf, sizeof(cbuf), " %s", city_name_get(city_list_ptrs[j]));
796
797 buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, cbuf,
800 buf->string_utf8->fgcol
802 width = MAX(width, buf->size.w);
803 height = MAX(height, buf->size.h);
804 buf->data.cont = cont;
805 buf->action = cities_callback;
807 /* MAX_ID is unigned short type range and city id must be in this range */
808 fc_assert(city_list_ptrs[j]->id <= MAX_ID);
809 add_to_gui_list(MAX_ID - city_list_ptrs[j]->id, buf);
810 count++;
811 }
812 }
813 FC_FREE(city_list_ptrs);
814 } /* Cities */
815
816 dlg->begin_widget_list = buf;
819 dlg->scroll = NULL;
820
821 area.h = (main_window_height() - adj_size(100) - (pwindow->size.h - pwindow->area.h));
822
823 if (area.h < (count * height)) {
825 count = area.h / height;
826 scroll_w = create_vertical_scrollbar(dlg, 1, count, TRUE, TRUE);
827 buf = pwindow;
828 /* Hide not seen widgets */
829 do {
830 buf = buf->prev;
831 if (count) {
832 count--;
833 } else {
834 set_wflag(buf, WF_HIDDEN);
835 }
836 } while (buf != dlg->begin_active_widget_list);
837 }
838
839 area.w = MAX(width + adj_size(4) + scroll_w, adj_size(150) - (pwindow->size.w - pwindow->area.w));
840
842 (pwindow->size.w - pwindow->area.w) + area.w,
843 (pwindow->size.h - pwindow->area.h) + area.h);
844
845 area = pwindow->area;
846
847 if (L_R) {
848 window_x = main_window->dst->dest_rect.x + main_window->size.w + adj_size(20);
849 } else {
850 window_x = main_window->dst->dest_rect.x - adj_size(20) - pwindow->size.w;
851 }
852 window_y = (main_window_height() - pwindow->size.h) / 2;
853
854 widget_set_position(pwindow, window_x, window_y);
855
857 area.x + adj_size(2), area.y + 1,
860
861 if (dlg->scroll) {
863 area.x + area.w,
864 area.y,
865 area.h, TRUE);
866 }
867
868 return dlg;
869}
870
871/**********************************************************************/
875 struct player *plr1)
876{
877 struct diplomacy_dialog *pdialog = fc_calloc(1, sizeof(struct diplomacy_dialog));
878
879 init_treaty(&pdialog->treaty, plr0, plr1);
880
881 pdialog->pdialog = fc_calloc(1, sizeof(struct advanced_dialog));
882
883 dialog_list_prepend(dialog_list, pdialog);
884
885 return pdialog;
886}
887
888/**********************************************************************/
892{
893 SDL_Color bg_color = {255, 255, 255, 136};
894 struct player *pplayer0, *pplayer1;
895 struct container *cont = fc_calloc(1, sizeof(struct container));
896 char cbuf[128];
897 struct widget *buf = NULL, *pwindow;
898 utf8_str *pstr;
901
902 if (pdialog) {
903 /* delete old content */
904 if (pdialog->pdialog->end_widget_list) {
906 pdialog->poffers->end_widget_list);
907 FC_FREE(pdialog->poffers->scroll);
908 FC_FREE(pdialog->poffers);
909
911 pdialog->pwants->end_widget_list);
912 FC_FREE(pdialog->pwants->scroll);
913 FC_FREE(pdialog->pwants);
914
916 pdialog->pdialog->end_widget_list);
917 }
918
919 pplayer0 = pdialog->treaty.plr0;
920 pplayer1 = pdialog->treaty.plr1;
921
924
925 fc_snprintf(cbuf, sizeof(cbuf), _("Diplomacy meeting"));
926
928 pstr->style |= TTF_STYLE_BOLD;
929
930 pwindow = create_window_skeleton(NULL, pstr, 0);
931
932 pwindow->action = dipomatic_window_callback;
933 set_wstate(pwindow, FC_WS_NORMAL);
934 pwindow->data.cont = cont;
935 pdialog->pdialog->end_widget_list = pwindow;
936
937 add_to_gui_list(ID_WINDOW, pwindow);
938
939 /* ============================================================= */
940
943 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
945
947 pwindow->dst, pstr,
950
951 buf->private_data.cbox = fc_calloc(1, sizeof(struct checkbox));
952 buf->private_data.cbox->state = FALSE;
953 buf->private_data.cbox->true_theme = current_theme->ok_pact_icon;
954 buf->private_data.cbox->false_theme = current_theme->cancel_pact_icon;
955
957
960 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
962
964 pwindow->dst, pstr,
967 buf->private_data.cbox = fc_calloc(1, sizeof(struct checkbox));
968 buf->private_data.cbox->state = FALSE;
969 buf->private_data.cbox->true_theme = current_theme->ok_pact_icon;
970 buf->private_data.cbox->false_theme = current_theme->cancel_pact_icon;
972 /* ============================================================= */
973
974 buf = create_themeicon(current_theme->cancel_pact_icon, pwindow->dst,
977 buf->info_label = create_utf8_from_char_fonto(_("Cancel meeting"),
980 buf->data.cont = cont;
982
984
985 buf = create_themeicon(current_theme->ok_pact_icon, pwindow->dst,
988 buf->info_label = create_utf8_from_char_fonto(_("Accept treaty"),
990 buf->action = accept_treaty_callback;
991 buf->data.cont = cont;
993
995 /* ============================================================= */
996
997 pdialog->pdialog->begin_widget_list = buf;
998
999 create_vertical_scrollbar(pdialog->pdialog, 1, 7, TRUE, TRUE);
1000 hide_scrollbar(pdialog->pdialog->scroll);
1001
1002 /* ============================================================= */
1003
1005 adj_size(250), adj_size(300));
1006
1007 area = pwindow->area;
1008
1009 widget_set_position(pwindow,
1010 (main_window_width() - pwindow->size.w) / 2,
1011 (main_window_height() - pwindow->size.h) / 2);
1012
1013 buf = pwindow->prev;
1014 buf->size.x = area.x + adj_size(17);
1015 buf->size.y = area.y + adj_size(6);
1016
1017 dst.y = area.y + adj_size(6) + buf->size.h + adj_size(10);
1018 dst.x = adj_size(10);
1019 dst.w = area.w - adj_size(14);
1020
1021 buf = buf->prev;
1022 buf->size.x = area.x + area.w - buf->size.w - adj_size(20);
1023 buf->size.y = area.y + adj_size(6);
1024
1025 buf = buf->prev;
1026 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(40))) / 2;
1027 buf->size.y = area.y + area.h - buf->size.w - adj_size(17);
1028
1029 buf = buf->prev;
1030 buf->size.x = buf->next->size.x + buf->next->size.w + adj_size(40);
1031 buf->size.y = area.y + area.h - buf->size.w - adj_size(17);
1032
1033 dst.h = area.h - buf->size.w - adj_size(3) - dst.y;
1034 /* ============================================================= */
1035
1036 fill_rect_alpha(pwindow->theme, &dst, &bg_color);
1037
1038 /* ============================================================= */
1040 area.x + dst.x + dst.w,
1041 dst.y,
1042 dst.h, TRUE);
1043 /* ============================================================= */
1045 FALSE);
1046
1047 pdialog->pwants = popup_diplomatic_objects(pplayer1, pplayer0, pwindow,
1048 TRUE);
1049 /* ============================================================= */
1050 /* redraw */
1051 redraw_group(pdialog->pdialog->begin_widget_list, pwindow, 0);
1052 widget_mark_dirty(pwindow);
1053
1055 pdialog->poffers->end_widget_list, 0);
1057
1059 pdialog->pwants->end_widget_list, 0);
1061
1062 flush_dirty();
1063 }
1064}
1065
1066/**********************************************************************/
1069static void update_acceptance_icons(struct diplomacy_dialog *pdialog)
1070{
1071 struct widget *label;
1073 SDL_Rect src = {0, 0, 0, 0};
1074
1075 /* updates your own acceptance status */
1076 label = pdialog->pdialog->end_widget_list->prev;
1077
1078 label->private_data.cbox->state = pdialog->treaty.accept0;
1079 if (label->private_data.cbox->state) {
1080 thm = label->private_data.cbox->true_theme;
1081 } else {
1082 thm = label->private_data.cbox->false_theme;
1083 }
1084
1085 src.w = thm->w / 4;
1086 src.h = thm->h;
1087
1088 alphablit(thm, &src, label->theme, NULL, 255);
1090
1091 widget_redraw(label);
1092 widget_flush(label);
1093
1094 /* updates other player's acceptance status */
1095 label = pdialog->pdialog->end_widget_list->prev->prev;
1096
1097 label->private_data.cbox->state = pdialog->treaty.accept1;
1098 if (label->private_data.cbox->state) {
1099 thm = label->private_data.cbox->true_theme;
1100 } else {
1101 thm = label->private_data.cbox->false_theme;
1102 }
1103
1104 src.w = thm->w / 4;
1105 src.h = thm->h;
1106
1107 alphablit(thm, &src, label->theme, NULL, 255);
1108
1109 widget_redraw(label);
1110 widget_flush(label);
1111}
1112
1113/**********************************************************************/
1116static void update_clauses_list(struct diplomacy_dialog *pdialog)
1117{
1118 utf8_str *pstr;
1119 struct widget *pbuf, *pwindow = pdialog->pdialog->end_widget_list;
1120 char cbuf[128];
1121 bool redraw_all, scroll = (pdialog->pdialog->active_widget_list != NULL);
1122 int len = pdialog->pdialog->scroll->up_left_button->size.w;
1123
1126
1128 pbuf = create_iconlabel(NULL, pwindow->dst, pstr,
1130
1131 if (pclause->from != client.conn.playing) {
1132 pbuf->string_utf8->style |= SF_CENTER_RIGHT;
1133 }
1134
1135 pbuf->data.cont = fc_calloc(1, sizeof(struct container));
1136 pbuf->data.cont->id0 = player_number(pclause->from);
1137 pbuf->data.cont->id1 = player_number(pdialog->treaty.plr1);
1138 pbuf->data.cont->value = ((int)pclause->type << 16) + pclause->value;
1139
1140 pbuf->action = remove_clause_callback;
1142
1143 pbuf->size.w = pwindow->size.w - adj_size(24) - (scroll ? len : 0);
1144
1146 pbuf, pdialog->pdialog->begin_widget_list,
1147 FALSE,
1148 pwindow->size.x + adj_size(12),
1149 pdialog->pdialog->scroll->up_left_button->size.y + adj_size(2));
1150
1151 if (!scroll && (pdialog->pdialog->active_widget_list != NULL)) {
1152 /* -> the scrollbar has been activated */
1154 do {
1155 pbuf = pbuf->prev;
1156 pbuf->size.w -= len;
1157 /* we need to save a new background because the width has changed */
1158 FREESURFACE(pbuf->gfx);
1159 } while (pbuf != pdialog->pdialog->begin_active_widget_list);
1160 scroll = TRUE;
1161 }
1162
1163 /* redraw */
1164 if (redraw_all) {
1165 redraw_group(pdialog->pdialog->begin_widget_list, pwindow, 0);
1166 widget_mark_dirty(pwindow);
1167 } else {
1170 }
1172
1173 flush_dirty();
1174}
1175
1176/**********************************************************************/
1180 enum clause_type type, int value)
1181{
1182 struct widget *buf;
1183 SDL_Rect src = {0, 0, 0, 0};
1184 bool scroll;
1186
1187 /* Find widget with clause */
1188 buf = pdialog->pdialog->end_active_widget_list->next;
1189
1190 do {
1191 buf = buf->prev;
1192 } while (!((buf->data.cont->id0 == giver)
1193 && (((buf->data.cont->value >> 16) & 0xFFFF) == (int)type)
1194 && ((buf->data.cont->value & 0xFFFF) == value))
1195 && (buf != pdialog->pdialog->begin_active_widget_list));
1196
1197 if (!(buf->data.cont->id0 == giver
1198 && ((buf->data.cont->value >> 16) & 0xFFFF) == (int)type
1199 && (buf->data.cont->value & 0xFFFF) == value)) {
1200 return;
1201 }
1202
1203 scroll = (pdialog->pdialog->active_widget_list != NULL);
1205
1206 if (scroll && (pdialog->pdialog->active_widget_list == NULL)) {
1207 /* -> the scrollbar has been deactivated */
1208 int len = pdialog->pdialog->scroll->up_left_button->size.w;
1209
1210 buf = pdialog->pdialog->end_active_widget_list->next;
1211 do {
1212 buf = buf->prev;
1213 widget_undraw(buf);
1214 buf->size.w += len;
1215 /* We need to save a new background because the width has changed */
1216 FREESURFACE(buf->gfx);
1217 } while (buf != pdialog->pdialog->begin_active_widget_list);
1218 }
1219
1220 /* Update state icons */
1221 buf = pdialog->pdialog->end_widget_list->prev;
1222
1223 if (buf->private_data.cbox->state) {
1224 buf->private_data.cbox->state = FALSE;
1225 src.w = buf->private_data.cbox->false_theme->w / 4;
1226 src.h = buf->private_data.cbox->false_theme->h;
1227
1228 alphablit(buf->private_data.cbox->false_theme, &src, buf->theme, NULL, 255);
1229 }
1230}
1231
1232/**********************************************************************/
1236void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
1237{
1238 struct diplomacy_dialog *pdialog;
1239
1240 if (!can_client_issue_orders()) {
1241 return;
1242 }
1243
1244 if (!is_human(client.conn.playing)) {
1245 return; /* Don't show if we are not under human control. */
1246 }
1247
1251 } else {
1252 /* bring existing dialog to front */
1254 pdialog->pdialog->end_widget_list);
1255 }
1256
1258}
1259
1260/**********************************************************************/
1264{
1265 if (pdialog != NULL) {
1267 pdialog->poffers->end_widget_list);
1268 FC_FREE(pdialog->poffers->scroll);
1269 FC_FREE(pdialog->poffers);
1270
1272 pdialog->pwants->end_widget_list);
1273 FC_FREE(pdialog->pwants->scroll);
1274 FC_FREE(pdialog->pwants);
1275
1277 pdialog->pdialog->end_widget_list);
1278
1279 FC_FREE(pdialog->pdialog->scroll);
1280 FC_FREE(pdialog->pdialog);
1282 }
1283}
1284
1285/**********************************************************************/
1289{
1293
1294 dialog_list_clear(dialog_list);
1295}
1296
1297/**********************************************************************/
1305
1306/* ================================================================= */
1307/* ========================== Small Diplomat Dialog ================ */
1308/* ================================================================= */
1309static struct small_dialog *spy_dlg = NULL;
1310
1311/**********************************************************************/
1314static void popdown_sdip_dialog(void)
1315{
1316 if (spy_dlg) {
1320 }
1321}
1322
1323/**********************************************************************/
1326static int sdip_window_callback(struct widget *pwindow)
1327{
1330 }
1331
1332 return -1;
1333}
1334
1335/**********************************************************************/
1338static int withdraw_vision_dlg_callback(struct widget *pwidget)
1339{
1342 player_number(pwidget->data.player),
1343 CLAUSE_VISION);
1344
1346 flush_dirty();
1347 }
1348
1349 return -1;
1350}
1351
1352/**********************************************************************/
1355static int cancel_pact_dlg_callback(struct widget *pwidget)
1356{
1359 player_number(pwidget->data.player),
1360 CLAUSE_CEASEFIRE);
1361
1363 flush_dirty();
1364 }
1365
1366 return -1;
1367}
1368
1369/**********************************************************************/
1372static int call_meeting_dlg_callback(struct widget *pwidget)
1373{
1375 if (can_meet_with_player(pwidget->data.player)) {
1378 (pwidget->data.player));
1379 }
1380
1382 flush_dirty();
1383 }
1384
1385 return -1;
1386}
1387
1388/**********************************************************************/
1391static int cancel_sdip_dlg_callback(struct widget *pwidget)
1392{
1395 flush_dirty();
1396 }
1397
1398 return -1;
1399}
1400
1401/**********************************************************************/
1404static void popup_war_dialog(struct player *pplayer)
1405{
1406 char cbuf[128];
1407 struct widget *buf = NULL, *pwindow;
1408 utf8_str *pstr;
1409 SDL_Surface *text;
1410 SDL_Rect dst;
1411 SDL_Rect area;
1412
1413 if (spy_dlg) {
1414 return;
1415 }
1416
1417 spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
1418
1419 fc_snprintf(cbuf, sizeof(cbuf),
1420 /* TRANS: "Polish incident !" FIXME!!! */
1421 _("%s incident !"),
1424 pstr->style |= TTF_STYLE_BOLD;
1425
1426 pwindow = create_window_skeleton(NULL, pstr, 0);
1427
1428 pwindow->action = sdip_window_callback;
1429 set_wstate(pwindow, FC_WS_NORMAL);
1430
1431 add_to_gui_list(ID_WINDOW, pwindow);
1432
1433 spy_dlg->end_widget_list = pwindow;
1434
1435 area = pwindow->area;
1436
1437 /* ============================================================= */
1438 /* Label */
1439 fc_snprintf(cbuf, sizeof(cbuf), _("Shall we declare WAR on them?"));
1440
1442 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1444
1447 area.w = MAX(area.w, text->w);
1448 area.h += text->h + adj_size(10);
1449
1451 pwindow->dst, _("No"),
1452 FONTO_ATTENTION, 0);
1453
1454 buf->action = cancel_sdip_dlg_callback;
1456 buf->key = SDLK_ESCAPE;
1457 area.h += buf->size.h;
1458
1460
1462 pwindow->dst,
1463 _("Yes"),
1464 FONTO_ATTENTION, 0);
1465
1466 buf->action = cancel_pact_dlg_callback;
1468 buf->data.player = pplayer;
1469 buf->key = SDLK_RETURN;
1471 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1472 buf->next->size.w = buf->size.w;
1473 area.w = MAX(area.w , 2 * buf->size.w + adj_size(20));
1474
1476
1477 /* Setup window size and start position */
1478 area.w += adj_size(10);
1479 area.h += adj_size(5);
1480
1482 (pwindow->size.w - pwindow->area.w) + area.w,
1483 (pwindow->size.h - pwindow->area.h) + area.h);
1484
1485 area = pwindow->area;
1486
1487 widget_set_position(pwindow,
1488 (main_window_width() - pwindow->size.w) / 2,
1489 (main_window_height() - pwindow->size.h) / 2);
1490
1491 /* Setup rest of widgets */
1492 /* Label */
1493 dst.x = area.x + (area.w - text->w) / 2;
1494 dst.y = area.y + 1;
1495 alphablit(text, NULL, pwindow->theme, &dst, 255);
1496 dst.y += text->h + adj_size(5);
1497 FREESURFACE(text);
1498
1499 /* No */
1500 buf = pwindow->prev;
1501 buf->size.y = dst.y;
1502
1503 /* Yes */
1504 buf = buf->prev;
1505 buf->size.x = area.x + (area.w - (2 * buf->size.w + adj_size(20))) / 2;
1506 buf->size.y = dst.y;
1507
1508 /* No */
1509 buf->next->size.x = buf->size.x + buf->size.w + adj_size(20);
1510
1511 /* ================================================== */
1512 /* Redraw */
1514 widget_mark_dirty(pwindow);
1515 flush_dirty();
1516}
1517
1518/* ===================================================================== */
1519
1520/**********************************************************************/
1523void popup_diplomacy_dialog(struct player *pplayer)
1524{
1525 enum diplstate_type type =
1527
1528 if (!can_meet_with_player(pplayer)) {
1529 if (DS_WAR == type || pplayer == client.conn.playing) {
1530 flush_dirty();
1531
1532 return;
1533 } else {
1534 popup_war_dialog(pplayer);
1535
1536 return;
1537 }
1538 } else {
1539 int button_w = 0, button_h = 0;
1540 char cbuf[128];
1541 struct widget *buf = NULL, *pwindow;
1542 utf8_str *pstr;
1543 SDL_Surface *text;
1544 SDL_Rect dst;
1545 bool shared;
1546 SDL_Rect area;
1547 int buttons = 0;
1548 bool can_toward_war;
1549
1550 if (spy_dlg) {
1551 return;
1552 }
1553
1554 spy_dlg = fc_calloc(1, sizeof(struct small_dialog));
1555
1556 fc_snprintf(cbuf, sizeof(cbuf), _("Foreign Minister"));
1558 pstr->style |= TTF_STYLE_BOLD;
1559
1560 pwindow = create_window_skeleton(NULL, pstr, 0);
1561
1562 pwindow->action = sdip_window_callback;
1563 set_wstate(pwindow, FC_WS_NORMAL);
1564 spy_dlg->end_widget_list = pwindow;
1565
1566 add_to_gui_list(ID_WINDOW, pwindow);
1567
1568 area = pwindow->area;
1569
1570 /* ============================================================= */
1571 /* Label */
1573 fc_snprintf(cbuf, sizeof(cbuf), _("Sir!, the %s ambassador has arrived\n"
1574 "What are your wishes?"),
1576 } else {
1577 fc_snprintf(cbuf, sizeof(cbuf), _("Ma'am!, the %s ambassador has arrived\n"
1578 "What are your wishes?"),
1580 }
1581
1583 pstr->style |= (TTF_STYLE_BOLD|SF_CENTER);
1585
1588 area.w = MAX(area.w , text->w);
1589 area.h += text->h + adj_size(15);
1590
1593
1594 if (can_toward_war) {
1595 if (type == DS_ARMISTICE) {
1596 fc_snprintf(cbuf, sizeof(cbuf), _("Declare WAR"));
1597 } else {
1598 fc_snprintf(cbuf, sizeof(cbuf), _("Cancel Treaty"));
1599 }
1600
1601 /* Cancel treaty */
1603 pwindow->dst, cbuf,
1604 FONTO_ATTENTION, 0);
1605
1606 buf->action = cancel_pact_dlg_callback;
1608 buf->string_utf8->fgcol
1610 buf->data.player = pplayer;
1611 buf->key = SDLK_c;
1613 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1614 buf->next->size.w = buf->size.w;
1615 button_w = MAX(button_w, buf->size.w);
1616 button_h = MAX(button_h, buf->size.h);
1617 buttons++;
1618 }
1619
1621
1622 if (shared) {
1623 /* Shared vision */
1625 pwindow->dst,
1626 _("Withdraw vision"),
1627 FONTO_ATTENTION, 0);
1628
1631 buf->data.player = pplayer;
1632 buf->key = SDLK_w;
1633 buf->string_utf8->fgcol
1636 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1637 buf->next->size.w = buf->size.w;
1638 button_w = MAX(button_w , buf->size.w);
1639 button_h = MAX(button_h , buf->size.h);
1640 buttons++;
1641 }
1642
1643 /* Meet */
1645 pwindow->dst,
1646 _("Call Diplomatic Meeting"),
1647 FONTO_ATTENTION, 0);
1648
1651 buf->data.player = pplayer;
1652 buf->key = SDLK_m;
1655 buf->size.w = MAX(buf->next->size.w, buf->size.w);
1656 buf->next->size.w = buf->size.w;
1657 button_w = MAX(button_w , buf->size.w);
1658 button_h = MAX(button_h , buf->size.h);
1659 buttons++;
1660
1662 pwindow->dst,
1663 _("Send them back"),
1664 FONTO_ATTENTION, 0);
1665
1666 buf->action = cancel_sdip_dlg_callback;
1669 buf->key = SDLK_ESCAPE;
1670 button_w = MAX(button_w , buf->size.w);
1671 button_h = MAX(button_h , buf->size.h);
1672 buttons++;
1673
1674 button_h += adj_size(4);
1675 area.w = MAX(area.w, button_w + adj_size(20));
1676
1677 area.h += buttons * (button_h + adj_size(10));
1678
1680
1682
1683 /* Setup window size and start position */
1684 area.w += adj_size(10);
1685 area.h += adj_size(2);
1686
1688 (pwindow->size.w - pwindow->area.w) + area.w,
1689 (pwindow->size.h - pwindow->area.h) + area.h);
1690
1691 area = pwindow->area;
1692
1693 widget_set_position(pwindow,
1694 (main_window_width() - pwindow->size.w) / 2,
1695 (main_window_height() - pwindow->size.h) / 2);
1696
1697 /* Setup rest of widgets */
1698 /* Label */
1699 dst.x = area.x + (area.w - text->w) / 2;
1700 dst.y = area.y + 1;
1701 alphablit(text, NULL, pwindow->theme, &dst, 255);
1702 dst.y += text->h + adj_size(15);
1703 FREESURFACE(text);
1704
1705 buf = pwindow;
1706
1707 /* War: meet, peace: cancel treaty */
1708 buf = buf->prev;
1709 buf->size.w = button_w;
1710 buf->size.h = button_h;
1711 buf->size.x = area.x + (area.w - (buf->size.w)) / 2;
1712 buf->size.y = dst.y;
1713
1714 if (shared) {
1715 /* Vision */
1716 buf = buf->prev;
1717 buf->size.w = button_w;
1718 buf->size.h = button_h;
1719 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1720 buf->size.x = buf->next->size.x;
1721 }
1722
1723 if (type != DS_WAR) {
1724 /* Meet */
1725 buf = buf->prev;
1726 buf->size.w = button_w;
1727 buf->size.h = button_h;
1728 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1729 buf->size.x = buf->next->size.x;
1730 }
1731
1732 /* Cancel */
1733 if (can_toward_war) {
1734 buf = buf->prev;
1735 buf->size.w = button_w;
1736 buf->size.h = button_h;
1737 buf->size.y = buf->next->size.y + buf->next->size.h + adj_size(10);
1738 buf->size.x = buf->next->size.x;
1739 }
1740
1741 /* ================================================== */
1742 /* Redraw */
1744 widget_mark_dirty(pwindow);
1745
1746 flush_dirty();
1747 }
1748}
#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:1552
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
int city_name_compare(const void *p1, const void *p2)
Definition city.c:1684
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define city_list_iterate_end
Definition city.h:490
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
int int initiated_from int int giver
Definition diplodlg_g.h:28
int int initiated_from handle_diplomacy_remove_clause
Definition diplodlg_g.h:28
handle_diplomacy_cancel_meeting
Definition diplodlg_g.h:24
int counterpart
Definition diplodlg_g.h:25
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:96
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:142
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:286
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:120
#define clause_list_iterate_end
Definition diptreaty.h:68
#define clause_list_iterate(clauselist, pclause)
Definition diptreaty.h:66
QString current_theme
Definition fc_client.cpp:65
#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:57
static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:962
static struct Diplomacy_dialog * create_diplomacy_dialog(struct player *plr0, struct player *plr1)
Definition diplodlg.c:670
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition diplodlg.c:135
void diplomacy_dialog_init(void)
Definition diplodlg.c:1175
#define dialog_list_iterate_end
Definition diplodlg.c:82
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition diplodlg.c:157
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1230
#define dialog_list_iterate(dialoglist, pdialog)
Definition diplodlg.c:80
static struct dialog_list * dialog_list
Definition diplodlg.c:84
void diplomacy_dialog_done(void)
Definition diplodlg.c:1184
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition diplodlg.c:116
static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
Definition diplodlg.c:192
void flush_dirty(void)
Definition mapview.c:450
GType type
Definition repodlgs.c:1312
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:44
static struct diplomacy_dialog * get_diplomacy_dialog(int other_player_id)
Definition diplodlg.c:98
static int dipomatic_window_callback(struct widget *pwindow)
Definition diplodlg.c:451
static int accept_treaty_callback(struct widget *pwidget)
Definition diplodlg.c:241
static void update_clauses_list(struct diplomacy_dialog *pdialog)
Definition diplodlg.c:1116
static int remove_clause_callback(struct widget *pwidget)
Definition diplodlg.c:152
static int cancel_pact_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1355
static void popdown_sdip_dialog(void)
Definition diplodlg.c:1314
static int sdip_window_callback(struct widget *pwindow)
Definition diplodlg.c:1326
static void remove_clause_widget_from_list(int counterpart, int giver, enum clause_type type, int value)
Definition diplodlg.c:1179
static int withdraw_vision_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1338
static int cities_callback(struct widget *pwidget)
Definition diplodlg.c:429
static int maps_callback(struct widget *pwidget)
Definition diplodlg.c:332
static int cancel_meeting_callback(struct widget *pwidget)
Definition diplodlg.c:228
static int embassy_callback(struct widget *pwidget)
Definition diplodlg.c:311
static int gold_callback(struct widget *pwidget)
Definition diplodlg.c:385
static void update_acceptance_icons(struct diplomacy_dialog *pdialog)
Definition diplodlg.c:1069
static void popdown_diplomacy_dialogs(void)
Definition diplodlg.c:1288
static void popdown_diplomacy_dialog(struct diplomacy_dialog *pdialog)
Definition diplodlg.c:1263
static int vision_callback(struct widget *pwidget)
Definition diplodlg.c:290
static int techs_callback(struct widget *pwidget)
Definition diplodlg.c:363
static int pact_callback(struct widget *pwidget)
Definition diplodlg.c:256
static struct advanced_dialog * popup_diplomatic_objects(struct player *pplayer0, struct player *pplayer1, struct widget *main_window, bool L_R)
Definition diplodlg.c:460
static int cancel_sdip_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1391
static int call_meeting_dlg_callback(struct widget *pwidget)
Definition diplodlg.c:1372
static void popup_war_dialog(struct player *pplayer)
Definition diplodlg.c:1404
static struct small_dialog * spy_dlg
Definition diplodlg.c:1309
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
#define adj_size(size)
Definition gui_main.h:138
#define PRESSED_EVENT(event)
Definition gui_main.h:68
@ 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
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:92
#define SF_CENTER
Definition gui_string.h:40
#define SF_CENTER_RIGHT
Definition gui_string.h:41
@ FONTO_HEADING
Definition gui_string.h:68
@ FONTO_DEFAULT
Definition gui_string.h:64
@ FONTO_ATTENTION
Definition gui_string.h:66
#define create_utf8_from_char_fonto(string_in, fonto)
Definition gui_string.h:107
#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:168
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:125
struct player * player_by_number(const int player_id)
Definition player.c:840
int player_number(const struct player *pplayer)
Definition player.c:828
enum dipl_reason pplayer_can_make_treaty(const struct player *p1, const struct player *p2, enum diplstate_type treaty)
Definition player.c:153
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:234
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, const struct player *p2)
Definition player.c:92
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1461
@ DIPL_OK
Definition player.h:195
#define is_human(plr)
Definition player.h:233
struct research * research_get(const struct player *pplayer)
Definition research.c:126
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:690
#define MAX(x, y)
Definition shared.h:54
struct player * plr0
Definition diptreaty.h:77
bool accept0
Definition diptreaty.h:78
bool accept1
Definition diptreaty.h:78
struct clause_list * clauses
Definition diptreaty.h:79
struct player * plr1
Definition diptreaty.h:77
struct widget * active_widget_list
Definition widget.h:186
struct widget * end_widget_list
Definition widget.h:182
struct widget * begin_widget_list
Definition widget.h:181
struct widget * begin_active_widget_list
Definition widget.h:184
struct widget * end_active_widget_list
Definition widget.h:185
struct scroll_bar * scroll
Definition widget.h:187
SDL_Surface * true_theme
SDL_Surface * false_theme
Definition city.h:309
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:156
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 advanced_dialog * pwants
Definition diplodlg.c:56
struct Treaty treaty
Definition diplodlg.c:54
struct advanced_dialog * poffers
Definition diplodlg.c:57
SDL_Rect dest_rect
Definition graphics.h:228
bool tech_trade_allow_holes
enum diplstate_type type
Definition player.h:201
struct city_list * cities
Definition player.h:281
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
Uint8 style
Definition gui_string.h:53
SDL_Color fgcol
Definition gui_string.h:57
char * text
Definition gui_string.h:60
struct widget * next
Definition widget.h:113
struct checkbox * cbox
Definition widget.h:137
union widget::@214 data
struct player * player
Definition widget.h:130
struct gui_layer * dst
Definition widget.h:116
SDL_Surface * gfx
Definition widget.h:120
struct widget * prev
Definition widget.h:114
int(* action)(struct widget *)
Definition widget.h:157
struct container * cont
Definition widget.h:127
union widget::@215 private_data
SDL_Surface * theme
Definition widget.h:118
utf8_str * string_utf8
Definition widget.h:121
SDL_Rect area
Definition widget.h:149
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:969
#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_end
Definition tech.h:248
#define A_FIRST
Definition tech.h:44
#define A_NONE
Definition tech.h:43
#define advance_index_iterate(_start, _index)
Definition tech.h:244
@ 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:585
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:997
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:1050
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:719
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:982
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1038
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)
int 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)