Split "Establish Embassy".
[freeciv.git] / doc / README.graphics
blob63ccdd373b07836378c017d35633e78304f08b8b
1 ----------------------------------------------------------------------
2 Freeciv Graphics, and Tile Specification Files
3 ----------------------------------------------------------------------
5 Using Graphics:
6 ---------------
8 To use different graphics with Freeciv, use the '--tiles' argument to
9 the Freeciv client. Eg, to use the 'engels' graphics, start the
10 client as:
11   
12     freeciv-gtk3 --tiles engels
14 What Freeciv actually does in this case is look for a file called
15 'engels.tilespec' somewhere in your Freeciv data path. (See the file
16 INSTALL for some information on the Freeciv data path.) That tilespec
17 file contains information telling Freeciv which graphics files to use,
18 and what those graphics files contain.
20 That is all you need to know to use alternative graphics provided by
21 Freeciv or by third-party add-ons. The rest of this file describes
22 (though not fully) the contents of the tilespec file and related
23 files. This is intended as developer reference, and for people
24 wanting to create/compile alternative tilesets and modpacks for
25 Freeciv.
27 ----------------------------------------------------------------------
28 Overview:
29 ---------
31 The purpose of the 'tilespec' file and related 'spec' files is to
32 allow the detailed layout of the graphics within the files to be
33 flexible and not hard-coded into Freeciv, and to allow add-ons to
34 conveniently provide additional graphics.
36 There are two layers to the tilespec files:
38 The top-level file is named, eg: 'trident.tilespec'.  The basename of
39 this file (here, 'trident') corresponds to the parameter of the
40 '--tiles' command-line argument for the Freeciv client, as described
41 above.
43 The top-level tilespec file contains general information on the full
44 tileset, and a list of files which specify information about the
45 individual graphics files. These filenames must be located somewhere
46 in the data path, though not necessarily the same place as the
47 top-level tilespec file. Note that with this system the number and
48 contents of the referenced files are completely flexible at this
49 level.
51 An exception is that the intro graphics must be in individual files,
52 as listed in the tilespec file, because Freeciv treats these
53 specially: these graphics are freed after the game starts, and
54 reloaded later as necessary.
56 ----------------------------------------------------------------------
57 Graphics formats:
58 -----------------
60 All clients currently use 24/32 bit PNGs.
62 ----------------------------------------------------------------------
63 Tileset options:
64 ----------------
66 In the top-level tilespec file you can set options for the tileset.
67 Each of these should go within the [tilespec] section. Currently
68 options include:
70   Strings (enclosed in "")
71   ------------------------
72   options               : A capability string, this should be "+Freeciv-a.b-tilespec", where
73                           "a.b" it the current freeciv version.
74   name                  : the name of the tileset
75   type                  : general type of tileset, different types have
76                           quite different format. Supported types are
77                           "overhead" and "isometric"
78   city_names_font       : an X font string
79   city_productions_font : an X font string
80   main_intro_file       : GFX file for the intro graphics
81   unit_default_orientation : Specifies a direction to use for unit types in
82                           worklists etc. See "Unit Sprites" below.
84   String vectors
85   --------------
86   preferred_themes      : List of preferred client themes to use with this
87                           tileset
89   Integers
90   --------
91   priority              : when user does not specify tileset, client
92                           automatically loads available compatible tileset
93                           with highest priority.
94   normal_tile_width     : the width of terrain tiles
95   normal_tile_height    : the height of terrain tiles
96   unit_width            : unit sprite width. Default is always ok, setting is
97                           provided just for symmetry with unit_height
98   unit_height           : unit sprite height if more than 1.5x terrain tile
99                           height in isometric tileset
100   small_tile_width      : the width of icon sprites
101   small_tile_height     : the height of icon sprites
102   fog_style             : Specifies how fog is drawn.
103                           "Auto" :     Code automatically adds fog.
104                           "Sprite :    A single fog sprite is drawn on top of all
105                                        other sprites for fogged tiles. The
106                                        tx.fog sprite is used for this.
107                           "Darkness" : No fog, or fog from darkness_style = 4.
108   darkness_style        : Specifies how "encroaching darkness" is drawn.
109                           "None"           : No darkness.
110                           "IsoRect"        : A single sprite can be split into 4
111                                              parts, each containing the darkness
112                                              for that particular cardinal direction.
113                                              (Iso-view only.)
114                           "CardinalSingle" : Four different sprites exist, each
115                                              holding the darkness for a particular
116                                              direction. Any or all of the sprites
117                                              may be drawn.
118                           "CardinalFull"   : The sprite is chosen based on the vector
119                                              sum of the darkness in all 4 cardinal
120                                              directions. 15 different sprites are
121                                              needed.
122                           "Corner"         : Corner darkness & fog, 81 sprites needed.
123   unit_flag_offset_x   : Gives an offset from the tile origin at which to
124   unit_flag_offset_y     draw flags behind units or cities. With isometric
125   city_flag_offset_x     tilesets this should be non-zero so that the flag
126   city_flag_offset_y     is placed correctly behind the unit/city.
127   occupied_offset_x    : Gives an offset from the tile origin at which to
128   occupied_offset_y      draw city occupied icon (in many tilesets placed above the flag)
129   city_size_offset_x   : Gives an offset from the full tile origin at which to
130   city_size_offset_y     draw city size number.
131   unit_offset_x        : Gives an offset from the tile origin at which to
132   unit_offset_y          draw units.
133   activity_offset_x    : Gives an offset from the tile origin at which to
134   activity_offset_y      draw normal unit activity icons. "Auto" icons are not
135                          affected by this as they are usually wanted in different
136                          offset than real activity icons for both to appear simultaneously
137   select_offset_x      : Gives an offset from the tile origin at which to
138   select_offset_y        draw selected unit sprites.
139   unit_upkeep_offset_y : Gives an offset from the unit origin at which to draw
140                          the upkeep icons when they are shown along the unit. The upkeep
141                          icons can safely extend below the unit icon itself.
142                          If this value is omitted, normal tile height is used instead;
143                          - Upkeep icons appear below the unit icon if the unit icons are
144                            equal to tile height (typical in overhead tileset)
145                          - Upkeep icons overlay lower part of the unit icon, if unit icon
146                            is higher than tile height (typical in iso tilesets)
147   unit_upkeep_small_offset_y:
148                          Like unit_upkeep_offset_y, but to be used in case there's only small
149                          space for the overall icon produced. Defaults to unit_upkeep_offset_y -
150                          not having alternative layout.
151   citybar_offset_y     : Gives an offset from city tile origin at which to
152                          draw city bar text.
153   hex_side             : When is_hex is specified (see is_hex, below), this
154                          value gives the length of the "extra" side of the
155                          hexagon. This extra side will be on the top/bottom
156                          of the tile if is_isometric (below) is given, or
157                          on the left/right of the tile otherwise. The actual
158                          dimensions of the hex tile are determined from the
159                          normal_tile_width/normal_tile_height of the tileset
160                          as well as the hex side. The "normal" dimensions
161                          give the X and Y offsets between adjacent tiles in
162                          the tileset - this is not the same as the dimensions
163                          of the tile itself. The dimension of the bounding
164                          box of the hexagonal tile will be equal to the
165                          "normal" dimension minus the hex_side. For instance
166                          "normal" dimensions of 64x32 with a hex_side of 16
167                          for an iso-hex tileset will give hexagons of size
168                          48x32.
169   city_names_font_size : Font size used in drawing city name
170   city_production_font_size : Font size used in drawing city production
172   Booleans (FALSE or TRUE)
173   ------------------------
174   is_hex                : set to TRUE for a hexagonal tileset. If is_isometric
175                           is also specified then you have an iso-hex tileset.
176                           Hex tilesets should be used with topologies 8-11 and
177                           iso-hex tilesets with topologies 12-15.
179   String lists (a comma-separated list of strings)
180   ------------------------------------------------
181   files                 : A list of .spec files to scan for sprites.
182                           See "individual spec files", below.
185 ----------------------------------------------------------------------
186 Terrain options:
187 ----------------
189 The top-level tilespec file also contains information on how to draw each
190 terrain type.  For each terrain type include a section "[tile_xxx]".
191 This section contains information on how to draw this terrain type.
192 (The terrain types are specified in the server ruleset file.)
194   [tile_XXX] options
195   ----------------
196   tag                   : Tag of the terrain this drawing information refers
197                           to. That must match the "graphic" or "graphic_alt"
198                           field given in the ruleset file.x
199   blend_layer           : If non-zero, given layer of this terrain will be
200                           blended with adjacent terrains. Blending is done
201                           civ2-style with a dither mask. Only iso-view
202                           currently supports blending. Only the base graphic
203                           will be blended.
204                           The blending mask has sprite t.dither_tile.
205   is_reversed           : Draw layers in reverse order.
206   num_layers            : The number of layers in the terrain. This value
207                           must be 1, 2 or 3. Each layer is drawn
208                           separately. The layerN options below control the
209                           drawing of each layer (N should be 0, 1 or 2)
210   layerN_is_tall        : Left right corner of terrain sprites is not based
211                           on normal_tile_width and normal_tile_height, but
212                           to corner of the full tile.
213   layerN_offset_x       : Offset for terrain sprites
214   layerN_offset_y       
215   layerN_match_type     : If 0 or unset, no terrain matching will be done and
216                           the base sprite will be drawn for the terrain. If
217                           non-zero, then terrain matching will be done. A
218                           matched sprite will be chosen that matches all
219                           cardinally adjacent tiles whose terrain has the same
220                           match_type.
221   layerN_match_with     : List of match_types to match against
222   layerN_sprite_type    : With traditional tilesets each tile is drawn using
223                           one sprite. This default sprite_type is "whole".
224                           Which sprite to use may be specified using a
225                           match_type, and there may be multiple layers
226                           (each having one sprite). This method corresponds
227                           to sprite_type "single".
228                           A more sophisticated drawing method breaks the tile
229                           up into 4 rectangles. Each rectangular cell is
230                           adjacent to 3 different tiles. Each adjacency is
231                           matched, giving 8 different sprites for each of the
232                           4 cells. This sprite_type is "corner".
234 Additionally the top-level tilespec file should contain information about
235 the drawing of each layer. This is needed because the way each layer is
236 drawn must be consistent between different terrain types. You may not have
237 more than 3 layers (either in this section or in the [tile_XXX] sections).
239   [layerN] options
240   ----------------
241   match_types            : Gives a string list of all different match types.
242                            This list must include every possible match_type
243                            used by terrains for this layer.
244                            First letter of the match_type must be unique
245                            within layer.
247   Extra options
248   ------------
250   Tilespec should define style of extra graphics for each extra type in
251   section [extras] like:
253   [extras]
254   styles =
255       { "name",          "style"
256         "road",          "RoadAllSeparate"
257         "rail",          "RoadAllSeparate"
258         "river",         "River"
259         "tx.irrigation", "Cardinals"
260       }
262   RoadAllSeparate    : A single sprite is drawn for every connection the tile has;
263                        only 8 sprites are needed.
264   RoadParityCombined : A single sprite is drawn for all cardinal connections and
265                        a second sprite is drawn for all diagonal connections;
266                        32 sprites are needed.
267   RoadAllCombined    : One sprite is drawn to show roads in all directions.
268                        There are thus 256 sprites (64 for a hex tileset).
269   River              : Cardinal connections are drawn, as well as delta at the coast
270   Single1            : Single sprite at layer Special1
271   Single2            : Single sprite at layer Special2
272   3Layer             : 3 Sprites, tagged <name>_bg, <name>_mg, and <name>_fg
273   Cardinals          : Sprite for each cardinal connection
275 ----------------------------------------------------------------------
276 Individual spec files:
277 ----------------------
279 Each spec file describes one graphics file (PNG format is standard,
280 although some clients may accept other formats as well) as specified in
281 the spec file. The graphics file must be in the Freeciv data path, but
282 not necessarily in the same location as the spec file. Note you can have
283 multiple spec files using a single graphics file in different ways.
285 The main data described in the spec file is in sections named
286 [grid_*], where * is some arbitrary tag (but unique within each file).
287 A grid corresponds to a regular rectangular array of tiles. In
288 general one may have multiple grids in one file, but the default
289 tilesets usually only have one per file. (Multiple grids would be
290 useful to have different size tiles in the same file.) Each grid
291 defines an origin (top left) and spacing, both in terms of pixels, and
292 then refers to individual tiles of the grid by row and column. The
293 origin, and rows and columns, are counted as (0,0) = top left.
295 x_top_left     : x-coordinate of the leftmost pixel of the leftomost cell
296 y_top_left     : y-coordinate of the topmost pixel of the topmost cell
297 dx             : cell width
298 dy             : cell height
299 pixel_border   : Number of pixels between cells, unless overridden by axis specific value
300 pixel_border_x : Number of pixels between cells in x-direction, overrides pixel_border
301 pixel_border_y : Number of pixels between cells in y-direction, overrides pixel_border
302 tiles          : Table of tags, each line having "row", "column", and "tag"
304 [grid_example]
305 x_top_left   = 1   ; Border (in x=0) also in left side of the entire grid
306 y_top_left   = 1   ; Border (in y=0) also in top side of the entire grid
307 dx           = 96
308 dy           = 48
309 pixel_border = 1
310 tiles = { "row", "column", "tag"
311  0, 0, "tag1"
312  0, 1, "tag2"
313  1, 0, "tag3"
314  1, 1, "tag4"
318 Each individual tile is given a "tag", which is a string which is
319 referenced in the code and/or from ruleset files. A grid may be
320 sparse, with some elements unused (simply don't mention their row and
321 column), and a single tile may have multiple tags (eg, to use the same
322 graphic for multiple purposes in the game): just specify a list of
323 comma-separated strings.
325 If a given tag appears multiple times in the spec files, the *last*
326 such tag is used. (That is, in the order of files listed in the
327 tilespec file, and order within each file.) This allows selected
328 graphics to be "overridden" by listing a replacement spec file near
329 the end of the 'files' list in the top-level tilespec file, without
330 having to modify earlier files in the list.
332 ----------------------------------------------------------------------
333 Tag prefixes:
334 -------------
336 To help keep the tags organised, there is a rough prefix system used 
337 for standard tags:
339   f.          national flags
340   r.          road/rail
341   s.          general "small"
342   u.          unit images
343   t.          basic terrain types (with _n0s0e0w0 to _n1s1e1w1)
344   ts.         terrain special resources
345   tx.         extra terrain-related
346   gov.        government types
347   unit.       unit overlays: hp, stack, activities (goto, fortify etc)
348   upkeep.     unit upkeep and unhappiness
349   city.       city related (city, size, sq.-prod., disorder, occupied)
350   cd.         city defaults
351   citizen.    citizens, including specialists
352   explode.    explosion graphics (nuke, units)
353   spaceship.  spaceship components
354   treaty.     treaty thumbs
355   user.       crosshairs (in general: user interface?)
357 In general, graphics tags hard-wired into Freeciv _must_ be provided
358 by the spec files, or the client will refuse to start. Graphics tags
359 provided by ruleset files (at least for the "standard" rulesets)
360 should also be provided, but generally the client will continue even
361 if they are not, though the results may not be satisfactory for the
362 user. To work properly tags should correspond to appropriately sized
363 graphics. (The basic size may vary, as specified in the top-level
364 tilespec file, but the individual tiles should be consistent with
365 those sizes and/or the usage of those graphics.)
367 ----------------------------------------------------------------------
368 Sprites
369 -------
371 Depending on the information given here the tileset must/may contain certain
372 sprites.
374   Theme Sprites
375   -------------
377   citizen sprites :
379     This provides citizen graphics. Each citizen has one or more sprites
380     which are shown in the city dialog. The types of citizen are "happy",
381     "content", "unhappy", and "angry". The tag name is "citizen.<type>_<n>".
382     <type> is one of the listed types. <n> is the number of the graphic
383     (numbered starting with 0, unlike most other graphics) which allows more
384     than one sprite to be used. No more than 6 sprites per citizen may be
385     used.
387     Currently the citizen and specialist sprites may not have any
388     transparency, as this is ignored in much of the drawing. This is
389     considered a bug.
391   specialist sprites:
393     These provide specialist graphics just like the citizen graphics. However
394     specialist types come from the ruleset and may be changed in modpacks.
395     The sprite name is "specialist.<type>_<n>". Again <type> is the
396     type of specialist (currently "elvis", "scientist", "taxman") while <n>
397     is the sprite number. See "citizen sprites" above.
399   progress indicators:
401     There are three types of progress indicator. "science_bulb" indicates
402     progress toward the current research target. "warming_sun" indicates 
403     progress toward global warming. "cooling_flake" indicates progress
404     toward nuclear winter. Each indicator should have 8 states, numbered
405     0 (least) through 7 (most). The sprite names are "s.<type>_<n>".
407   government icons:
409     There should be one icon for each government. Its name is "gov.<gov>",
410     where <gov> is the government name. Government types come from
411     governments.ruleset (currently "anarchy", "despotism", "monarchy",
412     "communism", "fundamentalism", "republic", "democracy").
414   tax icons:
416     One icon for each tax type. These are used to show the tax rates. The
417     sprites are "s.tax_luxury", "s.tax_science", "s.tax_gold". Commonly
418     the specialist sprites are reused for this.
420   right arrow:
422     A sprite "s.right_arrow" is used on the panel when more units are
423     present than can be shown.
425   Terrain sprites
426   ---------------
427   base sprite           : If the terrain has no match type or is layered, a
428                           base sprite is needed. This sprite has tag
429                           "t.<terrain>1" (e.g., "t.grassland1"). More than
430                           one such sprite may be given ("t.grassland2", etc.)
431                           in which case one will be chosen at random for each
432                           tile.
433   matched sprites       : If the terrain has a match type or is layered, a
434                           set of matched sprites is needed. This consists of
435                           16 sprites with tags "t.<terrain>_n<V>e<V>s<V>w<V>"
436                           (e.g., "t.hills_n0e0s1w0". Each direcional value
437                           <V> is either 0 or 1. Note that the directions are
438                           in map coordinates, so n (north) in iso-view is
439                           northeast on the mapview. (Note this only applies
440                           for cell_type "single".)
441   cell sprites          : For matched terrains that have cell_type "rect",
442                           32 different sprites are needed. Each sprite is
443                           a rectangle corresponding to one cell, and there are
444                           8 different sprites per cell. Each sprite has
445                           a name like "t.ocean_cell_u110" where "ocean" is the
446                           terrain, "u" means up (north on the map) and
447                           110 indicates which of the adjacent tiles are
448                           mismatched. For instance u110 means
450                                     /\
451                                    /B \
452                                   /\ 1/\
453                                  / A\/C \
454                                  \1 /\ 0/
455                                   \/D \/
456                                    \  /
457                                     \/
459                           a matching terrain exists at C but not at A or B. In
460                           this case D is the current tile.
462   Examples:
464     ; This specifies a civ2-like grassland tile. A single sprite
465     ; t.grassland is needed; it will be drawn blended.
466     [terrain_grassland]
467     blend_layer = 1
468     num_layers  = 1
469     layer0_match_type = 0
471     ; This specifies a civ1-like mountain tile. 16 sprites
472     ; t.mountains_n0s0e0w0 ... t.mountains_n1s1e1w1 are needed. One of them
473     ; will be drawn to match the adjacent tiles. Assuming only mountains
474     ; has this match_type, adjacent mountains will match.
475     [terrain_mountains]
476     blend_layer = 0
477     num_layers  = 1
478     layer0_match_type = 7
480     ; This specifies a civ2-like hills tile. A base sprite t.hills will be
481     ; needed, plus 16 matching sprites. The base sprite will be drawn,
482     ; dithered with adjacent base sprites, and the matching sprite will be
483     ; drawn on top. (In most civ2 tilesets the base sprite is the grassland
484     ; sprite).
485     [terrain_hills]
486     blend_layer = 1
487     num_layers  = 2
488     layer0_match_type = 0
489     layer1_match_type = 8
491     ; This specifies a civ2-like ocean tile. Ocean is drawn via a cell-based
492     ; system as explained above.
493     [terrain_ocean]
494     blend_layer = 1
495     num_layers  = 1
496     layer0_match_type = 6
497     layer0_cell_type = "rect"
499   Terrain Special Sprites
500   -----------------------
502   farmland/irrigation:
504     tx.farmland and tx.irrigation provide the basic sprites for farmland
505     and irrigation. Additionally, there is support for drawing continuous
506     farmland and irrigation (as is used in Civ3). Here there are 16
507     irrigation sprites (and the same for farmland), starting with
508     tx.irrigation_n0s0e0w0 and running through tx.irrigation_n1s1e1w1.
509     An appropriate sprite will be chosen depending on which adjacent tiles
510     also have farmland/irrigation. If any of these sprites are not present,
511     the default sprite will be used as a fallback.
513   Unit Sprites
514   ------------
516     Units sprites can be either unoriented or oriented, in which case the
517     sprite that is displayed depends on the direction the unit is facing (it
518     turns when it moves or fights).
520     Unoriented sprites are specified as 'u.phalanx'. Oriented sprites have
521     a direction suffix: 'u.phalanx_s', 'u.phalanx_nw' and so on.
522     For each unit type, either an unoriented sprite or a full set of
523     the oriented sprites needed for the tileset topology must be provided
524     (you can also provide both, see below).
526     The game sometimes needs to draw a sprite for a unit type that doesn't
527     correspond to a specific unit, so is not facing a particular direction.
528     There are several options for oriented tilesets:
530      - If the unit_default_orientation is specified for the tileset, the
531        game will by default use that directional sprite. (The direction
532        doesn't have to be a valid one for the tileset.)
534      - Specific unit types may override this by providing an unoriented
535        sprite as well as the oriented ones; this doesn't have to be
536        distinct, so it can point to one of the oriented sprites, allowing
537        choice of the best orientation for each individual unit type.
538        If unit_default_orientation is not specified, an unoriented sprite
539        must be specified for *every* unit.