Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-3.22/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.22 */
46#include "diplodlg.h"
47#include "gui_main.h"
48#include "gui_stuff.h"
49#include "mapview.h"
50#include "plrdlg.h"
51
52struct Diplomacy_dialog {
53 struct Treaty treaty;
54 struct gui_dialog* dialog;
55
56 GtkWidget *menu0;
57 GtkWidget *menu1;
58
59 GtkWidget *image0;
60 GtkWidget *image1;
61
62 GtkListStore *store;
63};
64
65struct Diplomacy_notebook {
66 struct gui_dialog* dialog;
67 GtkWidget *notebook;
68};
69
70struct 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 = gtk_menu_item_new_with_label(advance_name_translation(padvance));
340 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
341 g_object_set_data(G_OBJECT(item), "player_from",
342 GINT_TO_POINTER(player_number(pgiver)));
343 g_object_set_data(G_OBJECT(item), "player_to",
344 GINT_TO_POINTER(player_number(pother)));
345 g_signal_connect(item, "activate",
346 G_CALLBACK(diplomacy_dialog_tech_callback),
347 GINT_TO_POINTER(advance_number(padvance)));
348 }
349
350 gtk_menu_item_set_submenu(GTK_MENU_ITEM(advance_item), menu);
351 g_list_free(sorting_list);
352 }
353
354 gtk_widget_show_all(advance_item);
355 }
356
357 /* Trading: cities. */
358
359 /****************************************************************
360 Creates a sorted list of plr0's cities, excluding the capital and
361 any cities not visible to plr1. This means that you can only trade
362 cities visible to requesting player.
363
364 - Kris Bubendorfer
365 *****************************************************************/
366 if (clause_enabled(CLAUSE_CITY)) {
367 int i = 0;
368 int n = city_list_size(pgiver->cities);
369
370 menu = gtk_menu_new();
371
372 if (n > 0) {
373 struct city **city_list_ptrs;
374
375 city_list_ptrs = fc_malloc(sizeof(struct city *) * n);
376
377 city_list_iterate(pgiver->cities, pcity) {
378 if (!is_capital(pcity)) {
379 city_list_ptrs[i] = pcity;
380 i++;
381 }
382 } city_list_iterate_end;
383
384 if (i > 0) { /* Cities other than capitals */
385 int j;
386
387 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
388
389 for (j = 0; j < i; j++) {
390 struct city_deal *deal = fc_malloc(sizeof(struct city_deal));
391
392 item = gtk_menu_item_new_with_label(city_name_get(city_list_ptrs[j]));
393
394 deal->giver = player_number(pgiver);
395 deal->receiver = player_number(pother);
396 deal->id = city_list_ptrs[j]->id;
397
398 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
399 g_signal_connect(item, "activate",
400 G_CALLBACK(diplomacy_dialog_city_callback),
401 (gpointer)deal);
402 }
403 }
404
405 free(city_list_ptrs);
406 }
407
408 item = gtk_menu_item_new_with_mnemonic(_("_Cities"));
409 gtk_widget_set_sensitive(item, (i > 0));
410 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
411 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
412 gtk_widget_show_all(item);
413 }
414
415 /* Give shared vision. */
416 if (clause_enabled(CLAUSE_VISION)) {
417 item = gtk_menu_item_new_with_mnemonic(_("_Give shared vision"));
418 g_object_set_data(G_OBJECT(item), "plr", pgiver);
419 g_signal_connect(item, "activate",
420 G_CALLBACK(diplomacy_dialog_vision_callback), pdialog);
421
422 if (gives_shared_vision(pgiver, pother)) {
423 gtk_widget_set_sensitive(item, FALSE);
424 }
425 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
426 gtk_widget_show(item);
427 }
428
429 /* Give embassy. */
430 if (clause_enabled(CLAUSE_EMBASSY)) {
431 item = gtk_menu_item_new_with_mnemonic(_("Give _embassy"));
432 g_object_set_data(G_OBJECT(item), "plr", pgiver);
433 g_signal_connect(item, "activate",
434 G_CALLBACK(diplomacy_dialog_embassy_callback), pdialog);
435
436 /* Don't take in account the embassy effects. */
437 if (player_has_real_embassy(pother, pgiver)) {
438 gtk_widget_set_sensitive(item, FALSE);
439 }
440 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
441 gtk_widget_show(item);
442 }
443
444 /* Pacts. */
445 if (pgiver == pdialog->treaty.plr0) {
446 enum diplstate_type ds;
447 int pact_clauses = 0;
448
449 ds = player_diplstate_get(pgiver, pother)->type;
450
451 menu = gtk_menu_new();
452
453 if (clause_enabled(CLAUSE_CEASEFIRE)) {
454 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Cease-fire"));
455 gtk_menu_shell_append(GTK_MENU_SHELL(menu),item);
456 g_signal_connect(item, "activate",
457 G_CALLBACK(diplomacy_dialog_ceasefire_callback), pdialog);
458 gtk_widget_set_sensitive(item, ds != DS_CEASEFIRE && ds != DS_TEAM);
459 pact_clauses++;
460 }
461
462 if (clause_enabled(CLAUSE_PEACE)) {
463 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Peace"));
464 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
465 g_signal_connect(item, "activate",
466 G_CALLBACK(diplomacy_dialog_peace_callback), pdialog);
467 gtk_widget_set_sensitive(item, ds != DS_PEACE && ds != DS_TEAM);
468 pact_clauses++;
469 }
470
471 if (clause_enabled(CLAUSE_ALLIANCE)) {
472 item = gtk_menu_item_new_with_mnemonic(Q_("?diplomatic_state:Alliance"));
473 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
474 g_signal_connect(item, "activate",
475 G_CALLBACK(diplomacy_dialog_alliance_callback), pdialog);
476 gtk_widget_set_sensitive(item, ds != DS_ALLIANCE && ds != DS_TEAM);
477 pact_clauses++;
478 }
479
480 if (pact_clauses > 0) {
481 item = gtk_menu_item_new_with_mnemonic(_("_Pacts"));
482 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
483 gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
484 gtk_widget_show_all(item);
485 } else {
486 g_object_unref(menu);
487 }
488 }
489}
490
491/************************************************************************/
494 static void row_callback(GtkTreeView *view, GtkTreePath *path,
495 GtkTreeViewColumn *col, gpointer data)
496{
497 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
498 gint i;
499 gint *index;
500
501 index = gtk_tree_path_get_indices(path);
502
503 i = 0;
504 clause_list_iterate(pdialog->treaty.clauses, pclause) {
505 if (i == index[0]) {
506 dsend_packet_diplomacy_remove_clause_req(&client.conn,
507 player_number(pdialog->treaty.plr1),
508 player_number(pclause->from),
509 pclause->type,
510 pclause->value);
511 return;
512 }
513 i++;
514 } clause_list_iterate_end;
515}
516
517/************************************************************************/
520 static struct Diplomacy_notebook *diplomacy_main_create(void)
521{
522 /* Collect all meetings in one main tab. */
523 if (!dipl_main) {
524 GtkWidget *dipl_box, *dipl_sw;
525
526 dipl_main = fc_malloc(sizeof(*dipl_main));
527 gui_dialog_new(&(dipl_main->dialog), GTK_NOTEBOOK(top_notebook),
528 dipl_main->dialog, TRUE);
529 dipl_main->notebook = gtk_notebook_new();
530 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(dipl_main->notebook),
531 GTK_POS_RIGHT);
532 gtk_notebook_set_scrollable(GTK_NOTEBOOK(dipl_main->notebook), TRUE);
533
534 dipl_sw = gtk_scrolled_window_new(NULL, NULL);
535 g_object_set(dipl_sw, "margin", 2, NULL);
536 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dipl_sw),
537 GTK_POLICY_AUTOMATIC,
538 GTK_POLICY_AUTOMATIC);
539 gtk_container_add(GTK_CONTAINER(dipl_sw), dipl_main->notebook);
540
541 /* Buttons */
542 gui_dialog_add_button(dipl_main->dialog, NULL,
543 _("Cancel _all meetings"),
544 RESPONSE_CANCEL_MEETING_ALL);
545
546 /* Responses for _all_ meetings. */
547 gui_dialog_response_set_callback(dipl_main->dialog,
548 diplomacy_main_response);
549 gui_dialog_set_default_response(dipl_main->dialog,
550 RESPONSE_CANCEL_MEETING_ALL);
551
552 dipl_box = dipl_main->dialog->vbox;
553 gtk_container_add(GTK_CONTAINER(dipl_box), dipl_sw);
554
555 gui_dialog_show_all(dipl_main->dialog);
556 gui_dialog_present(dipl_main->dialog);
557 }
558
559 return dipl_main;
560}
561
562/************************************************************************/
565 static void diplomacy_main_destroy(void)
566{
567 if (dipl_main->dialog) {
568 gui_dialog_destroy(dipl_main->dialog);
569 }
570 free(dipl_main);
571 dipl_main = NULL;
572}
573
574/************************************************************************/
577 static void diplomacy_main_response(struct gui_dialog *dlg, int response,
578 gpointer data)
579{
580 if (!dipl_main) {
581 return;
582 }
583
584 switch (response) {
585 default:
586 log_error("unhandled response in %s: %d", __FUNCTION__, response);
587 fc__fallthrough; /* No break. */
588 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
589 case RESPONSE_CANCEL_MEETING_ALL: /* Cancel all meetings. */
590 dialog_list_iterate(dialog_list, adialog) {
591 /* This will do a round trip to the server ans close the diolag in the
592 * client. Closing the last dialog will also close the main tab.*/
593 dsend_packet_diplomacy_cancel_meeting_req(&client.conn,
594 player_number(
595 adialog->treaty.plr1));
596 } dialog_list_iterate_end;
597 break;
598 }
599}
600
601/************************************************************************/
604 static void diplomacy_destroy(struct Diplomacy_dialog* pdialog)
605{
606 if (NULL != pdialog->dialog) {
607 /* pdialog->dialog may be NULL if the tab has been destroyed
608 * by an other way. */
609 gui_dialog_destroy(pdialog->dialog);
610 pdialog->dialog = NULL;
611 }
612 dialog_list_remove(dialog_list, pdialog);
613 free(pdialog);
614
615 if (dialog_list) {
616 /* Diplomatic meetings in one main tab. */
617 if (dialog_list_size(dialog_list) > 0) {
618 if (dipl_main && dipl_main->dialog) {
619 gchar *buf;
620
621 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
622 gui_dialog_set_title(dipl_main->dialog, buf);
623 g_free(buf);
624 }
625 } else if (dipl_main) {
626 /* No meeting left - destroy main tab. */
627 diplomacy_main_destroy();
628 }
629 }
630}
631
632/************************************************************************/
635 static void diplomacy_response(struct gui_dialog *dlg, int response,
636 gpointer data)
637{
638 struct Diplomacy_dialog *pdialog = NULL;
639
640 fc_assert_ret(data);
641 pdialog = (struct Diplomacy_dialog *)data;
642
643 switch (response) {
644 case GTK_RESPONSE_ACCEPT: /* Accept treaty. */
645 dsend_packet_diplomacy_accept_treaty_req(&client.conn,
646 player_number(
647 pdialog->treaty.plr1));
648 break;
649
650 default:
651 log_error("unhandled response in %s: %d", __FUNCTION__, response);
652 fc__fallthrough; /* No break. */
653 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
654 case GTK_RESPONSE_CANCEL: /* GTK: cancel button. */
655 case RESPONSE_CANCEL_MEETING: /* Cancel meetings. */
656 dsend_packet_diplomacy_cancel_meeting_req(&client.conn,
657 player_number(
658 pdialog->treaty.plr1));
659 break;
660 }
661}
662
663/************************************************************************/
666 static struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0,
667 struct player *plr1)
668{
669 struct Diplomacy_notebook *dipl_dialog;
670 GtkWidget *vbox, *hbox, *table, *mainbox;
671 GtkWidget *label, *sw, *view, *image, *spin;
672 GtkWidget *menubar, *menuitem, *menu, *notebook;
673 struct sprite *flag_spr;
674 GtkListStore *store;
675 GtkCellRenderer *rend;
676 int i;
677
678 struct Diplomacy_dialog *pdialog;
679 char plr_buf[4 * MAX_LEN_NAME];
680 gchar *buf;
681
682 pdialog = fc_malloc(sizeof(*pdialog));
683
684 dialog_list_prepend(dialog_list, pdialog);
685 init_treaty(&pdialog->treaty, plr0, plr1);
686
687 /* Get main diplomacy tab. */
688 dipl_dialog = diplomacy_main_create();
689
690 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
691 gui_dialog_set_title(dipl_dialog->dialog, buf);
692 g_free(buf);
693
694 notebook = dipl_dialog->notebook;
695
696 gui_dialog_new(&(pdialog->dialog), GTK_NOTEBOOK(notebook), pdialog, FALSE);
697
698 /* Buttons */
699 gui_dialog_add_button(pdialog->dialog, NULL,
700 _("Accept treaty"), GTK_RESPONSE_ACCEPT);
701 gui_dialog_add_button(pdialog->dialog, NULL,
702 _("Cancel meeting"), RESPONSE_CANCEL_MEETING);
703
704 /* Responses for one meeting. */
705 gui_dialog_response_set_callback(pdialog->dialog, diplomacy_response);
706 gui_dialog_set_default_response(pdialog->dialog, RESPONSE_CANCEL_MEETING);
707
708 /* Label for the new meeting. */
709 buf = g_strdup_printf("%s", nation_plural_for_player(plr1));
710 gui_dialog_set_title(pdialog->dialog, buf);
711
712 /* Sort meeting tabs alphabetically by the tab label. */
713 for (i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i++) {
714 GtkWidget *prev_page
715 = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i);
716 struct gui_dialog *prev_dialog
717 = g_object_get_data(G_OBJECT(prev_page), "gui-dialog-data");
718 const char *prev_label
719 = gtk_label_get_text(GTK_LABEL(prev_dialog->v.tab.label));
720
721 if (fc_strcasecmp(buf, prev_label) < 0) {
722 gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook),
723 pdialog->dialog->vbox, i);
724 break;
725 }
726 }
727 g_free(buf);
728
729 /* Content. */
730 mainbox = pdialog->dialog->vbox;
731
732 /* us. */
733 vbox = gtk_grid_new();
734 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
735 GTK_ORIENTATION_VERTICAL);
736 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
737 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
738 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
739
740 /* Our nation. */
741 label = gtk_label_new(NULL);
742 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
743 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
744 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
745 nation_plural_for_player(plr0));
746 gtk_label_set_markup(GTK_LABEL(label), buf);
747 g_free(buf);
748 gtk_container_add(GTK_CONTAINER(vbox), label);
749
750 hbox = gtk_grid_new();
751 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
752 gtk_container_add(GTK_CONTAINER(vbox), hbox);
753
754 /* Our flag */
755 flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr0));
756
757 image = gtk_image_new_from_surface(flag_spr->surface);
758 gtk_container_add(GTK_CONTAINER(hbox), image);
759
760 /* Our name. */
761 label = gtk_label_new(NULL);
762 gtk_widget_set_hexpand(label, TRUE);
763 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
764 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
765 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
766 ruler_title_for_player(plr0, plr_buf, sizeof(plr_buf)));
767 gtk_label_set_markup(GTK_LABEL(label), buf);
768 g_free(buf);
769 gtk_container_add(GTK_CONTAINER(hbox), label);
770
771 image = gtk_image_new();
772 pdialog->image0 = image;
773 gtk_container_add(GTK_CONTAINER(hbox), image);
774
775 /* Menu for clauses: we. */
776 menubar = gtk_aux_menu_bar_new();
777
778 menu = gtk_menu_new();
779 pdialog->menu0 = menu;
780
781 menuitem = gtk_menu_item_new_with_label(_("Add Clause..."));
782 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
783 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
784 g_object_set_data(G_OBJECT(menu), "plr", plr0);
785 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
786
787 /* Main table for clauses and (if activated) gold trading: we. */
788 table = gtk_grid_new();
789 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
790 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
791 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
792 gtk_container_add(GTK_CONTAINER(vbox), table);
793
794 if (clause_enabled(CLAUSE_GOLD)) {
795 spin = gtk_spin_button_new_with_range(0.0, plr0->economic.gold + 0.1,
796 1.0);
797 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
798 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
799 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
800 g_object_set_data(G_OBJECT(spin), "plr", plr0);
801 g_signal_connect_after(spin, "value-changed",
802 G_CALLBACK(diplo_dialog_returnkey), pdialog);
803
804 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
805 "mnemonic-widget", spin, "label", _("Gold:"),
806 "xalign", 0.0, "yalign", 0.5, NULL);
807 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
808
809 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
810 } else {
811 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
812 }
813
814 /* them. */
815 vbox = gtk_grid_new();
816 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
817 GTK_ORIENTATION_VERTICAL);
818 gtk_grid_set_row_spacing(GTK_GRID(vbox), 5);
819 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
820 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
821
822 /* Their nation. */
823 label = gtk_label_new(NULL);
824 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
825 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
826 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
827 nation_plural_for_player(plr1));
828 gtk_label_set_markup(GTK_LABEL(label), buf);
829 g_free(buf);
830 gtk_container_add(GTK_CONTAINER(vbox), label);
831
832 hbox = gtk_grid_new();
833 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
834 gtk_container_add(GTK_CONTAINER(vbox), hbox);
835
836 /* Their flag */
837 flag_spr = get_nation_flag_sprite(tileset, nation_of_player(plr1));
838
839 image = gtk_image_new_from_surface(flag_spr->surface);
840 gtk_container_add(GTK_CONTAINER(hbox), image);
841
842 /* Their name. */
843 label = gtk_label_new(NULL);
844 gtk_widget_set_hexpand(label, TRUE);
845 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
846 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
847 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
848 ruler_title_for_player(plr1, plr_buf, sizeof(plr_buf)));
849 gtk_label_set_markup(GTK_LABEL(label), buf);
850 g_free(buf);
851 gtk_container_add(GTK_CONTAINER(hbox), label);
852
853 image = gtk_image_new();
854 pdialog->image1 = image;
855 gtk_container_add(GTK_CONTAINER(hbox), image);
856
857 /* Menu for clauses: they. */
858 menubar = gtk_aux_menu_bar_new();
859
860 menu = gtk_menu_new();
861 pdialog->menu1 = menu;
862
863 menuitem = gtk_menu_item_new_with_label(_("Add Clause..."));
864 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
865 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
866 g_object_set_data(G_OBJECT(menu), "plr", plr1);
867 g_signal_connect(menu, "show", G_CALLBACK(popup_add_menu), pdialog);
868
869 /* Main table for clauses and (if activated) gold trading: they. */
870 table = gtk_grid_new();
871 gtk_widget_set_halign(table, GTK_ALIGN_CENTER);
872 gtk_widget_set_valign(table, GTK_ALIGN_CENTER);
873 gtk_grid_set_column_spacing(GTK_GRID(table), 16);
874 gtk_container_add(GTK_CONTAINER(vbox), table);
875
876 if (clause_enabled(CLAUSE_GOLD)) {
877 spin = gtk_spin_button_new_with_range(0.0, plr1->economic.gold + 0.1,
878 1.0);
879 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 0);
880 gtk_entry_set_width_chars(GTK_ENTRY(spin), 16);
881 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
882 g_object_set_data(G_OBJECT(spin), "plr", plr1);
883 g_signal_connect_after(spin, "value-changed",
884 G_CALLBACK(diplo_dialog_returnkey), pdialog);
885
886 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
887 "mnemonic-widget", spin, "label", _("Gold:"),
888 "xalign", 0.0, "yalign", 0.5, NULL);
889 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
890
891 gtk_grid_attach(GTK_GRID(table), menubar, 2, 0, 1, 1);
892 } else {
893 gtk_grid_attach(GTK_GRID(table), menubar, 0, 0, 1, 1);
894 }
895
896 /* Clauses. */
897 mainbox = gtk_grid_new();
898 gtk_orientable_set_orientation(GTK_ORIENTABLE(mainbox),
899 GTK_ORIENTATION_VERTICAL);
900 gtk_container_add(GTK_CONTAINER(pdialog->dialog->vbox), mainbox);
901
902 store = gtk_list_store_new(1, G_TYPE_STRING);
903 pdialog->store = store;
904
905 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
906 gtk_widget_set_hexpand(view, TRUE);
907 gtk_widget_set_vexpand(view, TRUE);
908 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
909 g_object_unref(store);
910 gtk_widget_set_size_request(view, 320, 100);
911
912 rend = gtk_cell_renderer_text_new();
913 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, NULL,
914 rend, "text", 0, NULL);
915
916 sw = gtk_scrolled_window_new(NULL, NULL);
917 g_object_set(sw, "margin", 2, NULL);
918 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
919 GTK_SHADOW_ETCHED_IN);
920 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
921 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
922 gtk_container_add(GTK_CONTAINER(sw), view);
923
924 label = g_object_new(GTK_TYPE_LABEL,
925 "use-underline", TRUE,
926 "mnemonic-widget", view,
927 "label", _("C_lauses:"),
928 "xalign", 0.0,
929 "yalign", 0.5,
930 NULL);
931
932 vbox = gtk_grid_new();
933 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
934 GTK_ORIENTATION_VERTICAL);
935 gtk_container_add(GTK_CONTAINER(mainbox), vbox);
936 gtk_container_add(GTK_CONTAINER(vbox), label);
937 gtk_container_add(GTK_CONTAINER(vbox), sw);
938
939 gtk_widget_show_all(mainbox);
940
941 g_signal_connect(view, "row_activated", G_CALLBACK(row_callback), pdialog);
942
943 update_diplomacy_dialog(pdialog);
944 gui_dialog_show_all(pdialog->dialog);
945
946 return pdialog;
947}
948
949/************************************************************************/
952 static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
953{
954 GtkListStore *store;
955 GtkTreeIter it;
956 bool blank = TRUE;
957 GdkPixbuf *pixbuf;
958
959 store = pdialog->store;
960
961 gtk_list_store_clear(store);
962 clause_list_iterate(pdialog->treaty.clauses, pclause) {
963 char buf[128];
964
965 client_diplomacy_clause_string(buf, sizeof(buf), pclause);
966
967 gtk_list_store_append(store, &it);
968 gtk_list_store_set(store, &it, 0, buf, -1);
969 blank = FALSE;
970 } clause_list_iterate_end;
971
972 if (blank) {
973 gtk_list_store_append(store, &it);
974 gtk_list_store_set(store, &it, 0,
975 _("--- This treaty is blank. "
976 "Please add some clauses. ---"), -1);
977 }
978
979 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept0);
980 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image0), pixbuf);
981 g_object_unref(G_OBJECT(pixbuf));
982 pixbuf = get_thumb_pixbuf(pdialog->treaty.accept1);
983 gtk_image_set_from_pixbuf(GTK_IMAGE(pdialog->image1), pixbuf);
984 g_object_unref(G_OBJECT(pixbuf));
985}
986
987/************************************************************************/
990 static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
991{
992 int giver, dest, other, tech;
993
994 giver = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_from"));
995 dest = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "player_to"));
996 tech = GPOINTER_TO_INT(data);
997 if (player_by_number(giver) == client_player()) {
998 other = dest;
999 } else {
1000 other = giver;
1001 }
1002
1003 if (A_LAST == tech) {
1004 /* All techs. */
1005 struct player *pgiver = player_by_number(giver);
1006 struct player *pdest = player_by_number(dest);
1007 const struct research *dresearch, *gresearch;
1008
1009 fc_assert_ret(NULL != pgiver);
1010 fc_assert_ret(NULL != pdest);
1011
1012 dresearch = research_get(pdest);
1013 gresearch = research_get(pgiver);
1014 advance_iterate(A_FIRST, padvance) {
1015 Tech_type_id i = advance_number(padvance);
1016
1017 if (research_invention_state(gresearch, i) == TECH_KNOWN
1018 && research_invention_gettable(dresearch, i,
1019 game.info.tech_trade_allow_holes)
1020 && (research_invention_state(dresearch, i) == TECH_UNKNOWN
1021 || research_invention_state(dresearch, i)
1022 == TECH_PREREQS_KNOWN)) {
1023 dsend_packet_diplomacy_create_clause_req(&client.conn, other, giver,
1024 CLAUSE_ADVANCE, i);
1025 }
1026 } advance_iterate_end;
1027 } else {
1028 /* Only one tech. */
1029 dsend_packet_diplomacy_create_clause_req(&client.conn, other, giver,
1030 CLAUSE_ADVANCE, tech);
1031 }
1032}
1033
1034/************************************************************************/
1038 static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
1039{
1040 struct city_deal *deal_data = (struct city_deal *)data;
1041 int other;
1042
1043 if (player_by_number(deal_data->giver) == client_player()) {
1044 other = deal_data->receiver;
1045 } else {
1046 other = deal_data->giver;
1047 }
1048
1049 dsend_packet_diplomacy_create_clause_req(&client.conn, other, deal_data->giver,
1050 CLAUSE_CITY, deal_data->id);
1051
1052 free(deal_data);
1053}
1054
1055/************************************************************************/
1058 static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
1059{
1060 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1061 struct player *pgiver;
1062
1063 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1064
1065 dsend_packet_diplomacy_create_clause_req(&client.conn,
1066 player_number(pdialog->treaty.plr1),
1067 player_number(pgiver), CLAUSE_MAP, 0);
1068}
1069
1070/************************************************************************/
1073 static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
1074{
1075 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1076 struct player *pgiver;
1077
1078 pgiver = (struct player *)g_object_get_data(G_OBJECT(w), "plr");
1079
1080 dsend_packet_diplomacy_create_clause_req(&client.conn,
1081 player_number(pdialog->treaty.plr1),
1082 player_number(pgiver), CLAUSE_SEAMAP,
1083 0);
1084}
1085
1086/************************************************************************/
1089 static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data,
1090 int type)
1091{
1092 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1093
1094 dsend_packet_diplomacy_create_clause_req(&client.conn,
1095 player_number(pdialog->treaty.plr1),
1096 player_number(pdialog->treaty.plr0),
1097 type, 0);
1098}
1099
1100/************************************************************************/
1103 static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
1104{
1105 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_CEASEFIRE);
1106}
1107
1108/************************************************************************/
1111 static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
1112{
1113 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_PEACE);
1114}
1115
1116/************************************************************************/
1119 static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
1120{
1121 diplomacy_dialog_add_pact_clause(w, data, CLAUSE_ALLIANCE);
1122}
1123
1124/************************************************************************/
1127 static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
1128{
1129 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1130 struct player *pgiver =
1131 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1132
1133 dsend_packet_diplomacy_create_clause_req(&client.conn,
1134 player_number(pdialog->treaty.plr1),
1135 player_number(pgiver), CLAUSE_VISION,
1136 0);
1137}
1138
1139/************************************************************************/
1142 static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
1143{
1144 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1145 struct player *pgiver =
1146 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1147
1148 dsend_packet_diplomacy_create_clause_req(&client.conn,
1149 player_number(pdialog->treaty.plr1),
1150 player_number(pgiver), CLAUSE_EMBASSY,
1151 0);
1152}
1153
1154/************************************************************************/
1157 void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
1158{
1159 diplomacy_destroy(pdialog);
1160}
1161
1162/************************************************************************/
1165 void diplomacy_dialog_init(void)
1166{
1167 dialog_list = dialog_list_new();
1168 dipl_main = NULL;
1169}
1170
1171/************************************************************************/
1174 void diplomacy_dialog_done(void)
1175{
1176 dialog_list_destroy(dialog_list);
1177}
1178
1179/************************************************************************/
1182 static struct Diplomacy_dialog *find_diplomacy_dialog(int other_player_id)
1183{
1184 struct player *plr0 = client.conn.playing;
1185 struct player *plr1 = player_by_number(other_player_id);
1186
1187 dialog_list_iterate(dialog_list, pdialog) {
1188 if ((pdialog->treaty.plr0 == plr0 && pdialog->treaty.plr1 == plr1)
1189 || (pdialog->treaty.plr0 == plr1 && pdialog->treaty.plr1 == plr0)) {
1190 return pdialog;
1191 }
1192 } dialog_list_iterate_end;
1193
1194 return NULL;
1195}
1196
1197/************************************************************************/
1200 static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
1201{
1202 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1203 struct player *pgiver =
1204 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1205 int amount = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w));
1206
1207 if (amount >= 0 && amount <= pgiver->economic.gold) {
1208 dsend_packet_diplomacy_create_clause_req(&client.conn,
1209 player_number(pdialog->treaty.plr1),
1210 player_number(pgiver),
1211 CLAUSE_GOLD, amount);
1212 } else {
1213 output_window_append(ftc_client, _("Invalid amount of gold specified."));
1214 }
1215}
1216
1217/************************************************************************/
1220 void close_all_diplomacy_dialogs(void)
1221{
1222 while (dialog_list_size(dialog_list) > 0) {
1223 close_diplomacy_dialog(dialog_list_get(dialog_list, 0));
1224 }
1225}
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_button
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *text, int response)
Definition gui_stuff.c:706
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