Stop sharing requirement_unit_state_ereq().
[freeciv.git] / client / tilespec.h
blob856b938204437b388c4473d607463d7ceb2e6eb4
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_type;
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 #define SPECENUM_NAME mapview_layer
120 #define SPECENUM_VALUE0 LAYER_BACKGROUND
121 #define SPECENUM_VALUE0NAME "Background"
122 /* Adjust also TERRAIN_LAYER_COUNT if changing these */
123 #define SPECENUM_VALUE1 LAYER_TERRAIN1
124 #define SPECENUM_VALUE1NAME "Terrain1"
125 #define SPECENUM_VALUE2 LAYER_DARKNESS
126 #define SPECENUM_VALUE2NAME "Darkness"
127 #define SPECENUM_VALUE3 LAYER_TERRAIN2
128 #define SPECENUM_VALUE3NAME "Terrain2"
129 #define SPECENUM_VALUE4 LAYER_TERRAIN3
130 #define SPECENUM_VALUE4NAME "Terrain3"
131 #define SPECENUM_VALUE5 LAYER_WATER
132 #define SPECENUM_VALUE5NAME "Water"
133 #define SPECENUM_VALUE6 LAYER_ROADS
134 #define SPECENUM_VALUE6NAME "Roads"
135 #define SPECENUM_VALUE7 LAYER_SPECIAL1
136 #define SPECENUM_VALUE7NAME "Special1"
137 #define SPECENUM_VALUE8 LAYER_GRID1
138 #define SPECENUM_VALUE8NAME "Grid1"
139 #define SPECENUM_VALUE9 LAYER_CITY1
140 #define SPECENUM_VALUE9NAME "City1"
141 #define SPECENUM_VALUE10 LAYER_SPECIAL2
142 #define SPECENUM_VALUE10NAME "Special2"
143 #define SPECENUM_VALUE11 LAYER_FOG
144 #define SPECENUM_VALUE11NAME "Fog"
145 #define SPECENUM_VALUE12 LAYER_UNIT
146 #define SPECENUM_VALUE12NAME "Unit"
147 #define SPECENUM_VALUE13 LAYER_SPECIAL3
148 #define SPECENUM_VALUE13NAME "Special3"
149 #define SPECENUM_VALUE14 LAYER_CITY2
150 #define SPECENUM_VALUE14NAME "City2"
151 #define SPECENUM_VALUE15 LAYER_GRID2
152 #define SPECENUM_VALUE15NAME "Grid2"
153 #define SPECENUM_VALUE16 LAYER_OVERLAYS
154 #define SPECENUM_VALUE16NAME "Overlays"
155 #define SPECENUM_VALUE17 LAYER_TILELABEL
156 #define SPECENUM_VALUE17NAME "TileLabel"
157 #define SPECENUM_VALUE18 LAYER_CITYBAR
158 #define SPECENUM_VALUE18NAME "CityBar"
159 #define SPECENUM_VALUE19 LAYER_FOCUS_UNIT
160 #define SPECENUM_VALUE19NAME "FocusUnit"
161 #define SPECENUM_VALUE20 LAYER_GOTO
162 #define SPECENUM_VALUE20NAME "Goto"
163 #define SPECENUM_VALUE21 LAYER_WORKERTASK
164 #define SPECENUM_VALUE21NAME "WorkerTask"
165 #define SPECENUM_VALUE22 LAYER_EDITOR
166 #define SPECENUM_VALUE22NAME "Editor"
167 #define SPECENUM_COUNT LAYER_COUNT
168 #include "specenum_gen.h"
170 #define TERRAIN_LAYER_COUNT 3
172 #define mapview_layer_iterate(layer) \
174 enum mapview_layer layer; \
175 int layer_index; \
177 for (layer_index = 0; layer_index < LAYER_COUNT; layer_index++) { \
178 layer = tileset_get_layer(tileset, layer_index); \
180 #define mapview_layer_iterate_end \
184 /* Layer categories can be used to only render part of a tile. */
185 enum layer_category
187 LAYER_CATEGORY_CITY, /* Render cities */
188 LAYER_CATEGORY_TILE, /* Render terrain only */
189 LAYER_CATEGORY_UNIT /* Render units only */
192 #define NUM_TILES_PROGRESS 8
194 #define MAX_NUM_CITIZEN_SPRITES 6
196 enum arrow_type {
197 ARROW_RIGHT,
198 ARROW_PLUS,
199 ARROW_MINUS,
200 ARROW_LAST
203 struct tileset;
205 extern struct tileset *tileset;
207 struct strvec;
208 const struct strvec *get_tileset_list(const struct option *poption);
210 void tileset_error(enum log_level level, const char *format, ...);
212 void tileset_init(struct tileset *t);
213 void tileset_free(struct tileset *tileset);
214 void tileset_load_tiles(struct tileset *t);
215 void tileset_free_tiles(struct tileset *t);
216 void tileset_ruleset_reset(struct tileset *t);
217 bool tileset_is_fully_loaded(void);
219 void finish_loading_sprites(struct tileset *t);
221 void tilespec_try_read(const char *tileset_name, bool verbose, int topo_id,
222 bool global_default);
223 void tilespec_reread(const char *tileset_name, bool game_fully_initialized,
224 float scale);
225 void tilespec_reread_callback(struct option *poption);
226 void tilespec_reread_frozen_refresh(const char *tname);
228 void tileset_setup_specialist_type(struct tileset *t, Specialist_type_id id);
229 void tileset_setup_unit_type(struct tileset *t, struct unit_type *punittype);
230 void tileset_setup_impr_type(struct tileset *t,
231 struct impr_type *pimprove);
232 void tileset_setup_tech_type(struct tileset *t,
233 struct advance *padvance);
234 void tileset_setup_tile_type(struct tileset *t,
235 const struct terrain *pterrain);
236 void tileset_setup_resource(struct tileset *t,
237 const struct resource_type *presource);
238 void tileset_setup_extra(struct tileset *t,
239 struct extra_type *pextra);
240 void tileset_setup_government(struct tileset *t,
241 struct government *gov);
242 void tileset_setup_nation_flag(struct tileset *t,
243 struct nation_type *nation);
244 void tileset_setup_city_tiles(struct tileset *t, int style);
246 void tileset_player_init(struct tileset *t, struct player *pplayer);
247 void tileset_background_init(struct tileset *t);
248 void tileset_background_free(struct tileset *t);
250 /* Layer order */
252 enum mapview_layer tileset_get_layer(const struct tileset *t, int n);
253 bool tileset_layer_in_category(enum mapview_layer layer,
254 enum layer_category cat);
256 /* Gfx support */
258 int fill_sprite_array(struct tileset *t,
259 struct drawn_sprite *sprs, enum mapview_layer layer,
260 const struct tile *ptile,
261 const struct tile_edge *pedge,
262 const struct tile_corner *pcorner,
263 const struct unit *punit, const struct city *pcity,
264 const struct city *citymode,
265 const struct unit_type *putype);
266 int fill_basic_terrain_layer_sprite_array(struct tileset *t,
267 struct drawn_sprite *sprs,
268 int layer,
269 struct terrain *pterrain);
271 double get_focus_unit_toggle_timeout(const struct tileset *t);
272 void reset_focus_unit_state(struct tileset *t);
273 void focus_unit_in_combat(struct tileset *t);
274 void toggle_focus_unit_state(struct tileset *t);
275 struct unit *get_drawable_unit(const struct tileset *t,
276 struct tile *ptile,
277 const struct city *citymode);
278 bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus);
281 enum cursor_type {
282 CURSOR_GOTO,
283 CURSOR_PATROL,
284 CURSOR_PARADROP,
285 CURSOR_NUKE,
286 CURSOR_SELECT,
287 CURSOR_INVALID,
288 CURSOR_ATTACK,
289 CURSOR_EDIT_PAINT,
290 CURSOR_EDIT_ADD,
291 CURSOR_WAIT,
292 CURSOR_LAST,
293 CURSOR_DEFAULT,
296 #define NUM_CURSOR_FRAMES 6
298 enum indicator_type {
299 INDICATOR_BULB,
300 INDICATOR_WARMING,
301 INDICATOR_COOLING,
302 INDICATOR_COUNT
305 enum icon_type {
306 ICON_FREECIV,
307 ICON_CITYDLG,
308 ICON_COUNT
311 enum spaceship_part {
312 SPACESHIP_SOLAR_PANEL,
313 SPACESHIP_LIFE_SUPPORT,
314 SPACESHIP_HABITATION,
315 SPACESHIP_STRUCTURAL,
316 SPACESHIP_FUEL,
317 SPACESHIP_PROPULSION,
318 SPACESHIP_EXHAUST,
319 SPACESHIP_COUNT
322 struct citybar_sprites {
323 struct sprite
324 *shields,
325 *food,
326 *trade,
327 *occupied,
328 *background;
329 struct sprite_vector occupancy;
332 struct editor_sprites {
333 struct sprite
334 *erase,
335 *brush,
336 *copy,
337 *paste,
338 *copypaste,
339 *startpos,
340 *terrain,
341 *terrain_resource,
342 *terrain_special,
343 *unit,
344 *city,
345 *vision,
346 *territory,
347 *properties,
348 *road,
349 *military_base;
352 #define NUM_WALL_TYPES 7
354 struct sprite *get_spaceship_sprite(const struct tileset *t,
355 enum spaceship_part part);
356 struct sprite *get_citizen_sprite(const struct tileset *t,
357 enum citizen_category type,
358 int citizen_index,
359 const struct city *pcity);
360 struct sprite *get_city_flag_sprite(const struct tileset *t,
361 const struct city *pcity);
362 struct sprite *get_nation_flag_sprite(const struct tileset *t,
363 const struct nation_type *nation);
364 struct sprite *get_nation_shield_sprite(const struct tileset *t,
365 const struct nation_type *nation);
366 struct sprite *get_tech_sprite(const struct tileset *t, Tech_type_id tech);
367 struct sprite *get_building_sprite(const struct tileset *t,
368 struct impr_type *pimprove);
369 struct sprite *get_government_sprite(const struct tileset *t,
370 const struct government *gov);
371 struct sprite *get_unittype_sprite(const struct tileset *t,
372 const struct unit_type *punittype,
373 enum direction8 facing);
374 struct sprite *get_sample_city_sprite(const struct tileset *t,
375 int style_idx);
376 struct sprite *get_arrow_sprite(const struct tileset *t,
377 enum arrow_type arrow);
378 struct sprite *get_tax_sprite(const struct tileset *t, Output_type_id otype);
379 struct sprite *get_treaty_thumb_sprite(const struct tileset *t, bool on_off);
380 const struct sprite_vector *get_unit_explode_animation(const struct
381 tileset *t);
382 struct sprite *get_nuke_explode_sprite(const struct tileset *t);
383 struct sprite *get_cursor_sprite(const struct tileset *t,
384 enum cursor_type cursor,
385 int *hot_x, int *hot_y, int frame);
386 const struct citybar_sprites *get_citybar_sprites(const struct tileset *t);
387 const struct editor_sprites *get_editor_sprites(const struct tileset *t);
388 struct sprite *get_icon_sprite(const struct tileset *t, enum icon_type icon);
389 struct sprite *get_attention_crosshair_sprite(const struct tileset *t);
390 struct sprite *get_indicator_sprite(const struct tileset *t,
391 enum indicator_type indicator,
392 int index);
393 struct sprite *get_unit_unhappy_sprite(const struct tileset *t,
394 const struct unit *punit,
395 int happy_cost);
396 struct sprite *get_unit_upkeep_sprite(const struct tileset *t,
397 Output_type_id otype,
398 const struct unit *punit,
399 const int *upkeep_cost);
400 struct sprite *get_basic_fog_sprite(const struct tileset *t);
401 struct sprite *get_resource_sprite(const struct tileset *t,
402 const struct resource_type *presouce);
403 int fill_basic_extra_sprite_array(const struct tileset *t,
404 struct drawn_sprite *sprs,
405 const struct extra_type *pextra);
406 struct sprite *get_event_sprite(const struct tileset *t, enum event_type event);
408 struct sprite *tiles_lookup_sprite_tag_alt(struct tileset *t,
409 enum log_level level,
410 const char *tag, const char *alt,
411 const char *what,
412 const char *name,
413 bool scale);
415 struct color_system;
416 struct color_system *get_color_system(const struct tileset *t);
418 /* Tileset accessor functions. */
419 const char *tileset_basename(const struct tileset *t);
420 bool tileset_is_isometric(const struct tileset *t);
421 int tileset_hex_width(const struct tileset *t);
422 int tileset_hex_height(const struct tileset *t);
423 int tileset_tile_width(const struct tileset *t);
424 int tileset_tile_height(const struct tileset *t);
425 int tileset_full_tile_width(const struct tileset *t);
426 int tileset_full_tile_height(const struct tileset *t);
427 int tileset_unit_width(const struct tileset *t);
428 int tileset_unit_height(const struct tileset *t);
429 int tileset_unit_with_upkeep_height(const struct tileset *t);
430 int tileset_unit_with_small_upkeep_height(const struct tileset *t);
431 int tileset_unit_layout_offset_y(const struct tileset *t);
432 int tileset_unit_layout_small_offset_y(const struct tileset *t);
433 int tileset_small_sprite_width(const struct tileset *t);
434 int tileset_small_sprite_height(const struct tileset *t);
435 int tileset_citybar_offset_y(const struct tileset *t);
436 int tileset_tilelabel_offset_y(const struct tileset *t);
437 float tileset_scale(const struct tileset *t);
438 const char *tileset_main_intro_filename(const struct tileset *t);
439 int tileset_num_city_colors(const struct tileset *t);
440 void tileset_use_preferred_theme(const struct tileset *t);
441 bool tileset_use_hard_coded_fog(const struct tileset *t);
443 /* These are used as array index -> can't be changed freely to values
444 bigger than size of those arrays. */
445 #define TS_TOPO_OVERHEAD 0
446 #define TS_TOPO_ISO 1
447 #define TS_TOPO_HEX (1 << 1)
448 #define TS_TOPO_ISOHEX (TS_TOPO_ISO + TS_TOPO_HEX)
450 const char *tileset_name_get(struct tileset *t);
451 const char *tileset_version(struct tileset *t);
452 const char *tileset_summary(struct tileset *t);
453 const char *tileset_description(struct tileset *t);
454 char *tileset_what_ruleset(struct tileset *t);
455 int tileset_topo_index(struct tileset *t);
457 #ifdef __cplusplus
459 #endif /* __cplusplus */
461 #endif /* FC__TILESPEC_H */