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-3.22 */
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
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 cairo_t *cr,
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 return TRUE;
184}
185
186/************************************************************************/
190{
191 struct spaceship_dialog *pdialog = (struct spaceship_dialog *)data;
192
194
195 free(pdialog);
196}
197
198/************************************************************************/
201static void spaceship_response(struct gui_dialog *dlg, int response,
202 gpointer data)
203{
204 switch (response) {
207 break;
208
209 default:
211 break;
212 }
213}
214
215/************************************************************************/
219{
220 struct spaceship_dialog *pdialog;
221 GtkWidget *hbox, *frame;
222 int w, h;
223
224 pdialog = fc_malloc(sizeof(struct spaceship_dialog));
225 pdialog->pplayer = pplayer;
226
229
230 gui_dialog_add_button(pdialog->shell, "window-close", _("_Close"),
232 gui_dialog_add_button(pdialog->shell, NULL, _("_Launch"),
234
235 g_signal_connect(pdialog->shell->vbox, "destroy",
238
239 hbox = gtk_grid_new();
242
243 frame = gtk_frame_new(NULL);
245
250
254
255 g_signal_connect(pdialog->image_canvas, "draw",
257
259
263
265 gtk_widget_set_name(pdialog->info_label, "spaceship_label");
266
268
270
271 gui_dialog_show_all(pdialog->shell);
272
274
275 return pdialog;
276}
277
278/************************************************************************/
286
287/************************************************************************/
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 gboolean spaceship_image_canvas_expose(GtkWidget *widget, cairo_t *cr, gpointer data)
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 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 * vbox
Definition gui_stuff.h:72
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