wesnoth/data/schema/units/animations.cfg
Steve Cotton cc8dddea6e Support negative numbers in ranges
Adds support for using these in the weapons and ability filters:
* "-1", which was previously treated as an parse error (no number before the separator).
* "-3--1"
* "-infinity" as the lower number in the range, provided a different upper number is given.

This treats "-infinity" (with no other number), "-infinity--infinity",
"infinity" (with no other number) and "infinity-infinity" as errors. It seems
unlikely that someone would intend to use a filter that can't match any
reasonable number.

The range "-infinity-infinity" will be parsed successfully. I don't see a use
case for that, but nor do I see a reason to add extra C++ to reject it.
However, it's not added to the schema, as I think it's good for the schema to
give a warning when someone creates a filter which will accept every value
(including accepting the default, so "-infinity-infinity" accepts the unset
value too).

Includes new unit tests for the C++ and the Lua stringx.parse_range functions.
The next commit adds more WML tests, but is kept separate to credit the author.

This started as a change to move common filter functions from unit.cpp to
somewhere that they could be reused for other config-based filters. In the
process a missing feature was found and added, the move is still included in a
single Git commit because the move was required in order to make these
functions accessible to the Boost unit tests.

Two CodeBlocks project files additionally get src/utils/any.hpp added,
which was in one of them but missing from the other two. I noticed because
these are alphabetically at the start of the src/utils file list.

Thanks to @CelticMinstrel for the review comments and Xcode project updates.
2023-08-11 21:59:06 +02:00

181 lines
3.9 KiB
INI

[tag]
name="$animation"
max=0
# PART 1: Filters
{SIMPLE_KEY value unsigned_range_list}
{SIMPLE_KEY value_second unsigned_range_list}
{SIMPLE_KEY terrain_type terrain_list}
{SIMPLE_KEY direction dir_list}
{SIMPLE_KEY frequency int}
{SIMPLE_KEY base_score int}
{SIMPLE_KEY hits anim_hits_list}
{FILTER_TAG "filter" unit ()}
{FILTER_TAG "filter_second" unit ()}
{FILTER_TAG "filter_attack" weapon ()}
{FILTER_TAG "filter_second_attack" weapon ()}
# PART 2: Frame info
# Using a define for this because they're duplicated verbatim in three different places!
#define ANIMATION_FRAME_CONTENT PREFIX
{DEPRECATED_KEY {PREFIX}begin int}
{DEPRECATED_KEY {PREFIX}end int}
{SIMPLE_KEY {PREFIX}duration int}
{SIMPLE_KEY {PREFIX}image prog_string}
{SIMPLE_KEY {PREFIX}image_diagonal prog_string}
{SIMPLE_KEY {PREFIX}image_mod string}
{SIMPLE_KEY {PREFIX}sound prog_string}
{SIMPLE_KEY {PREFIX}halo prog_string}
{SIMPLE_KEY {PREFIX}halo_x prog_int}
{SIMPLE_KEY {PREFIX}halo_y prog_int}
{SIMPLE_KEY {PREFIX}halo_mod string}
{SIMPLE_KEY {PREFIX}alpha prog_real}
{SIMPLE_KEY {PREFIX}offset prog_real}
{SIMPLE_KEY {PREFIX}submerge prog_real}
{SIMPLE_KEY {PREFIX}blend_color color}
{SIMPLE_KEY {PREFIX}blend_ratio prog_real}
{SIMPLE_KEY {PREFIX}text string}
{SIMPLE_KEY {PREFIX}text_color color}
{SIMPLE_KEY {PREFIX}directional_x prog_int}
{SIMPLE_KEY {PREFIX}directional_y prog_int}
{SIMPLE_KEY {PREFIX}x prog_int}
{SIMPLE_KEY {PREFIX}y prog_int}
{SIMPLE_KEY {PREFIX}layer prog_int}
{SIMPLE_KEY {PREFIX}auto_hflip bool}
{SIMPLE_KEY {PREFIX}auto_vflip bool}
{SIMPLE_KEY {PREFIX}primary bool}
#enddef
{ANIMATION_FRAME_CONTENT ()}
{ANIMATION_FRAME_CONTENT *_}
# PART 3: Conditional branches
[tag]
name="if"
super="units/unit_type/$animation"
[/tag]
[tag]
name="else"
super="units/unit_type/$animation"
[/tag]
# PART 4: Frames
[tag]
name="frame"
max=infinite
{ANIMATION_FRAME_CONTENT ()}
{WML_MERGE_KEYS}
[/tag]
[tag]
name="*_frame"
max=infinite
super="units/unit_type/$animation/frame"
[/tag]
# PART 4: Miscellaneous
{SIMPLE_KEY start_time int}
{SIMPLE_KEY *_start_time int}
{WML_MERGE_KEYS}
[/tag]
# Specific animation tags
# Any new tag added here must also be linked from [effect]
[tag]
name="animation"
max=infinite
super="units/unit_type/$animation"
{REQUIRED_KEY apply_to string}
[/tag]
[tag]
name="defend"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="death"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="standing_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="movement_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="idle_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="attack_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="victory_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="pre_movement_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="post_movement_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="draw_weapon_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="sheath_weapon_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="leading_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="resistance_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="teaching_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="recruit_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="recruiting_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="healing_anim"
max=infinite
super="units/unit_type/$animation"
[/tag]
[tag]
name="extra_anim"
max=infinite
super="units/unit_type/$animation"
{REQUIRED_KEY flag string}
[/tag]