Replaced deprecated gtk_menu_popup() calls with modern constructs in gtk3.22-client
[freeciv.git] / client / tilespec.h
blob10737d1f8229af5650f8d75caa4572c39cce4956
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.
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 ***********************************************************************/
14 /***********************************************************************
15 Reading and using the tilespec files, which describe
16 the files and contents of tilesets.
17 ***********************************************************************/
18 #ifndef FC__TILESPEC_H
19 #define FC__TILESPEC_H
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
25 /* utility */
26 #include "log.h" /* enum log_level */
28 /* common */
29 #include "city.h" /* enum citizen_category */
30 #include "fc_types.h"
32 #include "options.h"
34 struct sprite; /* opaque; gui-dep */
36 struct base_type;
37 struct resource;
39 /* Create the sprite_vector type. */
40 #define SPECVEC_TAG sprite
41 #define SPECVEC_TYPE struct sprite *
42 #include "specvec.h"
43 #define sprite_vector_iterate(sprite_vec, psprite) \
44 TYPED_VECTOR_ITERATE(struct sprite *, sprite_vec, psprite)
45 #define sprite_vector_iterate_end VECTOR_ITERATE_END
47 #define SPECENUM_NAME ts_type
48 #define SPECENUM_VALUE0 TS_OVERHEAD
49 #define SPECENUM_VALUE0NAME N_("Overhead")
50 #define SPECENUM_VALUE1 TS_ISOMETRIC
51 #define SPECENUM_VALUE1NAME N_("Isometric")
52 #include "specenum_gen.h"
54 #define SPECENUM_NAME fog_style
55 /* Fog is automatically appended by the code. */
56 #define SPECENUM_VALUE0 FOG_AUTO
57 #define SPECENUM_VALUE0NAME "Auto"
58 /* A single fog sprite is provided by the tileset (tx.fog). */
59 #define SPECENUM_VALUE1 FOG_SPRITE
60 #define SPECENUM_VALUE1NAME "Sprite"
61 /* No fog, or fog derived from darkness style. */
62 #define SPECENUM_VALUE2 FOG_DARKNESS
63 #define SPECENUM_VALUE2NAME "Darkness"
64 #include "specenum_gen.h"
66 #define SPECENUM_NAME darkness_style
67 /* No darkness sprites are drawn. */
68 #define SPECENUM_VALUE0 DARKNESS_NONE
69 #define SPECENUM_VALUE0NAME "None"
70 /* 1 sprite that is split into 4 parts and treated as a darkness4. Only
71 * works in iso-view. */
72 #define SPECENUM_VALUE1 DARKNESS_ISORECT
73 #define SPECENUM_VALUE1NAME "IsoRect"
74 /* 4 sprites, one per direction. More than one sprite per tile may be
75 * drawn. */
76 #define SPECENUM_VALUE2 DARKNESS_CARD_SINGLE
77 #define SPECENUM_VALUE2NAME "CardinalSingle"
78 /* 15=2^4-1 sprites. A single sprite is drawn, chosen based on whether
79 * there's darkness in _each_ of the cardinal directions. */
80 #define SPECENUM_VALUE3 DARKNESS_CARD_FULL
81 #define SPECENUM_VALUE3NAME "CardinalFull"
82 /* Corner darkness & fog. 3^4 = 81 sprites. */
83 #define SPECENUM_VALUE4 DARKNESS_CORNER
84 #define SPECENUM_VALUE4NAME "Corner"
85 #include "specenum_gen.h"
87 /* An edge is the border between two tiles. This structure represents one
88 * edge. The tiles are given in the same order as the enumeration name. */
89 enum edge_type {
90 EDGE_NS, /* North and south */
91 EDGE_WE, /* West and east */
92 EDGE_UD, /* Up and down (nw/se), for hex_width tilesets */
93 EDGE_LR, /* Left and right (ne/sw), for hex_height tilesets */
94 EDGE_COUNT
96 struct tile_edge {
97 enum edge_type type;
98 #define NUM_EDGE_TILES 2
99 const struct tile *tile[NUM_EDGE_TILES];
102 /* A corner is the endpoint of several edges. At each corner 4 tiles will
103 * meet (3 in hex view). Tiles are in clockwise order NESW. */
104 struct tile_corner {
105 #define NUM_CORNER_TILES 4
106 const struct tile *tile[NUM_CORNER_TILES];
109 struct drawn_sprite {
110 bool foggable; /* Set to FALSE for sprites that are never fogged. */
111 struct sprite *sprite;
112 int offset_x, offset_y; /* offset from tile origin */
115 /* Items on the mapview are drawn in layers. Each entry below represents
116 * one layer. The names are basically arbitrary and just correspond to
117 * groups of elements in fill_sprite_array(). Callers of fill_sprite_array
118 * must call it once for each layer. */
119 enum mapview_layer {
120 LAYER_BACKGROUND,
121 LAYER_TERRAIN1,
122 LAYER_TERRAIN2,
123 LAYER_TERRAIN3, /* Adjust also TERRAIN_LAYER_COUNT if changing these */
124 LAYER_WATER,
125 LAYER_ROADS,
126 LAYER_SPECIAL1,
127 LAYER_GRID1,
128 LAYER_CITY1,
129 LAYER_SPECIAL2,
130 LAYER_FOG,
131 LAYER_UNIT,
132 LAYER_SPECIAL3,
133 LAYER_CITY2,
134 LAYER_GRID2,
135 LAYER_OVERLAYS,
136 LAYER_TILELABEL,
137 LAYER_CITYBAR,
138 LAYER_FOCUS_UNIT,
139 LAYER_GOTO,
140 LAYER_WORKERTASK,
141 LAYER_EDITOR,
142 LAYER_COUNT
145 #define TERRAIN_LAYER_COUNT 3
147 #define mapview_layer_iterate(layer) \
149 enum mapview_layer layer; \
151 for (layer = 0; layer < LAYER_COUNT; layer++) { \
153 #define mapview_layer_iterate_end \
157 #define NUM_TILES_PROGRESS 8
159 #define MAX_NUM_CITIZEN_SPRITES 6
161 enum arrow_type {
162 ARROW_RIGHT,
163 ARROW_PLUS,
164 ARROW_MINUS,
165 ARROW_LAST
168 struct tileset;
170 extern struct tileset *tileset;
172 struct strvec;
173 const struct strvec *get_tileset_list(const struct option *poption);
175 void tileset_error(enum log_level level, const char *format, ...);
177 struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose,
178 int topology_id);
179 void tileset_init(struct tileset *t);
180 void tileset_free(struct tileset *tileset);
181 void tileset_load_tiles(struct tileset *t);
182 void tileset_free_tiles(struct tileset *t);
183 void tileset_ruleset_reset(struct tileset *t);
184 bool tileset_is_fully_loaded(void);
186 void finish_loading_sprites(struct tileset *t);
188 void tilespec_try_read(const char *tileset_name, bool verbose, int topo_id,
189 bool global_default);
190 void tilespec_reread(const char *tileset_name, bool game_fully_initialized);
191 void tilespec_reread_callback(struct option *poption);
192 void tilespec_reread_frozen_refresh(const char *tname);
194 void tileset_setup_specialist_type(struct tileset *t, Specialist_type_id id);
195 void tileset_setup_unit_type(struct tileset *t, struct unit_type *punittype);
196 void tileset_setup_impr_type(struct tileset *t,
197 struct impr_type *pimprove);
198 void tileset_setup_tech_type(struct tileset *t,
199 struct advance *padvance);
200 void tileset_setup_tile_type(struct tileset *t,
201 const struct terrain *pterrain);
202 void tileset_setup_resource(struct tileset *t,
203 const struct resource *presource);
204 void tileset_setup_extra(struct tileset *t,
205 struct extra_type *pextra);
206 void tileset_setup_government(struct tileset *t,
207 struct government *gov);
208 void tileset_setup_nation_flag(struct tileset *t,
209 struct nation_type *nation);
210 void tileset_setup_city_tiles(struct tileset *t, int style);
212 void tileset_player_init(struct tileset *t, struct player *pplayer);
213 void tileset_background_init(struct tileset *t);
214 void tileset_background_free(struct tileset *t);
216 /* Gfx support */
218 int fill_sprite_array(struct tileset *t,
219 struct drawn_sprite *sprs, enum mapview_layer layer,
220 const struct tile *ptile,
221 const struct tile_edge *pedge,
222 const struct tile_corner *pcorner,
223 const struct unit *punit, const struct city *pcity,
224 const struct city *citymode,
225 const struct unit_type *putype);
226 int fill_basic_terrain_layer_sprite_array(struct tileset *t,
227 struct drawn_sprite *sprs,
228 int layer,
229 struct terrain *pterrain);
231 double get_focus_unit_toggle_timeout(const struct tileset *t);
232 void reset_focus_unit_state(struct tileset *t);
233 void focus_unit_in_combat(struct tileset *t);
234 void toggle_focus_unit_state(struct tileset *t);
235 struct unit *get_drawable_unit(const struct tileset *t,
236 struct tile *ptile,
237 const struct city *citymode);
238 bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus);
241 enum cursor_type {
242 CURSOR_GOTO,
243 CURSOR_PATROL,
244 CURSOR_PARADROP,
245 CURSOR_NUKE,
246 CURSOR_SELECT,
247 CURSOR_INVALID,
248 CURSOR_ATTACK,
249 CURSOR_EDIT_PAINT,
250 CURSOR_EDIT_ADD,
251 CURSOR_WAIT,
252 CURSOR_LAST,
253 CURSOR_DEFAULT,
256 #define NUM_CURSOR_FRAMES 6
258 enum indicator_type {
259 INDICATOR_BULB,
260 INDICATOR_WARMING,
261 INDICATOR_COOLING,
262 INDICATOR_COUNT
265 enum icon_type {
266 ICON_FREECIV,
267 ICON_CITYDLG,
268 ICON_COUNT
271 enum spaceship_part {
272 SPACESHIP_SOLAR_PANEL,
273 SPACESHIP_LIFE_SUPPORT,
274 SPACESHIP_HABITATION,
275 SPACESHIP_STRUCTURAL,
276 SPACESHIP_FUEL,
277 SPACESHIP_PROPULSION,
278 SPACESHIP_EXHAUST,
279 SPACESHIP_COUNT
282 struct citybar_sprites {
283 struct sprite
284 *shields,
285 *food,
286 *trade,
287 *occupied,
288 *background;
289 struct sprite_vector occupancy;
292 struct editor_sprites {
293 struct sprite
294 *erase,
295 *brush,
296 *copy,
297 *paste,
298 *copypaste,
299 *startpos,
300 *terrain,
301 *terrain_resource,
302 *terrain_special,
303 *unit,
304 *city,
305 *vision,
306 *territory,
307 *properties,
308 *road,
309 *military_base;
312 #define NUM_WALL_TYPES 7
314 struct sprite *get_spaceship_sprite(const struct tileset *t,
315 enum spaceship_part part);
316 struct sprite *get_citizen_sprite(const struct tileset *t,
317 enum citizen_category type,
318 int citizen_index,
319 const struct city *pcity);
320 struct sprite *get_city_flag_sprite(const struct tileset *t,
321 const struct city *pcity);
322 struct sprite *get_nation_flag_sprite(const struct tileset *t,
323 const struct nation_type *nation);
324 struct sprite *get_nation_shield_sprite(const struct tileset *t,
325 const struct nation_type *nation);
326 struct sprite *get_tech_sprite(const struct tileset *t, Tech_type_id tech);
327 struct sprite *get_building_sprite(const struct tileset *t,
328 struct impr_type *pimprove);
329 struct sprite *get_government_sprite(const struct tileset *t,
330 const struct government *gov);
331 struct sprite *get_unittype_sprite(const struct tileset *t,
332 const struct unit_type *punittype,
333 enum direction8 facing,
334 bool icon);
335 struct sprite *get_sample_city_sprite(const struct tileset *t,
336 int style_idx);
337 struct sprite *get_arrow_sprite(const struct tileset *t,
338 enum arrow_type arrow);
339 struct sprite *get_tax_sprite(const struct tileset *t, Output_type_id otype);
340 struct sprite *get_treaty_thumb_sprite(const struct tileset *t, bool on_off);
341 const struct sprite_vector *get_unit_explode_animation(const struct
342 tileset *t);
343 struct sprite *get_nuke_explode_sprite(const struct tileset *t);
344 struct sprite *get_cursor_sprite(const struct tileset *t,
345 enum cursor_type cursor,
346 int *hot_x, int *hot_y, int frame);
347 const struct citybar_sprites *get_citybar_sprites(const struct tileset *t);
348 const struct editor_sprites *get_editor_sprites(const struct tileset *t);
349 struct sprite *get_icon_sprite(const struct tileset *t, enum icon_type icon);
350 struct sprite *get_attention_crosshair_sprite(const struct tileset *t);
351 struct sprite *get_indicator_sprite(const struct tileset *t,
352 enum indicator_type indicator,
353 int index);
354 struct sprite *get_unit_unhappy_sprite(const struct tileset *t,
355 const struct unit *punit,
356 int happy_cost);
357 struct sprite *get_unit_upkeep_sprite(const struct tileset *t,
358 Output_type_id otype,
359 const struct unit *punit,
360 const int *upkeep_cost);
361 struct sprite *get_basic_fog_sprite(const struct tileset *t);
362 struct sprite *get_resource_sprite(const struct tileset *t,
363 const struct resource *presouce);
364 int fill_basic_extra_sprite_array(const struct tileset *t,
365 struct drawn_sprite *sprs,
366 const struct extra_type *pextra);
367 struct sprite *get_event_sprite(const struct tileset *t, enum event_type event);
369 struct sprite *tiles_lookup_sprite_tag_alt(struct tileset *t,
370 enum log_level level,
371 const char *tag, const char *alt,
372 const char *what,
373 const char *name);
375 struct color_system;
376 struct color_system *get_color_system(const struct tileset *t);
378 /* Tileset accessor functions. */
379 const char *tileset_basename(const struct tileset *t);
380 bool tileset_is_isometric(const struct tileset *t);
381 int tileset_hex_width(const struct tileset *t);
382 int tileset_hex_height(const struct tileset *t);
383 int tileset_tile_width(const struct tileset *t);
384 int tileset_tile_height(const struct tileset *t);
385 int tileset_full_tile_width(const struct tileset *t);
386 int tileset_full_tile_height(const struct tileset *t);
387 int tileset_unit_width(const struct tileset *t);
388 int tileset_unit_height(const struct tileset *t);
389 int tileset_unit_with_upkeep_height(const struct tileset *t);
390 int tileset_unit_with_small_upkeep_height(const struct tileset *t);
391 int tileset_unit_layout_offset_y(const struct tileset *t);
392 int tileset_unit_layout_small_offset_y(const struct tileset *t);
393 int tileset_small_sprite_width(const struct tileset *t);
394 int tileset_small_sprite_height(const struct tileset *t);
395 int tileset_citybar_offset_y(const struct tileset *t);
396 int tileset_tilelabel_offset_y(const struct tileset *t);
397 const char *tileset_main_intro_filename(const struct tileset *t);
398 const char *tileset_mini_intro_filename(const struct tileset *t);
399 int tileset_num_city_colors(const struct tileset *t);
400 void tileset_use_preferred_theme(const struct tileset *t);
401 bool tileset_use_hard_coded_fog(const struct tileset *t);
403 /* These are used as array index -> can't be changed freely to values
404 bigger than size of those arrays. */
405 #define TS_TOPO_OVERHEAD 0
406 #define TS_TOPO_ISO 1
407 #define TS_TOPO_HEX (1 << 1)
408 #define TS_TOPO_ISOHEX (TS_TOPO_ISO + TS_TOPO_HEX)
410 const char *tileset_name_get(struct tileset *t);
411 const char *tileset_version(struct tileset *t);
412 const char *tileset_summary(struct tileset *t);
413 const char *tileset_description(struct tileset *t);
414 int tileset_topo_index(struct tileset *t);
416 #ifdef __cplusplus
418 #endif /* __cplusplus */
420 #endif /* FC__TILESPEC_H */