Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/diplodlg.c Source File

Freeciv-3.1

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