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

Freeciv-3.1

Loading...
Searching...
No Matches
diplodlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#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
52 struct Diplomacy_dialog {
53 struct Treaty treaty;
54 struct gui_dialog* dialog;
55
56 GtkWidget *menu0;
57 GtkWidget *menu1;
58
59 GtkWidget *image0;
60 GtkWidget *image1;
61
62 GtkListStore *store;
63};
64
65 struct Diplomacy_notebook {
66 struct gui_dialog* dialog;
67 GtkWidget *notebook;
68};
69
70 struct city_deal {
71 int giver;
72 int receiver;
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
84 static struct dialog_list *dialog_list;
85 static struct Diplomacy_notebook *dipl_main;
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/************************************************************************/
116 void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted,
117 bool other_accepted)
118{
119 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(counterpart);
120
121 if (!pdialog) {
122 return;
123 }
124
125 pdialog->treaty.accept0 = I_accepted;
126 pdialog->treaty.accept1 = other_accepted;
127
128 update_diplomacy_dialog(pdialog);
129 gui_dialog_alert(pdialog->dialog);
130}
131
132/************************************************************************/
135 void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
136{
137 popup_diplomacy_dialog(counterpart, initiated_from);
138}
139
140/************************************************************************/
143 void handle_diplomacy_cancel_meeting(int counterpart, int initiated_from)
144{
145 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(counterpart);
146
147 if (!pdialog) {
148 return;
149 }
150
151 close_diplomacy_dialog(pdialog);
152}
153
154/************************************************************************/
157 void handle_diplomacy_create_clause(int counterpart, int giver,
158 enum clause_type type, int value)
159{
160 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(counterpart);
161
162 if (!pdialog) {
163 return;
164 }
165
166 add_clause(&pdialog->treaty, player_by_number(giver), type, value,
167 client_player());
168 update_diplomacy_dialog(pdialog);
169 gui_dialog_alert(pdialog->dialog);
170}
171
172/************************************************************************/
175 void handle_diplomacy_remove_clause(int counterpart, int giver,
176 enum clause_type type, int value)
177{
178 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(counterpart);
179
180 if (!pdialog) {
181 return;
182 }
183
184 remove_clause(&pdialog->treaty, player_by_number(giver), type, value);
185 update_diplomacy_dialog(pdialog);
186 gui_dialog_alert(pdialog->dialog);
187}
188
189/************************************************************************/
192 static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
193{
194 struct Diplomacy_dialog *pdialog = find_diplomacy_dialog(other_player_id);
195
196 if (!can_client_issue_orders()) {
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) {
205 pdialog = create_diplomacy_dialog(client.conn.playing,
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);
215 gui_dialog_raise(dipl_main->dialog);
216 gui_dialog_raise(pdialog->dialog);
217
218 if (players_dialog_shell != NULL) {
219 gui_dialog_set_return_dialog(pdialog->dialog, players_dialog_shell);
220 }
221 }
222}
223
224/************************************************************************/
227 static 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/************************************************************************/
239 static 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,
305 game.info.tech_trade_allow_holes))
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 }
311 } advance_iterate_end;
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",
331 G_CALLBACK(diplomacy_dialog_tech_callback),
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",
347 G_CALLBACK(diplomacy_dialog_tech_callback),
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 }
384 } city_list_iterate_end;
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",
402 G_CALLBACK(diplomacy_dialog_city_callback),
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/************************************************************************/
496 static 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]) {
508 dsend_packet_diplomacy_remove_clause_req(&client.conn,
509 player_number(pdialog->treaty.plr1),
510 player_number(pclause->from),
511 pclause->type,
512 pclause->value);
513 return;
514 }
515 i++;
516 } clause_list_iterate_end;
517}
518
519/************************************************************************/
522 static struct Diplomacy_notebook *diplomacy_main_create(void)
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),
530 dipl_main->dialog, TRUE);
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 */
544 gui_dialog_add_stockbutton(dipl_main->dialog, GTK_STOCK_CANCEL,
545 _("Cancel _all meetings"),
546 RESPONSE_CANCEL_MEETING_ALL);
547
548 /* Responses for _all_ meetings. */
549 gui_dialog_response_set_callback(dipl_main->dialog,
550 diplomacy_main_response);
551 gui_dialog_set_default_response(dipl_main->dialog,
552 RESPONSE_CANCEL_MEETING_ALL);
553
554 dipl_box = dipl_main->dialog->vbox;
555 gtk_container_add(GTK_CONTAINER(dipl_box), dipl_sw);
556
557 gui_dialog_show_all(dipl_main->dialog);
558 gui_dialog_present(dipl_main->dialog);
559 }
560
561 return dipl_main;
562}
563
564/************************************************************************/
567 static void diplomacy_main_destroy(void)
568{
569 if (dipl_main->dialog) {
570 gui_dialog_destroy(dipl_main->dialog);
571 }
572 free(dipl_main);
573 dipl_main = NULL;
574}
575
576/************************************************************************/
579 static 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. */
592 dialog_list_iterate(dialog_list, adialog) {
593 /* This will do a round trip to the server ans close the diolag in the
594 * client. Closing the last dialog will also close the main tab.*/
595 dsend_packet_diplomacy_cancel_meeting_req(&client.conn,
596 player_number(
597 adialog->treaty.plr1));
598 } dialog_list_iterate_end;
599 break;
600 }
601}
602
603/************************************************************************/
606 static 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 free(pdialog);
616
617 if (dialog_list) {
618 /* Diplomatic meetings in one main tab. */
619 if (dialog_list_size(dialog_list) > 0) {
620 if (dipl_main && dipl_main->dialog) {
621 gchar *buf;
622
623 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
624 gui_dialog_set_title(dipl_main->dialog, buf);
625 g_free(buf);
626 }
627 } else if (dipl_main) {
628 /* No meeting left - destroy main tab. */
629 diplomacy_main_destroy();
630 }
631 }
632}
633
634/************************************************************************/
637 static void diplomacy_response(struct gui_dialog *dlg, int response,
638 gpointer data)
639{
640 struct Diplomacy_dialog *pdialog = NULL;
641
642 fc_assert_ret(data);
643 pdialog = (struct Diplomacy_dialog *)data;
644
645 switch (response) {
646 case GTK_RESPONSE_ACCEPT: /* Accept treaty. */
647 dsend_packet_diplomacy_accept_treaty_req(&client.conn,
648 player_number(
649 pdialog->treaty.plr1));
650 break;
651
652 default:
653 log_error("unhandled response in %s: %d", __FUNCTION__, response);
654 fc__fallthrough; /* No break. */
655 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
656 case GTK_RESPONSE_CANCEL: /* GTK: cancel button. */
657 case RESPONSE_CANCEL_MEETING: /* Cancel meetings. */
658 dsend_packet_diplomacy_cancel_meeting_req(&client.conn,
659 player_number(
660 pdialog->treaty.plr1));
661 break;
662 }
663}
664
665/************************************************************************/
668 static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0,
669 struct player *plr1)
670{
671 struct Diplomacy_notebook *dipl_dialog;
672 GtkWidget *vbox, *hbox, *table, *mainbox;
673 GtkWidget *label, *sw, *view, *image, *spin;
674 GtkWidget *menubar, *menuitem, *menu, *notebook;
675 struct sprite *flag_spr;
676 GtkListStore *store;
677 GtkCellRenderer *rend;
678 int i;
679
680 struct Diplomacy_dialog *pdialog;
681 char plr_buf[4 * MAX_LEN_NAME];
682 gchar *buf;
683
684 pdialog = fc_malloc(sizeof(*pdialog));
685
686 dialog_list_prepend(dialog_list, pdialog);
687 init_treaty(&pdialog->treaty, plr0, plr1);
688
689 /* Get main diplomacy tab. */
690 dipl_dialog = diplomacy_main_create();
691
692 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
693 gui_dialog_set_title(dipl_dialog->dialog, buf);
694 g_free(buf);
695
696 notebook = dipl_dialog->notebook;
697
698 gui_dialog_new(&(pdialog->dialog), GTK_NOTEBOOK(notebook), pdialog, FALSE);
699
700 /* Buttons */
701 gui_dialog_add_stockbutton(pdialog->dialog, GTK_STOCK_DND,
702 _("Accept treaty"), GTK_RESPONSE_ACCEPT);
703 gui_dialog_add_stockbutton(pdialog->dialog, GTK_STOCK_CANCEL,
704 _("Cancel meeting"), RESPONSE_CANCEL_MEETING);
705
706 /* Responses for one meeting. */
707 gui_dialog_response_set_callback(pdialog->dialog, diplomacy_response);
708 gui_dialog_set_default_response(pdialog->dialog, RESPONSE_CANCEL_MEETING);
709
710 /* Label for the new meeting. */
711 buf = g_strdup_printf("%s", nation_plural_for_player(plr1));
712 gui_dialog_set_title(pdialog->dialog, buf);
713
714 /* Sort meeting tabs alphabetically by the tab label. */
715 for (i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i++) {
716 GtkWidget *prev_page
717 = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
718 struct gui_dialog *prev_dialog
719 = g_object_get_data(G_OBJECT(prev_page), "gui-dialog-data");
720 const char *prev_label
721 = gtk_label_get_text(GTK_LABEL(prev_dialog->v.tab.label));
722
723 if (fc_strcasecmp(buf, prev_label) < 0) {
724 gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook),
725 pdialog->dialog->vbox, i);
726 break;
727 }
728 }
729 g_free(buf);
730
731 /* Content. */
732 mainbox = pdialog->dialog->vbox;
733
734 /* us. */
735 vbox = gtk_grid_new();
736 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
737 GTK_ORIENTATION_VERTICAL);
738 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
739 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
740 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
741
742 /* Our nation. */
743 label = gtk_label_new(NULL);
744 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
745 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
746 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
747 nation_plural_for_player(plr0));
748 gtk_label_set_markup(GTK_LABEL(label), buf);
749 g_free(buf);
750 gtk_container_add(GTK_CONTAINER(vbox), label);
751
752 hbox = gtk_grid_new();
753 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
754 gtk_container_add(GTK_CONTAINER(vbox), hbox);
755
756 /* Our flag */
757 flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr0));
758
759 image = gtk_image_new_from_surface(flag_spr->surface);
760 gtk_container_add(GTK_CONTAINER(hbox), image);
761
762 /* Our name. */
763 label = gtk_label_new(NULL);
764 gtk_widget_set_hexpand(label, TRUE);
765 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
766 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
767 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
768 ruler_title_for_player(plr0, plr_buf, sizeof(plr_buf)));
769 gtk_label_set_markup(GTK_LABEL(label), buf);
770 g_free(buf);
771 gtk_container_add(GTK_CONTAINER(hbox), label);
772
773 image = gtk_image_new();
774 pdialog->image0 = image;
775 gtk_container_add(GTK_CONTAINER(hbox), image);
776
777 /* Menu for clauses: we. */
778 menubar = gtk_aux_menu_bar_new();
779
780 menu = gtk_menu_new();
781 pdialog->menu0 = menu;
782
783 menuitem = gtk_image_menu_item_new_with_label(_("Add Clause..."));
784 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
785 gtk_image_new_from_stock(GTK_STOCK_ADD,
786 GTK_ICON_SIZE_MENU));
787 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
788 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
789 g_object_set_data(G_OBJECT(menu), "plr", plr0);
790 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
791
792 /* Main table for clauses and (if activated) gold trading: we. */
793 table = gtk_grid_new();
794 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
795 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
796 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
797 gtk_container_add(GTK_CONTAINER(vbox), table);
798
799 if (clause_enabled(CLAUSE_GOLD)) {
800 spin = gtk_spin_button_new_with_range(0.0, plr0->economic.gold + 0.1,
801 1.0);
802 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
803 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
804 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
805 g_object_set_data(G_OBJECT(spin), "plr", plr0);
806 g_signal_connect_after(spin, "value-changed",
807 G_CALLBACK(diplo_dialog_returnkey), pdialog);
808
809 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
810 "mnemonic-widget", spin, "label", _("Gold:"),
811 "xalign", 0.0, "yalign", 0.5, NULL);
812 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
813
814 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
815 } else {
816 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
817 }
818
819 /* them. */
820 vbox = gtk_grid_new();
821 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
822 GTK_ORIENTATION_VERTICAL);
823 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
824 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
825 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
826
827 /* Their nation. */
828 label = gtk_label_new(NULL);
829 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
830 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
831 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
832 nation_plural_for_player(plr1));
833 gtk_label_set_markup(GTK_LABEL(label), buf);
834 g_free(buf);
835 gtk_container_add(GTK_CONTAINER(vbox), label);
836
837 hbox = gtk_grid_new();
838 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
839 gtk_container_add(GTK_CONTAINER(vbox), hbox);
840
841 /* Their flag */
842 flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr1));
843
844 image = gtk_image_new_from_surface(flag_spr->surface);
845 gtk_container_add(GTK_CONTAINER(hbox), image);
846
847 /* Their name. */
848 label = gtk_label_new(NULL);
849 gtk_widget_set_hexpand(label, TRUE);
850 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
851 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
852 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
853 ruler_title_for_player(plr1, plr_buf, sizeof(plr_buf)));
854 gtk_label_set_markup(GTK_LABEL(label), buf);
855 g_free(buf);
856 gtk_container_add(GTK_CONTAINER(hbox), label);
857
858 image = gtk_image_new();
859 pdialog->image1 = image;
860 gtk_container_add(GTK_CONTAINER(hbox), image);
861
862 /* Menu for clauses: they. */
863 menubar = gtk_aux_menu_bar_new();
864
865 menu = gtk_menu_new();
866 pdialog->menu1 = menu;
867
868 menuitem = gtk_image_menu_item_new_with_label(_("Add Clause..."));
869 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
870 gtk_image_new_from_stock(GTK_STOCK_ADD,
871 GTK_ICON_SIZE_MENU));
872 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
873 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
874 g_object_set_data(G_OBJECT(menu), "plr", plr1);
875 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
876
877 /* Main table for clauses and (if activated) gold trading: they. */
878 table = gtk_grid_new();
879 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
880 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
881 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
882 gtk_container_add(GTK_CONTAINER(vbox), table);
883
884 if (clause_enabled(CLAUSE_GOLD)) {
885 spin = gtk_spin_button_new_with_range(0.0, plr1->economic.gold + 0.1,
886 1.0);
887 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
888 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
889 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
890 g_object_set_data(G_OBJECT(spin), "plr", plr1);
891 g_signal_connect_after(spin, "value-changed",
892 G_CALLBACK(diplo_dialog_returnkey), pdialog);
893
894 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
895 "mnemonic-widget", spin, "label", _("Gold:"),
896 "xalign", 0.0, "yalign", 0.5, NULL);
897 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
898
899 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
900 } else {
901 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
902 }
903
904 /* Clauses. */
905 mainbox = gtk_grid_new();
906 gtk_orientable_set_orientation(GTK_ORIENTABLE(mainbox),
907 GTK_ORIENTATION_VERTICAL);
908 gtk_container_add(GTK_CONTAINER(pdialog->dialog->vbox), mainbox);
909
910 store = gtk_list_store_new(1, G_TYPE_STRING);
911 pdialog->store = store;
912
913 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
914 gtk_widget_set_hexpand(view, TRUE);
915 gtk_widget_set_vexpand(view, TRUE);
916 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
917 g_object_unref(store);
918 gtk_widget_set_size_request(view, 320, 100);
919
920 rend = gtk_cell_renderer_text_new();
921 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, NULL,
922 rend, "text", 0, NULL);
923
924 sw = gtk_scrolled_window_new(NULL, NULL);
925 g_object_set(sw, "margin", 2, NULL);
926 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
927 GTK_SHADOW_ETCHED_IN);
928 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
929 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
930 gtk_container_add(GTK_CONTAINER(sw), view);
931
932 label = g_object_new(GTK_TYPE_LABEL,
933 "use-underline", TRUE,
934 "mnemonic-widget", view,
935 "label", _("C_lauses:"),
936 "xalign", 0.0,
937 "yalign", 0.5,
938 NULL);
939
940 vbox = gtk_grid_new();
941 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
942 GTK_ORIENTATION_VERTICAL);
943 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
944 gtk_container_add(GTK_CONTAINER(vbox), label);
945 gtk_container_add(GTK_CONTAINER(vbox), sw);
946
947 gtk_widget_show_all(mainbox);
948
949 g_signal_connect(view, "row_activated", G_CALLBACK(row_callback), pdialog);
950
951 update_diplomacy_dialog(pdialog);
952 gui_dialog_show_all(pdialog->dialog);
953
954 return pdialog;
955}
956
957/************************************************************************/
960 static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
961{
962 GtkListStore *store;
963 GtkTreeIter it;
964 bool blank = TRUE;
965 GdkPixbuf *pixbuf;
966
967 store = pdialog->store;
968
969 gtk_list_store_clear(store);
970 clause_list_iterate(pdialog->treaty.clauses, pclause) {
971 char buf[128];
972
973 client_diplomacy_clause_string(buf, sizeof(buf), pclause);
974
975 gtk_list_store_append(store, &it);
976 gtk_list_store_set(store, &it, 0, buf, -1);
977 blank = FALSE;
978 } clause_list_iterate_end;
979
980 if (blank) {
981 gtk_list_store_append(store, &it);
982 gtk_list_store_set(store, &it, 0,
983 _("--- This treaty is blank. "
984 "Please add some clauses. ---"), -1);
985 }
986
987 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept0);
988 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image0), pixbuf);
989 g_object_unref(G_OBJECT(pixbuf));
990 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept1);
991 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image1), pixbuf);
992 g_object_unref(G_OBJECT(pixbuf));
993}
994
995/************************************************************************/
998 static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
999{
1000 int giver, dest, other, tech;
1001
1002 giver = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_from"));
1003 dest = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_to"));
1004 tech = GPOINTER_TO_INT(data);
1005 if (player_by_number(giver) == client_player()) {
1006 other = dest;
1007 } else {
1008 other = giver;
1009 }
1010
1011 if (A_LAST == tech) {
1012 /* All techs. */
1013 struct player *pgiver = player_by_number(giver);
1014 struct player *pdest = player_by_number(dest);
1015 const struct research *dresearch, *gresearch;
1016
1017 fc_assert_ret(NULL != pgiver);
1018 fc_assert_ret(NULL != pdest);
1019
1020 dresearch = research_get(pdest);
1021 gresearch = research_get(pgiver);
1022 advance_iterate(A_FIRST, padvance) {
1023 Tech_type_id i = advance_number(padvance);
1024
1025 if (research_invention_state(gresearch, i) == TECH_KNOWN
1026 && research_invention_gettable(dresearch, i,
1027 game.info.tech_trade_allow_holes)
1028 && (research_invention_state(dresearch, i) == TECH_UNKNOWN
1029 || research_invention_state(dresearch, i)
1030 == TECH_PREREQS_KNOWN)) {
1031 dsend_packet_diplomacy_create_clause_req(&client.conn, other, giver,
1032 CLAUSE_ADVANCE, i);
1033 }
1034 } advance_iterate_end;
1035 } else {
1036 /* Only one tech. */
1037 dsend_packet_diplomacy_create_clause_req(&client.conn, other, giver,
1038 CLAUSE_ADVANCE, tech);
1039 }
1040}
1041
1042/************************************************************************/
1046 static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
1047{
1048 struct city_deal *deal_data = (struct city_deal *)data;
1049 int other;
1050
1051 if (player_by_number(deal_data->giver) == client_player()) {
1052 other = deal_data->receiver;
1053 } else {
1054 other = deal_data->giver;
1055 }
1056
1057 dsend_packet_diplomacy_create_clause_req(&client.conn, other, deal_data->giver,
1058 CLAUSE_CITY, deal_data->id);
1059
1060 free(deal_data);
1061}
1062
1063/************************************************************************/
1066 static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
1067{
1068 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1069 struct player *pgiver;
1070
1071 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1072
1073 dsend_packet_diplomacy_create_clause_req(&client.conn,
1074 player_number(pdialog->treaty.plr1),
1075 player_number(pgiver), CLAUSE_MAP, 0);
1076}
1077
1078/************************************************************************/
1081 static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
1082{
1083 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1084 struct player *pgiver;
1085
1086 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1087
1088 dsend_packet_diplomacy_create_clause_req(&client.conn,
1089 player_number(pdialog->treaty.plr1),
1090 player_number(pgiver), CLAUSE_SEAMAP,
1091 0);
1092}
1093
1094/************************************************************************/
1097 static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data,
1098 int type)
1099{
1100 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1101
1102 dsend_packet_diplomacy_create_clause_req(&client.conn,
1103 player_number(pdialog->treaty.plr1),
1104 player_number(pdialog->treaty.plr0),
1105 type, 0);
1106}
1107
1108/************************************************************************/
1111 static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
1112{
1113 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_CEASEFIRE);
1114}
1115
1116/************************************************************************/
1119 static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
1120{
1121 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_PEACE);
1122}
1123
1124/************************************************************************/
1127 static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
1128{
1129 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_ALLIANCE);
1130}
1131
1132/************************************************************************/
1135 static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
1136{
1137 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1138 struct player *pgiver =
1139 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1140
1141 dsend_packet_diplomacy_create_clause_req(&client.conn,
1142 player_number(pdialog->treaty.plr1),
1143 player_number(pgiver), CLAUSE_VISION,
1144 0);
1145}
1146
1147/************************************************************************/
1150 static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
1151{
1152 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1153 struct player *pgiver =
1154 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1155
1156 dsend_packet_diplomacy_create_clause_req(&client.conn,
1157 player_number(pdialog->treaty.plr1),
1158 player_number(pgiver), CLAUSE_EMBASSY,
1159 0);
1160}
1161
1162/************************************************************************/
1165 void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
1166{
1167 diplomacy_destroy(pdialog);
1168}
1169
1170/************************************************************************/
1173 void diplomacy_dialog_init(void)
1174{
1175 dialog_list = dialog_list_new();
1176 dipl_main = NULL;
1177}
1178
1179/************************************************************************/
1182 void diplomacy_dialog_done(void)
1183{
1184 dialog_list_destroy(dialog_list);
1185}
1186
1187/************************************************************************/
1190 static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id)
1191{
1192 struct player *plr0 = client.conn.playing;
1193 struct player *plr1 = player_by_number(other_player_id);
1194
1195 dialog_list_iterate(dialog_list, pdialog) {
1196 if ((pdialog->treaty.plr0 == plr0 && pdialog->treaty.plr1 == plr1)
1197 || (pdialog->treaty.plr0 == plr1 && pdialog->treaty.plr1 == plr0)) {
1198 return pdialog;
1199 }
1200 } dialog_list_iterate_end;
1201
1202 return NULL;
1203}
1204
1205/************************************************************************/
1208 static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
1209{
1210 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1211 struct player *pgiver =
1212 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1213 int amount = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w));
1214
1215 if (amount >= 0 && amount <= pgiver->economic.gold) {
1216 dsend_packet_diplomacy_create_clause_req(&client.conn,
1217 player_number(pdialog->treaty.plr1),
1218 player_number(pgiver),
1219 CLAUSE_GOLD, amount);
1220 } else {
1221 output_window_append(ftc_client, _("Invalid amount of gold specified."));
1222 }
1223}
1224
1225/************************************************************************/
1228 void close_all_diplomacy_dialogs(void)
1229{
1230 while (dialog_list_size(dialog_list) > 0) {
1231 close_diplomacy_dialog(dialog_list_get(dialog_list, 0));
1232 }
1233}
n
#define n
Definition astring.c:77
output_window_append
void output_window_append(const struct ft_color color, const char *featured_text)
Definition chatline_common.c:104
is_capital
bool is_capital(const struct city *pcity)
Definition city.c:1548
city_name_get
const char * city_name_get(const struct city *pcity)
Definition city.c:1111
city_name_compare
int city_name_compare(const void *p1, const void *p2)
Definition city.c:1680
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:488
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:490
client
struct civclient client
Definition client_main.c:149
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1265
client_main.h
client_player
#define client_player()
Definition client_main.h:106
client_diplomacy_clause_string
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
climisc.h
giver
int int initiated_from int int giver
Definition diplodlg_g.h:28
handle_diplomacy_remove_clause
int int initiated_from handle_diplomacy_remove_clause
Definition diplodlg_g.h:28
handle_diplomacy_cancel_meeting
handle_diplomacy_cancel_meeting
Definition diplodlg_g.h:24
counterpart
int counterpart
Definition diplodlg_g.h:25
init_treaty
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:96
add_clause
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:142
clause_enabled
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:286
remove_clause
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:120
diptreaty.h
clause_list_iterate_end
#define clause_list_iterate_end
Definition diptreaty.h:68
clause_list_iterate
#define clause_list_iterate(clauselist, pclause)
Definition diptreaty.h:66
Tech_type_id
int Tech_type_id
Definition fc_types.h:347
MAX_LEN_NAME
#define MAX_LEN_NAME
Definition fc_types.h:66
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
_
#define _(String)
Definition fcintl.h:67
ftc_client
const struct ft_color ftc_client
Definition featured_text.c:78
game
struct civ_game game
Definition game.c:57
game.h
ruler_title_for_player
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:390
government.h
diplomacy_dialog_add_pact_clause
static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data, int type)
Definition diplodlg.c:1097
RESPONSE_CANCEL_MEETING
#define RESPONSE_CANCEL_MEETING
Definition diplodlg.c:110
sort_advance_names
static gint sort_advance_names(gconstpointer a, gconstpointer b)
Definition diplodlg.c:227
close_diplomacy_dialog
static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:1165
diplomacy_dialog_tech_callback
static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:998
row_callback
static void row_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition diplodlg.c:496
diplomacy_dialog_ceasefire_callback
static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1111
popup_add_menu
static void popup_add_menu(GtkMenuShell *parent, gpointer data)
Definition diplodlg.c:239
update_diplomacy_dialog
static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:960
find_diplomacy_dialog
static struct Diplomacy_dialog * find_diplomacy_dialog(int other_player_id)
Definition diplodlg.c:1190
create_diplomacy_dialog
static struct Diplomacy_dialog * create_diplomacy_dialog(struct player *plr0, struct player *plr1)
Definition diplodlg.c:668
diplomacy_dialog_seamap_callback
static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1081
diplomacy_dialog_city_callback
static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1046
handle_diplomacy_init_meeting
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
Definition diplodlg.c:135
diplomacy_dialog_map_callback
static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1066
diplomacy_dialog_init
void diplomacy_dialog_init(void)
Definition diplodlg.c:1173
diplomacy_destroy
static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:606
dialog_list_iterate_end
#define dialog_list_iterate_end
Definition diplodlg.c:82
diplomacy_main_create
static struct Diplomacy_notebook * diplomacy_main_create(void)
Definition diplodlg.c:522
handle_diplomacy_create_clause
void handle_diplomacy_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition diplodlg.c:157
diplomacy_dialog_vision_callback
static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1135
close_all_diplomacy_dialogs
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1228
RESPONSE_CANCEL_MEETING_ALL
#define RESPONSE_CANCEL_MEETING_ALL
Definition diplodlg.c:111
diplomacy_dialog_embassy_callback
static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1150
diplomacy_response
static void diplomacy_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:637
dialog_list_iterate
#define dialog_list_iterate(dialoglist, pdialog)
Definition diplodlg.c:80
dialog_list
static struct dialog_list * dialog_list
Definition diplodlg.c:84
diplomacy_main_response
static void diplomacy_main_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:579
diplomacy_dialog_peace_callback
static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1119
diplomacy_dialog_done
void diplomacy_dialog_done(void)
Definition diplodlg.c:1182
diplo_dialog_returnkey
static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
Definition diplodlg.c:1208
diplomacy_main_destroy
static void diplomacy_main_destroy(void)
Definition diplodlg.c:567
handle_diplomacy_accept_treaty
void handle_diplomacy_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition diplodlg.c:116
diplomacy_dialog_alliance_callback
static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1127
popup_diplomacy_dialog
static void popup_diplomacy_dialog(int other_player_id, int initiated_from)
Definition diplodlg.c:192
dipl_main
static struct Diplomacy_notebook * dipl_main
Definition diplodlg.c:85
top_notebook
GtkWidget * top_notebook
Definition gui_main.c:128
gui_dialog_destroy
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:951
gui_dialog_present
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:834
gui_dialog_set_default_response
void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:733
gui_dialog_raise
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:864
gui_dialog_new
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:504
gui_dialog_set_return_dialog
void gui_dialog_set_return_dialog(struct gui_dialog *dlg, struct gui_dialog *return_dialog)
Definition gui_stuff.c:994
gui_dialog_response_set_callback
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:985
gui_dialog_add_stockbutton
GtkWidget * gui_dialog_add_stockbutton(struct gui_dialog *dlg, const char *stock, const char *text, int response)
Definition gui_stuff.c:690
gui_dialog_show_all
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:794
gui_dialog_set_title
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:932
gui_dialog_alert
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:887
gtk_aux_menu_bar_new
GtkWidget * gtk_aux_menu_bar_new(void)
Definition gui_stuff.c:249
get_thumb_pixbuf
GdkPixbuf * get_thumb_pixbuf(int onoff)
Definition mapview.c:275
players_dialog_shell
struct gui_dialog * players_dialog_shell
Definition plrdlg.c:58
type
GType type
Definition repodlgs.c:1312
gui_stuff.h
chatline.h
diplodlg.h
gui_main.h
mapview.h
plrdlg.h
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
log_error
#define log_error(message,...)
Definition log.h:103
map.h
mem.h
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
nation_of_player
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:443
nation_plural_for_player
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:177
options.h
packets.h
dsend_packet_diplomacy_create_clause_req
int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:49121
dsend_packet_diplomacy_cancel_meeting_req
int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
Definition packets_gen.c:48643
dsend_packet_diplomacy_remove_clause_req
int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:49678
dsend_packet_diplomacy_accept_treaty_req
int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
Definition packets_gen.c:50132
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:840
player_number
int player_number(const struct player *pplayer)
Definition player.c:828
player_has_real_embassy
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:234
team_has_embassy
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
Definition player.c:214
player_diplstate_get
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:317
gives_shared_vision
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1461
player.h
is_human
#define is_human(plr)
Definition player.h:233
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
research_invention_gettable
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:690
research.h
shared.h
speclist.h
Diplomacy_dialog
Definition diplodlg.c:52
Diplomacy_dialog::image0
GtkWidget * image0
Definition diplodlg.c:59
Diplomacy_dialog::image1
GtkWidget * image1
Definition diplodlg.c:60
Diplomacy_dialog::treaty
struct Treaty treaty
Definition diplodlg.c:53
Diplomacy_dialog::dialog
struct gui_dialog * dialog
Definition diplodlg.c:54
Diplomacy_dialog::menu1
GtkWidget * menu1
Definition diplodlg.c:57
Diplomacy_dialog::menu0
GtkWidget * menu0
Definition diplodlg.c:56
Diplomacy_dialog::store
GtkListStore * store
Definition diplodlg.c:62
Diplomacy_notebook
Definition diplodlg.c:65
Diplomacy_notebook::dialog
struct gui_dialog * dialog
Definition diplodlg.c:66
Diplomacy_notebook::notebook
GtkWidget * notebook
Definition diplodlg.c:67
Treaty
Definition diptreaty.h:76
Treaty::plr0
struct player * plr0
Definition diptreaty.h:77
Treaty::accept0
bool accept0
Definition diptreaty.h:78
Treaty::accept1
bool accept1
Definition diptreaty.h:78
Treaty::clauses
struct clause_list * clauses
Definition diptreaty.h:79
Treaty::plr1
struct player * plr1
Definition diptreaty.h:77
advance
Definition tech.h:124
city_deal
Definition diplodlg.c:70
city_deal::giver
int giver
Definition diplodlg.c:71
city_deal::receiver
int receiver
Definition diplodlg.c:72
city_deal::id
int id
Definition diplodlg.c:73
city
Definition city.h:309
city::id
int id
Definition city.h:315
civ_game::info
struct packet_game_info info
Definition game.h:89
civclient::conn
struct connection conn
Definition client_main.h:96
connection::playing
struct player * playing
Definition connection.h:156
gui_dialog
Definition gui_stuff.h:69
gui_dialog::v
union gui_dialog::@149 v
gui_dialog::vbox
GtkWidget * vbox
Definition gui_stuff.h:71
gui_dialog::label
GtkWidget * label
Definition gui_stuff.h:86
gui_dialog::tab
struct gui_dialog::@149::@150 tab
gui_dialog::notebook
GtkWidget * notebook
Definition gui_stuff.h:87
item
Definition climisc.h:80
packet_game_info::tech_trade_allow_holes
bool tech_trade_allow_holes
Definition packets_gen.h:212
player_diplstate::type
enum diplstate_type type
Definition player.h:201
player_economic::gold
int gold
Definition player.h:70
player
Definition player.h:249
player::cities
struct city_list * cities
Definition player.h:281
player::team
struct team * team
Definition player.h:261
player::economic
struct player_economic economic
Definition player.h:284
research
Definition research.h:39
sprite
Definition sprite.h:22
sprite::surface
cairo_surface_t * surface
Definition sprite.h:23
tileset
Definition tilespec.c:459
view
Definition mapview_common.h:36
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
fc_strcoll
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:472
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
fc__fallthrough
#define fc__fallthrough
Definition support.h:109
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
advance_iterate
#define advance_iterate(_start, _p)
Definition tech.h:264
A_FIRST
#define A_FIRST
Definition tech.h:44
advance_iterate_end
#define advance_iterate_end
Definition tech.h:270
A_LAST
#define A_LAST
Definition tech.h:45
get_nation_flag_sprite
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6471