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#include <stdio.h>
19#include <stdlib.h>
20
21#include <gtk/gtk.h>
22
23/* utility */
24#include "log.h"
25#include "mem.h"
26#include "shared.h"
27#include "support.h"
28
29/* common */
30#include "diptreaty.h"
31#include "fcintl.h"
32#include "game.h"
33#include "government.h"
34#include "map.h"
35#include "packets.h"
36#include "player.h"
37#include "research.h"
38
39/* client */
40#include "chatline.h"
41#include "client_main.h"
42#include "climisc.h"
43#include "options.h"
44
45/* client/gui-gtk-4.0 */
46#include "diplodlg.h"
47#include "gui_main.h"
48#include "gui_stuff.h"
49#include "mapview.h"
50#include "plrdlg.h"
51
52struct Diplomacy_dialog {
53 struct Treaty treaty;
54 struct gui_dialog* dialog;
55
56 GtkWidget *pic0;
57 GtkWidget *pic1;
58
59 GtkListStore *store;
60};
61
62struct Diplomacy_notebook {
63 struct gui_dialog* dialog;
64 GtkWidget *notebook;
65};
66
67struct city_deal {
68 int giver;
69 int receiver;
70 int id;
71};
72
73#define SPECLIST_TAG dialog
74#define SPECLIST_TYPE struct Diplomacy_dialog
75#include "speclist.h"
76
77#define dialog_list_iterate(dialoglist, pdialog) \
78 TYPED_LIST_ITERATE(struct Diplomacy_dialog, dialoglist, pdialog)
79#define dialog_list_iterate_end LIST_ITERATE_END
80
81static struct dialog_list *dialog_list;
83
84static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0,
85 struct player *plr1);
86
87static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id);
88static void popup_diplomacy_dialog(int other_player_id, int initiated_from);
89static void diplomacy_dialog_map_callback(GSimpleAction *action,
90 GVariant *parameter,
91 gpointer data);
92static void diplomacy_dialog_seamap_callback(GSimpleAction *action,
93 GVariant *parameter,
94 gpointer data);
95
96static void diplomacy_dialog_tech_callback(GSimpleAction *action,
97 GVariant *parameter,
98 gpointer data);
99static void diplomacy_dialog_city_callback(GSimpleAction *action,
100 GVariant *parameter,
101 gpointer data);
102static void diplomacy_dialog_vision_callback(GSimpleAction *action,
103 GVariant *parameter,
104 gpointer data);
105static void diplomacy_dialog_embassy_callback(GSimpleAction *action,
106 GVariant *parameter,
107 gpointer data);
108static void diplomacy_dialog_ceasefire_callback(GSimpleAction *action,
109 GVariant *parameter,
110 gpointer data);
111static void diplomacy_dialog_peace_callback(GSimpleAction *action,
112 GVariant *parameter,
113 gpointer data);
114static void diplomacy_dialog_alliance_callback(GSimpleAction *action,
115 GVariant *parameter,
116 gpointer data);
117
118static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
119static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
120static void diplo_dialog_returnkey(GtkWidget *w, gpointer data);
121
122static struct Diplomacy_notebook *diplomacy_main_create(void);
123static void diplomacy_main_destroy(void);
124static void diplomacy_main_response(struct gui_dialog *dlg, int response,
125 gpointer data);
126
127#define RESPONSE_CANCEL_MEETING 100
128#define RESPONSE_CANCEL_MEETING_ALL 101
129
130/************************************************************************/
134 bool other_accepted)
135{
137
138 if (!pdialog) {
139 return;
140 }
141
142 pdialog->treaty.accept0 = I_accepted;
143 pdialog->treaty.accept1 = other_accepted;
144
146 gui_dialog_alert(pdialog->dialog);
147}
148
149/************************************************************************/
152void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
153{
154 popup_diplomacy_dialog(counterpart, initiated_from);
155}
156
157/************************************************************************/
160void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
161{
163
164 if (!pdialog) {
165 return;
166 }
167
168 close_diplomacy_dialog(pdialog);
169}
170
171/************************************************************************/
175 enum clause_type type, int value)
176{
178
179 if (!pdialog) {
180 return;
181 }
182
183 add_clause(&pdialog->treaty, player_by_number(giver), type, value,
184 client_player());
186 gui_dialog_alert(pdialog->dialog);
187}
188
189/************************************************************************/
193 enum clause_type type, int value)
194{
196
197 if (!pdialog) {
198 return;
199 }
200
201 remove_clause(&pdialog->treaty, player_by_number(giver), type, value);
203 gui_dialog_alert(pdialog->dialog);
204}
205
206/************************************************************************/
209static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
210{
211 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(other_player_id);
212
214 return;
215 }
216
217 if (!is_human(client.conn.playing)) {
218 return; /* Don't show if we are not human controlled. */
219 }
220
221 if (!pdialog) {
223 player_by_number(other_player_id));
224 }
225
226 gui_dialog_present(pdialog->dialog);
227 /* We initated the meeting - Make the tab active */
228 if (player_by_number(initiated_from) == client.conn.playing) {
229 /* we have to raise the diplomacy meeting tab as well as the selected
230 * meeting. */
231 fc_assert_ret(dipl_main != NULL);
233 gui_dialog_raise(pdialog->dialog);
234
235 if (players_dialog_shell != NULL) {
237 }
238 }
239}
240
241/************************************************************************/
244static gint sort_advance_names(gconstpointer a, gconstpointer b)
245{
246 const struct advance *padvance1 = (const struct advance *) a;
247 const struct advance *padvance2 = (const struct advance *) b;
248
249 return fc_strcoll(advance_name_translation(padvance1),
250 advance_name_translation(padvance2));
251}
252
253/************************************************************************/
256static GMenu *create_clause_menu(GActionGroup *group,
257 struct Diplomacy_dialog *pdialog,
258 struct player *partner, bool them)
259{
260 GMenu *topmenu, *submenu;
261 GSimpleAction *act;
262 bool any_map = FALSE;
263 char act_plr_part[20];
264 char act_name[60];
265 struct player *pgiver, *pother;
266
267 if (them) {
268 fc_strlcpy(act_plr_part, "_them", sizeof(act_plr_part));
269 pgiver = partner;
270 pother = client_player();
271 } else {
272 fc_strlcpy(act_plr_part, "_us", sizeof(act_plr_part));
273 pgiver = client_player();
274 pother = partner;
275 }
276
277 topmenu = g_menu_new();
278
279 /* Maps. */
280 if (clause_enabled(CLAUSE_MAP)) {
281 submenu = g_menu_new();
282
283 fc_snprintf(act_name, sizeof(act_name), "worldmap%s", act_plr_part);
284 act = g_simple_action_new(act_name, NULL);
285 g_object_set_data(G_OBJECT(act), "plr", pgiver);
286 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
287 g_signal_connect(act, "activate", G_CALLBACK(diplomacy_dialog_map_callback),
288 pdialog);
289
290 fc_snprintf(act_name, sizeof(act_name), "win.worldmap%s", act_plr_part);
291 menu_item_append_unref(submenu, g_menu_item_new(_("World-map"), act_name));
292
293 any_map = TRUE;
294 }
295
296 if (clause_enabled(CLAUSE_SEAMAP)) {
297 if (!any_map) {
298 submenu = g_menu_new();
299 }
300
301 fc_snprintf(act_name, sizeof(act_name), "seamap%s", act_plr_part);
302 act = g_simple_action_new(act_name, NULL);
303 g_object_set_data(G_OBJECT(act), "plr", pgiver);
304 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
305 g_signal_connect(act, "activate", G_CALLBACK(diplomacy_dialog_seamap_callback),
306 pdialog);
307
308 fc_snprintf(act_name, sizeof(act_name), "win.seamap%s", act_plr_part);
309 menu_item_append_unref(submenu, g_menu_item_new(_("Sea-map"), act_name));
310
311 any_map = TRUE;
312 }
313
314 if (any_map) {
315 submenu_append_unref(topmenu, _("_Maps"), G_MENU_MODEL(submenu));
316 }
317
318 /* Trading: advances */
319 if (clause_enabled(CLAUSE_ADVANCE)) {
320 const struct research *gresearch = research_get(pgiver);
321 const struct research *oresearch = research_get(pother);
322 GList *sorting_list = NULL;
323 bool team_embassy = team_has_embassy(pgiver->team, pother);
324 int i;
325
326 submenu = g_menu_new();
327
328 advance_iterate(A_FIRST, padvance) {
329 Tech_type_id tech = advance_number(padvance);
330
331 if (research_invention_state(gresearch, tech) == TECH_KNOWN
332 && (!team_embassy /* We don't know what the other could actually receive */
333 || research_invention_gettable(oresearch, tech,
335 && (research_invention_state(oresearch, tech) == TECH_UNKNOWN
336 || research_invention_state(oresearch, tech)
337 == TECH_PREREQS_KNOWN)) {
338 sorting_list = g_list_prepend(sorting_list, padvance);
339 }
341
342 if (NULL != sorting_list) {
343 GList *list_item;
344 const struct advance *padvance;
345
346 sorting_list = g_list_sort(sorting_list, sort_advance_names);
347
348 /* TRANS: All technologies menu item in the diplomatic dialog. */
349 fc_snprintf(act_name, sizeof(act_name), "advance%sall", act_plr_part);
350 act = g_simple_action_new(act_name, NULL);
351 g_object_set_data(G_OBJECT(act), "player_from",
352 GINT_TO_POINTER(player_number(pgiver)));
353 g_object_set_data(G_OBJECT(act), "player_to",
354 GINT_TO_POINTER(player_number(pother)));
355 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
356 g_signal_connect(act, "activate",
358 GINT_TO_POINTER(A_LAST));
359
360 fc_snprintf(act_name, sizeof(act_name), "win.advance%sall", act_plr_part);
361 menu_item_append_unref(submenu, g_menu_item_new(_("All advances"), act_name));
362
363 for (list_item = sorting_list, i = 0; NULL != list_item;
364 list_item = g_list_next(list_item), i++) {
365
366 fc_snprintf(act_name, sizeof(act_name), "advance%s%d",
367 act_plr_part, i);
368 act = g_simple_action_new(act_name, NULL);
369
370 padvance = (const struct advance *) list_item->data;
371 g_object_set_data(G_OBJECT(act), "player_from",
372 GINT_TO_POINTER(player_number(pgiver)));
373 g_object_set_data(G_OBJECT(act), "player_to",
374 GINT_TO_POINTER(player_number(pother)));
375 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
376 g_signal_connect(act, "activate",
378 GINT_TO_POINTER(advance_number(padvance)));
379
380 fc_snprintf(act_name, sizeof(act_name), "win.advance%s%d",
381 act_plr_part, i);
383 g_menu_item_new(advance_name_translation(padvance),
384 act_name));
385 }
386
387 g_list_free(sorting_list);
388 }
389
390 submenu_append_unref(topmenu, _("_Advances"), G_MENU_MODEL(submenu));
391 }
392
393 /* Trading: cities. */
394
395 /****************************************************************
396 Creates a sorted list of plr0's cities, excluding the capital and
397 any cities not visible to plr1. This means that you can only trade
398 cities visible to requesting player.
399
400 - Kris Bubendorfer
401 *****************************************************************/
402 if (clause_enabled(CLAUSE_CITY)) {
403 int i = 0;
404 int n = city_list_size(pgiver->cities);
405
406 submenu = g_menu_new();
407
408 if (n > 0) {
409 struct city **city_list_ptrs;
410
411 city_list_ptrs = fc_malloc(sizeof(struct city *) * n);
412
413 city_list_iterate(pgiver->cities, pcity) {
414 if (!is_capital(pcity)) {
415 city_list_ptrs[i] = pcity;
416 i++;
417 }
419
420 if (i > 0) { /* Cities other than capitals */
421 int j;
422
423 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
424
425 for (j = 0; j < i; j++) {
426 struct city_deal *deal = fc_malloc(sizeof(struct city_deal));
427
428 fc_snprintf(act_name, sizeof(act_name), "city%s%d", act_plr_part, i);
429 act = g_simple_action_new(act_name, NULL);
430
431 deal->giver = player_number(pgiver);
432 deal->receiver = player_number(pother);
433 deal->id = city_list_ptrs[j]->id;
434
435 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
436 g_signal_connect(act, "activate",
438 (gpointer)deal);
439
440 fc_snprintf(act_name, sizeof(act_name), "win.city%s%d",
441 act_plr_part, i);
443 g_menu_item_new(city_name_get(city_list_ptrs[j]),
444 act_name));
445 }
446 }
447
448 free(city_list_ptrs);
449 }
450
451 submenu_append_unref(topmenu, _("_Cities"), G_MENU_MODEL(submenu));
452 }
453
454 /* Give shared vision. */
455 if (clause_enabled(CLAUSE_VISION)) {
456 fc_snprintf(act_name, sizeof(act_name), "vision%s", act_plr_part);
457 act = g_simple_action_new(act_name, NULL);
458 g_object_set_data(G_OBJECT(act), "plr", pgiver);
459 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
460 g_signal_connect(act, "activate", G_CALLBACK(diplomacy_dialog_vision_callback),
461 pdialog);
462
463 fc_snprintf(act_name, sizeof(act_name), "win.vision%s", act_plr_part);
464 menu_item_append_unref(topmenu, g_menu_item_new(_("_Give shared vision"), act_name));
465
466 g_simple_action_set_enabled(G_SIMPLE_ACTION(act),
467 !gives_shared_vision(pgiver, pother));
468 }
469
470 /* Give embassy. */
471 if (clause_enabled(CLAUSE_EMBASSY)) {
472 fc_snprintf(act_name, sizeof(act_name), "embassy%s", act_plr_part);
473 act = g_simple_action_new(act_name, NULL);
474 g_object_set_data(G_OBJECT(act), "plr", pgiver);
475 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
476 g_signal_connect(act, "activate", G_CALLBACK(diplomacy_dialog_embassy_callback),
477 pdialog);
478
479 fc_snprintf(act_name, sizeof(act_name), "win.embassy%s", act_plr_part);
480 menu_item_append_unref(topmenu, g_menu_item_new(_("Give _embassy"), act_name));
481
482 g_simple_action_set_enabled(G_SIMPLE_ACTION(act),
483 !player_has_real_embassy(pother, pgiver));
484 }
485
486 /* Pacts. */
487 if (pgiver == pdialog->treaty.plr0) {
488 enum diplstate_type ds;
489 int pact_clauses = 0;
490
491 ds = player_diplstate_get(pgiver, pother)->type;
492
493 submenu = g_menu_new();
494
495 if (clause_enabled(CLAUSE_CEASEFIRE)) {
496 fc_snprintf(act_name, sizeof(act_name), "ceasefire%s", act_plr_part);
497 act = g_simple_action_new(act_name, NULL);
498 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
499 g_signal_connect(act, "activate",
500 G_CALLBACK(diplomacy_dialog_ceasefire_callback), pdialog);
501
502 fc_snprintf(act_name, sizeof(act_name), "win.ceasefire%s", act_plr_part);
504 g_menu_item_new(Q_("?diplomatic_state:Cease-fire"),
505 act_name));
506
507 g_simple_action_set_enabled(G_SIMPLE_ACTION(act),
508 ds != DS_CEASEFIRE && ds != DS_TEAM);
509 pact_clauses++;
510 }
511
512 if (clause_enabled(CLAUSE_PEACE)) {
513 fc_snprintf(act_name, sizeof(act_name), "peace%s", act_plr_part);
514 act = g_simple_action_new(act_name, NULL);
515 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
516 g_signal_connect(act, "activate",
517 G_CALLBACK(diplomacy_dialog_peace_callback), pdialog);
518
519 fc_snprintf(act_name, sizeof(act_name), "win.peace%s", act_plr_part);
520 menu_item_append_unref(submenu, g_menu_item_new(Q_("?diplomatic_state:Peace"),
521 act_name));
522
523 g_simple_action_set_enabled(G_SIMPLE_ACTION(act),
524 ds != DS_PEACE && ds != DS_TEAM);
525 pact_clauses++;
526 }
527
528 if (clause_enabled(CLAUSE_ALLIANCE)) {
529 fc_snprintf(act_name, sizeof(act_name), "alliance%s", act_plr_part);
530 act = g_simple_action_new(act_name, NULL);
531 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
532 g_signal_connect(act, "activate",
533 G_CALLBACK(diplomacy_dialog_alliance_callback), pdialog);
534
535 fc_snprintf(act_name, sizeof(act_name), "win.alliance%s", act_plr_part);
537 g_menu_item_new(Q_("?diplomatic_state:Alliance"),
538 act_name));
539
540 g_simple_action_set_enabled(G_SIMPLE_ACTION(act),
541 ds != DS_ALLIANCE && ds != DS_TEAM);
542 pact_clauses++;
543 }
544
545 if (pact_clauses > 0) {
546 submenu_append_unref(topmenu, _("_Pacts"), G_MENU_MODEL(submenu));
547 } else {
548 g_object_unref(submenu);
549 }
550 }
551
552 return topmenu;
553}
554
555/************************************************************************/
558static void row_callback(GtkTreeView *view, GtkTreePath *path,
559 GtkTreeViewColumn *col, gpointer data)
560{
561 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
562 gint i;
563 gint *index;
564
565 index = gtk_tree_path_get_indices(path);
566
567 i = 0;
568 clause_list_iterate(pdialog->treaty.clauses, pclause) {
569 if (i == index[0]) {
571 player_number(pdialog->treaty.plr1),
572 player_number(pclause->from),
573 pclause->type,
574 pclause->value);
575 return;
576 }
577 i++;
579}
580
581/************************************************************************/
585{
586 /* Collect all meetings in one main tab. */
587 if (!dipl_main) {
588 GtkWidget *dipl_sw;
589
590 dipl_main = fc_malloc(sizeof(*dipl_main));
591 gui_dialog_new(&(dipl_main->dialog), GTK_NOTEBOOK(top_notebook),
593 dipl_main->notebook = gtk_notebook_new();
594 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(dipl_main->notebook),
595 GTK_POS_RIGHT);
596 gtk_notebook_set_scrollable(GTK_NOTEBOOK(dipl_main->notebook), TRUE);
597
598 dipl_sw = gtk_scrolled_window_new();
599 gtk_widget_set_margin_bottom(dipl_sw, 2);
600 gtk_widget_set_margin_end(dipl_sw, 2);
601 gtk_widget_set_margin_start(dipl_sw, 2);
602 gtk_widget_set_margin_top(dipl_sw, 2);
603 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dipl_sw),
604 GTK_POLICY_AUTOMATIC,
605 GTK_POLICY_AUTOMATIC);
606 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(dipl_sw),
608
609 /* Buttons */
611 _("Cancel _all meetings"),
613
614 /* Responses for _all_ meetings. */
617
619
622 }
623
624 return dipl_main;
625}
626
627/************************************************************************/
630static void diplomacy_main_destroy(void)
631{
632 if (dipl_main->dialog) {
634 }
635 free(dipl_main);
636 dipl_main = NULL;
637}
638
639/************************************************************************/
642static void diplomacy_main_response(struct gui_dialog *dlg, int response,
643 gpointer data)
644{
645 if (!dipl_main) {
646 return;
647 }
648
649 switch (response) {
650 default:
651 log_error("unhandled response in %s: %d", __FUNCTION__, response);
652 fc__fallthrough; /* No break. */
653 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
654 case RESPONSE_CANCEL_MEETING_ALL: /* Cancel all meetings. */
656 /* This will do a round trip to the server ans close the dialog in the
657 * client. Closing the last dialog will also close the main tab.*/
660 adialog->treaty.plr1));
662 break;
663 }
664}
665
666/************************************************************************/
669static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
670{
671 if (NULL != pdialog->dialog) {
672 /* pdialog->dialog may be NULL if the tab has been destroyed
673 * by an other way. */
674 gui_dialog_destroy(pdialog->dialog);
675 pdialog->dialog = NULL;
676 }
677 dialog_list_remove(dialog_list, pdialog);
678
679 if (dialog_list) {
680 /* Diplomatic meetings in one main tab. */
681 if (dialog_list_size(dialog_list) > 0) {
682 if (dipl_main && dipl_main->dialog) {
683 gchar *buf;
684
685 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
687 g_free(buf);
688 }
689 } else if (dipl_main) {
690 /* No meeting left - destroy main tab. */
692 }
693 }
694
695 /* Last sub-tab must not be freed before diplomacy_main_destroy() call. */
696 free(pdialog);
697}
698
699/************************************************************************/
702static void diplomacy_response(struct gui_dialog *dlg, int response,
703 gpointer data)
704{
705 struct Diplomacy_dialog *pdialog = NULL;
706
707 fc_assert_ret(data);
708 pdialog = (struct Diplomacy_dialog *)data;
709
710 switch (response) {
711 case GTK_RESPONSE_ACCEPT: /* Accept treaty. */
714 pdialog->treaty.plr1));
715 break;
716
717 default:
718 log_error("unhandled response in %s: %d", __FUNCTION__, response);
719 fc__fallthrough; /* No break. */
720 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
721 case GTK_RESPONSE_CANCEL: /* GTK: cancel button. */
722 case RESPONSE_CANCEL_MEETING: /* Cancel meetings. */
725 pdialog->treaty.plr1));
726 break;
727 }
728}
729
730/************************************************************************/
734 struct player *plr1)
735{
736 struct Diplomacy_notebook *dipl_dialog;
737 GtkWidget *vbox, *hgrid, *table, *mainbox;
738 GtkWidget *label, *sw, *view, *pic, *spin;
739 GtkWidget *aux_menu, *notebook;
740 struct sprite *flag_spr;
741 GtkListStore *store;
742 GtkCellRenderer *rend;
743 int i;
744 struct Diplomacy_dialog *pdialog;
745 char plr_buf[4 * MAX_LEN_NAME];
746 gchar *buf;
747 int grid_col = 0;
748 int main_row = 0;
749 GActionGroup *group;
750 GMenu *menu;
751
752 pdialog = fc_malloc(sizeof(*pdialog));
753
754 dialog_list_prepend(dialog_list, pdialog);
755 init_treaty(&pdialog->treaty, plr0, plr1);
756
757 /* Get main diplomacy tab. */
758 dipl_dialog = diplomacy_main_create();
759
760 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
761 gui_dialog_set_title(dipl_dialog->dialog, buf);
762 g_free(buf);
763
764 notebook = dipl_dialog->notebook;
765
766 gui_dialog_new(&(pdialog->dialog), GTK_NOTEBOOK(notebook), pdialog, FALSE);
767
768 /* Buttons */
769 gui_dialog_add_button(pdialog->dialog, NULL,
770 _("Accept treaty"), GTK_RESPONSE_ACCEPT);
771 gui_dialog_add_button(pdialog->dialog, NULL,
772 _("Cancel meeting"), RESPONSE_CANCEL_MEETING);
773
774 /* Responses for one meeting. */
776
777 /* Label for the new meeting. */
778 buf = g_strdup_printf("%s", nation_plural_for_player(plr1));
779 gui_dialog_set_title(pdialog->dialog, buf);
780
781 /* Sort meeting tabs alphabetically by the tab label. */
782 for (i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i++) {
783 GtkWidget *prev_page
784 = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
785 struct gui_dialog *prev_dialog
786 = g_object_get_data(G_OBJECT(prev_page), "gui-dialog-data");
787 const char *prev_label
788 = gtk_label_get_text(GTK_LABEL(prev_dialog->v.tab.label));
789
790 if (fc_strcasecmp(buf, prev_label) < 0) {
791 gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook),
792 pdialog->dialog->grid, i);
793 break;
794 }
795 }
796 g_free(buf);
797
798 /* Us. */
799 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
800 gtk_widget_set_margin_start(vbox, 2);
801 gtk_widget_set_margin_end(vbox, 2);
802 gtk_widget_set_margin_top(vbox, 2);
803 gtk_widget_set_margin_bottom(vbox, 2);
805
806 /* Our nation. */
807 label = gtk_label_new(NULL);
808 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
809 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
810 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
812 gtk_label_set_markup(GTK_LABEL(label), buf);
813 g_free(buf);
814 gtk_box_append(GTK_BOX(vbox), label);
815
816 hgrid = gtk_grid_new();
817 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 5);
818 gtk_box_append(GTK_BOX(vbox), hgrid);
819
820 /* Our flag */
822
823 pic = gtk_picture_new();
824 picture_set_from_surface(GTK_PICTURE(pic), flag_spr->surface);
825 gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1);
826
827 /* Our name. */
828 label = gtk_label_new(NULL);
829 gtk_widget_set_hexpand(label, TRUE);
830 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
831 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
832 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
833 ruler_title_for_player(plr0, plr_buf, sizeof(plr_buf)));
834 gtk_label_set_markup(GTK_LABEL(label), buf);
835 g_free(buf);
836 gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1);
837
838 pdialog->pic0 = gtk_picture_new();
839 gtk_grid_attach(GTK_GRID(hgrid), pdialog->pic0, grid_col++, 0, 1, 1);
840
841 /* Menu for clauses: we. */
842 aux_menu = aux_menu_new();
843 group = G_ACTION_GROUP(g_simple_action_group_new());
844
845 menu = create_clause_menu(group, pdialog, plr1, FALSE);
846 gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(aux_menu), G_MENU_MODEL(menu));
847
848 /* Main table for clauses and (if activated) gold trading: we. */
849 table = gtk_grid_new();
850 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
851 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
852 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
853 gtk_box_append(GTK_BOX(vbox), table);
854
855 if (clause_enabled(CLAUSE_GOLD)) {
856 spin = gtk_spin_button_new_with_range(0.0, plr0->economic.gold + 0.1,
857 1.0);
858 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
859 gtk_editable_set_width_chars(GTK_EDITABLE(spin), 16);
860 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
861 g_object_set_data(G_OBJECT(spin), "plr", plr0);
862 g_signal_connect_after(spin, "value-changed",
863 G_CALLBACK(diplo_dialog_returnkey), pdialog);
864
865 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
866 "mnemonic-widget", spin, "label", _("Gold:"),
867 "xalign", 0.0, "yalign", 0.5, NULL);
868 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
869
870 gtk_grid_attach(GTK_GRID(table), aux_menu, 2, 0, 1, 1);
871 } else {
872 gtk_grid_attach(GTK_GRID(table), aux_menu, 0, 0, 1, 1);
873 }
874 gtk_widget_insert_action_group(aux_menu, "win", group);
875
876 /* Them. */
877 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
878 gtk_widget_set_margin_start(vbox, 2);
879 gtk_widget_set_margin_end(vbox, 2);
880 gtk_widget_set_margin_top(vbox, 2);
881 gtk_widget_set_margin_bottom(vbox, 2);
883
884 /* Their nation. */
885 label = gtk_label_new(NULL);
886 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
887 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
888 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
890 gtk_label_set_markup(GTK_LABEL(label), buf);
891 g_free(buf);
892 gtk_box_append(GTK_BOX(vbox), label);
893
894 hgrid = gtk_grid_new();
895 grid_col = 0;
896 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 5);
897 gtk_box_append(GTK_BOX(vbox), hgrid);
898
899 /* Their flag */
901
902 pic = gtk_picture_new();
903 picture_set_from_surface(GTK_PICTURE(pic), flag_spr->surface);
904 gtk_grid_attach(GTK_GRID(hgrid), pic, grid_col++, 0, 1, 1);
905
906 /* Their name. */
907 label = gtk_label_new(NULL);
908 gtk_widget_set_hexpand(label, TRUE);
909 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
910 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
911 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
912 title_for_player(plr1, plr_buf, sizeof(plr_buf)));
913 gtk_label_set_markup(GTK_LABEL(label), buf);
914 g_free(buf);
915 gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1);
916
917 pdialog->pic1 = gtk_picture_new();
918 gtk_grid_attach(GTK_GRID(hgrid), pdialog->pic1, grid_col++, 0, 1, 1);
919
920 /* Menu for clauses: they. */
921 aux_menu = aux_menu_new();
922 group = G_ACTION_GROUP(g_simple_action_group_new());
923
924 menu = create_clause_menu(group, pdialog, plr1, TRUE);
925 gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(aux_menu), G_MENU_MODEL(menu));
926
927 /* Main table for clauses and (if activated) gold trading: they. */
928 table = gtk_grid_new();
929 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
930 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
931 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
932 gtk_box_append(GTK_BOX(vbox), table);
933
934 if (clause_enabled(CLAUSE_GOLD)) {
935 spin = gtk_spin_button_new_with_range(0.0, plr1->economic.gold + 0.1,
936 1.0);
937 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
938 gtk_editable_set_width_chars(GTK_EDITABLE(spin), 16);
939 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
940 g_object_set_data(G_OBJECT(spin), "plr", plr1);
941 g_signal_connect_after(spin, "value-changed",
942 G_CALLBACK(diplo_dialog_returnkey), pdialog);
943
944 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
945 "mnemonic-widget", spin, "label", _("Gold:"),
946 "xalign", 0.0, "yalign", 0.5, NULL);
947 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
948
949 gtk_grid_attach(GTK_GRID(table), aux_menu, 2, 0, 1, 1);
950 } else {
951 gtk_grid_attach(GTK_GRID(table), aux_menu, 0, 0, 1, 1);
952 }
953 gtk_widget_insert_action_group(aux_menu, "win", group);
954
955 /* Clauses. */
956 mainbox = gtk_grid_new();
957 gtk_orientable_set_orientation(GTK_ORIENTABLE(mainbox),
958 GTK_ORIENTATION_VERTICAL);
959 gui_dialog_add_content_widget(pdialog->dialog, mainbox);
960
961 store = gtk_list_store_new(1, G_TYPE_STRING);
962 pdialog->store = store;
963
964 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
965 gtk_widget_set_hexpand(view, TRUE);
966 gtk_widget_set_vexpand(view, TRUE);
967 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
968 g_object_unref(store);
969 gtk_widget_set_size_request(view, 320, 100);
970
971 rend = gtk_cell_renderer_text_new();
972 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, NULL,
973 rend, "text", 0, NULL);
974
975 sw = gtk_scrolled_window_new();
976 gtk_widget_set_margin_bottom(sw, 2);
977 gtk_widget_set_margin_end(sw, 2);
978 gtk_widget_set_margin_start(sw, 2);
979 gtk_widget_set_margin_top(sw, 2);
980 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
981 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
982 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
983 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view);
984
985 label = g_object_new(GTK_TYPE_LABEL,
986 "use-underline", TRUE,
987 "mnemonic-widget", view,
988 "label", _("C_lauses:"),
989 "xalign", 0.0,
990 "yalign", 0.5,
991 NULL);
992
993 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
994
995 gtk_grid_attach(GTK_GRID(mainbox), vbox, 0, main_row++, 1, 1);
996 gtk_box_append(GTK_BOX(vbox), label);
997 gtk_box_append(GTK_BOX(vbox), sw);
998
999 gtk_widget_show(mainbox);
1000
1001 g_signal_connect(view, "row_activated", G_CALLBACK(row_callback), pdialog);
1002
1003 update_diplomacy_dialog(pdialog);
1004 gui_dialog_show_all(pdialog->dialog);
1005
1006 return pdialog;
1007}
1008
1009/************************************************************************/
1012static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
1013{
1014 GtkListStore *store;
1015 GtkTreeIter it;
1016 bool blank = TRUE;
1017 GdkPixbuf *pixbuf;
1018
1019 store = pdialog->store;
1020
1021 gtk_list_store_clear(store);
1022 clause_list_iterate(pdialog->treaty.clauses, pclause) {
1023 char buf[128];
1024
1025 client_diplomacy_clause_string(buf, sizeof(buf), pclause);
1026
1027 gtk_list_store_append(store, &it);
1028 gtk_list_store_set(store, &it, 0, buf, -1);
1029 blank = FALSE;
1031
1032 if (blank) {
1033 gtk_list_store_append(store, &it);
1034 gtk_list_store_set(store, &it, 0,
1035 _("--- This treaty is blank. "
1036 "Please add some clauses. ---"), -1);
1037 }
1038
1039 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept0);
1040 gtk_picture_set_pixbuf(GTK_PICTURE(pdialog->pic0), pixbuf);
1041 g_object_unref(G_OBJECT(pixbuf));
1042 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept1);
1043 gtk_picture_set_pixbuf(GTK_PICTURE(pdialog->pic1), pixbuf);
1044 g_object_unref(G_OBJECT(pixbuf));
1045}
1046
1047/************************************************************************/
1050static void diplomacy_dialog_tech_callback(GSimpleAction *action,
1051 GVariant *parameter,
1052 gpointer data)
1053{
1054 int giver, dest, other, tech;
1055
1056 giver = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "player_from"));
1057 dest = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "player_to"));
1058 tech = GPOINTER_TO_INT(data);
1060 other = dest;
1061 } else {
1062 other = giver;
1063 }
1064
1065 if (A_LAST == tech) {
1066 /* All techs. */
1067 struct player *pgiver = player_by_number(giver);
1068 struct player *pdest = player_by_number(dest);
1069 const struct research *dresearch, *gresearch;
1070
1071 fc_assert_ret(NULL != pgiver);
1072 fc_assert_ret(NULL != pdest);
1073
1074 dresearch = research_get(pdest);
1075 gresearch = research_get(pgiver);
1076 advance_iterate(A_FIRST, padvance) {
1077 Tech_type_id i = advance_number(padvance);
1078
1079 if (research_invention_state(gresearch, i) == TECH_KNOWN
1080 && research_invention_gettable(dresearch, i,
1082 && (research_invention_state(dresearch, i) == TECH_UNKNOWN
1083 || research_invention_state(dresearch, i)
1084 == TECH_PREREQS_KNOWN)) {
1086 CLAUSE_ADVANCE, i);
1087 }
1089 } else {
1090 /* Only one tech. */
1092 CLAUSE_ADVANCE, tech);
1093 }
1094}
1095
1096/************************************************************************/
1100static void diplomacy_dialog_city_callback(GSimpleAction *action,
1101 GVariant *parameter,
1102 gpointer data)
1103{
1104 struct city_deal *deal_data = (struct city_deal *)data;
1105 int other;
1106
1107 if (player_by_number(deal_data->giver) == client.conn.playing) {
1108 other = deal_data->receiver;
1109 } else {
1110 other = deal_data->giver;
1111 }
1112
1114 CLAUSE_CITY, deal_data->id);
1115
1116 free(deal_data);
1117}
1118
1119/************************************************************************/
1122static void diplomacy_dialog_map_callback(GSimpleAction *action, GVariant *parameter,
1123 gpointer data)
1124{
1125 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1126 struct player *pgiver;
1127
1128 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1129
1131 player_number(pdialog->treaty.plr1),
1132 player_number(pgiver), CLAUSE_MAP, 0);
1133}
1134
1135/************************************************************************/
1138static void diplomacy_dialog_seamap_callback(GSimpleAction *action, GVariant *parameter,
1139 gpointer data)
1140{
1141 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1142 struct player *pgiver;
1143
1144 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1145
1147 player_number(pdialog->treaty.plr1),
1148 player_number(pgiver), CLAUSE_SEAMAP,
1149 0);
1150}
1151
1152/************************************************************************/
1155static void diplomacy_dialog_add_pact_clause(gpointer data, int type)
1156{
1157 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1158
1160 player_number(pdialog->treaty.plr1),
1161 player_number(pdialog->treaty.plr0),
1162 type, 0);
1163}
1164
1165/************************************************************************/
1169 GVariant *parameter,
1170 gpointer data)
1171{
1172 diplomacy_dialog_add_pact_clause(data, CLAUSE_CEASEFIRE);
1173}
1174
1175/************************************************************************/
1178static void diplomacy_dialog_peace_callback(GSimpleAction *action,
1179 GVariant *parameter,
1180 gpointer data)
1181{
1182 diplomacy_dialog_add_pact_clause(data, CLAUSE_PEACE);
1183}
1184
1185/************************************************************************/
1189 GVariant *parameter,
1190 gpointer data)
1191{
1192 diplomacy_dialog_add_pact_clause(data, CLAUSE_ALLIANCE);
1193}
1194
1195/************************************************************************/
1198static void diplomacy_dialog_vision_callback(GSimpleAction *action,
1199 GVariant *parameter,
1200 gpointer data)
1201{
1202 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1203 struct player *pgiver;
1204
1205 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1206
1208 player_number(pdialog->treaty.plr1),
1209 player_number(pgiver), CLAUSE_VISION,
1210 0);
1211}
1212
1213/************************************************************************/
1217 GVariant *parameter,
1218 gpointer data)
1219{
1220 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1221 struct player *pgiver;
1222
1223 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1224
1226 player_number(pdialog->treaty.plr1),
1227 player_number(pgiver), CLAUSE_EMBASSY,
1228 0);
1229}
1230
1231/************************************************************************/
1235{
1236 diplomacy_destroy(pdialog);
1237}
1238
1239/************************************************************************/
1243{
1244 dialog_list = dialog_list_new();
1245 dipl_main = NULL;
1246}
1247
1248/************************************************************************/
1252{
1253 dialog_list_destroy(dialog_list);
1254}
1255
1256/************************************************************************/
1259static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id)
1260{
1261 struct player *plr0 = client.conn.playing;
1262 struct player *plr1 = player_by_number(other_player_id);
1263
1265 if ((pdialog->treaty.plr0 == plr0 && pdialog->treaty.plr1 == plr1)
1266 || (pdialog->treaty.plr0 == plr1 && pdialog->treaty.plr1 == plr0)) {
1267 return pdialog;
1268 }
1270
1271 return NULL;
1272}
1273
1274/************************************************************************/
1277static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
1278{
1279 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1280 struct player *pgiver =
1281 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1282 int amount = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w));
1283
1284 if (amount >= 0 && amount <= pgiver->economic.gold) {
1286 player_number(pdialog->treaty.plr1),
1287 player_number(pgiver),
1288 CLAUSE_GOLD, amount);
1289 } else {
1290 output_window_append(ftc_client, _("Invalid amount of gold specified."));
1291 }
1292}
1293
1294/************************************************************************/
1298{
1299 while (dialog_list_size(dialog_list) > 0) {
1300 close_diplomacy_dialog(dialog_list_get(dialog_list, 0));
1301 }
1302}
#define n
Definition astring.c:77
void output_window_append(const struct ft_color color, const char *featured_text)
bool is_capital(const struct city *pcity)
Definition city.c:1552
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
int city_name_compare(const void *p1, const void *p2)
Definition city.c:1684
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define city_list_iterate_end
Definition city.h:490
struct civclient client
bool can_client_issue_orders(void)
const char * title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
#define client_player()
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
int int initiated_from int int giver
Definition diplodlg_g.h:28
int int initiated_from handle_diplomacy_remove_clause
Definition diplodlg_g.h:28
handle_diplomacy_cancel_meeting
Definition diplodlg_g.h:24
int counterpart
Definition diplodlg_g.h:25
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:96
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:142
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:286
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:120
#define clause_list_iterate_end
Definition diptreaty.h:68
#define clause_list_iterate(clauselist, pclause)
Definition diptreaty.h:66
int Tech_type_id
Definition fc_types.h:347
#define MAX_LEN_NAME
Definition fc_types.h:66
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:57
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:390
static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data, int type)
Definition diplodlg.c:1099
#define RESPONSE_CANCEL_MEETING
Definition diplodlg.c:110
static gint sort_advance_names(gconstpointer a, gconstpointer b)
Definition diplodlg.c:227
static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:1167
static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1000
static void row_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition diplodlg.c:496
static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1113
static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:962
static struct Diplomacy_dialog * find_diplomacy_dialog(int other_player_id)
Definition diplodlg.c:1192
static struct Diplomacy_dialog * create_diplomacy_dialog(struct player *plr0, struct player *plr1)
Definition diplodlg.c:670
static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1083
static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1048
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition diplodlg.c:135
static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1068
void diplomacy_dialog_init(void)
Definition diplodlg.c:1175
static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:606
#define dialog_list_iterate_end
Definition diplodlg.c:82
static struct Diplomacy_notebook * diplomacy_main_create(void)
Definition diplodlg.c:522
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition diplodlg.c:157
static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1137
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1230
#define RESPONSE_CANCEL_MEETING_ALL
Definition diplodlg.c:111
static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1152
static void diplomacy_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:639
#define dialog_list_iterate(dialoglist, pdialog)
Definition diplodlg.c:80
static struct dialog_list * dialog_list
Definition diplodlg.c:84
static void diplomacy_main_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:579
static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1121
void diplomacy_dialog_done(void)
Definition diplodlg.c:1184
static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
Definition diplodlg.c:1210
static void diplomacy_main_destroy(void)
Definition diplodlg.c:567
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition diplodlg.c:116
static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1129
static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
Definition diplodlg.c:192
static struct Diplomacy_notebook * dipl_main
Definition diplodlg.c:85
GtkWidget * top_notebook
Definition gui_main.c:128
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:951
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:834
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:864
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:504
void gui_dialog_set_return_dialog(struct gui_dialog *dlg, struct gui_dialog *return_dialog)
Definition gui_stuff.c:994
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:985
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *text, int response)
Definition gui_stuff.c:706
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:794
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:932
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:887
GdkPixbuf * get_thumb_pixbuf(int onoff)
Definition mapview.c:275
struct gui_dialog * players_dialog_shell
Definition plrdlg.c:58
GType type
Definition repodlgs.c:1312
static GMenu * create_clause_menu(GActionGroup *group, struct Diplomacy_dialog *pdialog, struct player *partner, bool them)
Definition diplodlg.c:256
GtkWidget * aux_menu_new(void)
Definition gui_stuff.c:243
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1095
#define submenu_append_unref(menu, name, submenu)
Definition gui_stuff.h:165
#define menu_item_append_unref(menu, item)
Definition gui_stuff.h:149
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
#define fc_assert_ret(condition)
Definition log.h:191
#define log_error(message,...)
Definition log.h:103
#define fc_malloc(sz)
Definition mem.h:34
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:443
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
struct player * player_by_number(const int player_id)
Definition player.c:840
int player_number(const struct player *pplayer)
Definition player.c:828
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:234
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
Definition player.c:214
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1461
#define is_human(plr)
Definition player.h:233
struct research * research_get(const struct player *pplayer)
Definition research.c:126
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:690
GtkWidget * pic0
Definition diplodlg.c:56
GtkWidget * pic1
Definition diplodlg.c:57
struct Treaty treaty
Definition diplodlg.c:53
struct gui_dialog * dialog
Definition diplodlg.c:54
GtkListStore * store
Definition diplodlg.c:62
struct gui_dialog * dialog
Definition diplodlg.c:66
GtkWidget * notebook
Definition diplodlg.c:67
struct player * plr0
Definition diptreaty.h:77
bool accept0
Definition diptreaty.h:78
bool accept1
Definition diptreaty.h:78
struct clause_list * clauses
Definition diptreaty.h:79
struct player * plr1
Definition diptreaty.h:77
int giver
Definition diplodlg.c:71
int receiver
Definition diplodlg.c:72
Definition city.h:309
int id
Definition city.h:315
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:156
union gui_dialog::@149 v
GtkWidget * grid
Definition gui_stuff.h:71
GtkWidget * vbox
Definition gui_stuff.h:71
GtkWidget * label
Definition gui_stuff.h:86
struct gui_dialog::@149::@150 tab
GtkWidget * notebook
Definition gui_stuff.h:87
bool tech_trade_allow_holes
enum diplstate_type type
Definition player.h:201
struct city_list * cities
Definition player.h:281
struct team * team
Definition player.h:261
struct player_economic economic
Definition player.h:284
cairo_surface_t * surface
Definition sprite.h:23
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:787
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:472
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:109
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_iterate(_start, _p)
Definition tech.h:264
#define A_FIRST
Definition tech.h:44
#define advance_iterate_end
Definition tech.h:270
#define A_LAST
Definition tech.h:45
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6467