Freeciv-3.3
Loading...
Searching...
No Matches
infradlg.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 "extras.h"
25#include "game.h"
26
27/* client */
28#include "client_main.h"
29#include "dialogs_g.h"
30#include "mapview_common.h"
31
32/* client/gui-gtk-5.0 */
33#include "gui_main.h"
34#include "gui_stuff.h"
35
36#include "infradlg.h"
37
41static int infra_rows = 0;
42
43struct infra_cb_data {
44 struct tile *ptile;
45 struct extra_type *pextra;
46};
47
48/************************************************************************/
51static bool infra_dialog_open(void)
52{
53 return infra_list_box != NULL;
54}
55
56/************************************************************************/
70
71/************************************************************************/
81
82/************************************************************************/
86{
87 GtkWidget *dlg;
90 int grid_row = 0;
91
92 if (infra_dialog_open()) {
93 /* One infra dialog already open. */
94 return;
95 }
96
97 dlg = gtk_dialog_new_with_buttons(_("Place infrastructure"), NULL, 0,
98 _("Close"), GTK_RESPONSE_NO,
99 NULL);
100
104
108
109 instruction_label = gtk_label_new(_("First click a tile."));
111
114
115 points_label = gtk_label_new(_("- infrapoints"));
117
120
123
125 main_box);
126
129
132
134}
135
136/************************************************************************/
140{
141 if (infra_dialog_open()) {
142 char buffer[100];
143
144 fc_snprintf(buffer, sizeof(buffer),
145 PL_("%d infrapoint", "%d infrapoints",
148
150 }
151}
152
153/************************************************************************/
157{
158 return infra_list_box != NULL;
159}
160
161/************************************************************************/
165{
166 if (infra_list_box != NULL) {
168
169 while (child != NULL) {
172 }
173 }
174 infra_rows = 0;
175
177 return;
178 }
179
181
185 struct infra_cb_data *cbdata = fc_malloc(sizeof(struct infra_cb_data));
186
187 cbdata->ptile = ptile;
188 cbdata->pextra = pextra;
189
190 g_signal_connect(but, "clicked",
193 infra_rows++;
194 }
196
197 if (infra_rows <= 0) {
199 _("No infra possible. Select another tile."));
200 } else {
202 _("Select infra for the tile, or another tile."));
203 }
204
206}
bool client_map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
struct civclient client
char * incite_cost
Definition comments.c:76
bool player_can_place_extra(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
Definition extras.c:490
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_iterate_end
Definition extras.h:321
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
GtkWidget * toplevel
Definition gui_main.c:126
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
static GtkWidget * instruction_label
Definition infradlg.c:39
static void infra_response_callback(GtkWidget *dlg, gint arg)
Definition infradlg.c:59
bool infra_placement_mode(void)
Definition infradlg.c:155
static bool infra_dialog_open(void)
Definition infradlg.c:51
static void infra_selected_callback(GtkButton *but, gpointer userdata)
Definition infradlg.c:74
void infra_placement_set_tile(struct tile *ptile)
Definition infradlg.c:163
static GtkWidget * points_label
Definition infradlg.c:40
static int infra_rows
Definition infradlg.c:41
void update_infra_dialog(void)
Definition infradlg.c:138
void infra_dialog_popup(void)
Definition infradlg.c:85
static GtkWidget * infra_list_box
Definition infradlg.c:38
void client_infratile_set(struct tile *ptile)
#define fc_malloc(sz)
Definition mem.h:34
int dsend_packet_player_place_infra(struct connection *pc, int tile, int extra)
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
struct extra_type * pextra
Definition infradlg.c:45
struct tile * ptile
Definition infradlg.c:44
int infra_points
Definition player.h:67
struct player_economic economic
Definition player.h:284
Definition tile.h:50
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46