Freeciv-3.3
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 "nation.h"
36#include "packets.h"
37#include "player.h"
38#include "research.h"
39
40/* client */
41#include "chatline.h"
42#include "client_main.h"
43#include "climisc.h"
44#include "options.h"
45
46/* client/gui-gtk-5.0 */
47#include "diplodlg.h"
48#include "gui_main.h"
49#include "gui_stuff.h"
50#include "mapview.h"
51#include "plrdlg.h"
52
53struct Diplomacy_dialog {
54 struct treaty *treaty;
55 struct gui_dialog *dialog;
56
59
61};
62
63struct Diplomacy_notebook {
64 struct gui_dialog *dialog;
66};
67
68struct city_deal {
69 int giver;
70 int receiver;
71 int id;
72};
73
74#define SPECLIST_TAG dialog
75#define SPECLIST_TYPE struct Diplomacy_dialog
76#include "speclist.h"
77
78#define dialog_list_iterate(dialoglist, pdialog) \
79 TYPED_LIST_ITERATE(struct Diplomacy_dialog, dialoglist, pdialog)
80#define dialog_list_iterate_end LIST_ITERATE_END
81
82static struct dialog_list *dialog_list;
84
86 struct player *plr0,
87 struct player *plr1);
88
90static void popup_diplomacy_dialog(struct treaty *ptreaty, struct player *they,
91 struct player *initiator);
93 GVariant *parameter,
94 gpointer data);
96 GVariant *parameter,
97 gpointer data);
98
100 GVariant *parameter,
101 gpointer data);
103 GVariant *parameter,
104 gpointer data);
106 GVariant *parameter,
107 gpointer data);
109 GVariant *parameter,
110 gpointer data);
112 GVariant *parameter,
113 gpointer data);
115 GVariant *parameter,
116 gpointer data);
118 GVariant *parameter,
119 gpointer data);
121 GVariant *parameter,
122 gpointer data);
123
124static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
125static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
126static void diplo_dialog_returnkey(GtkWidget *w, gpointer data);
127
128static struct Diplomacy_notebook *diplomacy_main_create(void);
129static void diplomacy_main_destroy(void);
130static void diplomacy_main_response(struct gui_dialog *dlg, int response,
131 gpointer data);
132
133#define RESPONSE_CANCEL_MEETING 100
134#define RESPONSE_CANCEL_MEETING_ALL 101
135
136
137#define FC_TYPE_CLAUSE_ROW (fc_clause_row_get_type())
138
140
147
152
154
155/**********************************************************************/
158static void
162
163/**********************************************************************/
166static void
170
171/**********************************************************************/
174#if 0
175static FcClauseRow *fc_clause_row_new(void)
176{
177 FcClauseRow *result;
178
179 result = g_object_new(FC_TYPE_CLAUSE_ROW, nullptr);
180
181 return result;
182}
183#endif
184
185/************************************************************************/
189{
191
192 if (!pdialog) {
193 return;
194 }
195
196 fc_assert(pdialog->treaty == ptreaty);
197
199 gui_dialog_alert(pdialog->dialog);
200}
201
202/************************************************************************/
210
211/************************************************************************/
215 struct player *initiator)
216{
218
219 if (!pdialog) {
220 return;
221 }
222
223 fc_assert(pdialog->treaty == ptreaty);
224
225 close_diplomacy_dialog(pdialog);
226}
227
228/**********************************************************************/
232{
233 /* Not needed */
234}
235
236/************************************************************************/
240{
242
243 if (!pdialog) {
244 return;
245 }
246
247 fc_assert(pdialog->treaty == ptreaty);
248
250 gui_dialog_alert(pdialog->dialog);
251}
252
253/************************************************************************/
257{
259
260 if (!pdialog) {
261 return;
262 }
263
264 fc_assert(pdialog->treaty == ptreaty);
265
267 gui_dialog_alert(pdialog->dialog);
268}
269
270/************************************************************************/
273static void popup_diplomacy_dialog(struct treaty *ptreaty, struct player *they,
274 struct player *initiator)
275{
277
278 if (!is_human(client_player())) {
279 return; /* Don't show if we are not human controlled. */
280 }
281
282 if (!pdialog) {
284 }
285
286 gui_dialog_present(pdialog->dialog);
287 /* We initated the meeting - Make the tab active */
288 if (initiator == client_player()) {
289 /* We have to raise the diplomacy meeting tab as well as the selected
290 * meeting. */
293 gui_dialog_raise(pdialog->dialog);
294
295 if (players_dialog_shell != NULL) {
297 }
298 }
299}
300
301/************************************************************************/
305{
306 const struct advance *padvance1 = (const struct advance *) a;
307 const struct advance *padvance2 = (const struct advance *) b;
308
311}
312
313/************************************************************************/
317 struct Diplomacy_dialog *pdialog,
318 struct player *partner, bool them)
319{
321 GSimpleAction *act;
322 bool any_map = FALSE;
323 char act_plr_part[20];
324 char act_name[60];
325 struct player *pgiver, *pother;
326
327 if (them) {
328 fc_strlcpy(act_plr_part, "_them", sizeof(act_plr_part));
329 pgiver = partner;
331 } else {
332 fc_strlcpy(act_plr_part, "_us", sizeof(act_plr_part));
334 pother = partner;
335 }
336
338
339 /* Maps. */
342
343 fc_snprintf(act_name, sizeof(act_name), "worldmap%s", act_plr_part);
345 g_object_set_data(G_OBJECT(act), "plr", pgiver);
348 pdialog);
349
350 fc_snprintf(act_name, sizeof(act_name), "win.worldmap%s", act_plr_part);
352
353 any_map = TRUE;
354 }
355
357 if (!any_map) {
359 }
360
361 fc_snprintf(act_name, sizeof(act_name), "seamap%s", act_plr_part);
363 g_object_set_data(G_OBJECT(act), "plr", pgiver);
366 pdialog);
367
368 fc_snprintf(act_name, sizeof(act_name), "win.seamap%s", act_plr_part);
370
371 any_map = TRUE;
372 }
373
374 if (any_map) {
376 }
377
378 /* Trading: advances */
380 const struct research *gresearch = research_get(pgiver);
381 const struct research *oresearch = research_get(pother);
384 int i;
385
387
390
392 && (!team_embassy /* We don't know what the other could actually receive */
397 == TECH_PREREQS_KNOWN)) {
399 }
401
402 if (NULL != sorting_list) {
404 const struct advance *padvance;
405
407
408 /* TRANS: All technologies menu item in the diplomatic dialog. */
409 fc_snprintf(act_name, sizeof(act_name), "advance%sall", act_plr_part);
411
412 g_object_set_data(G_OBJECT(act), "player_from",
414 g_object_set_data(G_OBJECT(act), "player_to",
417 g_signal_connect(act, "activate",
420
421 fc_snprintf(act_name, sizeof(act_name), "win.advance%sall", act_plr_part);
423
424 for (list_item = sorting_list, i = 0; NULL != list_item;
426
427 fc_snprintf(act_name, sizeof(act_name), "advance%s%d",
428 act_plr_part, i);
430
431 padvance = (const struct advance *) list_item->data;
432 g_object_set_data(G_OBJECT(act), "player_from",
434 g_object_set_data(G_OBJECT(act), "player_to",
437 g_signal_connect(act, "activate",
440
441 fc_snprintf(act_name, sizeof(act_name), "win.advance%s%d",
442 act_plr_part, i);
445 act_name));
446 }
447
449 }
450
452 }
453
454 /* Trading: cities. */
455
456 /****************************************************************
457 Creates a sorted list of plr0's cities, excluding the capital and
458 any cities not visible to plr1. This means that you can only trade
459 cities visible to requesting player.
460
461 - Kris Bubendorfer
462 *****************************************************************/
464 int i = 0;
465 int n = city_list_size(pgiver->cities);
466
468
469 if (n > 0) {
470 struct city **city_list_ptrs;
471
472 city_list_ptrs = fc_malloc(sizeof(struct city *) * n);
473
474 city_list_iterate(pgiver->cities, pcity) {
475 if (!is_capital(pcity)) {
477 i++;
478 }
480
481 if (i > 0) { /* Cities other than capitals */
482 int j;
483
484 qsort(city_list_ptrs, i, sizeof(struct city *), city_name_compare);
485
486 for (j = 0; j < i; j++) {
487 struct city_deal *deal = fc_malloc(sizeof(struct city_deal));
488
489 fc_snprintf(act_name, sizeof(act_name), "city%s%d", act_plr_part, i);
491
492 deal->giver = player_number(pgiver);
493 deal->receiver = player_number(pother);
494 deal->id = city_list_ptrs[j]->id;
495
497 g_signal_connect(act, "activate",
499 (gpointer)deal);
500
501 fc_snprintf(act_name, sizeof(act_name), "win.city%s%d",
502 act_plr_part, i);
505 act_name));
506 }
507 }
508
510 }
511
513 }
514
515 /* Give shared vision. */
517 fc_snprintf(act_name, sizeof(act_name), "vision%s", act_plr_part);
519 g_object_set_data(G_OBJECT(act), "plr", pgiver);
522 pdialog);
523
524 fc_snprintf(act_name, sizeof(act_name), "win.vision%s", act_plr_part);
525 menu_item_append_unref(topmenu, g_menu_item_new(_("_Give shared vision"), act_name));
526
529 }
530
531 /* Give embassy. */
533 fc_snprintf(act_name, sizeof(act_name), "embassy%s", act_plr_part);
535 g_object_set_data(G_OBJECT(act), "plr", pgiver);
538 pdialog);
539
540 fc_snprintf(act_name, sizeof(act_name), "win.embassy%s", act_plr_part);
542
543 /* Don't take in account the embassy effects. */
546 }
547
548 /* Shared tiles */
550 fc_snprintf(act_name, sizeof(act_name), "tiles%s", act_plr_part);
552 g_object_set_data(G_OBJECT(act), "plr", pgiver);
555 pdialog);
556
557 fc_snprintf(act_name, sizeof(act_name), "win.tiles%s", act_plr_part);
559 }
560
561 /* Pacts. */
562 if (pgiver == pdialog->treaty->plr0) {
563 enum diplstate_type ds;
564 int pact_clauses = 0;
565
567
569
571 fc_snprintf(act_name, sizeof(act_name), "ceasefire%s", act_plr_part);
574 g_signal_connect(act, "activate",
576
577 fc_snprintf(act_name, sizeof(act_name), "win.ceasefire%s", act_plr_part);
579 g_menu_item_new(Q_("?diplomatic_state:Cease-fire"),
580 act_name));
581
583 ds != DS_CEASEFIRE && ds != DS_TEAM);
584 pact_clauses++;
585 }
586
588 fc_snprintf(act_name, sizeof(act_name), "peace%s", act_plr_part);
591 g_signal_connect(act, "activate",
593
594 fc_snprintf(act_name, sizeof(act_name), "win.peace%s", act_plr_part);
595 menu_item_append_unref(submenu, g_menu_item_new(Q_("?diplomatic_state:Peace"),
596 act_name));
597
599 ds != DS_PEACE && ds != DS_TEAM);
600 pact_clauses++;
601 }
602
604 fc_snprintf(act_name, sizeof(act_name), "alliance%s", act_plr_part);
607 g_signal_connect(act, "activate",
609
610 fc_snprintf(act_name, sizeof(act_name), "win.alliance%s", act_plr_part);
612 g_menu_item_new(Q_("?diplomatic_state:Alliance"),
613 act_name));
614
616 ds != DS_ALLIANCE && ds != DS_TEAM);
617 pact_clauses++;
618 }
619
620 if (pact_clauses > 0) {
622 } else {
624 }
625 }
626
627 return topmenu;
628}
629
630/************************************************************************/
635{
636 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
637 gint i;
638 gint *index;
639
640 index = gtk_tree_path_get_indices(path);
641
642 i = 0;
644 if (i == index[0]) {
646 player_number(pdialog->treaty->plr1),
647 player_number(pclause->from),
648 pclause->type,
649 pclause->value);
650 return;
651 }
652 i++;
654}
655
656/************************************************************************/
701
702/************************************************************************/
705static void diplomacy_main_destroy(void)
706{
707 if (dipl_main->dialog) {
709 }
711 dipl_main = NULL;
712}
713
714/************************************************************************/
717static void diplomacy_main_response(struct gui_dialog *dlg, int response,
718 gpointer data)
719{
720 if (!dipl_main) {
721 return;
722 }
723
724 switch (response) {
725 default:
726 log_error("unhandled response in %s: %d", __FUNCTION__, response);
727 fc__fallthrough; /* No break. */
728 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
729 case RESPONSE_CANCEL_MEETING_ALL: /* Cancel all meetings. */
731 /* This will do a round trip to the server ans close the dialog in the
732 * client. Closing the last dialog will also close the main tab.*/
735 adialog->treaty->plr1));
737 break;
738 }
739}
740
741/************************************************************************/
744static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
745{
746 if (NULL != pdialog->dialog) {
747 /* pdialog->dialog may be NULL if the tab has been destroyed
748 * by an other way. */
749 gui_dialog_destroy(pdialog->dialog);
750 pdialog->dialog = NULL;
751 }
753
754 if (dialog_list) {
755 /* Diplomatic meetings in one main tab. */
756 if (dialog_list_size(dialog_list) > 0) {
757 if (dipl_main && dipl_main->dialog) {
758 gchar *buf;
759
760 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
762 g_free(buf);
763 }
764 } else if (dipl_main) {
765 /* No meeting left - destroy main tab. */
767 }
768 }
769
770 /* Last sub-tab must not be freed before diplomacy_main_destroy() call. */
771 free(pdialog);
772}
773
774/************************************************************************/
777static void diplomacy_response(struct gui_dialog *dlg, int response,
778 gpointer data)
779{
780 struct Diplomacy_dialog *pdialog = NULL;
781
782 fc_assert_ret(data);
783 pdialog = (struct Diplomacy_dialog *)data;
784
785 switch (response) {
786 case GTK_RESPONSE_ACCEPT: /* Accept treaty. */
789 pdialog->treaty->plr1));
790 break;
791
792 default:
793 log_error("unhandled response in %s: %d", __FUNCTION__, response);
794 fc__fallthrough; /* No break. */
795 case GTK_RESPONSE_DELETE_EVENT: /* GTK: delete the widget. */
796 case GTK_RESPONSE_CANCEL: /* GTK: cancel button. */
797 case RESPONSE_CANCEL_MEETING: /* Cancel meetings. */
800 pdialog->treaty->plr1));
801 break;
802 }
803}
804
805/************************************************************************/
809 struct player *plr0,
810 struct player *plr1)
811{
813 GtkWidget *vbox, *hgrid, *table, *mainbox;
814 GtkWidget *label, *sw, *view, *pic, *spin;
816 struct sprite *flag_spr;
817 GtkListStore *store;
819 int i;
820 struct Diplomacy_dialog *pdialog;
821 char plr_buf[4 * MAX_LEN_NAME];
822 gchar *buf;
823 int grid_col = 0;
824 int main_row = 0;
825 GActionGroup *group;
826 GMenu *menu;
827
828 pdialog = fc_malloc(sizeof(*pdialog));
829
831 pdialog->treaty = ptreaty;
832
833 /* Get main diplomacy tab. */
835
836 buf = g_strdup_printf(_("Diplomacy [%d]"), dialog_list_size(dialog_list));
838 g_free(buf);
839
840 notebook = dipl_dialog->notebook;
841
842 gui_dialog_new(&(pdialog->dialog), GTK_NOTEBOOK(notebook), pdialog, FALSE);
843
844 /* Buttons */
846 _("Accept treaty"), GTK_RESPONSE_ACCEPT);
848 _("Cancel meeting"), RESPONSE_CANCEL_MEETING);
849
850 /* Responses for one meeting. */
852
853 /* Label for the new meeting. */
856
857 /* Sort meeting tabs alphabetically by the tab label. */
858 for (i = 0; i < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i++) {
861 struct gui_dialog *prev_dialog
862 = g_object_get_data(G_OBJECT(prev_page), "gui-dialog-data");
863 const char *prev_label
865
866 if (fc_strcasecmp(buf, prev_label) < 0) {
868 pdialog->dialog->grid, i);
869 break;
870 }
871 }
872 g_free(buf);
873
874 /* Us. */
881
882 /* Our nation. */
886 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
889 g_free(buf);
891
895
896 /* Our flag */
898
902
903 /* Our name. */
908 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
909 ruler_title_for_player(plr0, plr_buf, sizeof(plr_buf)));
911 g_free(buf);
913
914 pdialog->pic0 = gtk_picture_new();
915 gtk_grid_attach(GTK_GRID(hgrid), pdialog->pic0, grid_col++, 0, 1, 1);
916
917 /* Menu for clauses: we. */
920
921 menu = create_clause_menu(group, pdialog, plr1, FALSE);
923
924 /* Main table for clauses and (if activated) gold trading: we. */
930
933 1.0);
936 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
937 g_object_set_data(G_OBJECT(spin), "plr", plr0);
938 g_signal_connect_after(spin, "value-changed",
940
941 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
942 "mnemonic-widget", spin, "label", _("Gold:"),
943 "xalign", 0.0, "yalign", 0.5, NULL);
944 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
945
946 gtk_grid_attach(GTK_GRID(table), aux_menu, 2, 0, 1, 1);
947 } else {
948 gtk_grid_attach(GTK_GRID(table), aux_menu, 0, 0, 1, 1);
949 }
951
952 /* Them. */
959
960 /* Their nation. */
964 buf = g_strdup_printf("<span size=\"large\"><u>%s</u></span>",
967 g_free(buf);
969
971 grid_col = 0;
974
975 /* Their flag */
977
981
982 /* Their name. */
987 buf = g_strdup_printf("<span size=\"large\" weight=\"bold\">%s</span>",
988 title_for_player(plr1, plr_buf, sizeof(plr_buf)));
990 g_free(buf);
992
993 pdialog->pic1 = gtk_picture_new();
994 gtk_grid_attach(GTK_GRID(hgrid), pdialog->pic1, grid_col++, 0, 1, 1);
995
996 /* Menu for clauses: they. */
999
1000 menu = create_clause_menu(group, pdialog, plr1, TRUE);
1002
1003 /* Main table for clauses and (if activated) gold trading: they. */
1004 table = gtk_grid_new();
1009
1012 1.0);
1015 gtk_grid_attach(GTK_GRID(table), spin, 1, 0, 1, 1);
1016 g_object_set_data(G_OBJECT(spin), "plr", plr1);
1017 g_signal_connect_after(spin, "value-changed",
1019
1020 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
1021 "mnemonic-widget", spin, "label", _("Gold:"),
1022 "xalign", 0.0, "yalign", 0.5, NULL);
1023 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
1024
1025 gtk_grid_attach(GTK_GRID(table), aux_menu, 2, 0, 1, 1);
1026 } else {
1027 gtk_grid_attach(GTK_GRID(table), aux_menu, 0, 0, 1, 1);
1028 }
1030
1031 /* Clauses. */
1036
1038 pdialog->store = store;
1039
1044 g_object_unref(store);
1046
1049 rend, "text", 0, NULL);
1050
1060
1062 "use-underline", TRUE,
1063 "mnemonic-widget", view,
1064 "label", _("C_lauses:"),
1065 "xalign", 0.0,
1066 "yalign", 0.5,
1067 NULL);
1068
1070
1074
1076
1077 g_signal_connect(view, "row_activated", G_CALLBACK(row_callback), pdialog);
1078
1079 update_diplomacy_dialog(pdialog);
1080 gui_dialog_show_all(pdialog->dialog);
1081
1082 return pdialog;
1083}
1084
1085/************************************************************************/
1088static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
1089{
1090 GtkListStore *store;
1091 GtkTreeIter it;
1092 bool blank = TRUE;
1094
1095 store = pdialog->store;
1096
1097 gtk_list_store_clear(store);
1099 char buf[128];
1100
1102
1103 gtk_list_store_append(store, &it);
1104 gtk_list_store_set(store, &it, 0, buf, -1);
1105 blank = FALSE;
1107
1108 if (blank) {
1109 gtk_list_store_append(store, &it);
1110 gtk_list_store_set(store, &it, 0,
1111 _("--- This treaty is blank. "
1112 "Please add some clauses. ---"), -1);
1113 }
1114
1121}
1122
1123/************************************************************************/
1127 GVariant *parameter,
1128 gpointer data)
1129{
1130 int giver, dest, other, tech;
1131
1132 giver = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "player_from"));
1133 dest = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "player_to"));
1134 tech = GPOINTER_TO_INT(data);
1135 if (player_by_number(giver) == client_player()) {
1136 other = dest;
1137 } else {
1138 other = giver;
1139 }
1140
1141 if (A_LAST == tech) {
1142 /* All techs. */
1143 struct player *pgiver = player_by_number(giver);
1144 struct player *pdest = player_by_number(dest);
1145 const struct research *dresearch, *gresearch;
1146
1149
1154
1160 == TECH_PREREQS_KNOWN)) {
1162 CLAUSE_ADVANCE, i);
1163 }
1165 } else {
1166 /* Only one tech. */
1168 CLAUSE_ADVANCE, tech);
1169 }
1170}
1171
1172/************************************************************************/
1177 GVariant *parameter,
1178 gpointer data)
1179{
1180 struct city_deal *deal_data = (struct city_deal *)data;
1181 int other;
1182
1183 if (player_by_number(deal_data->giver) == client.conn.playing) {
1185 } else {
1186 other = deal_data->giver;
1187 }
1188
1191
1192 free(deal_data);
1193}
1194
1195/************************************************************************/
1199 gpointer data)
1200{
1201 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1202 struct player *pgiver;
1203
1204 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1205
1207 player_number(pdialog->treaty->plr1),
1209}
1210
1211/************************************************************************/
1215 gpointer data)
1216{
1217 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1218 struct player *pgiver;
1219
1220 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1221
1223 player_number(pdialog->treaty->plr1),
1225 0);
1226}
1227
1228/************************************************************************/
1232{
1233 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *)data;
1234
1236 player_number(pdialog->treaty->plr1),
1237 player_number(pdialog->treaty->plr0),
1238 type, 0);
1239}
1240
1241/************************************************************************/
1250
1251/************************************************************************/
1260
1261/************************************************************************/
1270
1271/************************************************************************/
1275 GVariant *parameter,
1276 gpointer data)
1277{
1278 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1279 struct player *pgiver;
1280
1281 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1282
1284 player_number(pdialog->treaty->plr1),
1286 0);
1287}
1288
1289/************************************************************************/
1293 GVariant *parameter,
1294 gpointer data)
1295{
1296 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1297 struct player *pgiver;
1298
1299 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1300
1302 player_number(pdialog->treaty->plr1),
1304 0);
1305}
1306
1307/************************************************************************/
1311 GVariant *parameter,
1312 gpointer data)
1313{
1314 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1315 struct player *pgiver;
1316
1317 pgiver = (struct player *)g_object_get_data(G_OBJECT(action), "plr");
1318
1320 player_number(pdialog->treaty->plr1),
1323 0);
1324}
1325
1326/************************************************************************/
1330{
1331 diplomacy_destroy(pdialog);
1332}
1333
1334/************************************************************************/
1338{
1340 dipl_main = NULL;
1341}
1342
1343/************************************************************************/
1350
1351/************************************************************************/
1355{
1356 struct player *plr0 = client.conn.playing;
1357
1359 if ((pdialog->treaty->plr0 == plr0 && pdialog->treaty->plr1 == they)
1360 || (pdialog->treaty->plr0 == they && pdialog->treaty->plr1 == plr0)) {
1361 return pdialog;
1362 }
1364
1365 return NULL;
1366}
1367
1368/************************************************************************/
1372{
1373 struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
1374 struct player *pgiver =
1375 (struct player *) g_object_get_data(G_OBJECT(w), "plr");
1377
1380 player_number(pdialog->treaty->plr1),
1383 } else {
1384 output_window_append(ftc_client, _("Invalid amount of gold specified."));
1385 }
1386}
1387
1388/************************************************************************/
#define n
Definition astring.c:77
void output_window_append(const struct ft_color color, const char *featured_text)
bool is_capital(const struct city *pcity)
Definition city.c:1579
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
int city_name_compare(const void *p1, const void *p2)
Definition city.c:1711
#define city_list_iterate(citylist, pcity)
Definition city.h:505
#define city_list_iterate_end
Definition city.h:507
static struct ai_type * self
Definition classicai.c:46
struct civclient client
const char * title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
#define client_player()
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Definition climisc.c:241
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct treaty * ptreaty
Definition diplodlg_g.h:28
struct treaty struct player struct player *initiator gui_recv_create_clause
Definition diplodlg_g.h:32
gui_recv_cancel_meeting
Definition diplodlg_g.h:27
struct treaty struct player * they
Definition diplodlg_g.h:28
struct treaty struct player struct player *initiator struct treaty struct player *they gui_recv_accept_treaty
Definition diplodlg_g.h:36
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:305
#define clause_list_iterate_end
Definition diptreaty.h:73
#define clause_list_iterate(clauselist, pclause)
Definition diptreaty.h:71
int Tech_type_id
Definition fc_types.h:236
#define MAX_LEN_NAME
Definition fc_types.h:66
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:61
const char * ruler_title_for_player(const struct player *pplayer, char *buf, size_t buf_len)
Definition government.c:391
static void diplomacy_dialog_add_pact_clause(GtkWidget *w, gpointer data, int type)
Definition diplodlg.c:1113
#define RESPONSE_CANCEL_MEETING
Definition diplodlg.c:114
void gui_init_meeting(struct treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.c:137
static gint sort_advance_names(gconstpointer a, gconstpointer b)
Definition diplodlg.c:236
static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:1198
static void diplomacy_dialog_tech_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1014
static void row_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition diplodlg.c:515
static void diplomacy_dialog_ceasefire_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1127
static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:976
static void diplomacy_dialog_seamap_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1097
static void diplomacy_dialog_city_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1062
static void diplomacy_dialog_map_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1082
void diplomacy_dialog_init(void)
Definition diplodlg.c:1206
static void diplomacy_destroy(struct Diplomacy_dialog *pdialog)
Definition diplodlg.c:625
static struct Diplomacy_dialog * create_diplomacy_dialog(struct treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diplodlg.c:689
#define dialog_list_iterate_end
Definition diplodlg.c:83
void gui_recv_remove_clause(struct treaty *ptreaty, struct player *they)
Definition diplodlg.c:188
static struct Diplomacy_notebook * diplomacy_main_create(void)
Definition diplodlg.c:541
static struct Diplomacy_dialog * find_diplomacy_dialog(struct player *they)
Definition diplodlg.c:1223
static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1151
void close_all_diplomacy_dialogs(void)
Definition diplodlg.c:1260
#define RESPONSE_CANCEL_MEETING_ALL
Definition diplodlg.c:115
static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1166
static void diplomacy_dialog_shared_tiles_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1181
static void diplomacy_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:658
#define dialog_list_iterate(dialoglist, pdialog)
Definition diplodlg.c:81
static struct dialog_list * dialog_list
Definition diplodlg.c:85
static void diplomacy_main_response(struct gui_dialog *dlg, int response, gpointer data)
Definition diplodlg.c:598
void gui_prepare_clause_updt(struct treaty *ptreaty, struct player *they)
Definition diplodlg.c:163
static void diplomacy_dialog_peace_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1135
void diplomacy_dialog_done(void)
Definition diplodlg.c:1215
static void diplo_dialog_returnkey(GtkWidget *w, gpointer data)
Definition diplodlg.c:1240
static void popup_diplomacy_dialog(struct treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.c:205
static void diplomacy_main_destroy(void)
Definition diplodlg.c:586
static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data)
Definition diplodlg.c:1143
static struct Diplomacy_notebook * dipl_main
Definition diplodlg.c:86
GtkWidget * top_notebook
Definition gui_main.c:130
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:954
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:835
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
void gui_dialog_set_return_dialog(struct gui_dialog *dlg, struct gui_dialog *return_dialog)
Definition gui_stuff.c:997
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:888
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
GdkPixbuf * get_thumb_pixbuf(int onoff)
Definition mapview.c:292
struct gui_dialog * players_dialog_shell
Definition plrdlg.c:58
GType type
Definition repodlgs.c:1313
static GMenu * create_clause_menu(GActionGroup *group, struct Diplomacy_dialog *pdialog, struct player *partner, bool them)
Definition diplodlg.c:267
GtkWidget * aux_menu_new(void)
Definition gui_stuff.c:244
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1105
#define submenu_append_unref(menu, name, submenu)
Definition gui_stuff.h:165
#define menu_item_append_unref(menu, item)
Definition gui_stuff.h:149
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
static void fc_clause_row_init(FcClauseRow *self)
Definition diplodlg.c:167
static void fc_clause_row_class_init(FcClauseRowClass *klass)
Definition diplodlg.c:159
#define FC_TYPE_CLAUSE_ROW
Definition diplodlg.c:137
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert(condition)
Definition log.h:177
#define log_error(message,...)
Definition log.h:104
#define fc_malloc(sz)
Definition mem.h:34
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
const char * nation_plural_for_player(const struct player *pplayer)
Definition nation.c:178
int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
struct player * player_by_number(const int player_id)
Definition player.c:849
int player_number(const struct player *pplayer)
Definition player.c:837
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Definition player.c:240
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
Definition player.c:220
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Definition player.c:324
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1489
#define is_human(plr)
Definition player.h:231
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
struct treaty * treaty
Definition diplodlg.c:54
GtkWidget * pic1
Definition diplodlg.c:58
GtkWidget * pic0
Definition diplodlg.c:57
struct gui_dialog * dialog
Definition diplodlg.c:55
GtkListStore * store
Definition diplodlg.c:63
struct gui_dialog * dialog
Definition diplodlg.c:67
GtkWidget * notebook
Definition diplodlg.c:68
GObjectClass parent_class
Definition diplodlg.c:150
char * clause
Definition diplodlg.c:145
GObject parent_instance
Definition diplodlg.c:143
int giver
Definition diplodlg.c:72
int receiver
Definition diplodlg.c:73
Definition city.h:317
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
GtkWidget * vbox
Definition gui_stuff.h:72
GtkWidget * grid
Definition gui_stuff.h:71
GtkWidget * label
Definition gui_stuff.h:87
GtkWidget * notebook
Definition gui_stuff.h:88
bool tech_trade_allow_holes
enum diplstate_type type
Definition player.h:199
struct player_economic economic
Definition player.h:284
struct player * plr1
Definition diptreaty.h:82
struct clause_list * clauses
Definition diptreaty.h:84
bool accept1
Definition diptreaty.h:83
struct player * plr0
Definition diptreaty.h:82
bool accept0
Definition diptreaty.h:83
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:471
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define fc__fallthrough
Definition support.h:119
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:300
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_iterate(_p)
Definition tech.h:271
#define advance_iterate_end
Definition tech.h:272
#define A_LAST
Definition tech.h:45
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6980