Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-gtk-5.0/dialogs.c Source File

Freeciv-3.3

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-5.0 */
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/******************************************************************/
72 static GtkWidget *races_shell;
73 static GtkWidget *nationsets_chooser;
74 struct player *races_player;
75/* One entry per nation group, plus one at the end for 'all nations' */
76 static GtkWidget *races_nation_list[MAX_NUM_NATION_GROUPS + 1];
77 static GtkWidget *races_notebook;
78 static GtkWidget *races_properties;
79 static GtkWidget *races_leader;
80 static GtkWidget *races_sex[2];
81 static GtkWidget *races_style_list;
82 static GtkTextBuffer *races_text;
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);
90static gboolean races_selection_func(GtkTreeSelection *select,
91 GtkTreeModel *model, GtkTreePath *path,
92 gboolean selected, gpointer data);
93
94 static int selected_nation;
95 static int selected_sex;
96 static int selected_style;
97
98 static int is_showing_pillage_dialog = FALSE;
99
100/**********************************************************************/
103 void popup_notify_dialog(const char *caption, const char *headline,
104 const char *lines)
105{
106 static struct gui_dialog *shell;
107 GtkWidget *vgrid, *label, *headline_label, *sw;
108 int grid_row = 0;
109
110 gui_dialog_new(&shell, GTK_NOTEBOOK(bottom_notebook), NULL, TRUE);
111 gui_dialog_set_title(shell, caption);
112
113 gui_dialog_add_button(shell, "window-close", _("_Close"),
114 GTK_RESPONSE_CLOSE);
115
116 vgrid = gtk_grid_new();
117 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
118 GTK_ORIENTATION_VERTICAL);
119 gtk_grid_set_row_spacing(GTK_GRID(vgrid), 2);
120 gui_dialog_add_content_widget(shell, vgrid);
121
122 headline_label = gtk_label_new(headline);
123 gtk_grid_attach(GTK_GRID(vgrid), headline_label, 0, grid_row++, 1, 1);
124 gtk_widget_set_name(headline_label, "notify_label");
125
126 gtk_label_set_justify(GTK_LABEL(headline_label), GTK_JUSTIFY_LEFT);
127 gtk_widget_set_halign(headline_label, GTK_ALIGN_START);
128 gtk_widget_set_valign(headline_label, GTK_ALIGN_START);
129
130 sw = gtk_scrolled_window_new();
131 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
132 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
133 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
134 label = gtk_label_new(lines);
135 gtk_widget_set_hexpand(label, TRUE);
136 gtk_widget_set_vexpand(label, TRUE);
137 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), label);
138
139 gtk_widget_set_name(label, "notify_label");
140 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
141 gtk_widget_set_halign(label, GTK_ALIGN_START);
142 gtk_widget_set_valign(label, GTK_ALIGN_START);
143
144 gtk_grid_attach(GTK_GRID(vgrid), sw, 0, grid_row++, 1, 1);
145
146 gui_dialog_show_all(shell);
147
148 gui_dialog_set_default_size(shell, -1, 265);
149 gui_dialog_present(shell);
150
151 shell = NULL;
152}
153
154/**********************************************************************/
158 static void notify_goto_response(GtkWidget *w, gint response)
159{
160 struct city *pcity = NULL;
161 struct tile *ptile = g_object_get_data(G_OBJECT(w), "tile");
162
163 switch (response) {
164 case 1:
165 center_tile_mapcanvas(ptile);
166 break;
167 case 2:
168 pcity = tile_city(ptile);
169
170 if (gui_options.center_when_popup_city) {
171 center_tile_mapcanvas(ptile);
172 }
173
174 if (pcity) {
175 popup_city_dialog(pcity);
176 }
177 break;
178 }
179
180 gtk_window_destroy(GTK_WINDOW(w));
181}
182
183/**********************************************************************/
186 static void notify_connect_msg_response(GtkWidget *w, gint response)
187{
188 gtk_window_destroy(GTK_WINDOW(w));
189}
190
191/**********************************************************************/
196 void popup_notify_goto_dialog(const char *headline, const char *lines,
197 const struct text_tag_list *tags,
198 struct tile *ptile)
199{
200 GtkWidget *shell, *label;
201
202 if (ptile == NULL) {
203 shell = gtk_dialog_new_with_buttons(headline, NULL, 0,
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) {
210 shell = gtk_dialog_new_with_buttons(headline, NULL, 0,
211 _("Goto _Location"), 1,
212 _("I_nspect City"), 2,
213 _("_Close"), GTK_RESPONSE_CLOSE,
214 NULL);
215 } else {
216 shell = gtk_dialog_new_with_buttons(headline, NULL, 0,
217 _("Goto _Location"), 1,
218 _("_Close"), GTK_RESPONSE_CLOSE,
219 NULL);
220 }
221 }
222 setup_dialog(shell, toplevel);
223 gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CLOSE);
224
225 label = gtk_label_new(lines);
226 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))),
227 label);
228 gtk_widget_set_visible(label, TRUE);
229
230 g_object_set_data(G_OBJECT(shell), "tile", ptile);
231
232 g_signal_connect(shell, "response", G_CALLBACK(notify_goto_response), NULL);
233 gtk_widget_set_visible(shell, TRUE);
234}
235
236/**********************************************************************/
239 void popup_connect_msg(const char *headline, const char *message)
240{
241 GtkWidget *shell, *label;
242
243 shell = gtk_dialog_new();
244 gtk_window_set_title(GTK_WINDOW(shell), headline);
245 setup_dialog(shell, toplevel);
246 gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CLOSE);
247
248 label = gtk_label_new(message);
249 gtk_label_set_selectable(GTK_LABEL(label), 1);
250
251 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))),
252 label);
253 gtk_widget_set_visible(label, TRUE);
254
255 gtk_dialog_add_button(GTK_DIALOG(shell), _("_Close"),GTK_RESPONSE_CLOSE);
256
257 g_signal_connect(shell, "response", G_CALLBACK(notify_connect_msg_response),
258 nullptr);
259 gtk_widget_set_visible(shell, TRUE);
260}
261
262/**********************************************************************/
265 static 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) {
271 start_revolution();
272 } else {
273 set_government_choice(government);
274 }
275 }
276 if (w) {
277 gtk_window_destroy(GTK_WINDOW(w));
278 }
279}
280
281/**********************************************************************/
284 void popup_revolution_dialog(struct government *government)
285{
286 static GtkWidget *shell = NULL;
287
288 if (0 > client.conn.playing->revolution_finishes) {
289 if (!shell) {
290 shell = gtk_message_dialog_new(NULL,
291 0,
292 GTK_MESSAGE_WARNING,
293 GTK_BUTTONS_YES_NO,
294 _("You say you wanna revolution?"));
295 gtk_window_set_title(GTK_WINDOW(shell), _("Revolution!"));
296 setup_dialog(shell, toplevel);
297
298 g_signal_connect(shell, "destroy",
299 G_CALLBACK(widget_destroyed), &shell);
300 }
301 g_signal_connect(shell, "response",
302 G_CALLBACK(revolution_response), government);
303
304 gtk_window_present(GTK_WINDOW(shell));
305 } else {
306 revolution_response(shell, GTK_RESPONSE_YES, government);
307 }
308}
309
310/**********************************************************************/
313 static void pillage_callback(GtkWidget *dlg, gint arg)
314{
315 is_showing_pillage_dialog = FALSE;
316
317 if (arg == GTK_RESPONSE_YES) {
318 int au_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dlg),
319 "actor"));
320 struct unit *actor = game_unit_by_number(au_id);
321
322 int tgt_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dlg),
323 "target"));
324 struct extra_type *tgt_extra = extra_by_number(tgt_id);
325
326 if (actor && tgt_extra) {
327 request_new_unit_activity_targeted(actor, ACTIVITY_PILLAGE,
328 tgt_extra);
329 }
330 }
331
332 gtk_window_destroy(GTK_WINDOW(dlg));
333}
334
335/**********************************************************************/
338 void popup_pillage_dialog(struct unit *punit, bv_extras extras)
339{
340 if (!is_showing_pillage_dialog) {
341 /* Possibly legal target extras. */
342 bv_extras alternative;
343 /* Selected by default. */
344 struct extra_type *preferred_tgt;
345 /* Current target to check. */
346 struct extra_type *tgt;
347
348 is_showing_pillage_dialog = TRUE;
349
350 BV_CLR_ALL(alternative);
351 preferred_tgt = get_preferred_pillage(extras);
352
353 while ((tgt = get_preferred_pillage(extras))) {
354 int what;
355
356 what = extra_index(tgt);
357 BV_CLR(extras, what);
358 BV_SET(alternative, what);
359 }
360
361 select_tgt_extra(punit, unit_tile(punit), alternative, preferred_tgt,
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/**********************************************************************/
377 void unit_select_dialog_popup(struct tile *ptile)
378{
379 unit_select_dialog_popup_main(ptile, TRUE);
380}
381
382/**********************************************************************/
386 void unit_select_dialog_update_real(void *unused)
387{
388 unit_select_dialog_popup_main(NULL, FALSE);
389}
390
391/**************************************************************************
392 NATION SELECTION DIALOG
393**************************************************************************/
394/**********************************************************************/
399 static GtkTreePath *path_to_nation_on_list(Nation_type_id nation,
400 GtkTreeView *list)
401{
402 if (nation == -1 || list == NULL) {
403 return NULL;
404 } else {
405 GtkTreeModel *model = gtk_tree_view_get_model(list);
406 GtkTreeIter iter;
407 GtkTreePath *path = NULL;
408
409 gtk_tree_model_get_iter_first(model, &iter);
410 do {
411 int nation_of_row;
412
413 gtk_tree_model_get(model, &iter, 0, &nation_of_row, -1);
414 if (nation == nation_of_row) {
415 path = gtk_tree_model_get_path(model, &iter);
416 break;
417 }
418 } while (gtk_tree_model_iter_next(model, &iter));
419
420 return path;
421 }
422}
423
424/**********************************************************************/
430 static void select_nation_on_tab(GtkWidget *tab_list, int nation)
431{
432 /* tab_list is a GtkTreeView (not its enclosing GtkScrolledWindow). */
433 GtkTreeView *list = GTK_TREE_VIEW(tab_list);
434 GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
435 GtkTreePath *path = path_to_nation_on_list(nation, list);
436
437 /* Suppress normal effects of selection change to avoid loops. */
438 g_signal_handlers_block_by_func(select, races_nation_callback, NULL);
439 if (path) {
440 /* Found nation on this list. */
441 /* Avoid disturbing tabs that already have the correct selection. */
442 if (!gtk_tree_selection_path_is_selected(select, path)) {
443 /* Set cursor -- this will cause the nation to be selected */
444 gtk_tree_view_set_cursor(list, path, NULL, FALSE);
445 /* Make sure selected nation is visible in list */
446 gtk_tree_view_scroll_to_cell(list, path, NULL, FALSE, 0, 0);
447 }
448 } else {
449 /* Either no nation was selected, or the nation is not mentioned in
450 * this tab. Either way we want to end up with no selection. */
451 GtkTreePath *cursorpath;
452
453 /* If there is no cursor, Gtk tends to focus and select the first row
454 * at the first opportunity, disturbing any existing state. We want to
455 * allow the no-rows-selected state, so detect this case and defuse
456 * it by setting a cursor. */
457 gtk_tree_view_get_cursor(list, &cursorpath, NULL);
458 /* Set the cursor in the case above, or if there was a previous
459 * selection */
460 if (!cursorpath || gtk_tree_selection_get_selected(select, NULL, NULL)) {
461 cursorpath = gtk_tree_path_new_first();
462 gtk_tree_view_set_cursor(list, cursorpath, NULL, FALSE);
463 }
464 gtk_tree_selection_unselect_all(select);
465 gtk_tree_path_free(cursorpath);
466 }
467 gtk_tree_path_free(path);
468 /* Re-enable selection change side-effects */
469 g_signal_handlers_unblock_by_func(select, races_nation_callback, NULL);
470}
471
472/**********************************************************************/
475 static void sync_tabs_to_nation(int nation)
476{
477 /* Ensure that all tabs are in sync with the new selection */
478 int i;
479
480 for (i = 0; i <= nation_group_count(); i++) {
481 if (races_nation_list[i]) {
482 select_nation_on_tab(races_nation_list[i], nation);
483 }
484 }
485}
486
487/**********************************************************************/
491 static void populate_leader_list(void)
492{
493 int i;
494 GtkListStore *model =
495 GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(races_leader)));
496
497 i = 0;
498 gtk_list_store_clear(model);
499 if (selected_nation >= 0) {
500 nation_leader_list_iterate(nation_leaders(nation_by_number
501 (selected_nation)), pleader) {
502 const char *leader_name = nation_leader_name(pleader);
503 GtkTreeIter iter; /* unused */
504
505 gtk_list_store_insert_with_values(model, &iter, i, 0, leader_name, -1);
506 i++;
507 } nation_leader_list_iterate_end;
508 }
509}
510
511/**********************************************************************/
517 static void select_nation(int nation,
518 const char *leadername, bool is_male,
519 int style_id)
520{
521 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(gtk_combo_box_get_child(GTK_COMBO_BOX(races_leader))));
522
523 selected_nation = nation;
524
525 /* Refresh the available leaders. */
526 populate_leader_list();
527
528 if (selected_nation != -1) {
529
530 /* Select leader name and sex. */
531 if (leadername) {
532 gtk_entry_buffer_set_text(buffer, leadername, -1);
533 /* Assume is_male is valid too. */
534 gtk_check_button_set_active(GTK_CHECK_BUTTON(races_sex[is_male]),
535 TRUE);
536 } else {
537 int idx = fc_rand(nation_leader_list_size(
538 nation_leaders(nation_by_number(selected_nation))));
539
540 gtk_combo_box_set_active(GTK_COMBO_BOX(races_leader), idx);
541 /* This also updates the leader sex, eventually. */
542 }
543
544 /* Select the appropriate city style entry. */
545 {
546 int i;
547 int j = 0;
548 GtkTreePath *path;
549
550 styles_iterate(pstyle) {
551 i = basic_city_style_for_style(pstyle);
552
553 if (i >= 0 && i < style_id) {
554 j++;
555 } else {
556 break;
557 }
558 } styles_iterate_end;
559
560 path = gtk_tree_path_new();
561 gtk_tree_path_append_index(path, j);
562 gtk_tree_view_set_cursor(GTK_TREE_VIEW(races_style_list), path,
563 NULL, FALSE);
564 gtk_tree_path_free(path);
565 }
566
567 /* Update nation description. */
568 {
569 char buf[4096];
570
571 helptext_nation(buf, sizeof(buf),
572 nation_by_number(selected_nation), NULL);
573 gtk_text_buffer_set_text(races_text, buf, -1);
574 }
575
576 gtk_widget_set_sensitive(races_properties, TRUE);
577 /* Once we've made a nation selection, allow user to ok */
578 gtk_dialog_set_response_sensitive(GTK_DIALOG(races_shell),
579 GTK_RESPONSE_ACCEPT, TRUE);
580 } else {
581 /* No nation selected. Blank properties and make controls insensitive. */
582 /* Leader name */
583 gtk_entry_buffer_set_text(buffer, "", -1);
584 /* Leader sex (*shrug*) */
585 gtk_check_button_set_active(GTK_CHECK_BUTTON(races_sex[0]), TRUE);
586 /* City style */
587 {
588 GtkTreeSelection *select
589 = gtk_tree_view_get_selection(GTK_TREE_VIEW(races_style_list));
590
591 gtk_tree_selection_unselect_all(select);
592 }
593 /* Nation description */
594 gtk_text_buffer_set_text(races_text, "", 0);
595
596 gtk_widget_set_sensitive(races_properties, FALSE);
597 /* Don't allow OK without a selection
598 * (user can still do "Random Nation") */
599 gtk_dialog_set_response_sensitive(GTK_DIALOG(races_shell),
600 GTK_RESPONSE_ACCEPT, FALSE);
601 }
602
603 /* Update notebook to reflect the current selection */
604 sync_tabs_to_nation(selected_nation);
605}
606
607/**********************************************************************/
613 static GtkWidget *create_list_of_nations_in_group(struct nation_group *group,
614 int index)
615{
616 GtkWidget *sw = NULL;
617 GtkListStore *store = NULL;
618 GtkWidget *list = NULL;
619
620 /* Populate nation list store. */
621 nations_iterate(pnation) {
622 bool used;
623 GdkPixbuf *img;
624 GtkTreeIter it;
625 GValue value = { 0, };
626
627 if (!is_nation_playable(pnation) || !is_nation_pickable(pnation)) {
628 continue;
629 }
630
631 if (NULL != group && !nation_is_in_group(pnation, group)) {
632 continue;
633 }
634
635 /* Only create tab on demand -- we don't want it if there aren't any
636 * currently pickable nations in this group. */
637 if (sw == NULL) {
638 GtkTreeSelection *select;
639 GtkCellRenderer *render;
640 GtkTreeViewColumn *column;
641
642 store = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_BOOLEAN,
643 GDK_TYPE_PIXBUF, G_TYPE_STRING);
644 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
645 3, GTK_SORT_ASCENDING);
646
647 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
648 gtk_widget_set_hexpand(list, TRUE);
649 gtk_widget_set_vexpand(list, TRUE);
650 gtk_tree_view_set_search_column(GTK_TREE_VIEW(list), 3);
651 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
652 g_object_unref(store);
653
654 select = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
655 g_signal_connect(select, "changed", G_CALLBACK(races_nation_callback),
656 NULL);
657 gtk_tree_selection_set_select_function(select, races_selection_func,
658 NULL, NULL);
659
660 sw = gtk_scrolled_window_new();
661 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
662 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
663 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
664 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), list);
665
666 render = gtk_cell_renderer_pixbuf_new();
667 column = gtk_tree_view_column_new_with_attributes("Flag", render,
668 "pixbuf", 2, NULL);
669 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
670 render = gtk_cell_renderer_text_new();
671 column = gtk_tree_view_column_new_with_attributes("Nation", render,
672 "text", 3, "strikethrough", 1, NULL);
673 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
674 }
675
676 gtk_list_store_append(store, &it);
677
678 used = (pnation->player != NULL && pnation->player != races_player);
679 gtk_list_store_set(store, &it, 0, nation_number(pnation), 1, used, -1);
680 img = get_flag(pnation);
681 if (img != NULL) {
682 gtk_list_store_set(store, &it, 2, img, -1);
683 g_object_unref(img);
684 }
685
686 g_value_init(&value, G_TYPE_STRING);
687 g_value_set_static_string(&value, nation_adjective_translation(pnation));
688 gtk_list_store_set_value(store, &it, 3, &value);
689 g_value_unset(&value);
690 } nations_iterate_end;
691
692 races_nation_list[index] = list;
693 return sw;
694}
695
696/**********************************************************************/
699 static void create_nation_selection_lists(void)
700{
701 GtkWidget *nation_list;
702 GtkWidget *group_name_label;
703 int i;
704
705 for (i = 0; i < nation_group_count(); i++) {
706 struct nation_group *group = (nation_group_by_number(i));
707
708 if (is_nation_group_hidden(group)) {
709 races_nation_list[i] = NULL;
710 continue;
711 }
712 nation_list = create_list_of_nations_in_group(group, i);
713 if (nation_list) {
714 group_name_label = gtk_label_new(nation_group_name_translation(group));
715 gtk_notebook_append_page(GTK_NOTEBOOK(races_notebook), nation_list,
716 group_name_label);
717 }
718 }
719
720 nation_list = create_list_of_nations_in_group(NULL, nation_group_count());
721 /* Even this list can be empty if there are no pickable nations (due to
722 * a combination of start position and nationset restrictions). */
723 if (nation_list) {
724 group_name_label = gtk_label_new(_("All"));
725 gtk_notebook_append_page(GTK_NOTEBOOK(races_notebook), nation_list,
726 group_name_label);
727 }
728}
729
730/**********************************************************************/
734 void races_update_pickable(bool nationset_change)
735{
736 int tab, groupidx;
737
738 if (!races_shell) {
739 return;
740 }
741
742 /* Save selected tab */
743 tab = gtk_notebook_get_current_page(GTK_NOTEBOOK(races_notebook));
744 if (tab != -1) {
745 int i = 0;
746
747 groupidx = 0;
748 /* Turn tab index into a nation group index (they're not always equal,
749 * as some groups may not currently have tabs). */
750 do {
751 while (groupidx <= nation_group_count()
752 && races_nation_list[groupidx] == NULL) {
753 groupidx++;
754 }
755 fc_assert_action(groupidx <= nation_group_count(), break);
756 /* Nation group 'groupidx' is what's displayed on the i'th tab */
757 if (i == tab) {
758 break;
759 }
760 i++;
761 groupidx++;
762 } while (TRUE);
763 } else {
764 /* No tabs currently */
765 groupidx = -1;
766 }
767
768 /* selected_nation already contains currently selected nation; however,
769 * it may no longer be a valid choice */
770 if (selected_nation != -1
771 && !is_nation_pickable(nation_by_number(selected_nation))) {
772 select_nation(-1, NULL, FALSE, 0);
773 }
774
775 /* Delete all list stores, treeviews, tabs */
776 while (gtk_notebook_get_n_pages(GTK_NOTEBOOK(races_notebook)) > 0) {
777 gtk_notebook_remove_page(GTK_NOTEBOOK(races_notebook), -1);
778 }
779
780 /* (Re)create all of them */
781 create_nation_selection_lists();
782
783 /* Can't set current tab before child widget is visible */
784 gtk_widget_set_visible(GTK_WIDGET(races_notebook), TRUE);
785
786 /* Restore selected tab */
787 if (groupidx != -1 && races_nation_list[groupidx] != nullptr) {
788 int i;
789
790 tab = 0;
791 for (i = 0; i < groupidx; i++) {
792 if (races_nation_list[i] != NULL) {
793 tab++;
794 }
795 }
796 gtk_notebook_set_current_page(GTK_NOTEBOOK(races_notebook), tab);
797 }
798
799 /* Restore selected nation */
800 sync_tabs_to_nation(selected_nation);
801}
802
803/**********************************************************************/
806 void nationset_sync_to_server(const char *nationset)
807{
808 if (nationsets_chooser) {
809 struct nation_set *set = nation_set_by_setting_value(nationset);
810
811 gtk_combo_box_set_active(GTK_COMBO_BOX(nationsets_chooser),
812 nation_set_index(set));
813 }
814}
815
816/**********************************************************************/
819 static void nationset_callback(GtkComboBox *b, gpointer data)
820{
821 GtkTreeIter iter;
822
823 if (gtk_combo_box_get_active_iter(b, &iter)) {
824 struct option *poption = optset_option_by_name(server_optset, "nationset");
825 gchar *rule_name;
826
827 gtk_tree_model_get(gtk_combo_box_get_model(b), &iter,
828 0, &rule_name, -1);
829 /* Suppress propagation of an option value equivalent to the current
830 * server state, after canonicalisation, to avoid loops from
831 * nationset_sync_to_server().
832 * (HACK: relies on local Gtk "changed" signal getting here before
833 * server response.) */
834 if (nation_set_by_setting_value(option_str_get(poption))
835 != nation_set_by_rule_name(rule_name)) {
836 option_str_set(poption, rule_name);
837 }
838 FC_FREE(rule_name);
839 }
840}
841
842/**********************************************************************/
845 static void create_races_dialog(struct player *pplayer)
846{
847 GtkWidget *shell;
848 GtkWidget *cmd;
849 GtkWidget *group;
850 GtkWidget *hbox, *table;
851 GtkWidget *frame, *label, *combo;
852 GtkWidget *text;
853 GtkWidget *notebook;
854 GtkWidget *sw;
855 GtkWidget *list;
856 GtkListStore *store;
857 GtkCellRenderer *render;
858 GtkTreeViewColumn *column;
859 int i;
860 char *title;
861
862 /* Init. */
863 selected_nation = -1;
864
865 if (C_S_RUNNING == client_state()) {
866 title = _("Edit Nation");
867 } else if (NULL != pplayer && pplayer == client.conn.playing) {
868 title = _("What Nation Will You Be?");
869 } else {
870 title = _("Pick Nation");
871 }
872
873 shell = gtk_dialog_new_with_buttons(title,
874 NULL,
875 0,
876 _("_Cancel"),
877 GTK_RESPONSE_CANCEL,
878 _("_Random Nation"),
879 GTK_RESPONSE_NO, /* Arbitrary */
880 _("_OK"),
881 GTK_RESPONSE_ACCEPT,
882 NULL);
883 races_shell = shell;
884 races_player = pplayer;
885 setup_dialog(shell, toplevel);
886
887 gtk_window_set_default_size(GTK_WINDOW(shell), -1, 590);
888
889 frame = gtk_frame_new(_("Select a nation"));
890 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(shell))), frame);
891
892 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 18);
893 gtk_widget_set_margin_start(hbox, 3);
894 gtk_widget_set_margin_end(hbox, 3);
895 gtk_widget_set_margin_top(hbox, 3);
896 gtk_widget_set_margin_bottom(hbox, 3);
897
898 gtk_frame_set_child(GTK_FRAME(frame), hbox);
899
900 /* Left side: nation list */
901 {
902 GtkWidget *nation_selection_list = gtk_grid_new();
903
904 nationsets_chooser = NULL;
905
906 gtk_grid_set_row_spacing(GTK_GRID(nation_selection_list), 2);
907
908 /* Nationset selector dropdown */
909 /* Only present this if there is more than one choice.
910 * (If ruleset is changed, possibly changing the number of available sets
911 * and invalidating this decision, then dialog will be popped down.) */
912 if (nation_set_count() > 1) {
913 GtkListStore *sets_model = gtk_list_store_new(4, G_TYPE_STRING,
914 G_TYPE_STRING,
915 G_TYPE_STRING,
916 G_TYPE_STRING);
917 GtkCellRenderer *renderer;
918
919 nation_sets_iterate(pset) {
920 /* Index in list store must match nation_set_index(). */
921 gchar *escaped;
922 struct astring s = ASTRING_INIT;
923 int num_nations = 0;
924
925 nations_iterate(pnation) {
926 if (is_nation_playable(pnation) && nation_is_in_set(pnation, pset)) {
927 num_nations++;
928 }
929 } nations_iterate_end;
930 escaped = g_markup_escape_text(nation_set_name_translation(pset), -1);
931 /* TRANS: nation set name followed by number of playable nations;
932 * <b> and </b> are Pango markup and should be left alone */
933 astr_set(&s, PL_("<b>%s</b> (%d nation)",
934 "<b>%s</b> (%d nations)", num_nations),
935 escaped, num_nations);
936 g_free(escaped);
937 if (strlen(nation_set_description(pset)) > 0) {
938 /* While in principle it would be better to get Gtk to wrap the
939 * drop-down (e.g. via "wrap-width" property), there's no way
940 * to specify the indentation we want. So we do it ourselves. */
941 char *desc = fc_strdup(_(nation_set_description(pset)));
942 char *p = desc;
943
944 fc_break_lines(desc, 70);
945 astr_add(&s, "\n");
946 while (*p) {
947 int len = strcspn(p, "\n");
948
949 if (p[len] == '\n') {
950 len++;
951 }
952 escaped = g_markup_escape_text(p, len);
953 astr_add(&s, "\t%s", escaped);
954 g_free(escaped);
955 p += len;
956 }
957 FC_FREE(desc);
958 }
959 gtk_list_store_insert_with_values(sets_model, NULL, -1,
960 0, nation_set_rule_name(pset),
961 1, astr_str(&s),
962 2, nation_set_name_translation(pset),
963 -1);
964 astr_free(&s);
965 } nation_sets_iterate_end;
966
967 /* We want a combo box where the button displays just the set name,
968 * but the dropdown displays the expanded description. */
969 nationsets_chooser
970 = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(sets_model));
971 g_object_unref(G_OBJECT(sets_model));
972 {
973 /* Do our best to turn the text-entry widget into something more
974 * like a cell-view: disable editing, and focusing (which removes
975 * the caret). */
976 GtkWidget *entry = gtk_combo_box_get_child(GTK_COMBO_BOX(nationsets_chooser));
977
978 gtk_editable_set_editable(GTK_EDITABLE(entry), FALSE);
979 gtk_widget_set_can_focus(entry, FALSE);
980 }
981 /* The entry displays the set name. */
982 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(nationsets_chooser),
983 2);
984 /* The dropdown displays the marked-up description. */
985 renderer = gtk_cell_renderer_text_new();
986 gtk_cell_layout_clear(GTK_CELL_LAYOUT(nationsets_chooser));
987 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(nationsets_chooser),
988 renderer, TRUE);
989 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(nationsets_chooser),
990 renderer, "markup", 1, NULL);
991 g_signal_connect(nationsets_chooser, "destroy",
992 G_CALLBACK(widget_destroyed), &nationsets_chooser);
993 g_signal_connect(nationsets_chooser, "changed",
994 G_CALLBACK(nationset_callback), NULL);
995 {
996 /* Populate initially from client's view of server setting */
997 struct option *poption = optset_option_by_name(server_optset,
998 "nationset");
999 if (poption) {
1000 nationset_sync_to_server(option_str_get(poption));
1001 }
1002 }
1003
1004 label = g_object_new(GTK_TYPE_LABEL,
1005 "use-underline", TRUE,
1006 "label", _("_Nation Set:"),
1007 "xalign", 0.0,
1008 "yalign", 0.5,
1009 NULL);
1010 gtk_label_set_mnemonic_widget(GTK_LABEL(label), nationsets_chooser);
1011
1012 gtk_widget_set_hexpand(nationsets_chooser, TRUE);
1013 gtk_grid_attach(GTK_GRID(nation_selection_list), label,
1014 0, 0, 1, 1);
1015 gtk_grid_attach(GTK_GRID(nation_selection_list), nationsets_chooser,
1016 1, 0, 1, 1);
1017 }
1018
1019 races_notebook = gtk_notebook_new();
1020 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(races_notebook), GTK_POS_LEFT);
1021 gtk_grid_attach(GTK_GRID(nation_selection_list), races_notebook,
1022 0, 2, 2, 1);
1023
1024 /* Suppress notebook tabs if there will be only one ("All") */
1025 {
1026 bool show_groups = FALSE;
1027
1028 nation_groups_iterate(pgroup) {
1029 if (!is_nation_group_hidden(pgroup)) {
1030 show_groups = TRUE;
1031 break;
1032 }
1033 } nation_groups_iterate_end;
1034 if (!show_groups) {
1035 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), FALSE);
1036 } else {
1037 label = g_object_new(GTK_TYPE_LABEL,
1038 "use-underline", TRUE,
1039 "label", _("Nation _Groups:"),
1040 "xalign", 0.0,
1041 "yalign", 0.5,
1042 NULL);
1043 gtk_label_set_mnemonic_widget(GTK_LABEL(label), races_notebook);
1044 gtk_grid_attach(GTK_GRID(nation_selection_list), label,
1045 0, 1, 2, 1);
1046 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(races_notebook), TRUE);
1047 }
1048 }
1049
1050 /* Populate treeview */
1051 create_nation_selection_lists();
1052
1053 gtk_box_append(GTK_BOX(hbox), nation_selection_list);
1054 }
1055
1056 /* Right side. */
1057 notebook = gtk_notebook_new();
1058 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);
1059 gtk_box_append(GTK_BOX(hbox), notebook);
1060
1061 /* Properties pane. */
1062 label = gtk_label_new_with_mnemonic(_("_Properties"));
1063
1064 races_properties = table = gtk_grid_new();
1065 g_signal_connect(table, "destroy",
1066 G_CALLBACK(widget_destroyed), &races_properties);
1067 gtk_widget_set_margin_bottom(table, 6);
1068 gtk_widget_set_margin_end(table, 6);
1069 gtk_widget_set_margin_start(table, 6);
1070 gtk_widget_set_margin_top(table, 6);
1071 gtk_grid_set_row_spacing(GTK_GRID(table), 2);
1072 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
1073
1074 /* Leader. */
1075 {
1076 GtkListStore *model = gtk_list_store_new(1, G_TYPE_STRING);
1077
1078 combo = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(model));
1079 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(combo), 0);
1080 g_object_unref(G_OBJECT(model));
1081 }
1082 races_leader = combo;
1083 label = g_object_new(GTK_TYPE_LABEL,
1084 "use-underline", TRUE,
1085 "mnemonic-widget", GTK_COMBO_BOX(combo),
1086 "label", _("_Leader:"),
1087 "xalign", 0.0,
1088 "yalign", 0.5,
1089 NULL);
1090 gtk_widget_set_margin_bottom(label, 6);
1091 gtk_widget_set_margin_end(label, 12);
1092 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 2);
1093 gtk_grid_attach(GTK_GRID(table), combo, 1, 0, 2, 1);
1094
1095 cmd = gtk_check_button_new_with_mnemonic(sex_name_mnemonic(SEX_FEMALE,
1096 "_"));
1097 gtk_widget_set_margin_bottom(cmd, 6);
1098 races_sex[0] = cmd;
1099 gtk_grid_attach(GTK_GRID(table), cmd, 1, 1, 1, 1);
1100 group = cmd;
1101
1102 cmd = gtk_check_button_new_with_mnemonic(sex_name_mnemonic(SEX_MALE,
1103 "_"));
1104 gtk_check_button_set_group(GTK_CHECK_BUTTON(cmd),
1105 GTK_CHECK_BUTTON(group));
1106 gtk_widget_set_margin_bottom(cmd, 6);
1107 races_sex[1] = cmd;
1108 gtk_grid_attach(GTK_GRID(table), cmd, 2, 1, 1, 1);
1109
1110 /* City style. */
1111 store = gtk_list_store_new(3, G_TYPE_INT,
1112 GDK_TYPE_PIXBUF, G_TYPE_STRING);
1113
1114 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1115 gtk_widget_set_hexpand(list, TRUE);
1116 gtk_widget_set_vexpand(list, TRUE);
1117 races_style_list = list;
1118 g_object_unref(store);
1119 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
1120 g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(list)), "changed",
1121 G_CALLBACK(races_style_callback), NULL);
1122
1123 sw = gtk_scrolled_window_new();
1124 gtk_widget_set_margin_top(sw, 6);
1125 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
1126 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1127 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1128 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), list);
1129 gtk_grid_attach(GTK_GRID(table), sw, 1, 2, 2, 2);
1130
1131 label = g_object_new(GTK_TYPE_LABEL,
1132 "use-underline", TRUE,
1133 "mnemonic-widget", list,
1134 "label", _("City _Styles:"),
1135 "xalign", 0.0,
1136 "yalign", 0.5,
1137 NULL);
1138 gtk_widget_set_margin_top(label, 6);
1139 gtk_widget_set_margin_end(label, 12);
1140 gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);
1141
1142 render = gtk_cell_renderer_pixbuf_new();
1143 column = gtk_tree_view_column_new_with_attributes(NULL, render,
1144 "pixbuf", 1, NULL);
1145 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
1146 render = gtk_cell_renderer_text_new();
1147 column = gtk_tree_view_column_new_with_attributes(NULL, render,
1148 "text", 2, NULL);
1149 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
1150
1151 /* Populate style store. */
1152 styles_iterate(pstyle) {
1153 GdkPixbuf *img;
1154 struct sprite *s;
1155 GtkTreeIter it;
1156
1157 i = basic_city_style_for_style(pstyle);
1158
1159 if (i >= 0) {
1160 gtk_list_store_append(store, &it);
1161
1162 s = crop_blankspace(get_sample_city_sprite(tileset, i));
1163 img = sprite_get_pixbuf(s);
1164 free_sprite(s);
1165 gtk_list_store_set(store, &it, 0, i, 1, img, 2,
1166 city_style_name_translation(i), -1);
1167 g_object_unref(img);
1168 }
1169 } styles_iterate_end;
1170
1171 /* Legend pane. */
1172 label = gtk_label_new_with_mnemonic(_("_Description"));
1173
1174 text = gtk_text_view_new();
1175 gtk_widget_set_margin_bottom(text, 6);
1176 gtk_widget_set_margin_end(text, 6);
1177 gtk_widget_set_margin_start(text, 6);
1178 gtk_widget_set_margin_top(text, 6);
1179 gtk_widget_set_hexpand(text, TRUE);
1180 gtk_widget_set_vexpand(text, TRUE);
1181 races_text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
1182 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
1183 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
1184 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
1185 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
1186 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
1187
1188 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), text, label);
1189
1190 /* Signals. */
1191 g_signal_connect(shell, "destroy",
1192 G_CALLBACK(widget_destroyed), &races_shell);
1193 g_signal_connect(shell, "response",
1194 G_CALLBACK(races_response), NULL);
1195
1196 g_signal_connect(GTK_COMBO_BOX(races_leader), "changed",
1197 G_CALLBACK(races_leader_callback), NULL);
1198
1199 g_signal_connect(races_sex[0], "toggled",
1200 G_CALLBACK(races_sex_callback), GINT_TO_POINTER(SEX_FEMALE));
1201 g_signal_connect(races_sex[1], "toggled",
1202 G_CALLBACK(races_sex_callback), GINT_TO_POINTER(SEX_MALE));
1203
1204 /* Finish up. */
1205 gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CANCEL);
1206
1207 /* You can't assign NO_NATION during a running game. */
1208 if (C_S_RUNNING == client_state()) {
1209 gtk_dialog_set_response_sensitive(GTK_DIALOG(shell), GTK_RESPONSE_NO,
1210 FALSE);
1211 }
1212
1213 gtk_widget_set_visible(gtk_dialog_get_content_area(GTK_DIALOG(shell)),
1214 TRUE);
1215
1216 /* Select player's current nation in UI, if any */
1217 if (races_player->nation) {
1218 select_nation(nation_number(races_player->nation),
1219 player_name(races_player),
1220 races_player->is_male,
1221 style_number(races_player->style));
1222 /* Make sure selected nation is visible
1223 * (last page, "All", will certainly contain it) */
1224 fc_assert(gtk_notebook_get_n_pages(GTK_NOTEBOOK(races_notebook)) > 0);
1225 gtk_notebook_set_current_page(GTK_NOTEBOOK(races_notebook), -1);
1226 } else {
1227 select_nation(-1, NULL, FALSE, 0);
1228 }
1229}
1230
1231/**********************************************************************/
1234 void popup_races_dialog(struct player *pplayer)
1235{
1236 if (!pplayer) {
1237 return;
1238 }
1239
1240 if (!races_shell) {
1241 create_races_dialog(pplayer);
1242 gtk_window_present(GTK_WINDOW(races_shell));
1243 }
1244}
1245
1246/**********************************************************************/
1249 void popdown_races_dialog(void)
1250{
1251 if (races_shell) {
1252 gtk_window_destroy(GTK_WINDOW(races_shell));
1253 }
1254
1255 /* We're probably starting a new game, maybe with a new ruleset.
1256 So we warn the worklist dialog. */
1257 blank_max_unit_size();
1258}
1259
1260/**********************************************************************/
1264 void races_toggles_set_sensitive(void)
1265{
1266 int i;
1267
1268 if (!races_shell) {
1269 return;
1270 }
1271
1272 for (i = 0; i <= nation_group_count(); i++) {
1273 if (races_nation_list[i]) {
1274 GtkTreeView *list = GTK_TREE_VIEW(races_nation_list[i]);
1275 GtkTreeModel *model = gtk_tree_view_get_model(list);
1276 GtkTreeSelection* select = gtk_tree_view_get_selection(list);
1277 GtkTreeIter it;
1278 gboolean chosen;
1279
1280 /* Update 'chosen' column in model */
1281 if (gtk_tree_model_get_iter_first(model, &it)) {
1282 do {
1283 int nation_no;
1284 struct nation_type *nation;
1285
1286 gtk_tree_model_get(model, &it, 0, &nation_no, -1);
1287 nation = nation_by_number(nation_no);
1288
1289 chosen = !is_nation_pickable(nation)
1290 || (nation->player && nation->player != races_player);
1291
1292 gtk_list_store_set(GTK_LIST_STORE(model), &it, 1, chosen, -1);
1293
1294 } while (gtk_tree_model_iter_next(model, &it));
1295 }
1296
1297 /* If our selection is now invalid, deselect it */
1298 if (gtk_tree_selection_get_selected(select, &model, &it)) {
1299 gtk_tree_model_get(model, &it, 1, &chosen, -1);
1300
1301 if (chosen) {
1302 gtk_tree_selection_unselect_all(select);
1303 }
1304 }
1305 }
1306 }
1307}
1308
1309/**********************************************************************/
1312 static void races_nation_callback(GtkTreeSelection *select, gpointer data)
1313{
1314 GtkTreeModel *model;
1315 GtkTreeIter it;
1316
1317 if (gtk_tree_selection_get_selected(select, &model, &it)) {
1318 gboolean chosen;
1319 int newnation;
1320
1321 gtk_tree_model_get(model, &it, 0, &newnation, 1, &chosen, -1);
1322
1323 /* Only allow nations not chosen by another player */
1324 if (!chosen) {
1325 if (newnation != selected_nation) {
1326 /* Choose a random leader */
1327 select_nation(newnation, NULL, FALSE,
1328 style_number(style_of_nation(nation_by_number(newnation))));
1329 }
1330 return;
1331 }
1332 }
1333
1334 /* Fall-through if no valid nation selected */
1335 select_nation(-1, NULL, FALSE, 0);
1336}
1337
1338/**********************************************************************/
1341 static void races_leader_callback(void)
1342{
1343 const struct nation_leader *pleader;
1344 const gchar *name;
1345
1346 name =
1347 gtk_entry_buffer_get_text(gtk_entry_get_buffer(GTK_ENTRY(gtk_combo_box_get_child(GTK_COMBO_BOX(races_leader)))));
1348
1349 if (selected_nation != -1
1350 &&(pleader = nation_leader_by_name(nation_by_number(selected_nation),
1351 name))) {
1352 selected_sex = nation_leader_is_male(pleader);
1353 gtk_check_button_set_active(GTK_CHECK_BUTTON(races_sex[selected_sex]),
1354 TRUE);
1355 }
1356}
1357
1358/**********************************************************************/
1361 static void races_sex_callback(GtkWidget *w, gpointer data)
1362{
1363 selected_sex = GPOINTER_TO_INT(data);
1364}
1365
1366/**********************************************************************/
1369 static gboolean races_selection_func(GtkTreeSelection *select,
1370 GtkTreeModel *model, GtkTreePath *path,
1371 gboolean selected, gpointer data)
1372{
1373 GtkTreeIter it;
1374 gboolean chosen;
1375
1376 gtk_tree_model_get_iter(model, &it, path);
1377 gtk_tree_model_get(model, &it, 1, &chosen, -1);
1378 return (!chosen || selected);
1379}
1380
1381/**********************************************************************/
1384 static void races_style_callback(GtkTreeSelection *select, gpointer data)
1385{
1386 GtkTreeModel *model;
1387 GtkTreeIter it;
1388
1389 if (gtk_tree_selection_get_selected(select, &model, &it)) {
1390 gtk_tree_model_get(model, &it, 0, &selected_style, -1);
1391 } else {
1392 selected_style = -1;
1393 }
1394}
1395
1396/**********************************************************************/
1399 static void races_response(GtkWidget *w, gint response, gpointer data)
1400{
1401 if (response == GTK_RESPONSE_ACCEPT) {
1402 const char *s;
1403
1404 /* This shouldn't be possible but... */
1405 if (selected_nation == -1) {
1406 return;
1407 }
1408
1409 if (selected_sex == -1) {
1410 output_window_append(ftc_client, _("You must select your sex."));
1411 return;
1412 }
1413
1414 if (selected_style == -1) {
1415 output_window_append(ftc_client, _("You must select your style."));
1416 return;
1417 }
1418
1419 s = gtk_entry_buffer_get_text(gtk_entry_get_buffer(
1420 GTK_ENTRY(gtk_combo_box_get_child(GTK_COMBO_BOX(races_leader)))));
1421
1422 /* Perform a minimum of sanity test on the name. */
1423 /* This could call is_allowed_player_name() if it were available. */
1424 if (strlen(s) == 0) {
1425 output_window_append(ftc_client, _("You must type a legal name."));
1426 return;
1427 }
1428
1429 dsend_packet_nation_select_req(&client.conn,
1430 player_number(races_player), selected_nation,
1431 selected_sex, s,
1432 selected_style);
1433 } else if (response == GTK_RESPONSE_NO) {
1434 dsend_packet_nation_select_req(&client.conn,
1435 player_number(races_player),
1436 -1, FALSE, "", 0);
1437 }
1438
1439 popdown_races_dialog();
1440}
1441
1442/**********************************************************************/
1445 gboolean taxrates_callback(GtkGestureClick *gesture, int n_press,
1446 double x, double y)
1447{
1448 GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
1449
1450 common_taxrates_callback(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(widget),
1451 "rate_button")), FALSE);
1452
1453 return TRUE;
1454}
1455
1456/**********************************************************************/
1459 gboolean reverse_taxrates_callback(GtkGestureClick *gesture, int n_press,
1460 double x, double y)
1461{
1462 GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
1463
1464 common_taxrates_callback(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(widget),
1465 "rate_button")), TRUE);
1466
1467 return TRUE;
1468}
1469
1470/**********************************************************************/
1473 void popup_upgrade_dialog(struct unit_list *punits)
1474{
1475 GtkWidget *shell;
1476 char buf[512];
1477
1478 if (!punits || unit_list_size(punits) == 0) {
1479 return;
1480 }
1481
1482 if (!get_units_upgrade_info(buf, sizeof(buf), punits)) {
1483 shell = gtk_message_dialog_new(NULL, 0,
1484 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
1485 "%s", buf);
1486 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Unit!"));
1487 setup_dialog(shell, toplevel);
1488 g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy),
1489 NULL);
1490 gtk_window_present(GTK_WINDOW(shell));
1491 } else {
1492 shell = gtk_message_dialog_new(NULL, 0,
1493 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
1494 "%s", buf);
1495 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1496 setup_dialog(shell, toplevel);
1497 gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_YES);
1498
1499 /* FIXME: Should not block */
1500 if (blocking_dialog(shell) == GTK_RESPONSE_YES) {
1501 unit_list_iterate(punits, punit) {
1502 request_unit_upgrade(punit);
1503 } unit_list_iterate_end;
1504 }
1505 gtk_window_destroy(GTK_WINDOW(shell));
1506 }
1507}
1508
1509/**********************************************************************/
1512 void popup_disband_dialog(struct unit_list *punits)
1513{
1514 GtkWidget *shell;
1515 char buf[512];
1516
1517 if (!punits || unit_list_size(punits) == 0) {
1518 return;
1519 }
1520
1521 if (!get_units_disband_info(buf, sizeof(buf), punits)) {
1522 shell = gtk_message_dialog_new(NULL, 0,
1523 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
1524 "%s", buf);
1525 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1526 setup_dialog(shell, toplevel);
1527 g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy),
1528 NULL);
1529 gtk_window_present(GTK_WINDOW(shell));
1530 } else {
1531 shell = gtk_message_dialog_new(NULL, 0,
1532 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
1533 "%s", buf);
1534 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1535 setup_dialog(shell, toplevel);
1536 gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_YES);
1537
1538 /* FIXME: Should not block */
1539 if (blocking_dialog(shell) == GTK_RESPONSE_YES) {
1540 unit_list_iterate(punits, punit) {
1541 if (unit_can_do_action(punit, ACTION_DISBAND_UNIT)) {
1542 request_unit_disband(punit);
1543 }
1544 } unit_list_iterate_end;
1545 }
1546 gtk_window_destroy(GTK_WINDOW(shell));
1547 }
1548}
1549
1550/**********************************************************************/
1554 void popdown_all_game_dialogs(void)
1555{
1556 gui_dialog_destroy_all();
1557 property_editor_popdown(editprop_get_property_editor());
1558 unit_select_dialog_popdown();
1559}
1560
1561/**********************************************************************/
1564 void show_tech_gained_dialog(Tech_type_id tech)
1565{
1566 const struct advance *padvance = valid_advance_by_number(tech);
1567
1568 if (NULL != padvance
1569 && (GUI_GTK_OPTION(popup_tech_help) == GUI_POPUP_TECH_HELP_ENABLED
1570 || (GUI_GTK_OPTION(popup_tech_help) == GUI_POPUP_TECH_HELP_RULESET
1571 && game.control.popup_tech_help))) {
1572 popup_help_dialog_typed(advance_name_translation(padvance), HELP_TECH);
1573 }
1574}
1575
1576/**********************************************************************/
1580 void show_tileset_error(bool fatal, const char *tset_name, const char *msg)
1581{
1582 if (is_gui_up()) {
1583 GtkWidget *dialog;
1584
1585 if (tset_name != NULL) {
1586 dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
1587 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
1588 _("Tileset \"%s\" problem, "
1589 "it's probably incompatible with "
1590 "the ruleset:\n%s"),
1591 tset_name, msg);
1592 } else {
1593 dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
1594 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
1595 _("Tileset problem, "
1596 "it's probably incompatible with "
1597 "the ruleset:\n%s"),
1598 msg);
1599 }
1600
1601 setup_dialog(dialog, toplevel);
1602
1603 blocking_dialog(dialog);
1604
1605 gtk_window_destroy(GTK_WINDOW(dialog));
1606 }
1607}
1608
1609/**********************************************************************/
1613 bool handmade_scenario_warning(void)
1614{
1615 /* Just tell the client common code to handle this. */
1616 return FALSE;
1617}
1618
1619/**********************************************************************/
1623 void popup_combat_info(int attacker_unit_id, int defender_unit_id,
1624 int attacker_hp, int defender_hp,
1625 bool make_att_veteran, bool make_def_veteran)
1626{
1627}
1628
1629/**********************************************************************/
1632 static void act_conf_response(GtkWidget *dialog, gint response,
1633 gpointer data)
1634{
1635 gtk_window_destroy(GTK_WINDOW(dialog));
1636
1637 if (response == GTK_RESPONSE_YES) {
1638 action_confirmation(data, TRUE);
1639 } else {
1640 action_confirmation(data, FALSE);
1641 }
1642}
1643
1644/**********************************************************************/
1647 void request_action_confirmation(const char *expl,
1648 struct act_confirmation_data *data)
1649{
1650 GtkWidget *dialog;
1651 char buf[1024];
1652
1653 if (expl != NULL) {
1654 fc_snprintf(buf, sizeof(buf), _("Are you sure you want to do %s?\n%s"),
1655 action_id_name_translation(data->act), expl);
1656 } else {
1657 fc_snprintf(buf, sizeof(buf), _("Are you sure you want to do %s?"),
1658 action_id_name_translation(data->act));
1659 }
1660
1661 dialog = gtk_message_dialog_new(NULL,
1662 0,
1663 GTK_MESSAGE_WARNING,
1664 GTK_BUTTONS_YES_NO,
1665 "%s", buf);
1666 setup_dialog(dialog, toplevel);
1667
1668 g_signal_connect(dialog, "response",
1669 G_CALLBACK(act_conf_response), data);
1670
1671 gtk_window_present(GTK_WINDOW(dialog));
1672}
action_id_name_translation
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1215
astr_free
void astr_free(struct astring *astr)
Definition astring.c:148
astr_set
void astr_set(struct astring *astr, const char *format,...)
Definition astring.c:251
astr_add
void astr_add(struct astring *astr, const char *format,...)
Definition astring.c:271
astring.h
astr_str
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
ASTRING_INIT
#define ASTRING_INIT
Definition astring.h:44
bitvector.h
BV_CLR_ALL
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
BV_SET
#define BV_SET(bv, bit)
Definition bitvector.h:81
BV_CLR
#define BV_CLR(bv, bit)
Definition bitvector.h:86
output_window_append
void output_window_append(const struct ft_color color, const char *featured_text)
Definition chatline_common.c:104
city_style_name_translation
const char * city_style_name_translation(const int style)
Definition city.c:1748
city_owner
#define city_owner(_pcity_)
Definition city.h:563
popup_city_dialog
void popup_city_dialog(struct city *pcity)
Definition update_queue.c:623
client
struct civclient client
Definition client_main.c:150
client_state
enum client_states client_state(void)
Definition client_main.c:1026
client_main.h
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
common_taxrates_callback
void common_taxrates_callback(int idx, bool reverse)
Definition climisc.c:1183
climisc.h
list
static struct fc_sockaddr_list * list
Definition clinet.c:102
incite_cost
char * incite_cost
Definition comments.c:74
connectdlg_common.h
request_unit_disband
void request_unit_disband(struct unit *punit)
Definition control.c:2046
request_new_unit_activity_targeted
void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, struct extra_type *tgt)
Definition control.c:1912
action_confirmation
void action_confirmation(struct act_confirmation_data *data, bool confirm)
Definition control.c:1740
request_unit_upgrade
void request_unit_upgrade(struct unit *punit)
Definition control.c:2077
control.h
show_tileset_error
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
actor
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
caption
const char * caption
Definition dialogs_g.h:37
headline
const char const char * headline
Definition dialogs_g.h:38
popup_notify_dialog
popup_notify_dialog
Definition dialogs_g.h:37
fatal
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
punit
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
tset_name
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
extra_by_number
struct extra_type * extra_by_number(int id)
Definition extras.c:183
extras
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
extra_index
#define extra_index(_e_)
Definition extras.h:183
Tech_type_id
int Tech_type_id
Definition fc_types.h:381
Nation_type_id
int Nation_type_id
Definition fc_types.h:384
MAX_NUM_NATION_GROUPS
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:58
fcintl.h
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#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:62
game_unit_by_number
struct unit * game_unit_by_number(int id)
Definition game.c:116
game.h
goto.h
government.h
races_properties
static GtkWidget * races_properties
Definition dialogs.c:78
races_selection_func
static gboolean races_selection_func(GtkTreeSelection *select, GtkTreeModel *model, GtkTreePath *path, gboolean selected, gpointer data)
Definition dialogs.c:1350
races_shell
static GtkWidget * races_shell
Definition dialogs.c:72
select_nation
static void select_nation(int nation, const char *leadername, bool is_male, int style_id)
Definition dialogs.c:513
sync_tabs_to_nation
static void sync_tabs_to_nation(int nation)
Definition dialogs.c:471
races_style_list
static GtkWidget * races_style_list
Definition dialogs.c:81
revolution_response
static void revolution_response(GtkWidget *w, gint response, gpointer data)
Definition dialogs.c:265
races_leader_callback
static void races_leader_callback(void)
Definition dialogs.c:1322
selected_style
static int selected_style
Definition dialogs.c:96
create_nation_selection_lists
static void create_nation_selection_lists(void)
Definition dialogs.c:696
is_showing_pillage_dialog
static int is_showing_pillage_dialog
Definition dialogs.c:98
create_races_dialog
static void create_races_dialog(struct player *pplayer)
Definition dialogs.c:839
races_leader
static GtkWidget * races_leader
Definition dialogs.c:79
races_nation_list
static GtkWidget * races_nation_list[MAX_NUM_NATION_GROUPS+1]
Definition dialogs.c:76
populate_leader_list
static void populate_leader_list(void)
Definition dialogs.c:487
unit_select_dialog_popup
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
popup_upgrade_dialog
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
races_update_pickable
void races_update_pickable(bool nationset_change)
Definition dialogs.c:731
notify_connect_msg_response
static void notify_connect_msg_response(GtkWidget *w, gint response)
Definition dialogs.c:186
races_sex_callback
static void races_sex_callback(GtkWidget *w, gpointer data)
Definition dialogs.c:1342
pillage_callback
static void pillage_callback(GtkWidget *dlg, gint arg)
Definition dialogs.c:313
popup_notify_goto_dialog
void popup_notify_goto_dialog(const char *headline, const char *lines, const struct text_tag_list *tags, struct tile *ptile)
Definition dialogs.c:196
show_tech_gained_dialog
void show_tech_gained_dialog(Tech_type_id tech)
Definition dialogs.c:1524
races_sex
static GtkWidget * races_sex[2]
Definition dialogs.c:80
popup_races_dialog
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
popup_disband_dialog
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1473
path_to_nation_on_list
static GtkTreePath * path_to_nation_on_list(Nation_type_id nation, GtkTreeView *list)
Definition dialogs.c:399
popdown_races_dialog
void popdown_races_dialog(void)
Definition dialogs.c:1230
selected_nation
static int selected_nation
Definition dialogs.c:94
races_notebook
static GtkWidget * races_notebook
Definition dialogs.c:77
popup_pillage_dialog
void popup_pillage_dialog(struct unit *punit, bv_extras extras)
Definition dialogs.c:338
races_response
static void races_response(GtkWidget *w, gint response, gpointer data)
Definition dialogs.c:1380
act_conf_response
static void act_conf_response(GtkWidget *dialog, gint response, gpointer data)
Definition dialogs.c:1592
notify_goto_response
static void notify_goto_response(GtkWidget *w, gint response)
Definition dialogs.c:159
races_nation_callback
static void races_nation_callback(GtkTreeSelection *select, gpointer data)
Definition dialogs.c:1293
popup_connect_msg
void popup_connect_msg(const char *headline, const char *message)
Definition dialogs.c:239
handmade_scenario_warning
bool handmade_scenario_warning(void)
Definition dialogs.c:1573
unit_select_dialog_update_real
void unit_select_dialog_update_real(void *unused)
Definition dialogs.c:386
nationset_callback
static void nationset_callback(GtkComboBox *b, gpointer data)
Definition dialogs.c:814
races_toggles_set_sensitive
void races_toggles_set_sensitive(void)
Definition dialogs.c:1245
races_style_callback
static void races_style_callback(GtkTreeSelection *select, gpointer data)
Definition dialogs.c:1365
popup_combat_info
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
selected_sex
static int selected_sex
Definition dialogs.c:95
races_player
struct player * races_player
Definition dialogs.c:74
nationsets_chooser
static GtkWidget * nationsets_chooser
Definition dialogs.c:73
request_action_confirmation
void request_action_confirmation(const char *expl, struct act_confirmation_data *data)
Definition dialogs.c:1607
races_text
static GtkTextBuffer * races_text
Definition dialogs.c:82
nationset_sync_to_server
void nationset_sync_to_server(const char *nationset)
Definition dialogs.c:801
taxrates_callback
gboolean taxrates_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition dialogs.c:1425
create_list_of_nations_in_group
static GtkWidget * create_list_of_nations_in_group(struct nation_group *group, int index)
Definition dialogs.c:609
select_nation_on_tab
static void select_nation_on_tab(GtkWidget *tab_list, int nation)
Definition dialogs.c:427
popdown_all_game_dialogs
void popdown_all_game_dialogs(void)
Definition dialogs.c:1514
editprop_get_property_editor
struct property_editor * editprop_get_property_editor(void)
Definition editprop.c:6204
property_editor_popdown
void property_editor_popdown(struct property_editor *pe)
Definition editprop.c:6269
bottom_notebook
GtkWidget * bottom_notebook
Definition gui_main.c:129
is_gui_up
bool is_gui_up(void)
Definition gui_main.c:2080
toplevel
GtkWidget * toplevel
Definition gui_main.c:125
GUI_GTK_OPTION
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
gui_dialog_present
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:835
gui_dialog_new
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
gui_dialog_show_all
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
gui_dialog_set_title
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
gui_dialog_set_default_size
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
gui_dialog_destroy_all
void gui_dialog_destroy_all(void)
Definition gui_stuff.c:974
gui_dialog_add_button
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
popup_help_dialog_typed
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
shell
static struct gui_dialog * shell
Definition messagedlg.c:39
get_flag
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
title
const char * title
Definition repodlgs.c:1314
free_sprite
void free_sprite(struct sprite *s)
Definition sprite.c:278
sprite_get_pixbuf
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
crop_blankspace
struct sprite * crop_blankspace(struct sprite *s)
Definition sprite.c:386
unit_select_dialog_popup_main
void unit_select_dialog_popup_main(struct tile *ptile, bool create)
Definition unitselect.c:193
unit_select_dialog_popdown
void unit_select_dialog_popdown(void)
Definition unitselect.c:214
select_tgt_extra
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)
Definition unitselextradlg.c:107
blank_max_unit_size
void blank_max_unit_size(void)
Definition wldlg.c:79
reverse_taxrates_callback
gboolean reverse_taxrates_callback(GtkGestureClick *gesture, int n_press, double x, double y)
Definition dialogs.c:1459
blocking_dialog
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1136
gui_dialog_add_content_widget
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1105
widget_destroyed
void widget_destroyed(GtkWidget *wdg, void *data)
Definition gui_stuff.c:1155
choice_dialog.h
editprop.h
gui_stuff.h
unitselect.h
unitselextradlg.h
leader_name
static char * leader_name
Definition dialogs.c:97
chatline.h
citydlg.h
popup_revolution_dialog
void popup_revolution_dialog(void)
Definition dialogs.c:112
dialogs.h
graphics.h
gui_main.h
mapview.h
plrdlg.h
wldlg.h
helptext_nation
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5003
helpdata.h
HELP_TECH
@ HELP_TECH
Definition helpdlg_g.h:21
name
const char * name
Definition inputfile.c:127
log.h
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_action
#define fc_assert_action(condition, action)
Definition log.h:187
map.h
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
mem.h
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_strdup
#define fc_strdup(str)
Definition mem.h:43
nation_number
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:486
nation_leader_by_name
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Definition nation.c:267
nation_leader_is_male
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:290
nation_adjective_translation
const char * nation_adjective_translation(const struct nation_type *pnation)
Definition nation.c:149
nation_by_number
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:475
nation_set_index
int nation_set_index(const struct nation_set *pset)
Definition nation.c:699
is_nation_pickable
bool is_nation_pickable(const struct nation_type *nation)
Definition nation.c:188
nation_leaders
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:230
nation_set_name_translation
const char * nation_set_name_translation(const struct nation_set *pset)
Definition nation.c:818
is_nation_playable
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:200
nation_is_in_group
bool nation_is_in_group(const struct nation_type *pnation, const struct nation_group *pgroup)
Definition nation.c:1099
nation_is_in_set
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:837
nation_set_description
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:828
nation_group_name_translation
const char * nation_group_name_translation(const struct nation_group *pgroup)
Definition nation.c:1090
nation_set_count
int nation_set_count(void)
Definition nation.c:691
nation_group_by_number
struct nation_group * nation_group_by_number(int id)
Definition nation.c:1004
nation_set_by_rule_name
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:779
is_nation_group_hidden
bool is_nation_group_hidden(struct nation_group *pgroup)
Definition nation.c:1057
nation_set_by_setting_value
struct nation_set * nation_set_by_setting_value(const char *setting)
Definition nation.c:859
nation_leader_name
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:281
nation_group_count
int nation_group_count(void)
Definition nation.c:935
nation_set_rule_name
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:807
style_of_nation
struct nation_style * style_of_nation(const struct nation_type *pnation)
Definition nation.c:672
nation_leader_list_iterate
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:57
nation_sets_iterate_end
#define nation_sets_iterate_end
Definition nation.h:305
nation_sets_iterate
#define nation_sets_iterate(NAME_pset)
Definition nation.h:301
nations_iterate_end
#define nations_iterate_end
Definition nation.h:336
nations_iterate
#define nations_iterate(NAME_pnation)
Definition nation.h:333
nation_leader_list_iterate_end
#define nation_leader_list_iterate_end
Definition nation.h:59
nation_groups_iterate
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:311
nation_groups_iterate_end
#define nation_groups_iterate_end
Definition nation.h:315
server_optset
const struct option_set * server_optset
Definition options.c:4281
option_str_set
bool option_str_set(struct option *poption, const char *str)
Definition options.c:961
option_str_get
const char * option_str_get(const struct option *poption)
Definition options.c:928
gui_options
struct client_options gui_options
Definition options.c:71
optset_option_by_name
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Definition options.c:466
options.h
GUI_POPUP_TECH_HELP_RULESET
@ GUI_POPUP_TECH_HELP_RULESET
Definition options.h:77
GUI_POPUP_TECH_HELP_ENABLED
@ GUI_POPUP_TECH_HELP_ENABLED
Definition options.h:75
packets.h
dsend_packet_nation_select_req
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)
Definition packets_gen.c:2739
start_revolution
void start_revolution(void)
Definition packhand.c:2392
set_government_choice
void set_government_choice(struct government *government)
Definition packhand.c:2379
lines
char * lines
Definition packhand.c:131
len
int len
Definition packhand.c:127
packhand.h
player_number
int player_number(const struct player *pplayer)
Definition player.c:837
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:895
player.h
rand.h
fc_rand
#define fc_rand(_size)
Definition rand.h:56
sex_name_mnemonic
const char * sex_name_mnemonic(sex_t kind, const char *mnemonic)
Definition sex.c:74
sex.h
SEX_FEMALE
@ SEX_FEMALE
Definition sex.h:22
SEX_MALE
@ SEX_MALE
Definition sex.h:23
y
struct sprite int int y
Definition sprite_g.h:31
x
struct sprite int x
Definition sprite_g.h:31
act_confirmation_data
Definition control.h:145
act_confirmation_data::act
action_id act
Definition control.h:146
advance
Definition tech.h:124
astring
Definition astring.h:36
city
Definition city.h:320
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::center_when_popup_city
bool center_when_popup_city
Definition options.h:162
connection::playing
struct player * playing
Definition connection.h:151
entry
Definition registry_ini.c:193
extra_type
Definition extras.h:88
government
Definition government.h:52
gui_dialog
Definition gui_stuff.h:70
gui_dialog::label
GtkWidget * label
Definition gui_stuff.h:87
img
Definition mapimg.c:367
message
Definition messagewin_common.h:29
nation_group
Definition nation.h:167
nation_leader
Definition nation.c:221
nation_set
Definition nation.c:41
nation_type
Definition nation.h:98
nation_type::player
struct player * player
Definition nation.h:118
option
Definition options.c:514
packet_ruleset_control::popup_tech_help
bool popup_tech_help
Definition packets_gen.h:1483
player
Definition player.h:249
player::is_male
bool is_male
Definition player.h:257
player::revolution_finishes
int revolution_finishes
Definition player.h:273
player::nation
struct nation_type * nation
Definition player.h:260
player::style
struct nation_style * style
Definition player.h:279
sprite
Definition sprite.h:22
tile
Definition tile.h:50
tile::label
char * label
Definition tile.h:66
tileset
Definition tilespec.c:481
unit
Definition unit.h:140
widget
Definition widget.h:112
style_number
int style_number(const struct nation_style *pstyle)
Definition style.c:68
basic_city_style_for_style
int basic_city_style_for_style(struct nation_style *pstyle)
Definition style.c:210
styles_iterate
#define styles_iterate(_p)
Definition style.h:46
styles_iterate_end
#define styles_iterate_end
Definition style.h:52
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
fc_break_lines
int fc_break_lines(char *str, size_t desired_len)
Definition support.c:1135
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:300
valid_advance_by_number
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:176
get_preferred_pillage
struct extra_type * get_preferred_pillage(bv_extras extras)
Definition terrain.c:550
get_units_upgrade_info
bool get_units_upgrade_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1270
get_units_disband_info
bool get_units_disband_info(char *buf, size_t bufsz, struct unit_list *punits)
Definition text.c:1336
text.h
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
get_sample_city_sprite
struct sprite * get_sample_city_sprite(const struct tileset *t, int style_idx)
Definition tilespec.c:6869
tilespec.h
unit_can_do_action
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:385
unit_tile
#define unit_tile(_pu)
Definition unit.h:397
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33