Freeciv-3.2
Loading...
Searching...
No Matches
unitselunitdlg.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 "game.h"
25#include "movement.h"
26#include "unit.h"
27
28/* client */
29#include "control.h"
30#include "tilespec.h"
31
32/* client/gui-gtk-3.22 */
33#include "gui_main.h"
34#include "gui_stuff.h"
35#include "sprite.h"
36#include "unitselect.h"
37
38#include "unitselunitdlg.h"
39
44
45/************************************************************************/
58
59/************************************************************************/
66
67/************************************************************************/
70bool select_tgt_unit(struct unit *actor, struct tile *ptile,
71 struct unit_list *potential_tgt_units,
73 const gchar *dlg_title,
74 const gchar *actor_label,
75 const gchar *tgt_label,
76 const gchar *do_label,
78{
81 GtkWidget *box;
82 GtkWidget *icon;
88 struct sprite *spr;
89 const struct unit_type *actor_type = unit_type_get(actor);
90 int tcount;
91 const struct unit *default_unit = NULL;
92
94 _("Close"), GTK_RESPONSE_NO,
96 NULL);
100
104 box = gtk_grid_new();
107
109 gtk_grid_attach(GTK_GRID(box), lbl, 0, 0, 1, 1);
110
113 if (spr != NULL) {
115 } else {
116 icon = gtk_image_new();
117 }
118 gtk_grid_attach(GTK_GRID(box), icon, 1, 0, 1, 1);
119
121 gtk_grid_attach(GTK_GRID(box), lbl, 2, 0, 1, 1);
122
124
127
130
131 box = gtk_grid_new();
132
133 tcount = 0;
136
138 = fc_malloc(sizeof(struct unit_sel_unit_cb_data));
139
140 cbdata->tp_id = ptgt->id;
141 cbdata->dlg = dlg;
142
145 if (first_option == NULL) {
149 }
150 /* The lists must be the same length if they contain the same
151 * elements. */
156 "The radio button for '%s' is broken.",
158 g_signal_connect(radio, "toggled",
160 g_signal_connect(radio, "destroy",
162 if (ptgt == suggested_tgt_unit) {
165 }
166 gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1);
167
169 if (tubuf != NULL) {
172 } else {
173 icon = gtk_image_new();
174 }
175 gtk_grid_attach(GTK_GRID(box), icon, 1, tcount, 1, 1);
176
178 gtk_grid_attach(GTK_GRID(box), lbl, 2, tcount, 1, 1);
179
180 tcount++;
183
186
189 main_box);
190
192 g_object_set_data(G_OBJECT(dlg), "tile", ptile);
193
194 /* This function should never be called so that there would be no unit to select,
195 * and where there is unit to select, one of them gets selected as the default. */
197 if (default_unit != NULL) { /* Compiler still wants this */
199 }
200
201 g_signal_connect(dlg, "response", do_callback, actor);
202
205
206 return TRUE;
207}
char * incite_cost
Definition comments.c:75
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
#define _(String)
Definition fcintl.h:67
GtkWidget * toplevel
Definition gui_main.c:125
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
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
bool select_tgt_unit(struct unit *actor, struct tile *ptile, struct unit_list *potential_tgt_units, struct unit *suggested_tgt_unit, const gchar *dlg_title, const gchar *actor_label, const gchar *tgt_label, const gchar *do_label, GCallback do_callback)
static void unit_sel_unit_toggled(GtkToggleButton *tb, gpointer userdata)
static void unit_sel_unit_destroyed(GtkWidget *radio, gpointer userdata)
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define fc_malloc(sz)
Definition mem.h:34
Definition tile.h:50
Definition unit.h:138
enum unit_activity activity
Definition unit.h:157
int id
Definition unit.h:145
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6805
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1587
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560