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)
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
23 #endif /* __cplusplus */
26 #include "log.h" /* enum log_level */
29 #include "city.h" /* enum citizen_category */
34 struct sprite
; /* opaque; gui-dep */
39 /* Create the sprite_vector type. */
40 #define SPECVEC_TAG sprite
41 #define SPECVEC_TYPE struct sprite *
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
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. */
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 */
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. */
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. */
123 LAYER_TERRAIN3
, /* Adjust also TERRAIN_LAYER_COUNT if changing these */
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
170 extern struct tileset
*tileset
;
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
,
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
);
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
,
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
,
237 const struct city
*citymode
);
238 bool unit_drawn_with_city_outline(const struct unit
*punit
, bool check_focus
);
256 #define NUM_CURSOR_FRAMES 6
258 enum indicator_type
{
271 enum spaceship_part
{
272 SPACESHIP_SOLAR_PANEL
,
273 SPACESHIP_LIFE_SUPPORT
,
274 SPACESHIP_HABITATION
,
275 SPACESHIP_STRUCTURAL
,
277 SPACESHIP_PROPULSION
,
282 struct citybar_sprites
{
289 struct sprite_vector occupancy
;
292 struct editor_sprites
{
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
,
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
,
335 struct sprite
*get_sample_city_sprite(const struct tileset
*t
,
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
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
,
354 struct sprite
*get_unit_unhappy_sprite(const struct tileset
*t
,
355 const struct unit
*punit
,
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
,
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
);
418 #endif /* __cplusplus */
420 #endif /* FC__TILESPEC_H */