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-3.0 */
46#include "diplodlg.h"
47#include "gui_main.h"
48#include "gui_stuff.h"
49#include "mapview.h"
50#include "plrdlg.h"
51
53 struct Treaty treaty;
55
56 GtkWidget *menu0;
57 GtkWidget *menu1;
58
59 GtkWidget *image0;
60 GtkWidget *image1;
61
62 GtkListStore *store;
63};
64
67 GtkWidget *notebook;
68};
69
70struct city_deal {
71 int giver;
73 int id;
74};
75
76#define SPECLIST_TAG dialog
77#define SPECLIST_TYPE struct Diplomacy_dialog
78#include "speclist.h"
79
80#define dialog_list_iterate(dialoglist, pdialog) \
81 TYPED_LIST_ITERATE(struct Diplomacy_dialog, dialoglist, pdialog)
82#define dialog_list_iterate_end LIST_ITERATE_END
83
84static struct dialog_list *dialog_list;
86
87static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0,
88 struct player *plr1);
89
90static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id);
91static void popup_diplomacy_dialog(int other_player_id, int initiated_from);
92static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data);
93static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data);
94static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data);
95static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data);
96static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data);
97static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data);
98static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data);
99static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data);
100static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data);
101static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
102static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
103static void diplo_dialog_returnkey(GtkWidget *w, gpointer data);
104
105static struct Diplomacy_notebook *diplomacy_main_create(void);
106static void diplomacy_main_destroy(void);
107static void diplomacy_main_response(struct gui_dialog *dlg, int response,
108 gpointer data);
109
110#define RESPONSE_CANCEL_MEETING 100
111#define RESPONSE_CANCEL_MEETING_ALL 101
112
113/************************************************************************/
117 bool other_accepted)
118{
120
121 if (!pdialog) {
122 return;
123 }
124
125 pdialog->treaty.accept0 = I_accepted;
126 pdialog->treaty.accept1 = other_accepted;
127
129 gui_dialog_alert(pdialog->dialog);
130}
131
132/************************************************************************/
135void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
136{
137 popup_diplomacy_dialog(counterpart, initiated_from);
138}
139
140/************************************************************************/
143void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
144{
146
147 if (!pdialog) {
148 return;
149 }
150
151 close_diplomacy_dialog(pdialog);
152}
153
154/************************************************************************/
158 enum clause_type type, int value)
159{
161
162 if (!pdialog) {
163 return;
164 }
165
166 add_clause(&pdialog->treaty, player_by_number(giver), type, value,
167 client_player());
169 gui_dialog_alert(pdialog->dialog);
170}
171
172/************************************************************************/
176 enum clause_type type, int value)
177{
179
180 if (!pdialog) {
181 return;
182 }
183
184 remove_clause(&pdialog->treaty, player_by_number(giver), type, value);
186 gui_dialog_alert(pdialog->dialog);
187}
188
189/************************************************************************/
192static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
193{
194 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(other_player_id);
195
197 return;
198 }
199
200 if (!is_human(client.conn.playing)) {
201 return; /* Don't show if we are not human controlled. */
202 }
203
204 if (!pdialog) {
206 player_by_number(other_player_id));
207 }
208
209 gui_dialog_present(pdialog->dialog);
210 /* We initated the meeting - Make the tab active */
211 if (player_by_number(initiated_from) == client.conn.playing) {
212 /* we have to raise the diplomacy meeting tab as well as the selected
213 * meeting. */
214 fc_assert_ret(dipl_main != NULL);
216 gui_dialog_raise(pdialog->dialog);
217
218 if (players_dialog_shell != NULL) {
220 }
221 }
222}
223
224/************************************************************************/
227static gint sort_advance_names(gconstpointer a, gconstpointer b)
228{
229 const struct advance *padvance1 = (const struct advance *) a;
230 const struct advance *padvance2 = (const struct advance *) b;
231
232 return fc_strcoll(advance_name_translation(padvance1),
233 advance_name_translation(padvance2));
234}
235
236/************************************************************************/
239static void popup_add_menu(GtkMenuShell *parent, gpointer data)
240{
241 struct Diplomacy_dialog *pdialog;
242 struct player *pgiver, *pother;
243 GtkWidget *item, *menu;
244 bool any_map = FALSE;
245
246 /* Init. */
247 gtk_container_foreach(GTK_CONTAINER(parent),
248 (GtkCallback) gtk_widget_destroy, NULL);
249
250 pdialog = (struct Diplomacy_dialog *) data;
251 pgiver = (struct player *) g_object_get_data(G_OBJECT(parent), "plr");
252 pother = (pgiver == pdialog->treaty.plr0
253 ? pdialog->treaty.plr1 : pdialog->treaty.plr0);
254
255
256 /* Maps. */
257 if (clause_enabled(CLAUSE_MAP)) {
258 menu = gtk_menu_new();
259
260 item = gtk_menu_item_new_with_mnemonic(_("World-map"));
261 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
262 g_object_set_data(G_OBJECT(item), "plr", pgiver);
263 g_signal_connect(item, "activate",
264 G_CALLBACK(diplomacy_dialog_map_callback), pdialog);
265 any_map = TRUE;
266 }
267
268 if (clause_enabled(CLAUSE_SEAMAP)) {
269 if (!any_map) {
270 menu = gtk_menu_new();
271 }
272
273 item = gtk_menu_item_new_with_mnemonic(_("Sea-map"));
274 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
275 g_object_set_data(G_OBJECT(item), "plr", pgiver);
276 g_signal_connect(item, "activate",
277 G_CALLBACK(diplomacy_dialog_seamap_callback), pdialog);
278 any_map = TRUE;
279 }
280
281 if (any_map) {
282 item = gtk_menu_item_new_with_mnemonic(_("_Maps"));
283 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
284 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
285 gtk_widget_show_all(item);
286 }
287
288 /* Trading: advances */
289 if (clause_enabled(CLAUSE_ADVANCE)) {
290 const struct research *gresearch = research_get(pgiver);
291 const struct research *oresearch = research_get(pother);
292 GtkWidget *advance_item;
293 GList *sorting_list = NULL;
294 bool team_embassy = team_has_embassy(pgiver->team, pother);
295
296 advance_item = gtk_menu_item_new_with_mnemonic(_("_Advances"));
297 gtk_menu_shell_append(GTK_MENU_SHELL(parent), advance_item);
298
299 advance_iterate(A_FIRST, padvance) {
300 Tech_type_id i = advance_number(padvance);
301
302 if (research_invention_state(gresearch, i) == TECH_KNOWN
303 && (!team_embassy /* We don't know what the other could actually receive */
304 || research_invention_gettable(oresearch, i,
306 && (research_invention_state(oresearch, i) == TECH_UNKNOWN
307 || research_invention_state(oresearch, i)
308 == TECH_PREREQS_KNOWN)) {
309 sorting_list = g_list_prepend(sorting_list, padvance);
310 }
312
313 if (NULL == sorting_list) {
314 /* No advance. */
315 gtk_widget_set_sensitive(advance_item, FALSE);
316 } else {
317 GList *list_item;
318 const struct advance *padvance;
319
320 sorting_list = g_list_sort(sorting_list, sort_advance_names);
321 menu = gtk_menu_new();
322
323 /* TRANS: All technologies menu item in the diplomatic dialog. */
324 item = gtk_menu_item_new_with_label(_("All advances"));
325 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
326 g_object_set_data(G_OBJECT(item), "player_from",
327 GINT_TO_POINTER(player_number(pgiver)));
328 g_object_set_data(G_OBJECT(item), "player_to",
329 GINT_TO_POINTER(player_number(pother)));
330 g_signal_connect(item, "activate",
332 GINT_TO_POINTER(A_LAST));
333 gtk_menu_shell_append(GTK_MENU_SHELL(menu),
334 gtk_separator_menu_item_new());
335
336 for (list_item = sorting_list; NULL != list_item;
337 list_item = g_list_next(list_item)) {
338 padvance = (const struct advance *) list_item->data;
339 item =
340 gtk_menu_item_new_with_label(advance_name_translation(padvance));
341 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
342 g_object_set_data(G_OBJECT(item), "player_from",
343 GINT_TO_POINTER(player_number(pgiver)));
344 g_object_set_data(G_OBJECT(item), "player_to",
345 GINT_TO_POINTER(player_number(pother)));
346 g_signal_connect(item, "activate",
348 GINT_TO_POINTER(advance_number(padvance)));
349 }
350
351 gtk_menu_item_set_submenu(GTK_MENU_ITEM(advance_item), menu);
352 g_list_free(sorting_list);
353 }
354
355 gtk_widget_show_all(advance_item);
356 }
357
358
359 /* Trading: cities. */
360
361 /****************************************************************
362 Creates a sorted list of plr0's cities, excluding the capital and
363 any cities not visible to plr1. This means that you can only trade
364 cities visible to requesting player.
365
366 - Kris Bubendorfer
367 *****************************************************************/
368 if (clause_enabled(CLAUSE_CITY)) {
369 int i = 0;
370 int n = city_list_size(pgiver->cities);
371
372 menu = gtk_menu_new();
373
374 if (n > 0) {
375 struct city **city_list_ptrs;
376
377 city_list_ptrs = fc_malloc(sizeof(struct city *) * n);
378
379 city_list_iterate(pgiver->cities, pcity) {
380 if (!is_capital(pcity)) {
381 city_list_ptrs[i] = pcity;
382 i++;
383 }
385
386 if (i > 0) { /* Cities other than capitals */
387 int j;
388
389 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
390
391 for (j = 0; j < i; j++) {
392 struct city_deal *deal = fc_malloc(sizeof(struct city_deal));
393
394 item = gtk_menu_item_new_with_label(city_name_get(city_list_ptrs[j]));
395
396 deal->giver = player_number(pgiver);
397 deal->receiver = player_number(pother);
398 deal->id = city_list_ptrs[j]->id;
399
400 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
401 g_signal_connect(item, "activate",
403 (gpointer)deal);
404 }
405 }
406
407 free(city_list_ptrs);
408 }
409
410 item = gtk_menu_item_new_with_mnemonic(_("_Cities"));
411 gtk_widget_set_sensitive(item, (i > 0));
412 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
413 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
414 gtk_widget_show_all(item);
415 }
416
417 /* Give shared vision. */
418 if (clause_enabled(CLAUSE_VISION)) {
419 item = gtk_menu_item_new_with_mnemonic(_("_Give shared vision"));
420 g_object_set_data(G_OBJECT(item), "plr", pgiver);
421 g_signal_connect(item, "activate",
422 G_CALLBACK(diplomacy_dialog_vision_callback), pdialog);
423
424 if (gives_shared_vision(pgiver, pother)) {
425 gtk_widget_set_sensitive(item, FALSE);
426 }
427 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
428 gtk_widget_show(item);
429 }
430
431 /* Give embassy. */
432 if (clause_enabled(CLAUSE_EMBASSY)) {
433 item = gtk_menu_item_new_with_mnemonic(_("Give _embassy"));
434 g_object_set_data(G_OBJECT(item), "plr", pgiver);
435 g_signal_connect(item, "activate",
436 G_CALLBACK(diplomacy_dialog_embassy_callback), pdialog);
437
438 /* Don't take in account the embassy effects. */
439 if (player_has_real_embassy(pother, pgiver)) {
440 gtk_widget_set_sensitive(item, FALSE);
441 }
442 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
443 gtk_widget_show(item);
444 }
445
446 /* Pacts. */
447 if (pgiver == pdialog->treaty.plr0) {
448 enum diplstate_type ds;
449 int pact_clauses = 0;
450
451 ds = player_diplstate_get(pgiver, pother)->type;
452
453 menu = gtk_menu_new();
454
455 if (clause_enabled(CLAUSE_CEASEFIRE)) {
456 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Cease-fire"));
457 gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
458 g_signal_connect(item, "activate",
459 G_CALLBACK(diplomacy_dialog_ceasefire_callback), pdialog);
460 gtk_widget_set_sensitive(item, ds != DS_CEASEFIRE && ds != DS_TEAM);
461 pact_clauses++;
462 }
463
464 if (clause_enabled(CLAUSE_PEACE)) {
465 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Peace"));
466 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
467 g_signal_connect(item, "activate",
468 G_CALLBACK(diplomacy_dialog_peace_callback), pdialog);
469 gtk_widget_set_sensitive(item, ds != DS_PEACE && ds != DS_TEAM);
470 pact_clauses++;
471 }
472
473 if (clause_enabled(CLAUSE_ALLIANCE)) {
474 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Alliance"));
475 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
476 g_signal_connect(item, "activate",
477 G_CALLBACK(diplomacy_dialog_alliance_callback), pdialog);
478 gtk_widget_set_sensitive(item, ds != DS_ALLIANCE && ds != DS_TEAM);
479 pact_clauses++;
480 }
481
482 if (pact_clauses > 0) {
483 item = gtk_menu_item_new_with_mnemonic(_("_Pacts"));
484 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
485 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
486 gtk_widget_show_all(item);
487 } else {
488 g_object_unref(menu);
489 }
490 }
491}
492
493/************************************************************************/
496static void row_callback(GtkTreeView *view, GtkTreePath *path,
497 GtkTreeViewColumn *col, gpointer data)
498{
499 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
500 gint i;
501 gint *index;
502
503 index = gtk_tree_path_get_indices(path);
504
505 i = 0;
506 clause_list_iterate(pdialog->treaty.clauses, pclause) {
507 if (i == index[0]) {
509 player_number(pdialog->treaty.plr1),
510 player_number(pclause->from),
511 pclause->type,
512 pclause->value);
513 return;
514 }
515 i++;
517}
518
519/************************************************************************/
523{
524 /* Collect all meetings in one main tab. */
525 if (!dipl_main) {
526 GtkWidget *dipl_box, *dipl_sw;
527
528 dipl_main = fc_malloc(sizeof(*dipl_main));
529 gui_dialog_new(&(dipl_main->dialog), GTK_NOTEBOOK(top_notebook),
531 dipl_main->notebook = gtk_notebook_new();
532 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(dipl_main->notebook),
533 GTK_POS_RIGHT);
534 gtk_notebook_set_scrollable(GTK_NOTEBOOK(dipl_main->notebook), TRUE);
535
536 dipl_sw = gtk_scrolled_window_new(NULL, NULL);
537 g_object_set(dipl_sw, "margin", 2, NULL);
538 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dipl_sw),
539 GTK_POLICY_AUTOMATIC,
540 GTK_POLICY_AUTOMATIC);
541 gtk_container_add(GTK_CONTAINER(dipl_sw), dipl_main->notebook);
542
543 /* Buttons */
545 _("Cancel _all meetings"),
547
548 /* Responses for _all_ meetings. */
553
554 dipl_box = dipl_main->dialog->vbox;
555 gtk_container_add(GTK_CONTAINER(dipl_box), dipl_sw);
556
559 }
560
561 return dipl_main;
562}
563
564/************************************************************************/
567static void diplomacy_main_destroy(void)
568{
569 if (dipl_main->dialog) {
571 }
572 free(dipl_main);
573 dipl_main = NULL;
574}
575
576/************************************************************************/
579static void diplomacy_main_response(struct gui_dialog *dlg, int response,
580 gpointer data)
581{
582 if (!dipl_main) {
583 return;
584 }
585
586 switch (response) {
587 default:
588 log_error("unhandled response in %s: %d", __FUNCTION__, response);
589 fc__fallthrough; /* No break. */
590 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
591 case RESPONSE_CANCEL_MEETING_ALL: /* Cancel all meetings. */
593 /* This will do a round trip to the server ans close the dialog in the
594 * client. Closing the last dialog will also close the main tab.*/
597 adialog->treaty.plr1));
599 break;
600 }
601}
602
603/************************************************************************/
606static void diplomacy_destroy(struct Diplomacy_dialog* pdialog)
607{
608 if (NULL != pdialog->dialog) {
609 /* pdialog->dialog may be NULL if the tab has been destroyed
610 * by an other way. */
611 gui_dialog_destroy(pdialog->dialog);
612 pdialog->dialog = NULL;
613 }
614 dialog_list_remove(dialog_list, pdialog);
615
616 if (dialog_list) {
617 /* Diplomatic meetings in one main tab. */
618 if (dialog_list_size(dialog_list) > 0) {
619 if (dipl_main && dipl_main->dialog) {
620 gchar *buf;
621
622 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
624 g_free(buf);
625 }
626 } else if (dipl_main) {
627 /* No meeting left - destroy main tab. */
629 }
630 }
631
632 /* Last sub-tab must not be freed before diplomacy_main_destroy() call. */
633 free(pdialog);
634}
635
636/************************************************************************/
639static void diplomacy_response(struct gui_dialog *dlg, int response,
640 gpointer data)
641{
642 struct Diplomacy_dialog *pdialog = NULL;
643
644 fc_assert_ret(data);
645 pdialog = (struct Diplomacy_dialog *)data;
646
647 switch (response) {
648 case GTK_RESPONSE_ACCEPT: /* Accept treaty. */
651 pdialog->treaty.plr1));
652 break;
653
654 default:
655 log_error("unhandled response in %s: %d", __FUNCTION__, response);
656 fc__fallthrough; /* No break. */
657 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
658 case GTK_RESPONSE_CANCEL: /* GTK: cancel button. */
659 case RESPONSE_CANCEL_MEETING: /* Cancel meetings. */
662 pdialog->treaty.plr1));
663 break;
664 }
665}
666
667/************************************************************************/
671 struct player *plr1)
672{
673 struct Diplomacy_notebook *dipl_dialog;
674 GtkWidget *vbox, *hbox, *table, *mainbox;
675 GtkWidget *label, *sw, *view, *image, *spin;
676 GtkWidget *menubar, *menuitem, *menu, *notebook;
677 struct sprite *flag_spr;
678 GtkListStore *store;
679 GtkCellRenderer *rend;
680 int i;
681
682 struct Diplomacy_dialog *pdialog;
683 char plr_buf[4 * MAX_LEN_NAME];
684 gchar *buf;
685
686 pdialog = fc_malloc(sizeof(*pdialog));
687
688 dialog_list_prepend(dialog_list, pdialog);
689 init_treaty(&pdialog->treaty, plr0, plr1);
690
691 /* Get main diplomacy tab. */
692 dipl_dialog = diplomacy_main_create();
693
694 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
695 gui_dialog_set_title(dipl_dialog->dialog, buf);
696 g_free(buf);
697
698 notebook = dipl_dialog->notebook;
699
700 gui_dialog_new(&(pdialog->dialog), GTK_NOTEBOOK(notebook), pdialog, FALSE);
701
702 /* Buttons */
703 gui_dialog_add_stockbutton(pdialog->dialog, GTK_STOCK_DND,
704 _("Accept treaty"), GTK_RESPONSE_ACCEPT);
705 gui_dialog_add_stockbutton(pdialog->dialog, GTK_STOCK_CANCEL,
706 _("Cancel meeting"), RESPONSE_CANCEL_MEETING);
707
708 /* Responses for one meeting. */
711
712 /* Label for the new meeting. */
713 buf = g_strdup_printf("%s", nation_plural_for_player(plr1));
714 gui_dialog_set_title(pdialog->dialog, buf);
715
716 /* Sort meeting tabs alphabetically by the tab label. */
717 for (i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i++) {
718 GtkWidget *prev_page
719 = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
720 struct gui_dialog *prev_dialog
721 = g_object_get_data(G_OBJECT(prev_page), "gui-dialog-data");
722 const char *prev_label
723 = gtk_label_get_text(GTK_LABEL(prev_dialog->v.tab.label));
724
725 if (fc_strcasecmp(buf, prev_label) < 0) {
726 gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook),
727 pdialog->dialog->vbox, i);
728 break;
729 }
730 }
731 g_free(buf);
732
733 /* Content. */
734 mainbox = pdialog->dialog->vbox;
735
736 /* us. */
737 vbox = gtk_grid_new();
738 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
739 GTK_ORIENTATION_VERTICAL);
740 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
741 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
742 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
743
744 /* Our nation. */
745 label = gtk_label_new(NULL);
746 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
747 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
748 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
750 gtk_label_set_markup(GTK_LABEL(label), buf);
751 g_free(buf);
752 gtk_container_add(GTK_CONTAINER(vbox), label);
753
754 hbox = gtk_grid_new();
755 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
756 gtk_container_add(GTK_CONTAINER(vbox), hbox);
757
758 /* Our flag */
760
761 image = gtk_image_new_from_surface(flag_spr->surface);
762 gtk_container_add(GTK_CONTAINER(hbox), image);
763
764 /* Our name. */
765 label = gtk_label_new(NULL);
766 gtk_widget_set_hexpand(label, TRUE);
767 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
768 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
769 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
770 ruler_title_for_player(plr0, plr_buf, sizeof(plr_buf)));
771 gtk_label_set_markup(GTK_LABEL(label), buf);
772 g_free(buf);
773 gtk_container_add(GTK_CONTAINER(hbox), label);
774
775 image = gtk_image_new();
776 pdialog->image0 = image;
777 gtk_container_add(GTK_CONTAINER(hbox), image);
778
779 /* Menu for clauses: we. */
780 menubar = gtk_aux_menu_bar_new();
781
782 menu = gtk_menu_new();
783 pdialog->menu0 = menu;
784
785 menuitem = gtk_image_menu_item_new_with_label(_("Add Clause..."));
786 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
787 gtk_image_new_from_stock(GTK_STOCK_ADD,
788 GTK_ICON_SIZE_MENU));
789 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
790 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
791 g_object_set_data(G_OBJECT(menu), "plr", plr0);
792 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
793
794 /* Main table for clauses and (if activated) gold trading: we. */
795 table = gtk_grid_new();
796 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
797 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
798 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
799 gtk_container_add(GTK_CONTAINER(vbox), table);
800
801 if (clause_enabled(CLAUSE_GOLD)) {
802 spin = gtk_spin_button_new_with_range(0.0, plr0->economic.gold + 0.1,
803 1.0);
804 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
805 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
806 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
807 g_object_set_data(G_OBJECT(spin), "plr", plr0);
808 g_signal_connect_after(spin, "value-changed",
809 G_CALLBACK(diplo_dialog_returnkey), pdialog);
810
811 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
812 "mnemonic-widget", spin, "label", _("Gold:"),
813 "xalign", 0.0, "yalign", 0.5, NULL);
814 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
815
816 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
817 } else {
818 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
819 }
820
821 /* them. */
822 vbox = gtk_grid_new();
823 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
824 GTK_ORIENTATION_VERTICAL);
825 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
826 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
827 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
828
829 /* Their nation. */
830 label = gtk_label_new(NULL);
831 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
832 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
833 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
835 gtk_label_set_markup(GTK_LABEL(label), buf);
836 g_free(buf);
837 gtk_container_add(GTK_CONTAINER(vbox), label);
838
839 hbox = gtk_grid_new();
840 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
841 gtk_container_add(GTK_CONTAINER(vbox), hbox);
842
843 /* Their flag */
845
846 image = gtk_image_new_from_surface(flag_spr->surface);
847 gtk_container_add(GTK_CONTAINER(hbox), image);
848
849 /* Their name. */
850 label = gtk_label_new(NULL);
851 gtk_widget_set_hexpand(label, TRUE);
852 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
853 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
854 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
855 title_for_player(plr1, plr_buf, sizeof(plr_buf)));
856 gtk_label_set_markup(GTK_LABEL(label), buf);
857 g_free(buf);
858 gtk_container_add(GTK_CONTAINER(hbox), label);
859
860 image = gtk_image_new();
861 pdialog->image1 = image;
862 gtk_container_add(GTK_CONTAINER(hbox), image);
863
864 /* Menu for clauses: they. */
865 menubar = gtk_aux_menu_bar_new();
866
867 menu = gtk_menu_new();
868 pdialog->menu1 = menu;
869
870 menuitem = gtk_image_menu_item_new_with_label(_("Add Clause..."));
871 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
872 gtk_image_new_from_stock(GTK_STOCK_ADD,
873 GTK_ICON_SIZE_MENU));
874 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
875 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
876 g_object_set_data(G_OBJECT(menu), "plr", plr1);
877 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
878
879 /* Main table for clauses and (if activated) gold trading: they. */
880 table = gtk_grid_new();
881 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
882 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
883 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
884 gtk_container_add(GTK_CONTAINER(vbox), table);
885
886 if (clause_enabled(CLAUSE_GOLD)) {
887 spin = gtk_spin_button_new_with_range(0.0, plr1->economic.gold + 0.1,
888 1.0);
889 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
890 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
891 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
892 g_object_set_data(G_OBJECT(spin), "plr", plr1);
893 g_signal_connect_after(spin, "value-changed",
894 G_CALLBACK(diplo_dialog_returnkey), pdialog);
895
896 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
897 "mnemonic-widget", spin, "label", _("Gold:"),
898 "xalign", 0.0, "yalign", 0.5, NULL);
899 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
900
901 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
902 } else {
903 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
904 }
905
906 /* Clauses. */
907 mainbox = gtk_grid_new();
908 gtk_orientable_set_orientation(GTK_ORIENTABLE(mainbox),
909 GTK_ORIENTATION_VERTICAL);
910 gtk_container_add(GTK_CONTAINER(pdialog->dialog->vbox), mainbox);
911
912 store = gtk_list_store_new(1, G_TYPE_STRING);
913 pdialog->store = store;
914
915 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
916 gtk_widget_set_hexpand(view, TRUE);
917 gtk_widget_set_vexpand(view, TRUE);
918 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
919 g_object_unref(store);
920 gtk_widget_set_size_request(view, 320, 100);
921
922 rend = gtk_cell_renderer_text_new();
923 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, NULL,
924 rend, "text", 0, NULL);
925
926 sw = gtk_scrolled_window_new(NULL, NULL);
927 g_object_set(sw, "margin", 2, NULL);
928 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
929 GTK_SHADOW_ETCHED_IN);
930 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
931 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
932 gtk_container_add(GTK_CONTAINER(sw), view);
933
934 label = g_object_new(GTK_TYPE_LABEL,
935 "use-underline", TRUE,
936 "mnemonic-widget", view,
937 "label", _("C_lauses:"),
938 "xalign", 0.0,
939 "yalign", 0.5,
940 NULL);
941
942 vbox = gtk_grid_new();
943 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
944 GTK_ORIENTATION_VERTICAL);
945 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
946 gtk_container_add(GTK_CONTAINER(vbox), label);
947 gtk_container_add(GTK_CONTAINER(vbox), sw);
948
949 gtk_widget_show_all(mainbox);
950
951 g_signal_connect(view, "row_activated", G_CALLBACK(row_callback), pdialog);
952
954 gui_dialog_show_all(pdialog->dialog);
955
956 return pdialog;
957}
958
959/************************************************************************/
962static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
963{
964 GtkListStore *store;
965 GtkTreeIter it;
966 bool blank = TRUE;
967 GdkPixbuf *pixbuf;
968
969 store = pdialog->store;
970
971 gtk_list_store_clear(store);
972 clause_list_iterate(pdialog->treaty.clauses, pclause) {
973 char buf[128];
974
975 client_diplomacy_clause_string(buf, sizeof(buf), pclause);
976
977 gtk_list_store_append(store, &it);
978 gtk_list_store_set(store, &it, 0, buf, -1);
979 blank = FALSE;
981
982 if (blank) {
983 gtk_list_store_append(store, &it);
984 gtk_list_store_set(store, &it, 0,
985 _("--- This treaty is blank. "
986 "Please add some clauses. ---"), -1);
987 }
988
989 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept0);
990 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image0), pixbuf);
991 g_object_unref(G_OBJECT(pixbuf));
992 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept1);
993 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image1), pixbuf);
994 g_object_unref(G_OBJECT(pixbuf));
995}
996
997/************************************************************************/
1000static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
1001{
1002 int giver, dest, other, tech;
1003
1004 giver = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_from"));
1005 dest = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_to"));
1006 tech = GPOINTER_TO_INT(data);
1008 other = dest;
1009 } else {
1010 other = giver;
1011 }
1012
1013 if (A_LAST == tech) {
1014 /* All techs. */
1015 struct player *pgiver = player_by_number(giver);
1016 struct player *pdest = player_by_number(dest);
1017 const struct research *dresearch, *gresearch;
1018
1019 fc_assert_ret(NULL != pgiver);
1020 fc_assert_ret(NULL != pdest);
1021
1022 dresearch = research_get(pdest);
1023 gresearch = research_get(pgiver);
1024 advance_iterate(A_FIRST, padvance) {
1025 Tech_type_id i = advance_number(padvance);
1026
1027 if (research_invention_state(gresearch, i) == TECH_KNOWN
1028 && research_invention_gettable(dresearch, i,
1030 && (research_invention_state(dresearch, i) == TECH_UNKNOWN
1031 || research_invention_state(dresearch, i)
1032 == TECH_PREREQS_KNOWN)) {
1034 CLAUSE_ADVANCE, i);
1035 }
1037 } else {
1038 /* Only one tech. */
1040 CLAUSE_ADVANCE, tech);
1041 }
1042}
1043
1044/************************************************************************/
1048static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
1049{
1050 struct city_deal *deal_data = (struct city_deal *)data;
1051 int other;
1052
1053 if (player_by_number(deal_data->giver) == client_player()) {
1054 other = deal_data->receiver;
1055 } else {
1056 other = deal_data->giver;
1057 }
1058
1060 CLAUSE_CITY, deal_data->id);
1061
1062 free(deal_data);
1063}
1064
1065/************************************************************************/
1068static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
1069{
1070 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1071 struct player *pgiver;
1072
1073 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1074
1076 player_number(pdialog->treaty.plr1),
1077 player_number(pgiver), CLAUSE_MAP, 0);
1078}
1079
1080/************************************************************************/
1083static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
1084{
1085 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1086 struct player *pgiver;
1087
1088 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1089
1091 player_number(pdialog->treaty.plr1),
1092 player_number(pgiver), CLAUSE_SEAMAP,
1093 0);
1094}
1095
1096/************************************************************************/
1099static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data,
1100 int type)
1101{
1102 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1103
1105 player_number(pdialog->treaty.plr1),
1106 player_number(pdialog->treaty.plr0),
1107 type, 0);
1108}
1109
1110/************************************************************************/
1113static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
1114{
1115 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_CEASEFIRE);
1116}
1117
1118/************************************************************************/
1121static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
1122{
1123 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_PEACE);
1124}
1125
1126/************************************************************************/
1129static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
1130{
1131 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_ALLIANCE);
1132}
1133
1134/************************************************************************/
1137static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
1138{
1139 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1140 struct player *pgiver =
1141 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1142
1144 player_number(pdialog->treaty.plr1),
1145 player_number(pgiver), CLAUSE_VISION,
1146 0);
1147}
1148
1149/************************************************************************/
1152static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
1153{
1154 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1155 struct player *pgiver =
1156 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1157
1159 player_number(pdialog->treaty.plr1),
1160 player_number(pgiver), CLAUSE_EMBASSY,
1161 0);
1162}
1163
1164/************************************************************************/
1168{
1169 diplomacy_destroy(pdialog);
1170}
1171
1172/************************************************************************/
1176{
1177 dialog_list = dialog_list_new();
1178 dipl_main = NULL;
1179}
1180
1181/************************************************************************/
1185{
1186 dialog_list_destroy(dialog_list);
1187}
1188
1189/************************************************************************/
1192static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id)
1193{
1194 struct player *plr0 = client.conn.playing;
1195 struct player *plr1 = player_by_number(other_player_id);
1196
1198 if ((pdialog->treaty.plr0 == plr0 && pdialog->treaty.plr1 == plr1)
1199 || (pdialog->treaty.plr0 == plr1 && pdialog->treaty.plr1 == plr0)) {
1200 return pdialog;
1201 }
1203
1204 return NULL;
1205}
1206
1207/************************************************************************/
1210static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
1211{
1212 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1213 struct player *pgiver =
1214 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1215 int amount = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w));
1216
1217 if (amount >= 0 && amount <= pgiver->economic.gold) {
1219 player_number(pdialog->treaty.plr1),
1220 player_number(pgiver),
1221 CLAUSE_GOLD, amount);
1222 } else {
1223 output_window_append(ftc_client, _("Invalid amount of gold specified."));
1224 }
1225}
1226
1227/************************************************************************/
1231{
1232 while (dialog_list_size(dialog_list) > 0) {
1233 close_diplomacy_dialog(dialog_list_get(dialog_list, 0));
1234 }
1235}
#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 popup_add_menu(GtkMenuShell *parent, gpointer data)
Definition diplodlg.c:239
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_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:733
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_stockbutton(struct gui_dialog *dlg, const char *stock, const char *text, int response)
Definition gui_stuff.c:690
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
GtkWidget * gtk_aux_menu_bar_new(void)
Definition gui_stuff.c:249
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
#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 * image0
Definition diplodlg.c:59
GtkWidget * image1
Definition diplodlg.c:60
struct Treaty treaty
Definition diplodlg.c:53
struct gui_dialog * dialog
Definition diplodlg.c:54
GtkWidget * menu1
Definition diplodlg.c:57
GtkWidget * menu0
Definition diplodlg.c:56
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 * 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
Definition climisc.h:82
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_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