Freeciv-3.3
Loading...
Searching...
No Matches
spaceshipdlg.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 <stdio.h>
19#include <stdlib.h>
20
21#include <gtk/gtk.h>
22
23/* utility */
24#include "fcintl.h"
25#include "log.h"
26#include "mem.h"
27#include "shared.h"
28#include "support.h"
29
30/* common */
31#include "game.h"
32#include "map.h"
33#include "packets.h"
34#include "player.h"
35#include "spaceship.h"
36#include "victory.h"
37
38/* client */
39#include "client_main.h"
40#include "climisc.h"
41#include "colors.h"
42#include "options.h"
43#include "text.h"
44#include "tilespec.h"
45
46/* client/gui-gtk-5.0 */
47#include "dialogs.h"
48#include "graphics.h"
49#include "gui_main.h"
50#include "gui_stuff.h"
51#include "helpdlg.h"
52#include "inputdlg.h"
53#include "mapctrl.h"
54#include "mapview.h"
55#include "repodlgs.h"
56
57#include "spaceshipdlg.h"
58
59struct spaceship_dialog {
60 struct player *pplayer;
61 struct gui_dialog *shell;
65};
66
67#define SPECLIST_TAG dialog
68#define SPECLIST_TYPE struct spaceship_dialog
69#include "speclist.h"
70
71#define dialog_list_iterate(dialoglist, pdialog) \
72 TYPED_LIST_ITERATE(struct spaceship_dialog, dialoglist, pdialog)
73#define dialog_list_iterate_end LIST_ITERATE_END
74
75static struct dialog_list *dialog_list;
76
79 *pplayer);
80
81static void spaceship_dialog_update_image(struct spaceship_dialog *pdialog);
82static void spaceship_dialog_update_info(struct spaceship_dialog *pdialog);
83
84/************************************************************************/
91
92/************************************************************************/
99
100/************************************************************************/
104{
106 if (pdialog->pplayer == pplayer) {
107 return pdialog;
108 }
110
111 return NULL;
112}
113
114/************************************************************************/
118{
119 struct spaceship_dialog *pdialog;
120 struct player_spaceship *pship;
121
122 if (!(pdialog = get_spaceship_dialog(pplayer))) {
123 return;
124 }
125
126 pship = &(pdialog->pplayer->spaceship);
127
129 && pplayer == client.conn.playing
130 && pship->state == SSHIP_STARTED
131 && pship->success_rate > 0.0) {
134 } else {
137 }
138
141}
142
143/************************************************************************/
146void popup_spaceship_dialog(struct player *pplayer)
147{
148 struct spaceship_dialog *pdialog;
149
150 if (!(pdialog = get_spaceship_dialog(pplayer))) {
152 }
153
154 gui_dialog_raise(pdialog->shell);
155}
156
157/************************************************************************/
161{
162 struct spaceship_dialog *pdialog;
163
164 if ((pdialog = get_spaceship_dialog(pplayer))) {
165 gui_dialog_destroy(pdialog->shell);
166 }
167}
168
169/************************************************************************/
173 int width, int height,
174 gpointer data)
175{
176 struct spaceship_dialog *pdialog = (struct spaceship_dialog *)data;
177 struct canvas store = FC_STATIC_CANVAS_INIT;
178
179 store.drawable = cr;
180
181 put_spaceship(&store, 0, 0, pdialog->pplayer);
182}
183
184/************************************************************************/
188{
189 struct spaceship_dialog *pdialog = (struct spaceship_dialog *)data;
190
192
193 free(pdialog);
194}
195
196/************************************************************************/
199static void spaceship_response(struct gui_dialog *dlg, int response,
200 gpointer data)
201{
202 switch (response) {
205 break;
206
207 default:
209 break;
210 }
211}
212
213/************************************************************************/
217{
218 struct spaceship_dialog *pdialog;
219 GtkWidget *hgrid, *frame;
220 int w, h;
221 int grid_col = 0;
222
223 pdialog = fc_malloc(sizeof(struct spaceship_dialog));
224 pdialog->pplayer = pplayer;
225
228
229 gui_dialog_add_button(pdialog->shell, "window-close", _("_Close"),
231 gui_dialog_add_button(pdialog->shell, NULL, _("_Launch"),
233
234 g_signal_connect(pdialog->shell->grid, "destroy",
237
241
242 frame = gtk_frame_new(NULL);
243 gtk_grid_attach(GTK_GRID(hgrid), frame, grid_col++, 0, 1, 1);
244
249
252
255
257
261
262 gtk_grid_attach(GTK_GRID(hgrid), pdialog->info_label, grid_col++, 0, 1, 1);
263 gtk_widget_set_name(pdialog->info_label, "spaceship_label");
264
266
268
269 gui_dialog_show_all(pdialog->shell);
270
272
273 return pdialog;
274}
275
276/************************************************************************/
284
285/************************************************************************/
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
struct civclient client
char * incite_cost
Definition comments.c:76
@ VC_SPACERACE
Definition fc_types.h:979
#define _(String)
Definition fcintl.h:67
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * top_notebook
Definition gui_main.c:130
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:954
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, int response, bool setting)
Definition gui_stuff.c:760
static void spaceship_dialog_update_info(struct spaceship_dialog *pdialog)
static struct spaceship_dialog * get_spaceship_dialog(struct player *pplayer)
void popdown_spaceship_dialog(struct player *pplayer)
static void spaceship_destroy_callback(GtkWidget *w, gpointer data)
#define dialog_list_iterate_end
void spaceship_dialog_init(void)
#define dialog_list_iterate(dialoglist, pdialog)
static struct dialog_list * dialog_list
static void spaceship_dialog_update_image(struct spaceship_dialog *pdialog)
void spaceship_dialog_done(void)
void popup_spaceship_dialog(struct player *pplayer)
void refresh_spaceship_dialog(struct player *pplayer)
static struct spaceship_dialog * create_spaceship_dialog(struct player *pplayer)
static void spaceship_response(struct gui_dialog *dlg, int response, gpointer data)
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1105
static void spaceship_image_canvas_draw(GtkDrawingArea *w, cairo_t *cr, int width, int height, gpointer data)
void get_spaceship_dimensions(int *width, int *height)
void put_spaceship(struct canvas *pcanvas, int canvas_x, int canvas_y, const struct player *pplayer)
#define fc_malloc(sz)
Definition mem.h:34
int send_packet_spaceship_launch(struct connection *pc)
const char * player_name(const struct player *pplayer)
Definition player.c:895
@ SSHIP_STARTED
Definition spaceship.h:84
cairo_t * drawable
Definition canvas.h:24
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
GtkWidget * grid
Definition gui_stuff.h:71
struct player_spaceship spaceship
Definition player.h:286
GtkWidget * image_canvas
struct gui_dialog * shell
struct player * pplayer
GtkWidget * info_label
GtkWidget * main_form
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * get_spaceship_descr(struct player_spaceship *pship)
Definition text.c:1547
bool victory_enabled(enum victory_condition_type victory)
Definition victory.c:26