diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2019-07-25 09:11:41 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2019-07-25 09:29:51 +0200 |
| commit | 336846e547c1daeb8855b091d21df3b91c2a80a8 (patch) | |
| tree | 4deeade72d8d600e64721adbe4a65baffb810f6d /scene/2d/animated_sprite.cpp | |
| parent | eb300ba8fe48a76d31b97564eb34c58c355cdbd5 (diff) | |
| download | redot-engine-336846e547c1daeb8855b091d21df3b91c2a80a8.tar.gz | |
Inspector: Fix PROPERTY_HINT_SPRITE_FRAME not behaving as RANGE
This was a regression in 3.1 and later from the new inspector, where
PROPERTY_HINT_SPRITE_FRAME was not fully re-implemented. It's meant to
be a normal PROPERTY_HINT_RANGE which also automatically increments its
value when keyed in the animation player.
To avoid code duplication, I made the frames properties use the actual
PROPERTY_HINT_RANGE and introduced a PROPERTY_USAGE_KEYING_INCREMENTS
usage flag instead.
Diffstat (limited to 'scene/2d/animated_sprite.cpp')
| -rw-r--r-- | scene/2d/animated_sprite.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index c7f622dee3..83cc1eeb46 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "animated_sprite.h" + #include "core/os/os.h" #include "scene/scene_string_names.h" @@ -356,12 +357,11 @@ void AnimatedSprite::_validate_property(PropertyInfo &property) const { } if (property.name == "frame") { - - property.hint = PROPERTY_HINT_SPRITE_FRAME; - + property.hint = PROPERTY_HINT_RANGE; if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) { property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1"; } + property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; } } @@ -709,7 +709,7 @@ void AnimatedSprite::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), "set_frame", "get_frame"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed_scale"), "set_speed_scale", "get_speed_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered"); |
