Freeciv-3.1
Loading...
Searching...
No Matches
unitselect.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 <gtk/gtk.h>
19
20/* utility */
21#include "fcintl.h"
22
23/* common */
24#include "fc_types.h"
25#include "game.h"
26#include "player.h"
27#include "unit.h"
28#include "unitlist.h"
29#include "unittype.h"
30
31/* client */
32#include "client_main.h"
33#include "control.h"
34#include "goto.h"
35#include "tilespec.h"
36#include "unitselect_common.h"
37
38/* client/gui-gtk-4.0 */
39#include "graphics.h"
40#include "gui_stuff.h"
41#include "gui_main.h"
42
43#include "unitselect.h"
44
45/* Activate this to get more columns (see below) */
46#undef DEBUG_USDLG
47
53
60
61/* Basic data (Unit, description, count) */
62#define USDLG_COLUMNS_DEFAULT 3
63/* Additional data; shown if DEBUG_USDLG */
64#define USDLG_COL_UTID USDLG_COLUMNS_DEFAULT + 0 /* Unit type ID */
65#define USDLG_COL_UID USDLG_COLUMNS_DEFAULT + 1 /* Unit ID */
66#define USDLG_COL_LOCATION USDLG_COLUMNS_DEFAULT + 2 /* Unit location */
67#define USDLG_COL_ACTIVITY USDLG_COLUMNS_DEFAULT + 3 /* Unit activity */
68#define USDLG_COL_ROW_TYPE USDLG_COLUMNS_DEFAULT + 4 /* Row type */
69#define USDLG_COLUMNS_DEBUG USDLG_COLUMNS_DEFAULT + 5
70/* Layout options; never shown */
71#define USDLG_COL_STYLE USDLG_COLUMNS_DEBUG + 0
72#define USDLG_COL_WEIGHT USDLG_COLUMNS_DEBUG + 1
73#define USDLG_COLUMNS_ALL USDLG_COLUMNS_DEBUG + 2
74
75#ifdef DEBUG_USDLG
76 #define USDLG_COLUMNS_SHOW USDLG_COLUMNS_DEBUG
77#else
78 #define USDLG_COLUMNS_SHOW USDLG_COLUMNS_DEFAULT
79#endif /* DEBUG_USDLG */
80
82 COL_PIXBUF, /* Unit */
83 COL_TEXT, /* Description */
84 COL_INT, /* Count */
85 COL_INT, /* Debug: unit type */
86 COL_INT, /* Debug: unit ID */
87 COL_INT, /* Debug: location */
88 COL_INT, /* Debug: activity */
89 COL_INT, /* Debug: row type */
90 COL_INT, /* Layout: style */
91 COL_INT /* Layout: width */
92};
93
94static const char *usdlg_col_titles[USDLG_COLUMNS_ALL] = {
95 N_("Unit"),
96 N_("Description"),
97 N_("Count"),
98 "[Unittype]", /* Only for debug, no translation! */
99 "[Unit ID]",
100 "[Location]",
101 "[Activity]",
102 "[Row type]",
103 "[Style]",
104 "[Width]"
105};
106
116
117struct unit_select_dialog {
118 struct tile *ptile;
119 int unit_id_focus;
120
121 GtkWidget *shell;
122 GtkWidget *notebook;
123
124 struct {
125 GtkTreeStore *store;
126 GtkWidget *view;
127 GtkTreePath *path;
129
130 struct {
131 GtkTreeStore *store;
132 GtkWidget *page;
133 GtkWidget *view;
134 GtkTreePath *path;
135
136 GtkWidget *cmd[USDLG_CMD_LAST];
137 } tabs[SELLOC_COUNT];
138};
139
140/* The unit selection dialog; should only be used in usdlg_get(). */
142
143static struct unit_select_dialog *usdlg_get(bool create);
144static struct unit_select_dialog *usdlg_create(void);
145static void usdlg_destroy(void);
146static void usdlg_destroy_callback(GObject *object, gpointer data);
147static void usdlg_tile(struct unit_select_dialog *pdialog,
148 struct tile *ptile);
149static void usdlg_refresh(struct unit_select_dialog *pdialog);
150
151static void usdlg_tab_select(struct unit_select_dialog *pdialog,
152 const char *title,
153 enum unit_select_location_mode loc);
154static GtkTreeStore *usdlg_tab_store_new(void);
155static bool usdlg_tab_update(struct unit_select_dialog *pdialog,
156 struct usdata_hash *ushash,
157 enum unit_select_location_mode loc);
158static void usdlg_tab_append_utype(GtkTreeStore *store,
159 enum unit_select_location_mode loc,
160 const struct unit_type *putype,
161 GtkTreeIter *it);
162static void usdlg_tab_append_activity(GtkTreeStore *store,
163 enum unit_select_location_mode loc,
164 const struct unit_type *putype,
165 enum unit_activity act,
166 int count, GtkTreeIter *it,
167 GtkTreeIter *parent);
168static void usdlg_tab_append_units(struct unit_select_dialog *pdialog,
169 enum unit_select_location_mode loc,
170 enum unit_activity act,
171 const struct unit *punit,
172 bool transported, GtkTreeIter *it,
173 GtkTreeIter *parent);
174
175static void usdlg_cmd_ready(GObject *object, gpointer data);
176static void usdlg_cmd_sentry(GObject *object, gpointer data);
177static void usdlg_cmd_select(GObject *object, gpointer data);
178static void usdlg_cmd_deselect(GObject *object, gpointer data);
179static void usdlg_cmd_exec(GObject *object, gpointer mode_data,
180 enum usdlg_cmd cmd);
181static void usdlg_cmd_exec_unit(struct unit *punit, enum usdlg_cmd cmd);
182static void usdlg_cmd_center(GObject *object, gpointer data);
183static void usdlg_cmd_focus(GObject *object, gpointer data);
184static void usdlg_cmd_focus_real(GtkTreeView *view);
185static void usdlg_cmd_row_activated(GtkTreeView *view, GtkTreePath *path,
186 GtkTreeViewColumn *col, gpointer data);
187static void usdlg_cmd_cursor_changed(GtkTreeView *view, gpointer data);
188
189
190/*************************************************************************/
193void unit_select_dialog_popup_main(struct tile *ptile, bool create)
194{
195 struct unit_select_dialog *pdialog;
196
197 /* Create the dialog if it is requested. */
198 pdialog = usdlg_get(create);
199
200 /* Present the unit selection dialog if it exists. */
201 if (pdialog) {
202 /* Show all. */
203 gtk_widget_show(GTK_WIDGET(pdialog->shell));
204 /* Update tile. */
205 usdlg_tile(pdialog, ptile);
206 /* Refresh data and hide unused tabs. */
207 usdlg_refresh(pdialog);
208 }
209}
210
211/*************************************************************************/
215{
217}
218
219/*************************************************************************/
223static struct unit_select_dialog *usdlg_get(bool create)
224{
225 if (unit_select_dlg) {
226 /* Return existing dialog. */
227 return unit_select_dlg;
228 } else if (create) {
229 /* Create new dialog. */
231 return unit_select_dlg;
232 } else {
233 /* Nothing. */
234 return NULL;
235 }
236}
237
238/*************************************************************************/
242{
243 GtkWidget *vbox;
244 GtkWidget *close_cmd;
245 struct unit_select_dialog *pdialog;
246
247 /* Create a container for the dialog. */
248 pdialog = fc_calloc(1, sizeof(*pdialog));
249
250 /* No tile defined. */
251 pdialog->ptile = NULL;
252
253 /* Create the dialog. */
254 pdialog->shell = gtk_dialog_new();
255 gtk_window_set_title(GTK_WINDOW(pdialog->shell), _("Unit selection"));
256 setup_dialog(pdialog->shell, toplevel);
257 g_signal_connect(pdialog->shell, "destroy",
258 G_CALLBACK(usdlg_destroy_callback), pdialog);
259 gtk_widget_realize(pdialog->shell);
260
261 vbox = gtk_dialog_get_content_area(GTK_DIALOG(pdialog->shell));
262
263 /* Notebook. */
264 pdialog->notebook = gtk_notebook_new();
265 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(pdialog->notebook),
266 GTK_POS_BOTTOM);
267 gtk_box_insert_child_after(GTK_BOX(vbox), pdialog->notebook, NULL);
268
269 /* Append pages. */
270 usdlg_tab_select(pdialog, _("_Units"), SELLOC_UNITS);
271 usdlg_tab_select(pdialog, _("_Tile"), SELLOC_TILE);
272 usdlg_tab_select(pdialog, _("C_ontinent"), SELLOC_CONT);
273 usdlg_tab_select(pdialog, _("_Land"), SELLOC_LAND);
274 usdlg_tab_select(pdialog, _("_Sea"), SELLOC_SEA);
275 usdlg_tab_select(pdialog, _("_Both"), SELLOC_BOTH);
276 usdlg_tab_select(pdialog, _("_World"), SELLOC_WORLD);
277
278 /* Buttons. */
279 close_cmd = gtk_dialog_add_button(GTK_DIALOG(pdialog->shell),
280 _("_Close"), GTK_RESPONSE_CLOSE);
281 gtk_dialog_set_default_response(GTK_DIALOG(pdialog->shell),
282 GTK_RESPONSE_CLOSE);
283 g_signal_connect(close_cmd, "clicked",
284 G_CALLBACK(usdlg_destroy_callback), pdialog);
285
286 return pdialog;
287}
288
289/*************************************************************************/
292static void usdlg_destroy(void)
293{
294 if (unit_select_dlg) {
295 gtk_window_destroy(GTK_WINDOW(unit_select_dlg->shell));
296 free(unit_select_dlg);
297 }
298 unit_select_dlg = NULL;
299}
300
301/*************************************************************************/
304static void usdlg_destroy_callback(GObject *object, gpointer data)
305{
307}
308
309/*************************************************************************/
312static void usdlg_tile(struct unit_select_dialog *pdialog,
313 struct tile *ptile)
314{
315 if (!pdialog) {
316 return;
317 }
318
319 /* Check for a valid tile. */
320 if (ptile != NULL) {
321 pdialog->ptile = ptile;
322 } else if (pdialog->ptile == NULL) {
324
325 if (punit) {
326 pdialog->ptile = unit_tile(punit);
328 } else {
329 pdialog->ptile = get_center_tile_mapcanvas();
330 }
331 }
332}
333
334/*************************************************************************/
337static void usdlg_refresh(struct unit_select_dialog *pdialog)
338{
339 struct usdata_hash *ushash = NULL;
340 enum unit_select_location_mode loc;
341
342 if (!pdialog) {
343 return;
344 }
345
346 /* Sort units into the hash. */
347 ushash = usdlg_data_new(pdialog->ptile);
348 /* Update all tabs. */
349 for (loc = unit_select_location_mode_begin();
350 loc != unit_select_location_mode_end();
351 loc = unit_select_location_mode_next(loc)) {
352 bool show = usdlg_tab_update(pdialog, ushash, loc);
353
354 if (!show) {
355 gtk_widget_hide(pdialog->tabs[loc].page);
356 } else {
357 gtk_widget_show(pdialog->tabs[loc].page);
358
359 if (pdialog->tabs[loc].path) {
360 gtk_tree_view_expand_row(GTK_TREE_VIEW(pdialog->tabs[loc].view),
361 pdialog->tabs[loc].path,FALSE);
362 gtk_tree_view_set_cursor(GTK_TREE_VIEW(pdialog->tabs[loc].view),
363 pdialog->tabs[loc].path, NULL, FALSE);
364 gtk_tree_path_free(pdialog->tabs[loc].path);
365 pdialog->tabs[loc].path = NULL;
366 }
367 }
368 }
369 /* Destroy the hash. */
370 usdlg_data_destroy(ushash);
371}
372
373/*************************************************************************/
386static void usdlg_tab_select(struct unit_select_dialog *pdialog,
387 const char *title,
388 enum unit_select_location_mode loc)
389{
390 GtkWidget *page, *label, *hgrid, *vgrid, *view, *sw;
391 GtkTreeStore *store;
392 static bool titles_done;
393 int i;
394 int page_row = 0;
395 int grid_col = 0;
396 int grid_row = 0;
397
398 page = gtk_grid_new();
399 gtk_orientable_set_orientation(GTK_ORIENTABLE(page),
400 GTK_ORIENTATION_VERTICAL);
401 gtk_widget_set_margin_start(page, 8);
402 gtk_widget_set_margin_end(page, 8);
403 gtk_widget_set_margin_top(page, 8);
404 gtk_widget_set_margin_bottom(page, 8);
405 pdialog->tabs[loc].page = page;
406
407 label = gtk_label_new_with_mnemonic(title);
408 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
409
410 hgrid = gtk_grid_new();
411 gtk_grid_attach(GTK_GRID(page), hgrid, 0, page_row++, 1, 1);
412
413 store = usdlg_tab_store_new();
414 pdialog->tabs[loc].store = store;
415
416 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
417 gtk_widget_set_hexpand(view, TRUE);
418 gtk_widget_set_vexpand(view, TRUE);
419 pdialog->tabs[loc].view = view;
420 g_object_unref(store);
421
422 g_signal_connect(view, "row-activated", G_CALLBACK(usdlg_cmd_row_activated),
423 GINT_TO_POINTER(loc));
424 g_signal_connect(view, "cursor-changed",
425 G_CALLBACK(usdlg_cmd_cursor_changed), GINT_TO_POINTER(loc));
426
427 /* Translate titles. */
429
430 for (i = 0; i < USDLG_COLUMNS_SHOW; i++) {
431 GtkTreeViewColumn *column = NULL;
432 GtkCellRenderer *renderer = NULL;
433
434 switch (usdlg_col_types[i]) {
435 case COL_PIXBUF:
436 renderer = gtk_cell_renderer_pixbuf_new();
437 column = gtk_tree_view_column_new_with_attributes(
438 usdlg_col_titles[i], renderer, "pixbuf", i, NULL);
439 gtk_tree_view_column_set_expand(column, FALSE);
440 break;
441 case COL_TEXT:
442 renderer = gtk_cell_renderer_text_new();
443 column = gtk_tree_view_column_new_with_attributes(
444 usdlg_col_titles[i], renderer, "text", i,
445 "style", USDLG_COL_STYLE, "weight", USDLG_COL_WEIGHT, NULL);
446 gtk_tree_view_column_set_expand(column, TRUE);
447 break;
448 case COL_INT:
449 renderer = gtk_cell_renderer_text_new();
450 column = gtk_tree_view_column_new_with_attributes(
451 usdlg_col_titles[i], renderer, "text", i,
452 "style", USDLG_COL_STYLE, "weight", USDLG_COL_WEIGHT, NULL);
453 g_object_set(renderer, "xalign", 1.0, NULL);
454 gtk_tree_view_column_set_alignment(column, 1.0);
455 gtk_tree_view_column_set_expand(column, FALSE);
456 break;
457 }
458
459 fc_assert_ret(column != NULL);
460 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
461 }
462
463 sw = gtk_scrolled_window_new();
464 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sw), 300);
465 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
466 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
467 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
468 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view);
469 gtk_grid_attach(GTK_GRID(hgrid), sw, grid_col++, 0, 1, 1);
470
471 vgrid = gtk_grid_new();
472 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
473 GTK_ORIENTATION_VERTICAL);
474 gtk_grid_attach(GTK_GRID(hgrid), vgrid, grid_col++, 0, 1, 1);
475
476 /* button box 1: ready, sentry */
477
478 pdialog->tabs[loc].cmd[USDLG_CMD_READY]
479 = gtk_button_new_with_mnemonic(_("Ready"));
480 gtk_grid_attach(GTK_GRID(vgrid),
481 pdialog->tabs[loc].cmd[USDLG_CMD_READY],
482 0, grid_row++, 1, 1);
483 g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_READY], "clicked",
484 G_CALLBACK(usdlg_cmd_ready), GINT_TO_POINTER(loc));
485 gtk_widget_set_sensitive(
486 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_READY]), FALSE);
487
488 pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY]
489 = gtk_button_new_with_mnemonic(_("Sentry"));
490 gtk_widget_set_margin_bottom(
491 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY]), 10);
492 gtk_grid_attach(GTK_GRID(vgrid),
493 pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY],
494 0, grid_row++, 1, 1);
495 g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY], "clicked",
496 G_CALLBACK(usdlg_cmd_sentry), GINT_TO_POINTER(loc));
497 gtk_widget_set_sensitive(
498 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_SENTRY]), FALSE);
499
500 /* button box 2: select, deselect */
501
502 pdialog->tabs[loc].cmd[USDLG_CMD_SELECT]
503 = gtk_button_new_with_mnemonic(_("_Select"));
504 gtk_grid_attach(GTK_GRID(vgrid),
505 pdialog->tabs[loc].cmd[USDLG_CMD_SELECT],
506 0, grid_row++, 1, 1);
507 g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_SELECT], "clicked",
508 G_CALLBACK(usdlg_cmd_select), GINT_TO_POINTER(loc));
509 gtk_widget_set_sensitive(
510 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_SELECT]), FALSE);
511
512 pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT]
513 = gtk_button_new_with_mnemonic(_("_Deselect"));
514 gtk_widget_set_margin_bottom(
515 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT]), 10);
516 gtk_grid_attach(GTK_GRID(vgrid),
517 pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT],
518 0, grid_row++, 1, 1);
519 g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT], "clicked",
520 G_CALLBACK(usdlg_cmd_deselect), GINT_TO_POINTER(loc));
521 gtk_widget_set_sensitive(
522 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_DESELECT]), FALSE);
523
524 /* button box 3: center, focus */
525
526 pdialog->tabs[loc].cmd[USDLG_CMD_CENTER]
527 = gtk_button_new_with_mnemonic(_("C_enter"));
528 gtk_grid_attach(GTK_GRID(vgrid),
529 pdialog->tabs[loc].cmd[USDLG_CMD_CENTER],
530 0, grid_row++, 1, 1);
531 g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_CENTER], "clicked",
532 G_CALLBACK(usdlg_cmd_center), GINT_TO_POINTER(loc));
533 gtk_widget_set_sensitive(
534 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_CENTER]), FALSE);
535
536 pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS]
537 = gtk_button_new_with_mnemonic(_("_Focus"));
538 gtk_grid_attach(GTK_GRID(vgrid),
539 pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS],
540 0, grid_row++, 1, 1);
541 g_signal_connect(pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS], "clicked",
542 G_CALLBACK(usdlg_cmd_focus), GINT_TO_POINTER(loc));
543 gtk_widget_set_sensitive(
544 GTK_WIDGET(pdialog->tabs[loc].cmd[USDLG_CMD_FOCUS]), FALSE);
545}
546
547/*************************************************************************/
550static GtkTreeStore *usdlg_tab_store_new(void)
551{
552 GtkTreeStore *store;
553 GType model_types[USDLG_COLUMNS_ALL];
554 int i;
555
556 for (i = 0; i < USDLG_COLUMNS_ALL; i++) {
557 switch (usdlg_col_types[i]) {
558 case COL_PIXBUF:
559 model_types[i] = GDK_TYPE_PIXBUF;
560 break;
561 case COL_TEXT:
562 model_types[i] = G_TYPE_STRING;
563 break;
564 case COL_INT:
565 model_types[i] = G_TYPE_INT;
566 break;
567 }
568 }
569
570 store = gtk_tree_store_newv(i, model_types);
571
572 return store;
573}
574
575/*************************************************************************/
578static bool usdlg_tab_update(struct unit_select_dialog *pdialog,
579 struct usdata_hash *ushash,
580 enum unit_select_location_mode loc)
581{
582 bool show = FALSE;
583 GtkTreeStore *store;
584
585 fc_assert_ret_val(ushash, FALSE);
586 fc_assert_ret_val(pdialog != NULL, FALSE);
587
588 store = pdialog->tabs[loc].store;
589
590 /* clear current store. */
591 gtk_tree_store_clear(GTK_TREE_STORE(store));
592
593 /* Iterate over all unit types. */
594 if (loc == SELLOC_UNITS) {
595 /* Special case - show all units on this tile in their transports. */
596 unit_type_iterate(utype) {
597 struct usdata *data;
598
599 usdata_hash_lookup(ushash, utype_index(utype), &data);
600
601 if (!data) {
602 continue;
603 }
604
606 if (unit_list_size(data->units[loc][act]) == 0) {
607 continue;
608 }
609
610 unit_list_iterate(data->units[loc][act], punit) {
611 GtkTreeIter it_unit;
612
613 usdlg_tab_append_units(pdialog, loc, act, punit, FALSE,
614 &it_unit, NULL);
616
617 /* Show this tab. */
618 show = TRUE;
621 } else {
623 struct usdata *data;
624 bool first = TRUE;
625 GtkTreeIter it_utype;
626 GtkTreePath *path;
627 int count = 0;
628
629 usdata_hash_lookup(ushash, utype_index(utype), &data);
630
631 if (!data) {
632 continue;
633 }
634
636 GtkTreeIter it_act;
637
638 if (unit_list_size(data->units[loc][act]) == 0) {
639 continue;
640 }
641
642 /* Level 1: Display unit type. */
643 if (first) {
644 usdlg_tab_append_utype(GTK_TREE_STORE(store), loc, data->utype,
645 &it_utype);
646 first = FALSE;
647 }
648
649 /* Level 2: Display unit activities. */
650 usdlg_tab_append_activity(GTK_TREE_STORE(store), loc, data->utype,
651 act, unit_list_size(data->units[loc][act]),
652 &it_act, &it_utype);
653
654 /* Level 3: Display all units with this activitiy
655 * (and transported units in further level(s)). */
656 unit_list_iterate(data->units[loc][act], punit) {
657 GtkTreeIter it_unit;
658
659 usdlg_tab_append_units(pdialog, loc, act, punit, FALSE,
660 &it_unit, &it_act);
662
663 count += unit_list_size(data->units[loc][act]);
664
665 /* Update sum of units with this type. */
666 gtk_tree_store_set(GTK_TREE_STORE(store), &it_utype, 2, count, -1);
667
668 /* Expand to the activities. */
669 path
670 = gtk_tree_model_get_path(GTK_TREE_MODEL(pdialog->tabs[loc].store),
671 &it_utype);
672 gtk_tree_view_expand_row(GTK_TREE_VIEW(pdialog->tabs[loc].view), path,
673 FALSE);
674 gtk_tree_path_free(path);
675
676 /* Show this tab. */
677 show = TRUE;
680 }
681
682 return show;
683}
684
685/*************************************************************************/
688static void usdlg_tab_append_utype(GtkTreeStore *store,
689 enum unit_select_location_mode loc,
690 const struct unit_type *putype,
691 GtkTreeIter *it)
692{
693 GdkPixbuf *pix;
694 char buf[128];
695
696 fc_assert_ret(store != NULL);
697 fc_assert_ret(putype != NULL);
698
699 /* Add this item. */
700 gtk_tree_store_append(GTK_TREE_STORE(store), it, NULL);
701
702 /* Create a icon */
703 {
704 struct canvas canvas_store = FC_STATIC_CANVAS_INIT;
705
706 canvas_store.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
708
709 put_unittype(putype, &canvas_store, 1.0, 0, 0);
712 cairo_surface_destroy(canvas_store.surface);
713 }
714
715 /* The name of the unit. */
716 fc_snprintf(buf, sizeof(buf), "%s", utype_name_translation(putype));
717
718 /* Add it to the tree. */
719 gtk_tree_store_set(GTK_TREE_STORE(store), it,
720 0, pix, /* Unit pixmap */
721 1, buf, /* Text */
722 2, -1, /* will be set later */ /* Number of units */
723 3, utype_index(putype), /* Unit type ID */
724 /* 4: not set */ /* Unit ID */
725 5, loc, /* Unit location */
726 /* 6: not set */ /* Unit activity */
727 7, ROW_UNITTYPE, /* Row type */
728 8, PANGO_STYLE_NORMAL, /* Style */
729 9, PANGO_WEIGHT_BOLD, /* Weight */
730 -1);
731 g_object_unref(pix);
732}
733
734/*************************************************************************/
737static void usdlg_tab_append_activity(GtkTreeStore *store,
738 enum unit_select_location_mode loc,
739 const struct unit_type *putype,
740 enum unit_activity act,
741 int count, GtkTreeIter *it,
742 GtkTreeIter *parent)
743{
744 char buf[128] = "";
745
746 fc_assert_ret(store != NULL);
747 fc_assert_ret(putype != NULL);
748
749 /* Add this item. */
750 gtk_tree_store_append(GTK_TREE_STORE(store), it, parent);
751
752 /* The activity. */
753 fc_snprintf(buf, sizeof(buf), "%s", get_activity_text(act));
754
755 /* Add it to the tree. */
756 gtk_tree_store_set(GTK_TREE_STORE(store), it,
757 /* 0: not set */ /* Unit pixmap */
758 1, buf, /* Text */
759 2, count, /* Number of units */
760 3, utype_index(putype), /* Unit type ID */
761 /* 4: not set */ /* Unit ID */
762 5, loc, /* Unit location */
763 6, act, /* Unit activity */
764 7, ROW_ACTIVITY, /* Row type */
765 8, PANGO_STYLE_NORMAL, /* Style */
766 9, PANGO_WEIGHT_NORMAL, /* Weight */
767 -1);
768}
769
770/*************************************************************************/
775GdkPixbuf *usdlg_get_unit_image(const struct unit *punit)
776{
777 GdkPixbuf *out;
778 struct canvas canvas_store = FC_STATIC_CANVAS_INIT;
779
780 canvas_store.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
782
783 put_unit(punit, &canvas_store, 1.0, 0, 0);
784 out = surface_get_pixbuf(canvas_store.surface,
787 cairo_surface_destroy(canvas_store.surface);
788
789 return out;
790}
791
792/*************************************************************************/
796const char *usdlg_get_unit_descr(const struct unit *punit)
797{
798 static char buf[248] = "";
799 char buf2[248] = "";
800 struct city *phome;
801
803 if (phome) {
804 fc_snprintf(buf2, sizeof(buf2), "%s", city_name_get(phome));
805 } else if (unit_owner(punit) == client_player()
807 /* TRANS: used in place of unit home city name */
808 sz_strlcpy(buf2, _("no home city"));
809 } else {
810 /* TRANS: used in place of unit home city name */
811 sz_strlcpy(buf2, _("unknown"));
812 }
813#ifdef FREECIV_DEBUG
814 /* Strings only used in debug builds, don't bother with i18n */
815 fc_snprintf(buf, sizeof(buf), "%s [Unit ID %d]\n(%s)\nCoordinates: (%d,%d)",
818 {
819 struct unit *ptrans = unit_transport_get(punit);
820
821 if (ptrans) {
822 cat_snprintf(buf, sizeof(buf), "\nTransported by unit ID %d",
823 ptrans->id);
824 }
825 }
826#else /* FREECIV_DEBUG */
827 /* TRANS: unit type and home city, e.g. "Transport\n(New Orleans)" */
828 fc_snprintf(buf, sizeof(buf), _("%s\n(%s)"), unit_name_translation(punit),
829 buf2);
830#endif /* FREECIV_DEBUG */
831
832 return buf;
833}
834
835/*************************************************************************/
838static void usdlg_tab_append_units(struct unit_select_dialog *pdialog,
839 enum unit_select_location_mode loc,
840 enum unit_activity act,
841 const struct unit *punit,
842 bool transported, GtkTreeIter *it,
843 GtkTreeIter *parent)
844{
845 const char *text;
846 GdkPixbuf *pix;
847 enum usdlg_row_types row = ROW_UNIT;
848 int style = PANGO_STYLE_NORMAL;
849 int weight = PANGO_WEIGHT_NORMAL;
850 GtkTreeStore *store;
851
852 fc_assert_ret(pdialog != NULL);
853 fc_assert_ret(punit != NULL);
854
855 store = pdialog->tabs[loc].store;
856
857
858 /* Add this item. */
859 gtk_tree_store_append(GTK_TREE_STORE(store), it, parent);
860
861 /* Unit gfx */
863
865
866 if (transported) {
867 weight = PANGO_WEIGHT_NORMAL;
868 style = PANGO_STYLE_ITALIC;
870 }
871
872 /* Add it to the tree. */
873 gtk_tree_store_set(GTK_TREE_STORE(store), it,
874 0, pix, /* Unit pixmap */
875 1, text, /* Text */
876 2, 1, /* Number of units */
877 3, utype_index(unit_type_get(punit)), /* Unit type ID */
878 4, punit->id, /* Unit ID */
879 5, loc, /* Unit location */
880 6, act, /* Unit activity */
881 7, row, /* Row type */
882 8, style, /* Style */
883 9, weight, /* Weight */
884 -1);
885 g_object_unref(pix);
886
889 GtkTreeIter it_cargo;
890
891 usdlg_tab_append_units(pdialog, loc, act, pcargo, TRUE, &it_cargo, it);
893 }
894
895 if (!transported && unit_is_in_focus(punit)
896 && get_num_units_in_focus() == 1) {
897 /* Put the keyboard focus on the selected unit. It isn't transported.
898 * Selection maps to keyboard focus since it alone is selected. */
899 fc_assert_action(pdialog->tabs[loc].path == NULL,
900 /* Don't leak memory. */
901 gtk_tree_path_free(pdialog->tabs[loc].path));
902
903 pdialog->tabs[loc].path
904 = gtk_tree_model_get_path(GTK_TREE_MODEL(store), it);
905 }
906}
907
908/*************************************************************************/
911static void usdlg_cmd_ready(GObject *object, gpointer data)
912{
913 usdlg_cmd_exec(object, data, USDLG_CMD_READY);
914}
915
916/*************************************************************************/
919static void usdlg_cmd_sentry(GObject *object, gpointer data)
920{
921 usdlg_cmd_exec(object, data, USDLG_CMD_SENTRY);
922}
923
924/*************************************************************************/
927static void usdlg_cmd_select(GObject *object, gpointer data)
928{
929 usdlg_cmd_exec(object, data, USDLG_CMD_SELECT);
930}
931
932/*************************************************************************/
935static void usdlg_cmd_deselect(GObject *object, gpointer data)
936{
937 usdlg_cmd_exec(object, data, USDLG_CMD_DESELECT);
938}
939
940/*************************************************************************/
943static void usdlg_cmd_exec(GObject *object, gpointer mode_data,
944 enum usdlg_cmd cmd)
945{
946 enum unit_select_location_mode loc_mode
947 = (enum unit_select_location_mode) GPOINTER_TO_INT(mode_data);
948 GtkTreeView *view;
949 GtkTreeSelection *selection;
950 GtkTreeModel *model;
951 GtkTreeIter it;
952 gint row;
953 struct unit_select_dialog *pdialog = usdlg_get(FALSE);
954
955 fc_assert_ret(pdialog != NULL);
956 fc_assert_ret(unit_select_location_mode_is_valid(loc_mode));
957
959 return;
960 }
961
962 view = GTK_TREE_VIEW(pdialog->tabs[loc_mode].view);
963 selection = gtk_tree_view_get_selection(view);
964
965 if (!gtk_tree_selection_get_selected(selection, &model, &it)) {
966 log_debug("No selection");
967 return;
968 }
969 gtk_tree_model_get(model, &it, USDLG_COL_ROW_TYPE, &row, -1);
970
971 switch (row) {
972 case ROW_UNITTYPE:
973 {
974 gint loc, utid;
975 struct usdata_hash *ushash;
976 struct usdata *data;
977
978 gtk_tree_model_get(model, &it, USDLG_COL_LOCATION, &loc,
979 USDLG_COL_UTID, &utid, -1);
980
981 /* We can't be sure that all units still exists - recalc the data. */
982 ushash = usdlg_data_new(pdialog->ptile);
983
984 usdata_hash_lookup(ushash, utid, &data);
985 if (data != NULL) {
987 if (unit_list_size(data->units[loc][act]) == 0) {
988 continue;
989 }
990
991 unit_list_iterate(data->units[loc][act], punit) {
995 }
996
997 /* Destroy the hash. */
998 usdlg_data_destroy(ushash);
999 }
1000 break;
1001 case ROW_ACTIVITY:
1002 {
1003 gint loc, act, utid;
1004 struct usdata_hash *ushash;
1005 struct usdata *data;
1006
1007 gtk_tree_model_get(model, &it, USDLG_COL_ACTIVITY, &act,
1008 USDLG_COL_LOCATION, &loc, USDLG_COL_UTID, &utid, -1);
1009
1010 /* We can't be sure that all units still exists - recalc the data. */
1011 ushash = usdlg_data_new(pdialog->ptile);
1012
1013 usdata_hash_lookup(ushash, utid, &data);
1014 if (data != NULL
1015 && unit_list_size(data->units[loc][act]) != 0) {
1016 unit_list_iterate(data->units[loc][act], punit) {
1019 }
1020
1021 /* Destroy the hash. */
1022 usdlg_data_destroy(ushash);
1023 }
1024 break;
1025 case ROW_UNIT:
1027 {
1028 gint uid;
1029 struct unit *punit;
1030
1031 gtk_tree_model_get(model, &it, USDLG_COL_UID, &uid, -1);
1032
1034
1035 if (!punit) {
1036 log_debug("Unit vanished (Unit ID %d)!", uid);
1037 return;
1038 }
1039
1041 }
1042 break;
1043 }
1044
1045 /* Update focus. */
1047 /* Refresh dialog. */
1048 usdlg_refresh(pdialog);
1049}
1050
1051/*************************************************************************/
1054static void usdlg_cmd_exec_unit(struct unit *punit, enum usdlg_cmd cmd)
1055{
1057
1058 switch (cmd) {
1059 case USDLG_CMD_SELECT:
1060 if (!unit_is_in_focus(punit)) {
1062 }
1063 break;
1064 case USDLG_CMD_DESELECT:
1065 if (unit_is_in_focus(punit)) {
1067 }
1068 break;
1069 case USDLG_CMD_READY:
1070 if (punit->activity != ACTIVITY_IDLE) {
1071 request_new_unit_activity(punit, ACTIVITY_IDLE);
1072 }
1073 break;
1074 case USDLG_CMD_SENTRY:
1075 if (punit->activity != ACTIVITY_SENTRY) {
1076 request_new_unit_activity(punit, ACTIVITY_SENTRY);
1077 }
1078 break;
1079 case USDLG_CMD_CENTER:
1080 case USDLG_CMD_FOCUS:
1081 /* Nothing here. It is done in its own functions. */
1082 break;
1083 case USDLG_CMD_LAST:
1084 /* Should never happen. */
1086 break;
1087 }
1088}
1089
1090/*************************************************************************/
1093static void usdlg_cmd_center(GObject *object, gpointer data)
1094{
1095 enum unit_select_location_mode loc
1096 = (enum unit_select_location_mode) GPOINTER_TO_INT(data);
1097 GtkTreeView *view;
1098 GtkTreeSelection *selection;
1099 GtkTreeModel *model;
1100 GtkTreeIter it;
1101 gint row;
1102 struct unit_select_dialog *pdialog = usdlg_get(FALSE);
1103
1104 fc_assert_ret(pdialog != NULL);
1105 fc_assert_ret(unit_select_location_mode_is_valid(loc));
1106
1107 view = GTK_TREE_VIEW(pdialog->tabs[loc].view);
1108 selection = gtk_tree_view_get_selection(view);
1109
1110 if (!gtk_tree_selection_get_selected(selection, &model, &it)) {
1111 log_debug("No selection");
1112 return;
1113 }
1114 gtk_tree_model_get(model, &it, USDLG_COL_ROW_TYPE, &row, -1);
1115
1116 if (row == ROW_UNIT || row == ROW_UNIT_TRANSPORTED) {
1117 gint uid;
1118 struct unit *punit;
1119
1120 gtk_tree_model_get(model, &it, USDLG_COL_UID, &uid, -1);
1121
1123 if (punit) {
1125 }
1126 }
1127}
1128
1129/*************************************************************************/
1132static void usdlg_cmd_focus(GObject *object, gpointer data)
1133{
1134 enum unit_select_location_mode loc
1135 = (enum unit_select_location_mode) GPOINTER_TO_INT(data);
1136 struct unit_select_dialog *pdialog = usdlg_get(FALSE);
1137
1138 fc_assert_ret(pdialog != NULL);
1139 fc_assert_ret(unit_select_location_mode_is_valid(loc));
1140
1141 usdlg_cmd_focus_real(GTK_TREE_VIEW(pdialog->tabs[loc].view));
1142}
1143
1144/*************************************************************************/
1147static void usdlg_cmd_row_activated(GtkTreeView *view, GtkTreePath *path,
1148 GtkTreeViewColumn *col, gpointer data)
1149{
1151}
1152
1153/*************************************************************************/
1156static void usdlg_cmd_focus_real(GtkTreeView *view)
1157{
1158 GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
1159 GtkTreeModel *model;
1160 GtkTreeIter it;
1161 gint row;
1162
1164 return;
1165 }
1166
1167 if (!gtk_tree_selection_get_selected(selection, &model, &it)) {
1168 log_debug("No selection");
1169 return;
1170 }
1171 gtk_tree_model_get(model, &it, USDLG_COL_ROW_TYPE, &row, -1);
1172
1173 if (row == ROW_UNIT || row == ROW_UNIT_TRANSPORTED) {
1174 gint uid;
1175 struct unit *punit;
1176
1177 gtk_tree_model_get(model, &it, USDLG_COL_UID, &uid, -1);
1178
1180 if (punit && unit_owner(punit) == client_player()) {
1182 usdlg_destroy();
1183 }
1184 }
1185}
1186
1187/*************************************************************************/
1190static void usdlg_cmd_cursor_changed(GtkTreeView *view, gpointer data)
1191{
1192 enum unit_select_location_mode loc
1193 = (enum unit_select_location_mode) GPOINTER_TO_INT(data);
1194 GtkTreeSelection *selection;
1195 GtkTreeModel *model;
1196 GtkTreeIter it;
1197 gint row, uid;
1198 struct unit_select_dialog *pdialog = usdlg_get(FALSE);
1199 struct unit *punit;
1200 bool cmd_status[USDLG_CMD_LAST];
1201 int cmd_id;
1202
1203 fc_assert_ret(unit_select_location_mode_is_valid(loc));
1204
1205 if (pdialog == NULL) {
1206 /* Dialog closed, nothing we can do */
1207 return;
1208 }
1209
1210 selection = gtk_tree_view_get_selection(view);
1211 if (!gtk_tree_selection_get_selected(selection, &model, &it)) {
1212 log_debug("No selection");
1213 return;
1214 }
1215 gtk_tree_model_get(model, &it, USDLG_COL_ROW_TYPE, &row, USDLG_COL_UID,
1216 &uid, -1);
1217
1218 switch (row) {
1219 case ROW_UNITTYPE:
1220 case ROW_ACTIVITY:
1221 /* Button status for rows unittype and activity:
1222 * player observer
1223 * ready TRUE FALSE
1224 * sentry TRUE FALSE
1225 * select TRUE FALSE
1226 * deselect TRUE FALSE
1227 * center FALSE FALSE
1228 * focus FALSE FALSE */
1230 cmd_status[USDLG_CMD_READY] = TRUE;
1231 cmd_status[USDLG_CMD_SENTRY] = TRUE;
1232 cmd_status[USDLG_CMD_SELECT] = TRUE;
1233 cmd_status[USDLG_CMD_DESELECT] = TRUE;
1234 } else {
1235 cmd_status[USDLG_CMD_READY] = FALSE;
1236 cmd_status[USDLG_CMD_SENTRY] = FALSE;
1237 cmd_status[USDLG_CMD_SELECT] = FALSE;
1238 cmd_status[USDLG_CMD_DESELECT] = FALSE;
1239 }
1240
1241 cmd_status[USDLG_CMD_CENTER] = FALSE;
1242 cmd_status[USDLG_CMD_FOCUS] = FALSE;
1243 break;
1244 case ROW_UNIT:
1246 /* Button status for rows unit and unit (transported):
1247 * player observer
1248 * ready !IDLE FALSE
1249 * sentry !SENTRY FALSE
1250 * select !FOCUS FALSE
1251 * deselect FOCUS FALSE
1252 * center TRUE TRUE
1253 * focus !FOCUS FALSE */
1255
1257 if (punit->activity == ACTIVITY_IDLE) {
1258 cmd_status[USDLG_CMD_READY] = FALSE;
1259 } else {
1260 cmd_status[USDLG_CMD_READY] = TRUE;
1261 }
1262
1263 if (punit->activity == ACTIVITY_SENTRY) {
1264 cmd_status[USDLG_CMD_SENTRY] = FALSE;
1265 } else {
1266 cmd_status[USDLG_CMD_SENTRY] = TRUE;
1267 }
1268
1269 if (!unit_is_in_focus(punit)) {
1270 cmd_status[USDLG_CMD_SELECT] = TRUE;
1271 cmd_status[USDLG_CMD_DESELECT] = FALSE;
1272 cmd_status[USDLG_CMD_FOCUS] = TRUE;
1273 } else {
1274 cmd_status[USDLG_CMD_SELECT] = FALSE;
1275 cmd_status[USDLG_CMD_DESELECT] = TRUE;
1276 cmd_status[USDLG_CMD_FOCUS] = FALSE;
1277 }
1278 } else {
1279 cmd_status[USDLG_CMD_READY] = FALSE;
1280 cmd_status[USDLG_CMD_SENTRY] = FALSE;
1281
1282 cmd_status[USDLG_CMD_SELECT] = FALSE;
1283 cmd_status[USDLG_CMD_DESELECT] = FALSE;
1284
1285 cmd_status[USDLG_CMD_FOCUS] = FALSE;
1286 }
1287
1288 cmd_status[USDLG_CMD_CENTER] = TRUE;
1289 break;
1290
1291 default:
1293 for (cmd_id = 0; cmd_id < USDLG_CMD_LAST; cmd_id++) {
1294 cmd_status[cmd_id] = FALSE;
1295 }
1296 break;
1297 }
1298
1299 /* Set widget status. */
1300 for (cmd_id = 0; cmd_id < USDLG_CMD_LAST; cmd_id++) {
1301 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->tabs[loc].cmd[cmd_id]),
1302 cmd_status[cmd_id]);
1303 }
1304}
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
bool can_client_control(void)
bool client_is_global_observer(void)
bool can_client_change_view(void)
#define client_player()
bool unit_is_in_focus(const struct unit *punit)
Definition control.c:389
void unit_focus_add(struct unit *punit)
Definition control.c:562
void unit_focus_set(struct unit *punit)
Definition control.c:507
void unit_focus_remove(struct unit *punit)
Definition control.c:592
struct unit * head_of_units_in_focus(void)
Definition control.c:411
int get_num_units_in_focus(void)
Definition control.c:185
void unit_focus_update(void)
Definition control.c:790
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1854
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:73
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
struct unit * game_unit_by_number(int id)
Definition game.c:111
struct city * game_city_by_number(int id)
Definition game.c:102
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:27
struct tile * loc
Definition citydlg.c:220
GtkWidget * toplevel
Definition gui_main.c:124
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:281
void intl_slist(int n, const char **s, bool *done)
Definition gui_stuff.c:105
const char * title
Definition repodlgs.c:1313
GdkPixbuf * surface_get_pixbuf(cairo_surface_t *surf, int width, int height)
Definition sprite.c:418
#define USDLG_COL_LOCATION
Definition unitselect.c:66
static void usdlg_cmd_ready(GObject *object, gpointer data)
Definition unitselect.c:901
static void usdlg_cmd_deselect(GObject *object, gpointer data)
Definition unitselect.c:925
static void usdlg_cmd_center(GObject *object, gpointer data)
#define USDLG_COL_ROW_TYPE
Definition unitselect.c:68
static void usdlg_cmd_cursor_changed(GtkTreeView *view, gpointer data)
GdkPixbuf * usdlg_get_unit_image(const struct unit *punit)
Definition unitselect.c:765
const char * usdlg_get_unit_descr(const struct unit *punit)
Definition unitselect.c:786
static void usdlg_tab_append_units(struct unit_select_dialog *pdialog, enum unit_select_location_mode loc, enum unit_activity act, const struct unit *punit, bool transported, GtkTreeIter *it, GtkTreeIter *parent)
Definition unitselect.c:828
static void usdlg_tile(struct unit_select_dialog *pdialog, struct tile *ptile)
Definition unitselect.c:313
#define USDLG_COL_UTID
Definition unitselect.c:64
static void usdlg_cmd_sentry(GObject *object, gpointer data)
Definition unitselect.c:909
static struct unit_select_dialog * usdlg_get(bool create)
Definition unitselect.c:223
#define USDLG_COL_STYLE
Definition unitselect.c:71
#define USDLG_COL_UID
Definition unitselect.c:65
static void usdlg_cmd_exec_unit(struct unit *punit, enum usdlg_cmd cmd)
static void usdlg_tab_append_activity(GtkTreeStore *store, enum unit_select_location_mode loc, const struct unit_type *putype, enum unit_activity act, int count, GtkTreeIter *it, GtkTreeIter *parent)
Definition unitselect.c:727
static struct unit_select_dialog * usdlg_create(void)
Definition unitselect.c:241
static void usdlg_cmd_focus(GObject *object, gpointer data)
#define USDLG_COL_ACTIVITY
Definition unitselect.c:67
static void usdlg_cmd_exec(GObject *object, gpointer mode_data, enum usdlg_cmd cmd)
Definition unitselect.c:933
#define USDLG_COLUMNS_ALL
Definition unitselect.c:73
static void usdlg_destroy_callback(GObject *object, gpointer data)
Definition unitselect.c:305
usdlg_row_types
Definition unitselect.c:54
@ ROW_UNITTYPE
Definition unitselect.c:55
@ ROW_UNIT_TRANSPORTED
Definition unitselect.c:58
@ ROW_UNIT
Definition unitselect.c:57
@ ROW_ACTIVITY
Definition unitselect.c:56
static void usdlg_cmd_select(GObject *object, gpointer data)
Definition unitselect.c:917
static const char * usdlg_col_titles[USDLG_COLUMNS_ALL]
Definition unitselect.c:94
static void usdlg_cmd_focus_real(GtkTreeView *view)
#define USDLG_COLUMNS_SHOW
Definition unitselect.c:78
static struct unit_select_dialog * unit_select_dlg
Definition unitselect.c:141
enum usdlg_column_types usdlg_col_types[USDLG_COLUMNS_ALL]
Definition unitselect.c:81
void unit_select_dialog_popup_main(struct tile *ptile, bool create)
Definition unitselect.c:193
static void usdlg_cmd_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
void unit_select_dialog_popdown(void)
Definition unitselect.c:214
static void usdlg_tab_append_utype(GtkTreeStore *store, enum unit_select_location_mode loc, const struct unit_type *putype, GtkTreeIter *it)
Definition unitselect.c:678
#define USDLG_COL_WEIGHT
Definition unitselect.c:72
static void usdlg_tab_select(struct unit_select_dialog *pdialog, const char *title, enum unit_select_location_mode loc)
Definition unitselect.c:387
static bool usdlg_tab_update(struct unit_select_dialog *pdialog, struct usdata_hash *ushash, enum unit_select_location_mode loc)
Definition unitselect.c:568
static void usdlg_refresh(struct unit_select_dialog *pdialog)
Definition unitselect.c:338
usdlg_column_types
Definition unitselect.c:48
@ COL_INT
Definition unitselect.c:51
@ COL_TEXT
Definition unitselect.c:50
@ COL_PIXBUF
Definition unitselect.c:49
usdlg_cmd
Definition unitselect.c:107
@ USDLG_CMD_FOCUS
Definition unitselect.c:113
@ USDLG_CMD_SENTRY
Definition unitselect.c:111
@ USDLG_CMD_LAST
Definition unitselect.c:114
@ USDLG_CMD_CENTER
Definition unitselect.c:112
@ USDLG_CMD_READY
Definition unitselect.c:110
@ USDLG_CMD_DESELECT
Definition unitselect.c:109
@ USDLG_CMD_SELECT
Definition unitselect.c:108
static void usdlg_destroy(void)
Definition unitselect.c:293
static GtkTreeStore * usdlg_tab_store_new(void)
Definition unitselect.c:540
@ USDLG_CMD_LAST
Definition unitselect.c:114
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_debug(message,...)
Definition log.h:115
struct tile * get_center_tile_mapcanvas(void)
void put_unit(const struct unit *punit, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void put_unittype(const struct unit_type *putype, struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y)
void center_tile_mapcanvas(const struct tile *ptile)
#define fc_calloc(n, esz)
Definition mem.h:38
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1205
#define ARRAY_SIZE(x)
Definition shared.h:85
cairo_surface_t * surface
Definition canvas.h:22
Definition city.h:309
Definition tile.h:49
struct tile * ptile
Definition unitselect.c:118
GtkTreePath * path
Definition unitselect.c:127
GtkWidget * shell
Definition unitselect.c:121
GtkWidget * view
Definition unitselect.c:126
GtkWidget * cmd[USDLG_CMD_LAST]
Definition unitselect.c:136
GtkWidget * notebook
Definition unitselect.c:122
GtkTreeStore * store
Definition unitselect.c:125
struct unit_select_dialog::@156 units
GtkWidget * page
Definition unitselect.c:132
struct unit_select_dialog::@157 tabs[SELLOC_COUNT]
Definition unit.h:138
enum unit_activity activity
Definition unit.h:157
int id
Definition unit.h:145
int homecity
Definition unit.h:146
struct unit_list * units[SELLOC_COUNT][ACTIVITY_LAST]
const struct unit_type * utype
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:995
#define sz_strlcpy(dest, src)
Definition support.h:167
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define TILE_XY(ptile)
Definition tile.h:42
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:752
int tileset_full_tile_width(const struct tileset *t)
Definition tilespec.c:739
int get_transporter_occupancy(const struct unit *ptrans)
Definition unit.c:1767
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2425
const char * get_activity_text(enum unit_activity activity)
Definition unit.c:625
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
Definition unit.c:2435
#define unit_tile(_pu)
Definition unit.h:395
#define unit_owner(_pu)
Definition unit.h:394
#define activity_type_iterate(_act_)
Definition unit.h:288
#define activity_type_iterate_end
Definition unit.h:292
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
struct usdata_hash * usdlg_data_new(const struct tile *ptile)
void usdlg_data_destroy(struct usdata_hash *ushash)
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_name_translation(const struct unit *punit)
Definition unittype.c:1621
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
#define unit_type_iterate(_p)
Definition unittype.h:841
#define unit_type_iterate_end
Definition unittype.h:848
#define show(id)
Definition widget.h:235