Freeciv-3.2
Loading...
Searching...
No Matches
dialogs.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 <stdarg.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <gtk/gtk.h>
24#include <gdk/gdkkeysyms.h>
25
26/* utility */
27#include "astring.h"
28#include "bitvector.h"
29#include "fcintl.h"
30#include "log.h"
31#include "mem.h"
32#include "rand.h"
33#include "support.h"
34
35/* common */
36#include "game.h"
37#include "government.h"
38#include "map.h"
39#include "packets.h"
40#include "player.h"
41#include "sex.h"
42
43/* client */
44#include "client_main.h"
45#include "climisc.h"
46#include "connectdlg_common.h"
47#include "control.h"
48#include "helpdata.h" /* for helptext_nation() */
49#include "goto.h"
50#include "options.h"
51#include "packhand.h"
52#include "text.h"
53#include "tilespec.h"
54
55/* client/gui-gtk-3.22 */
56#include "chatline.h"
57#include "choice_dialog.h"
58#include "citydlg.h"
59#include "editprop.h"
60#include "graphics.h"
61#include "gui_main.h"
62#include "gui_stuff.h"
63#include "mapview.h"
64#include "plrdlg.h"
65#include "wldlg.h"
66#include "unitselect.h"
67#include "unitselextradlg.h"
68
69#include "dialogs.h"
70
71/******************************************************************/
75/* One entry per nation group, plus one at the end for 'all nations' */
83
84static void create_races_dialog(struct player *pplayer);
85static void races_response(GtkWidget *w, gint response, gpointer data);
86static void races_nation_callback(GtkTreeSelection *select, gpointer data);
87static void races_leader_callback(void);
88static void races_sex_callback(GtkWidget *w, gpointer data);
89static void races_style_callback(GtkTreeSelection *select, gpointer data);
91 GtkTreeModel *model, GtkTreePath *path,
92 gboolean selected, gpointer data);
93
94static int selected_nation;
95static int selected_sex;
96static int selected_style;
97
99
100/**********************************************************************/
103void popup_notify_dialog(const char *caption, const char *headline,
104 const char *lines)
105{
106 static struct gui_dialog *shell;
108
111
112 gui_dialog_add_button(shell, "window-close", _("_Close"),
115
116 vbox = gtk_grid_new();
121
124 gtk_widget_set_name(headline_label, "notify_label");
125
129
139
140 gtk_widget_set_name(label, "notify_label");
144
146
148
151
152 shell = NULL;
153}
154
155/**********************************************************************/
159static void notify_goto_response(GtkWidget *w, gint response)
160{
161 struct city *pcity = NULL;
162 struct tile *ptile = g_object_get_data(G_OBJECT(w), "tile");
163
164 switch (response) {
165 case 1:
167 break;
168 case 2:
169 pcity = tile_city(ptile);
170
173 }
174
175 if (pcity) {
176 popup_city_dialog(pcity);
177 }
178 break;
179 }
181}
182
183/**********************************************************************/
187{
189}
190
191/**********************************************************************/
196void popup_notify_goto_dialog(const char *headline, const char *lines,
197 const struct text_tag_list *tags,
198 struct tile *ptile)
199{
201
202 if (ptile == NULL) {
204 _("_Close"), GTK_RESPONSE_CLOSE,
205 NULL);
206 } else {
207 struct city *pcity = tile_city(ptile);
208
209 if (pcity != NULL && city_owner(pcity) == client.conn.playing) {
211 _("Goto _Location"), 1,
212 _("I_nspect City"), 2,
213 _("_Close"), GTK_RESPONSE_CLOSE,
214 NULL);
215 } else {
217 _("Goto _Location"), 1,
218 _("_Close"), GTK_RESPONSE_CLOSE,
219 NULL);
220 }
221 }
225
226 label = gtk_label_new(lines);
228 gtk_widget_show(label);
229
230 g_object_set_data(G_OBJECT(shell), "tile", ptile);
231
234}
235
236/**********************************************************************/
261
262/**********************************************************************/
265static void revolution_response(GtkWidget *w, gint response, gpointer data)
266{
267 struct government *government = data;
268
269 if (response == GTK_RESPONSE_YES) {
270 if (!government) {
272 } else {
274 }
275 }
276 if (w) {
278 }
279}
280
281/**********************************************************************/
285{
286 static GtkWidget *shell = NULL;
287
289 if (!shell) {
291 0,
294 _("You say you wanna revolution?"));
295 gtk_window_set_title(GTK_WINDOW(shell), _("Revolution!"));
297
298 g_signal_connect(shell, "destroy",
300 }
301 g_signal_connect(shell, "response",
303
305 } else {
307 }
308}
309
310/**********************************************************************/
313static void pillage_callback(GtkWidget *dlg, gint arg)
314{
316
317 if (arg == GTK_RESPONSE_YES) {
319 "actor"));
321
323 "target"));
325
326 if (actor && tgt_extra) {
328 tgt_extra);
329 }
330 }
331
333}
334
335/**********************************************************************/
339{
341 /* Possibly legal target extras. */
342 bv_extras alternative;
343 /* Selected by default. */
345 /* Current target to check. */
346 struct extra_type *tgt;
347
349
350 BV_CLR_ALL(alternative);
352
353 while ((tgt = get_preferred_pillage(extras))) {
354 int what;
355
356 what = extra_index(tgt);
358 BV_SET(alternative, what);
359 }
360
362 /* TRANS: Pillage dialog title. */
363 _("What To Pillage"),
364 /* TRANS: Pillage dialog actor text. */
365 _("Looking for target extra:"),
366 /* TRANS: Pillage dialog target text. */
367 _("Select what to pillage:"),
368 /* TRANS: Pillage dialog do button text. */
369 _("Pillage"), G_CALLBACK(pillage_callback));
370 }
371}
372
373/**********************************************************************/
378{
380}
381
382/**********************************************************************/
390
391/**************************************************************************
392 NATION SELECTION DIALOG
393**************************************************************************/
394/**********************************************************************/
401{
402 if (nation == -1 || list == NULL) {
403 return NULL;
404 } else {
407 GtkTreePath *path = NULL;
409 do {
410 int nation_of_row;
411 gtk_tree_model_get(model, &iter, 0, &nation_of_row, -1);
412 if (nation == nation_of_row) {
413 path = gtk_tree_model_get_path(model, &iter);
414 break;
415 }
416 } while (gtk_tree_model_iter_next(model, &iter));
417 return path;
418 }
419}
420
421/**********************************************************************/
427static void select_nation_on_tab(GtkWidget *tab_list, int nation)
428{
429 /* tab_list is a GtkTreeView (not its enclosing GtkScrolledWindow). */
432 GtkTreePath *path = path_to_nation_on_list(nation, list);
433
434 /* Suppress normal effects of selection change to avoid loops. */
436 if (path) {
437 /* Found nation on this list. */
438 /* Avoid disturbing tabs that already have the correct selection. */
439 if (!gtk_tree_selection_path_is_selected(select, path)) {
440 /* Set cursor -- this will cause the nation to be selected */
442 /* Make sure selected nation is visible in list */
444 }
445 } else {
446 /* Either no nation was selected, or the nation is not mentioned in
447 * this tab. Either way we want to end up with no selection. */
449 /* If there is no cursor, Gtk tends to focus and select the first row
450 * at the first opportunity, disturbing any existing state. We want to
451 * allow the no-rows-selected state, so detect this case and defuse
452 * it by setting a cursor. */
454 /* Set the cursor in the case above, or if there was a previous
455 * selection */
459 }
462 }
463 gtk_tree_path_free(path);
464 /* Re-enable selection change side-effects */
466}
467
468/**********************************************************************/
471static void sync_tabs_to_nation(int nation)
472{
473 /* Ensure that all tabs are in sync with the new selection */
474 int i;
475
476 for (i = 0; i <= nation_group_count(); i++) {
477 if (races_nation_list[i]) {
479 }
480 }
481}
482
483/**********************************************************************/
506
507/**********************************************************************/
513static void select_nation(int nation,
514 const char *leadername, bool is_male,
515 int style_id)
516{
517 selected_nation = nation;
518
519 /* Refresh the available leaders. */
521
522 if (selected_nation != -1) {
523
524 /* Select leader name and sex. */
525 if (leadername) {
527 leadername);
528 /* Assume is_male is valid too. */
530 TRUE);
531 } else {
534
536 /* This also updates the leader sex, eventually. */
537 }
538
539 /* Select the appropriate city style entry. */
540 {
541 int i;
542 int j = 0;
543 GtkTreePath *path;
544
547
548 if (i >= 0 && i < style_id) {
549 j++;
550 } else {
551 break;
552 }
554
555 path = gtk_tree_path_new();
558 NULL, FALSE);
559 gtk_tree_path_free(path);
560 }
561
562 /* Update nation description. */
563 {
564 char buf[4096];
565
566 helptext_nation(buf, sizeof(buf),
569 }
570
572 /* Once we've made a nation selection, allow user to ok */
575 } else {
576 /* No nation selected. Blank properties and make controls insensitive. */
577 /* Leader name */
579 "");
580 /* Leader sex (*shrug*) */
582 /* City style */
583 {
584 GtkTreeSelection* select
586
588 }
589 /* Nation description */
591
593 /* Don't allow OK without a selection
594 * (user can still do "Random Nation") */
597 }
598
599 /* Update notebook to reflect the current selection */
601}
602
603/**********************************************************************/
610 int index)
611{
612 GtkWidget *sw = NULL;
613 GtkListStore *store = NULL;
615
616 /* Populate nation list store. */
617 nations_iterate(pnation) {
618 bool used;
619 GdkPixbuf *img;
620 GtkTreeIter it;
621 GValue value = { 0, };
622
623 if (!is_nation_playable(pnation) || !is_nation_pickable(pnation)) {
624 continue;
625 }
626
627 if (NULL != group && !nation_is_in_group(pnation, group)) {
628 continue;
629 }
630
631 /* Only create tab on demand -- we don't want it if there aren't any
632 * currently pickable nations in this group. */
633 if (sw == NULL) {
634 GtkTreeSelection *select;
635 GtkCellRenderer *render;
637
642
648 g_object_unref(store);
649
652 NULL);
654 NULL, NULL);
655
662
665 "pixbuf", 2, NULL);
669 "text", 3, "strikethrough", 1, NULL);
671 }
672
673 gtk_list_store_append(store, &it);
674
675 used = (pnation->player != NULL && pnation->player != races_player);
676 gtk_list_store_set(store, &it, 0, nation_number(pnation), 1, used, -1);
677 img = get_flag(pnation);
678 if (img != NULL) {
679 gtk_list_store_set(store, &it, 2, img, -1);
681 }
682
685 gtk_list_store_set_value(store, &it, 3, &value);
686 g_value_unset(&value);
688
689 races_nation_list[index] = list;
690 return sw;
691}
692
693/**********************************************************************/
697{
700
701 int i;
702
703 for (i = 0; i < nation_group_count(); i++) {
704 struct nation_group* group = (nation_group_by_number(i));
705 if (is_nation_group_hidden(group)) {
707 continue;
708 }
710 if (nation_list) {
714 }
715 }
716
718 /* Even this list can be empty if there are no pickable nations (due to
719 * a combination of start position and nationset restrictions). */
720 if (nation_list) {
724 }
725}
726
727/**********************************************************************/
731void races_update_pickable(bool nationset_change)
732{
733 int tab, groupidx;
734
735 if (!races_shell) {
736 return;
737 }
738
739 /* Save selected tab */
741 if (tab != -1) {
742 int i = 0;
743 groupidx = 0;
744 /* Turn tab index into a nation group index (they're not always equal,
745 * as some groups may not currently have tabs). */
746 do {
747 while (groupidx <= nation_group_count()
749 groupidx++;
750 }
752 /* Nation group 'groupidx' is what's displayed on the i'th tab */
753 if (i == tab) {
754 break;
755 }
756 i++;
757 groupidx++;
758 } while (TRUE);
759 } else {
760 /* No tabs currently */
761 groupidx = -1;
762 }
763
764 /* selected_nation already contains currently selected nation; however,
765 * it may no longer be a valid choice */
766 if (selected_nation != -1
768 select_nation(-1, NULL, FALSE, 0);
769 }
770
771 /* Delete all list stores, treeviews, tabs */
774 }
775
776 /* (Re)create all of them */
778
779 /* Can't set current tab before child widget is visible */
781
782 /* Restore selected tab */
783 if (groupidx != -1 && races_nation_list[groupidx] != NULL) {
784 int i;
785 tab = 0;
786 for (i = 0; i < groupidx; i++) {
787 if (races_nation_list[i] != NULL) {
788 tab++;
789 }
790 }
792 }
793
794 /* Restore selected nation */
796}
797
798/**********************************************************************/
801void nationset_sync_to_server(const char *nationset)
802{
803 if (nationsets_chooser) {
804 struct nation_set *set = nation_set_by_setting_value(nationset);
805
807 nation_set_index(set));
808 }
809}
810
811/**********************************************************************/
815{
818 struct option *poption = optset_option_by_name(server_optset, "nationset");
819 gchar *rule_name;
820
822 0, &rule_name, -1);
823 /* Suppress propagation of an option value equivalent to the current
824 * server state, after canonicalisation, to avoid loops from
825 * nationset_sync_to_server().
826 * (HACK: relies on local Gtk "changed" signal getting here before
827 * server response.) */
829 != nation_set_by_rule_name(rule_name)) {
830 option_str_set(poption, rule_name);
831 }
832 FC_FREE(rule_name);
833 }
834}
835
836/**********************************************************************/
839static void create_races_dialog(struct player *pplayer)
840{
842 GtkWidget *cmd;
844 GtkWidget *frame, *label, *combo;
845 GtkWidget *text;
846 GtkWidget *notebook;
847 GtkWidget *sw;
848 GtkWidget *list;
849 GtkListStore *store;
850 GtkCellRenderer *render;
852 int i;
853 char *title;
854
855 /* Init. */
856 selected_nation = -1;
857
858 if (C_S_RUNNING == client_state()) {
859 title = _("Edit Nation");
860 } else if (NULL != pplayer && pplayer == client.conn.playing) {
861 title = _("What Nation Will You Be?");
862 } else {
863 title = _("Pick Nation");
864 }
865
867 NULL,
868 0,
869 _("_Cancel"),
871 _("_Random Nation"),
872 GTK_RESPONSE_NO, /* arbitrary */
873 _("_OK"),
875 NULL);
877 races_player = pplayer;
879
882
883 frame = gtk_frame_new(_("Select a nation"));
885
886 hbox = gtk_grid_new();
890
891 /* Left side: nation list */
892 {
895
897
898 /* Nationset selector dropdown */
899 /* Only present this if there is more than one choice.
900 * (If ruleset is changed, possibly changing the number of available sets
901 * and invalidating this decision, then dialog will be popped down.) */
902 if (nation_set_count() > 1) {
907 GtkCellRenderer *renderer;
909 /* Index in list store must match nation_set_index(). */
910 gchar *escaped;
911 struct astring s = ASTRING_INIT;
912 int num_nations = 0;
913
914 nations_iterate(pnation) {
915 if (is_nation_playable(pnation) && nation_is_in_set(pnation, pset)) {
916 num_nations++;
917 }
920 /* TRANS: nation set name followed by number of playable nations;
921 * <b> and </b> are Pango markup and should be left alone */
922 astr_set(&s, PL_("<b>%s</b> (%d nation)",
923 "<b>%s</b> (%d nations)", num_nations),
924 escaped, num_nations);
925 g_free(escaped);
927 /* While in principle it would be better to get Gtk to wrap the
928 * drop-down (e.g. via "wrap-width" property), there's no way
929 * to specify the indentation we want. So we do it ourselves. */
930 char *desc = fc_strdup(_(nation_set_description(pset)));
931 char *p = desc;
932
933 fc_break_lines(desc, 70);
934 astr_add(&s, "\n");
935 while (*p) {
936 int len = strcspn(p, "\n");
937
938 if (p[len] == '\n') {
939 len++;
940 }
941 escaped = g_markup_escape_text(p, len);
942 astr_add(&s, "\t%s", escaped);
943 g_free(escaped);
944 p += len;
945 }
946 FC_FREE(desc);
947 }
950 1, astr_str(&s),
952 -1);
953 astr_free(&s);
955
956 /* We want a combo box where the button displays just the set name,
957 * but the dropdown displays the expanded description. */
961 {
962 /* Do our best to turn the text-entry widget into something more
963 * like a cell-view: disable editing, and focusing (which removes
964 * the caret). */
966
969 }
970 /* The entry displays the set name. */
972 2);
973 /* The dropdown displays the marked-up description. */
974 renderer = gtk_cell_renderer_text_new();
977 renderer, TRUE);
979 renderer, "markup", 1, NULL);
984 {
985 /* Populate initially from client's view of server setting */
987 "nationset");
988 if (poption) {
990 }
991 }
992
994 "use-underline", TRUE,
995 "label", _("_Nation Set:"),
996 "xalign", 0.0,
997 "yalign", 0.5,
998 NULL);
1000
1003 0, 0, 1, 1);
1005 1, 0, 1, 1);
1006 }
1007
1011 0, 2, 2, 1);
1012
1013 /* Suppress notebook tabs if there will be only one ("All") */
1014 {
1015 bool show_groups = FALSE;
1016
1019 show_groups = TRUE;
1020 break;
1021 }
1023 if (!show_groups) {
1025 } else {
1027 "use-underline", TRUE,
1028 "label", _("Nation _Groups:"),
1029 "xalign", 0.0,
1030 "yalign", 0.5,
1031 NULL);
1034 0, 1, 2, 1);
1036 }
1037 }
1038
1039 /* Populate treeview */
1041
1043 }
1044
1045 /* Right side. */
1046 notebook = gtk_notebook_new();
1049
1050 /* Properties pane. */
1051 label = gtk_label_new_with_mnemonic(_("_Properties"));
1052
1054 g_signal_connect(table, "destroy",
1056 g_object_set(table, "margin", 6, NULL);
1058 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
1059
1060 /* Leader. */
1061 {
1063
1066 g_object_unref(G_OBJECT(model));
1067 }
1068 races_leader = combo;
1070 "use-underline", TRUE,
1071 "mnemonic-widget", GTK_COMBO_BOX(combo),
1072 "label", _("_Leader:"),
1073 "xalign", 0.0,
1074 "yalign", 0.5,
1075 NULL);
1077 gtk_widget_set_margin_end(label, 12);
1078 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 2);
1079 gtk_grid_attach(GTK_GRID(table), combo, 1, 0, 2, 1);
1080
1084 races_sex[0] = cmd;
1085 gtk_grid_attach(GTK_GRID(table), cmd, 1, 1, 1, 1);
1086
1089 "_"));
1091 races_sex[1] = cmd;
1092 gtk_grid_attach(GTK_GRID(table), cmd, 2, 1, 1, 1);
1093
1094 /* City style. */
1095 store = gtk_list_store_new(3, G_TYPE_INT,
1097
1102 g_object_unref(store);
1106
1114 gtk_grid_attach(GTK_GRID(table), sw, 1, 2, 2, 2);
1115
1117 "use-underline", TRUE,
1118 "mnemonic-widget", list,
1119 "label", _("City _Styles:"),
1120 "xalign", 0.0,
1121 "yalign", 0.5,
1122 NULL);
1123 gtk_widget_set_margin_top(label, 6);
1124 gtk_widget_set_margin_end(label, 12);
1125 gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);
1126
1129 "pixbuf", 1, NULL);
1131 render = gtk_cell_renderer_text_new();
1133 "text", 2, NULL);
1135
1136 /* Populate style store. */
1138 GdkPixbuf *img;
1139 struct sprite *s;
1140 GtkTreeIter it;
1141
1143
1144 if (i >= 0) {
1145 gtk_list_store_append(store, &it);
1146
1149 free_sprite(s);
1150 gtk_list_store_set(store, &it, 0, i, 1, img, 2,
1153 }
1155
1156 /* Legend pane. */
1157 label = gtk_label_new_with_mnemonic(_("_Description"));
1158
1159 text = gtk_text_view_new();
1160 g_object_set(text, "margin", 6, NULL);
1169
1170 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), text, label);
1171
1172 /* Signals. */
1173 g_signal_connect(shell, "destroy",
1175 g_signal_connect(shell, "response",
1177
1180
1181 g_signal_connect(races_sex[0], "toggled",
1183 g_signal_connect(races_sex[1], "toggled",
1185
1186 /* Finish up. */
1188
1189 /* You can't assign NO_NATION during a running game. */
1190 if (C_S_RUNNING == client_state()) {
1192 FALSE);
1193 }
1194
1196
1197 /* Select player's current nation in UI, if any */
1198 if (races_player->nation) {
1203 /* Make sure selected nation is visible
1204 * (last page, "All", will certainly contain it) */
1207 } else {
1208 select_nation(-1, NULL, FALSE, 0);
1209 }
1210}
1211
1212/**********************************************************************/
1215void popup_races_dialog(struct player *pplayer)
1216{
1217 if (!pplayer) {
1218 return;
1219 }
1220
1221 if (!races_shell) {
1222 create_races_dialog(pplayer);
1224 }
1225}
1226
1227/**********************************************************************/
1231{
1232 if (races_shell) {
1234 }
1235
1236 /* We're probably starting a new game, maybe with a new ruleset.
1237 So we warn the worklist dialog. */
1239}
1240
1241/**********************************************************************/
1246{
1247 int i;
1248
1249 if (!races_shell) {
1250 return;
1251 }
1252
1253 for (i = 0; i <= nation_group_count(); i++) {
1254 if (races_nation_list[i]) {
1258 GtkTreeIter it;
1260
1261 /* Update 'chosen' column in model */
1262 if (gtk_tree_model_get_iter_first(model, &it)) {
1263 do {
1264 int nation_no;
1265 struct nation_type *nation;
1266
1267 gtk_tree_model_get(model, &it, 0, &nation_no, -1);
1268 nation = nation_by_number(nation_no);
1269
1270 chosen = !is_nation_pickable(nation)
1271 || (nation->player && nation->player != races_player);
1272
1273 gtk_list_store_set(GTK_LIST_STORE(model), &it, 1, chosen, -1);
1274
1275 } while (gtk_tree_model_iter_next(model, &it));
1276 }
1277
1278 /* If our selection is now invalid, deselect it */
1279 if (gtk_tree_selection_get_selected(select, &model, &it)) {
1280 gtk_tree_model_get(model, &it, 1, &chosen, -1);
1281
1282 if (chosen) {
1284 }
1285 }
1286 }
1287 }
1288}
1289
1290/**********************************************************************/
1294{
1295 GtkTreeModel *model;
1296 GtkTreeIter it;
1297
1298 if (gtk_tree_selection_get_selected(select, &model, &it)) {
1300 int newnation;
1301
1302 gtk_tree_model_get(model, &it, 0, &newnation, 1, &chosen, -1);
1303
1304 /* Only allow nations not chosen by another player */
1305 if (!chosen) {
1306 if (newnation != selected_nation) {
1307 /* Choose a random leader */
1310 }
1311 return;
1312 }
1313 }
1314
1315 /* Fall-through if no valid nation selected */
1316 select_nation(-1, NULL, FALSE, 0);
1317}
1318
1319/**********************************************************************/
1338
1339/**********************************************************************/
1343{
1345}
1346
1347/**********************************************************************/
1351 GtkTreeModel *model, GtkTreePath *path,
1352 gboolean selected, gpointer data)
1353{
1354 GtkTreeIter it;
1356
1357 gtk_tree_model_get_iter(model, &it, path);
1358 gtk_tree_model_get(model, &it, 1, &chosen, -1);
1359 return (!chosen || selected);
1360}
1361
1362/**********************************************************************/
1366{
1367 GtkTreeModel *model;
1368 GtkTreeIter it;
1369
1370 if (gtk_tree_selection_get_selected(select, &model, &it)) {
1371 gtk_tree_model_get(model, &it, 0, &selected_style, -1);
1372 } else {
1373 selected_style = -1;
1374 }
1375}
1376
1377/**********************************************************************/
1380static void races_response(GtkWidget *w, gint response, gpointer data)
1381{
1382 if (response == GTK_RESPONSE_ACCEPT) {
1383 const char *s;
1384
1385 /* This shouldn't be possible but... */
1386 if (selected_nation == -1) {
1387 return;
1388 }
1389
1390 if (selected_sex == -1) {
1391 output_window_append(ftc_client, _("You must select your sex."));
1392 return;
1393 }
1394
1395 if (selected_style == -1) {
1396 output_window_append(ftc_client, _("You must select your style."));
1397 return;
1398 }
1399
1401
1402 /* Perform a minimum of sanity test on the name. */
1403 /* This could call is_allowed_player_name if it were available. */
1404 if (strlen(s) == 0) {
1405 output_window_append(ftc_client, _("You must type a legal name."));
1406 return;
1407 }
1408
1411 selected_sex, s,
1413 } else if (response == GTK_RESPONSE_NO) {
1416 -1, FALSE, "", 0);
1417 }
1418
1420}
1421
1422/**********************************************************************/
1426{
1427 common_taxrates_callback((size_t) data, FALSE);
1428
1429 return TRUE;
1430}
1431
1432/**********************************************************************/
1435void popup_upgrade_dialog(struct unit_list *punits)
1436{
1438 char buf[512];
1439
1440 if (!punits || unit_list_size(punits) == 0) {
1441 return;
1442 }
1443
1444 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
1447 "%s", buf);
1448 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Unit!"));
1451 NULL);
1453 } else {
1456 "%s", buf);
1457 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1460
1465 }
1467 }
1468}
1469
1470/**********************************************************************/
1473void popup_disband_dialog(struct unit_list *punits)
1474{
1476 char buf[512];
1477
1478 if (!punits || unit_list_size(punits) == 0) {
1479 return;
1480 }
1481
1482 if (!get_units_disband_info(buf, sizeof(buf), punits)) {
1485 "%s", buf);
1486 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1489 NULL);
1491 } else {
1494 "%s", buf);
1495 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1498
1503 }
1505 }
1507 }
1508}
1509
1510/**********************************************************************/
1520
1521/**********************************************************************/
1535
1536/**********************************************************************/
1540void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
1541{
1542 if (is_gui_up()) {
1543 GtkWidget *dialog;
1544
1545 if (tset_name != NULL) {
1548 _("Tileset \"%s\" problem, "
1549 "it's probably incompatible with "
1550 "the ruleset:\n%s"),
1551 tset_name, msg);
1552 } else {
1555 _("Tileset problem, "
1556 "it's probably incompatible with "
1557 "the ruleset:\n%s"),
1558 msg);
1559 }
1560
1561 setup_dialog(dialog, toplevel);
1562
1563 gtk_dialog_run(GTK_DIALOG(dialog));
1564
1565 gtk_widget_destroy(dialog);
1566 }
1567}
1568
1569/**********************************************************************/
1574{
1575 /* Just tell the client common code to handle this. */
1576 return FALSE;
1577}
1578
1579/**********************************************************************/
1583void popup_combat_info(int attacker_unit_id, int defender_unit_id,
1584 int attacker_hp, int defender_hp,
1585 bool make_att_veteran, bool make_def_veteran)
1586{
1587}
1588
1589/**********************************************************************/
1592static void act_conf_response(GtkWidget *dialog, gint response,
1593 gpointer data)
1594{
1595 gtk_widget_destroy(dialog);
1596
1597 if (response == GTK_RESPONSE_YES) {
1599 } else {
1601 }
1602}
1603
1604/**********************************************************************/
1607void request_action_confirmation(const char *expl,
1608 struct act_confirmation_data *data)
1609{
1610 GtkWidget *dialog;
1611 char buf[1024];
1612
1613 if (expl != NULL) {
1614 fc_snprintf(buf, sizeof(buf), _("Are you sure you want to do %s?\n%s"),
1615 action_id_name_translation(data->act), expl);
1616 } else {
1617 fc_snprintf(buf, sizeof(buf), _("Are you sure you want to do %s?"),
1619 }
1620
1621 dialog = gtk_message_dialog_new(NULL, 0,
1624 "%s", buf);
1625 setup_dialog(dialog, toplevel);
1626
1627 g_signal_connect(dialog, "response",
1629
1631}
1632
1633/**********************************************************************/
1636void popup_image(const char *tag)
1637{
1638 struct sprite *spr = load_popup_sprite(tag);
1639
1640 if (spr != NULL) {
1644
1647 gtk_widget_show(win);
1648
1650 } else {
1651 log_error(_("No image for tag \"%s\", requested by the server."), tag);
1652 }
1653}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2011
void astr_free(struct astring *astr)
Definition astring.c:153
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:267
void astr_add(struct astring *astr, const char *format,...)
Definition astring.c:287
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
#define BV_CLR(bv, bit)
Definition bitvector.h:86
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_style_name_translation(const int style)
Definition city.c:1756
#define city_owner(_pcity_)
Definition city.h:563
void popup_city_dialog(struct city *pcity)
struct civclient client
enum client_states client_state(void)
@ C_S_RUNNING
Definition client_main.h:47
void common_taxrates_callback(int idx, bool reverse)
Definition climisc.c:1193
static struct fc_sockaddr_list * list
Definition clinet.c:102
char * incite_cost
Definition comments.c:75
void request_unit_disband(struct unit *punit)
Definition control.c:2075
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1938
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1766
void request_unit_upgrade(struct unit *punit)
Definition control.c:2106
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 show_tileset_error
Definition dialogs_g.h:85
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit * actor
Definition dialogs_g.h:73
const char * caption
Definition dialogs_g.h:37
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
Definition dialogs_g.h:37
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 bool fatal
Definition dialogs_g.h:86
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 * punit
Definition dialogs_g.h:74
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 bool const char * tset_name
Definition dialogs_g.h:86
struct extra_type * extra_by_number(int id)
Definition extras.c:183
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
#define extra_index(_e_)
Definition extras.h:183
int Tech_type_id
Definition fc_types.h:377
int Nation_type_id
Definition fc_types.h:380
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:58
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
const struct ft_color ftc_client
struct civ_game game
Definition game.c:62
struct unit * game_unit_by_number(int id)
Definition game.c:116
static GtkWidget * races_properties
Definition dialogs.c:78
static gboolean races_selection_func(GtkTreeSelection *select, GtkTreeModel *model, GtkTreePath *path, gboolean selected, gpointer data)
Definition dialogs.c:1350
static GtkWidget * races_shell
Definition dialogs.c:72
static void select_nation(int nation, const char *leadername, bool is_male, int style_id)
Definition dialogs.c:513
static void sync_tabs_to_nation(int nation)
Definition dialogs.c:471
static GtkWidget * races_style_list
Definition dialogs.c:81
static void revolution_response(GtkWidget *w, gint response, gpointer data)
Definition dialogs.c:265
static void races_leader_callback(void)
Definition dialogs.c:1322
static int selected_style
Definition dialogs.c:96
static void create_nation_selection_lists(void)
Definition dialogs.c:696
static int is_showing_pillage_dialog
Definition dialogs.c:98
static void create_races_dialog(struct player *pplayer)
Definition dialogs.c:839
static GtkWidget * races_leader
Definition dialogs.c:79
static GtkWidget * races_nation_list[MAX_NUM_NATION_GROUPS+1]
Definition dialogs.c:76
static void populate_leader_list(void)
Definition dialogs.c:487
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void races_update_pickable(bool nationset_change)
Definition dialogs.c:731
static void notify_connect_msg_response(GtkWidget *w, gint response)
Definition dialogs.c:186
static void races_sex_callback(GtkWidget *w, gpointer data)
Definition dialogs.c:1342
static void pillage_callback(GtkWidget *dlg, gint arg)
Definition dialogs.c:313
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:196
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1524
static GtkWidget * races_sex[2]
Definition dialogs.c:80
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1473
static GtkTreePath * path_to_nation_on_list(Nation_type_id nation, GtkTreeView *list)
Definition dialogs.c:399
void popdown_races_dialog(void)
Definition dialogs.c:1230
static int selected_nation
Definition dialogs.c:94
static GtkWidget * races_notebook
Definition dialogs.c:77
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.c:338
static void races_response(GtkWidget *w, gint response, gpointer data)
Definition dialogs.c:1380
static void act_conf_response(GtkWidget *dialog, gint response, gpointer data)
Definition dialogs.c:1592
static void notify_goto_response(GtkWidget *w, gint response)
Definition dialogs.c:159
static void races_nation_callback(GtkTreeSelection *select, gpointer data)
Definition dialogs.c:1293
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:239
bool handmade_scenario_warning(void)
Definition dialogs.c:1573
void unit_select_dialog_update_real(void *unused)
Definition dialogs.c:386
static void nationset_callback(GtkComboBox *b, gpointer data)
Definition dialogs.c:814
void races_toggles_set_sensitive(void)
Definition dialogs.c:1245
static void races_style_callback(GtkTreeSelection *select, gpointer data)
Definition dialogs.c:1365
void popup_combat_info(int attacker_unit_id, int defender_unit_id, int attacker_hp, int defender_hp, bool make_att_veteran, bool make_def_veteran)
Definition dialogs.c:1583
static int selected_sex
Definition dialogs.c:95
struct player * races_player
Definition dialogs.c:74
static GtkWidget * nationsets_chooser
Definition dialogs.c:73
void request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.c:1607
static GtkTextBuffer * races_text
Definition dialogs.c:82
void nationset_sync_to_server(const char *nationset)
Definition dialogs.c:801
gboolean taxrates_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition dialogs.c:1425
static GtkWidget * create_list_of_nations_in_group(struct nation_group *group, int index)
Definition dialogs.c:609
void popup_image(const char *tag)
Definition dialogs.c:1636
static void select_nation_on_tab(GtkWidget *tab_list, int nation)
Definition dialogs.c:427
void popdown_all_game_dialogs(void)
Definition dialogs.c:1514
struct property_editor * editprop_get_property_editor(void)
Definition editprop.c:6244
void property_editor_popdown(struct property_editor *pe)
Definition editprop.c:6309
GtkWidget * bottom_notebook
Definition gui_main.c:129
bool is_gui_up(void)
Definition gui_main.c:2058
GtkWidget * toplevel
Definition gui_main.c:125
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:835
void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:734
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
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_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
void gui_dialog_destroy_all(void)
Definition gui_stuff.c:974
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
static struct gui_dialog * shell
Definition messagedlg.c:39
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
const char * title
Definition repodlgs.c:1314
void free_sprite(struct sprite *s)
Definition sprite.c:278
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
struct sprite * crop_blankspace(struct sprite *s)
Definition sprite.c:386
void unit_select_dialog_popup_main(struct tile *ptile, bool create)
Definition unitselect.c:193
void unit_select_dialog_popdown(void)
Definition unitselect.c:214
bool select_tgt_extra(struct unit *actor, struct tile *ptile, bv_extras potential_tgt_extras, struct extra_type *suggested_tgt_extra, const gchar *dlg_title, const gchar *actor_label, const gchar *tgt_label, const gchar *do_label, GCallback do_callback)
void blank_max_unit_size(void)
Definition wldlg.c:79
static char * leader_name
Definition dialogs.c:97
void popup_revolution_dialog(void)
Definition dialogs.c:112
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5039
@ HELP_TECH
Definition helpdlg_g.h:21
const char * name
Definition inputfile.c:127
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_error(message,...)
Definition log.h:103
void center_tile_mapcanvas(const struct tile *ptile)
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_strdup(str)
Definition mem.h:43
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Definition nation.c:267
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:837
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
int nation_set_count(void)
Definition nation.c:691
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1057
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
int nation_group_count(void)
Definition nation.c:935
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
#define nation_sets_iterate_end
Definition nation.h:305
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
#define nations_iterate_end
Definition nation.h:336
#define nations_iterate(NAME_pnation)
Definition nation.h:333
#define nation_leader_list_iterate_end
Definition nation.h:59
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:311
#define nation_groups_iterate_end
Definition nation.h:315
const struct option_set * server_optset
Definition options.c:4016
bool option_str_set(struct option *poption, const char *str)
Definition options.c:926
const char * option_str_get(const struct option *poption)
Definition options.c:893
struct client_options gui_options
Definition options.c:71
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:431
@ GUI_POPUP_TECH_HELP_RULESET
Definition options.h:77
@ GUI_POPUP_TECH_HELP_ENABLED
Definition options.h:75
int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
void start_revolution(void)
Definition packhand.c:2376
void set_government_choice(struct government *government)
Definition packhand.c:2363
char * lines
Definition packhand.c:131
int len
Definition packhand.c:127
int player_number(const struct player *pplayer)
Definition player.c:837
const char * player_name(const struct player *pplayer)
Definition player.c:895
#define fc_rand(_size)
Definition rand.h:56
const char * sex_name_mnemonic(sex_t kind, const char *mnemonic)
Definition sex.c:74
@ SEX_FEMALE
Definition sex.h:22
@ SEX_MALE
Definition sex.h:23
Definition city.h:320
struct packet_ruleset_control control
Definition game.h:83
struct connection conn
Definition client_main.h:96
bool center_when_popup_city
Definition options.h:161
struct player * playing
Definition connection.h:151
GtkWidget * vbox
Definition gui_stuff.h:72
GtkWidget * label
Definition gui_stuff.h:87
Definition mapimg.c:367
struct player * player
Definition nation.h:118
bool is_male
Definition player.h:255
int revolution_finishes
Definition player.h:271
struct nation_type * nation
Definition player.h:258
struct nation_style * style
Definition player.h:277
Definition tile.h:50
char * label
Definition tile.h:65
Definition unit.h:138
int style_number(const struct nation_style *pstyle)
Definition style.c:68
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
#define styles_iterate(_p)
Definition style.h:46
#define styles_iterate_end
Definition style.h:52
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int fc_break_lines(char *str, size_t desired_len)
Definition support.c:1149
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:176
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1257
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1323
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
struct sprite * load_popup_sprite(const char *tag)
Definition tilespec.c:7578
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:6851
void unload_popup_sprite(const char *tag)
Definition tilespec.c:7586
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:359
#define unit_tile(_pu)
Definition unit.h:397
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33