From 4bc91b83f2aa16f198eeada2ae2baca6bc4617e8 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 15 Feb 2023 17:56:17 +0200 Subject: [PATCH 22/22] Add svgflag related information to .tilespec format See osdn #47357 Signed-off-by: Marko Lindqvist --- client/tilespec.c | 61 ++++++++++++++++++++++++++++++++++------ data/alio.tilespec | 7 ++++- data/amplio.tilespec | 4 +++ data/amplio2.tilespec | 7 ++++- data/cimpletoon.tilespec | 7 ++++- data/hex2t.tilespec | 4 +++ data/hexemplio.tilespec | 8 +++++- data/isophex.tilespec | 4 +++ data/isotrident.tilespec | 4 +++ data/toonhex.tilespec | 7 ++++- data/trident.tilespec | 4 +++ doc/README.graphics | 9 +++++- 12 files changed, 111 insertions(+), 15 deletions(-) diff --git a/client/tilespec.c b/client/tilespec.c index 3a1c1afe3a..e7064befdb 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -157,6 +157,13 @@ enum sprite_type { CELL_CORNER /* Corner of tile */ }; +enum spec_file_types { + SFILE_COMMON, + SFILE_SVG, + SFILE_PIXEL, + SFILE_LAST +}; + struct drawing_data { bool init; @@ -1862,8 +1869,8 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, char *fname; const char *c; int i; - size_t num_spec_files; - const char **spec_filenames; + size_t num_spec_files[SFILE_LAST]; + const char **spec_filenames[SFILE_LAST]; size_t num_layers; const char **layer_order; size_t num_preferred_themes; @@ -1875,12 +1882,17 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, const char *extraname; const char *tstr; int topo; + bool svg; + enum spec_file_types slist_type; + const char *type_name; fname = tilespec_fullname(tileset_name); - if (!fname) { + + if (fname == NULL) { if (verbose) { log_error("Can't find tileset \"%s\".", tileset_name); } + return NULL; } log_verbose("tilespec file is \"%s\".", fname); @@ -2520,22 +2532,53 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, } } - spec_filenames = secfile_lookup_str_vec(file, &num_spec_files, - "tilespec.files"); - if (NULL == spec_filenames || 0 == num_spec_files) { - log_error("No tile graphics files specified in \"%s\"", fname); + svg = is_svg_flag_enabled(); + + spec_filenames[SFILE_COMMON] = secfile_lookup_str_vec(file, + &(num_spec_files[SFILE_COMMON]), + "tilespec.files"); + + if (svg) { + slist_type = SFILE_SVG; + type_name = "svg"; + + /* Avoid "unused entry" warning about the other list */ + (void) secfile_entry_by_path(file, "tilespec.files_pixel"); + } else { + slist_type = SFILE_PIXEL; + type_name = "pixel"; + + /* Avoid "unused entry" warning about the other list */ + (void) secfile_entry_by_path(file, "tilespec.files_svg"); + } + + spec_filenames[slist_type] = secfile_lookup_str_vec(file, + &(num_spec_files[slist_type]), + "tilespec.files_%s", type_name); + if ((spec_filenames[SFILE_COMMON] == NULL || num_spec_files[SFILE_COMMON] == 0) + && (spec_filenames[slist_type] == NULL || num_spec_files[slist_type] == 0)) { + log_error("No tile graphics files specified in \"%s\" for %s mode.", + type_name, fname); goto ON_ERROR; } fc_assert(t->sprite_hash == NULL); t->sprite_hash = sprite_hash_new(); - if (!tileset_scan_single_list(t, spec_filenames, num_spec_files, + if (!tileset_scan_single_list(t, spec_filenames[SFILE_COMMON], + num_spec_files[SFILE_COMMON], + verbose, duplicates_ok)) { + goto ON_ERROR; + } + + if (!tileset_scan_single_list(t, spec_filenames[slist_type], + num_spec_files[slist_type], verbose, duplicates_ok)) { goto ON_ERROR; } - free(spec_filenames); + free(spec_filenames[SFILE_COMMON]); + free(spec_filenames[slist_type]); t->color_system = color_system_read(file); diff --git a/data/alio.tilespec b/data/alio.tilespec index cf9c304bf7..9795d6f76a 100644 --- a/data/alio.tilespec +++ b/data/alio.tilespec @@ -159,7 +159,6 @@ files = "misc/events.spec", "misc/buildings-large.spec", "misc/wonders-large.spec", - "misc/flags-large.spec", "misc/shields-large.spec", "misc/cursors.spec", "misc/space.spec", @@ -197,6 +196,12 @@ files = "alio/fortresses.spec", "alio/hills.spec" +files_svg = + "misc/flags.spec" + +files_pixel = + "misc/flags-large.spec" + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/amplio.tilespec b/data/amplio.tilespec index a7d80a2ac2..f0fd5769a0 100644 --- a/data/amplio.tilespec +++ b/data/amplio.tilespec @@ -170,6 +170,10 @@ files = "misc/editor.spec", "misc/icons.spec" +; No need for svgflags specific list, as misc/flags.spec always used +;files_svg = +;files_pixel = + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/amplio2.tilespec b/data/amplio2.tilespec index ff22d364d6..1be5a1f1a3 100644 --- a/data/amplio2.tilespec +++ b/data/amplio2.tilespec @@ -156,7 +156,6 @@ files = "amplio2/extra_units.spec", "amplio2/animals.spec", "amplio2/veterancy.spec", - "misc/flags-large.spec", "misc/buildings-large.spec", "misc/wonders-large.spec", "misc/space.spec", @@ -175,6 +174,12 @@ files = "misc/editor.spec", "misc/icons.spec" +files_svg = + "misc/flags.spec" + +files_pixel = + "misc/flags-large.spec" + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/cimpletoon.tilespec b/data/cimpletoon.tilespec index 2674686032..abe49e7893 100644 --- a/data/cimpletoon.tilespec +++ b/data/cimpletoon.tilespec @@ -157,7 +157,6 @@ files = "misc/specialists.spec", "amplio2/veterancy.spec", "cimpletoon/orient_units.spec", - "misc/flags-large.spec", "misc/buildings-large.spec", "misc/wonders-large.spec", "misc/space.spec", @@ -198,6 +197,12 @@ files = "cimpletoon/units/truck/xxx.spec", "cimpletoon/units/zeppelin/xxx.spec" +files_svg = + "misc/flags.spec" + +files_pixel = + "misc/flags-large.spec" + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/hex2t.tilespec b/data/hex2t.tilespec index 47440d2d88..2fe2149808 100644 --- a/data/hex2t.tilespec +++ b/data/hex2t.tilespec @@ -165,6 +165,10 @@ files = "misc/editor.spec", "amplio2/nuke.spec" +; No need for svgflags specific list, as misc/flags.spec always used +;files_svg = +;files_pixel = + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/hexemplio.tilespec b/data/hexemplio.tilespec index d13e88c650..16bf64602a 100644 --- a/data/hexemplio.tilespec +++ b/data/hexemplio.tilespec @@ -151,7 +151,6 @@ files = "misc/events.spec", "misc/buildings-large.spec", "misc/wonders-large.spec", - "misc/flags-large.spec", "misc/shields-large.spec", "misc/cursors.spec", "misc/space.spec", @@ -185,6 +184,13 @@ files = "hexemplio/water2.spec", "hexemplio/water3.spec" +files_svg = + "misc/flags.spec" + +files_pixel = + "misc/flags-large.spec" + + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/isophex.tilespec b/data/isophex.tilespec index 31acabdf9c..eb08a67cae 100644 --- a/data/isophex.tilespec +++ b/data/isophex.tilespec @@ -169,6 +169,10 @@ files = "isotrident/cities.spec", "isotrident/morecities.spec" +; No need for svgflags specific list, as misc/flags.spec always used +;files_svg = +;files_pixel = + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/isotrident.tilespec b/data/isotrident.tilespec index 5cc9aef78c..bc6760a9b5 100644 --- a/data/isotrident.tilespec +++ b/data/isotrident.tilespec @@ -169,6 +169,10 @@ files = "isotrident/cities.spec", "isotrident/morecities.spec" +; No need for svgflags specific list, as misc/flags.spec always used +;files_svg = +;files_pixel = + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/toonhex.tilespec b/data/toonhex.tilespec index ba7f18ca2d..7647036a27 100644 --- a/data/toonhex.tilespec +++ b/data/toonhex.tilespec @@ -153,7 +153,6 @@ files = "misc/events.spec", "misc/buildings-large.spec", "misc/wonders-large.spec", - "misc/flags-large.spec", "misc/shields-large.spec", "misc/cursors.spec", "misc/space.spec", @@ -207,6 +206,12 @@ files = "cimpletoon/units/truck/xxx.spec", "cimpletoon/units/zeppelin/xxx.spec" +files_svg = + "misc/flags.spec" + +files_pixel = + "misc/flags-large.spec" + ; Include color definitions *include "misc/colors.tilespec" diff --git a/data/trident.tilespec b/data/trident.tilespec index fc3f9565da..87ab410635 100644 --- a/data/trident.tilespec +++ b/data/trident.tilespec @@ -166,6 +166,10 @@ files = "trident/cities.spec", "trident/explosions.spec" +; No need for svgflags specific list, as misc/flags.spec always used +;files_svg = +;files_pixel = + ; Include color definitions *include "misc/colors.tilespec" diff --git a/doc/README.graphics b/doc/README.graphics index 76e8062fd6..0906bc25a1 100644 --- a/doc/README.graphics +++ b/doc/README.graphics @@ -177,8 +177,15 @@ options include: String lists (a comma-separated list of strings) ------------------------------------------------ - files : A list of .spec files to scan for sprites. + files : A main list of .spec files to scan for sprites. + These files are always looked at. See "individual spec files", below. + files_svg : List of .spec files to scan for sprites. + This list is added to the main 'files' list + when client svgflags feature is enabled. + files_pixel : List of .spec files to scan for sprites. + This list is added to the main 'files' list + when client svgflags feature is disabled. ---------------------------------------------------------------------- -- 2.39.1