Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-sdl3/diplodlg.c Source File

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