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