Author: jtn
Date: Wed Jun  8 22:29:00 2016
New Revision: 32803

URL: http://svn.gna.org/viewcvs/freeciv?rev=32803&view=rev
Log:
Add new tileset option (unit_default_orientation) to control which unit
sprite is used for unit types in the abstract (in worklists, help, etc).
Set this for Cimpletoon and Toonhex tilesets.

See gna patch #7243.

Modified:
    trunk/client/tilespec.c
    trunk/data/alio.tilespec
    trunk/data/amplio.tilespec
    trunk/data/amplio2.tilespec
    trunk/data/cimpletoon.tilespec
    trunk/data/hex2t.tilespec
    trunk/data/hexemplio.tilespec
    trunk/data/isophex.tilespec
    trunk/data/isotrident.tilespec
    trunk/data/toonhex.tilespec
    trunk/data/trident.tilespec

Modified: trunk/client/tilespec.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.c?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/client/tilespec.c     (original)
+++ trunk/client/tilespec.c     Wed Jun  8 22:29:00 2016
@@ -76,7 +76,7 @@
 
 #include "tilespec.h"
 
-#define TILESPEC_CAPSTR "+Freeciv-tilespec-Devel-2015-Dec-17 duplicates_ok"
+#define TILESPEC_CAPSTR "+Freeciv-tilespec-Devel-2016-Jun-07 duplicates_ok"
 /*
  * Tilespec capabilities acceptable to this program:
  *
@@ -475,6 +475,8 @@
 
   char *main_intro_filename;
 
+  enum direction8 unit_default_orientation;
+
   int city_names_font_size, city_productions_font_size;
 
   enum fog_style fogstyle;
@@ -927,6 +929,24 @@
   }
   log_error("Wrong direction8 variant: %d.", dir);
   return "";
+}
+
+/****************************************************************************
+  Parse a direction name as a direction8.
+****************************************************************************/
+static enum direction8 dir_by_tileset_name(const char *str)
+{
+  enum direction8 dir;
+
+  for (dir = direction8_begin();
+       dir != direction8_end();
+       dir = direction8_next(dir)) {
+    if (strcmp(dir_get_tileset_name(dir), str) == 0) {
+      return dir;
+    }
+  }
+
+  return direction8_invalid();
 }
 
 /****************************************************************************
@@ -1959,6 +1979,27 @@
 
   set_city_names_font_sizes(t->city_names_font_size,
                             t->city_productions_font_size);
+
+  c = secfile_lookup_str_default(file, NULL,
+                                 "tilespec.unit_default_orientation");
+  if (!c) {
+    t->unit_default_orientation = direction8_invalid();
+  } else {
+    dir = dir_by_tileset_name(c);
+
+    if (!direction8_is_valid(dir)) {
+      tileset_error(LOG_ERROR, "Tileset \"%s\": unknown "
+                    "unit_default_orientation \"%s\"", t->name, c);
+      goto ON_ERROR;
+    } else if (!is_valid_tileset_dir(t, dir)) {
+      tileset_error(LOG_ERROR, "Tileset \"%s\": unsuitable "
+                    "unit_default_orientation \"%s\" for this tileset",
+                    t->name, c);
+      goto ON_ERROR;
+    } else {
+      t->unit_default_orientation = dir;
+    }
+  }
 
   c = secfile_lookup_str(file, "tilespec.main_intro_file");
   t->main_intro_filename = tilespec_gfx_filename(c);
@@ -5993,8 +6034,11 @@
   fc_assert_ret_val(NULL != punittype, NULL);
 
   if (!direction8_is_valid(facing) || !is_valid_dir(facing)) {
-    /* Fallback to using random orientation sprite. */
-    facing = rand_direction();
+    facing = t->unit_default_orientation;
+    if (!direction8_is_valid(facing)) {
+      /* Fallback to using random orientation sprite. */
+      facing = rand_direction();
+    }
   }
 
   if (t->sprites.units.icon[uidx]

Modified: trunk/data/alio.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alio.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/alio.tilespec    (original)
+++ trunk/data/alio.tilespec    Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Alio"
@@ -87,6 +87,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 10
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/amplio.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/amplio.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/amplio.tilespec  (original)
+++ trunk/data/amplio.tilespec  Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Amplio"
@@ -77,6 +77,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 8
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/amplio2.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/amplio2.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/amplio2.tilespec (original)
+++ trunk/data/amplio2.tilespec Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Amplio2"
@@ -77,6 +77,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 8
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/cimpletoon.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/cimpletoon.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/cimpletoon.tilespec      (original)
+++ trunk/data/cimpletoon.tilespec      Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Cimpletoon"
@@ -81,6 +81,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 8
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/hex2t.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/hex2t.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/hex2t.tilespec   (original)
+++ trunk/data/hex2t.tilespec   Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Hex-2"
@@ -80,6 +80,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 10
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/hexemplio.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/hexemplio.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/hexemplio.tilespec       (original)
+++ trunk/data/hexemplio.tilespec       Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Hexemplio"
@@ -83,6 +83,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 10
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/isophex.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/isophex.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/isophex.tilespec (original)
+++ trunk/data/isophex.tilespec Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Isophex"
@@ -80,6 +80,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 10
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/isotrident.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/isotrident.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/isotrident.tilespec      (original)
+++ trunk/data/isotrident.tilespec      Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "MacroIsoTrident"
@@ -79,6 +79,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 10
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/toonhex.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/toonhex.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/toonhex.tilespec (original)
+++ trunk/data/toonhex.tilespec Wed Jun  8 22:29:00 2016
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Toonhex"
@@ -84,6 +84,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 10
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:

Modified: trunk/data/trident.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/trident.tilespec?rev=32803&r1=32802&r2=32803&view=diff
==============================================================================
--- trunk/data/trident.tilespec (original)
+++ trunk/data/trident.tilespec Wed Jun  8 22:29:00 2016
@@ -1,7 +1,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+Freeciv-tilespec-Devel-2015-Dec-17"
+options = "+Freeciv-tilespec-Devel-2016-Jun-07"
 
 ; A simple name for the tileset specified by this file:
 name = "Trident"
@@ -80,6 +80,12 @@
 ; Font size (points) to use to draw city names and productions:
 city_names_font_size = 10
 city_productions_font_size = 10
+
+; For tilesets with oriented units, the directional sprite to use to
+; represent a unit type rather than a specific unit from the map
+; (e.g., in worklists, editor, and online help). If not specified, such
+; sprites will be oriented randomly.
+;unit_default_orientation = "s"
 
 ; These are special because they get freed and reloaded
 ; as required:


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to