From 1a24c9e14bf1f9578eda338344c12faf66fb0e65 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Fri, 12 Aug 2022 23:57:11 +0300 Subject: Make `_validate_property` a multilevel method --- scene/animation/animation_blend_space_1d.cpp | 9 ++++----- scene/animation/animation_blend_space_1d.h | 2 +- scene/animation/animation_blend_space_2d.cpp | 13 ++++++------- scene/animation/animation_blend_space_2d.h | 2 +- scene/animation/animation_blend_tree.cpp | 18 ++++++++---------- scene/animation/animation_blend_tree.h | 4 ++-- scene/animation/animation_player.cpp | 8 +++----- scene/animation/animation_player.h | 2 +- scene/animation/animation_tree.cpp | 6 +++--- scene/animation/animation_tree.h | 2 +- 10 files changed, 30 insertions(+), 36 deletions(-) (limited to 'scene/animation') diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp index b42e426f51..f30aea3bdd 100644 --- a/scene/animation/animation_blend_space_1d.cpp +++ b/scene/animation/animation_blend_space_1d.cpp @@ -42,15 +42,14 @@ Ref AnimationNodeBlendSpace1D::get_child_by_name(const StringName return get_blend_point_node(p_name.operator String().to_int()); } -void AnimationNodeBlendSpace1D::_validate_property(PropertyInfo &property) const { - if (property.name.begins_with("blend_point_")) { - String left = property.name.get_slicec('/', 0); +void AnimationNodeBlendSpace1D::_validate_property(PropertyInfo &p_property) const { + if (p_property.name.begins_with("blend_point_")) { + String left = p_property.name.get_slicec('/', 0); int idx = left.get_slicec('_', 2).to_int(); if (idx >= blend_points_used) { - property.usage = PROPERTY_USAGE_NONE; + p_property.usage = PROPERTY_USAGE_NONE; } } - AnimationRootNode::_validate_property(property); } void AnimationNodeBlendSpace1D::_tree_changed() { diff --git a/scene/animation/animation_blend_space_1d.h b/scene/animation/animation_blend_space_1d.h index 346e8a3a2f..1876ccebc7 100644 --- a/scene/animation/animation_blend_space_1d.h +++ b/scene/animation/animation_blend_space_1d.h @@ -65,7 +65,7 @@ class AnimationNodeBlendSpace1D : public AnimationRootNode { protected: bool sync = false; - virtual void _validate_property(PropertyInfo &property) const override; + void _validate_property(PropertyInfo &p_property) const; static void _bind_methods(); public: diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index 6b5851a977..2dc61efb94 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -566,18 +566,17 @@ String AnimationNodeBlendSpace2D::get_caption() const { return "BlendSpace2D"; } -void AnimationNodeBlendSpace2D::_validate_property(PropertyInfo &property) const { - if (auto_triangles && property.name == "triangles") { - property.usage = PROPERTY_USAGE_NONE; +void AnimationNodeBlendSpace2D::_validate_property(PropertyInfo &p_property) const { + if (auto_triangles && p_property.name == "triangles") { + p_property.usage = PROPERTY_USAGE_NONE; } - if (property.name.begins_with("blend_point_")) { - String left = property.name.get_slicec('/', 0); + if (p_property.name.begins_with("blend_point_")) { + String left = p_property.name.get_slicec('/', 0); int idx = left.get_slicec('_', 2).to_int(); if (idx >= blend_points_used) { - property.usage = PROPERTY_USAGE_NONE; + p_property.usage = PROPERTY_USAGE_NONE; } } - AnimationRootNode::_validate_property(property); } void AnimationNodeBlendSpace2D::set_auto_triangles(bool p_enable) { diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h index 689b96e356..250189f202 100644 --- a/scene/animation/animation_blend_space_2d.h +++ b/scene/animation/animation_blend_space_2d.h @@ -90,7 +90,7 @@ protected: protected: bool sync = false; - virtual void _validate_property(PropertyInfo &property) const override; + void _validate_property(PropertyInfo &p_property) const; static void _bind_methods(); public: diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index fe2fb1b7a1..791ea53ab8 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -47,8 +47,8 @@ void AnimationNodeAnimation::get_parameter_list(List *r_list) cons r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE)); } -void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const { - if (property.name == "animation" && get_editable_animation_list) { +void AnimationNodeAnimation::_validate_property(PropertyInfo &p_property) const { + if (p_property.name == "animation" && get_editable_animation_list) { Vector names = get_editable_animation_list(); String anims; for (int i = 0; i < names.size(); i++) { @@ -58,8 +58,8 @@ void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const { anims += String(names[i]); } if (!anims.is_empty()) { - property.hint = PROPERTY_HINT_ENUM; - property.hint_string = anims; + p_property.hint = PROPERTY_HINT_ENUM; + p_property.hint_string = anims; } } } @@ -768,18 +768,16 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_seek_ return rem; } -void AnimationNodeTransition::_validate_property(PropertyInfo &property) const { - if (property.name.begins_with("input_")) { - String n = property.name.get_slicec('/', 0).get_slicec('_', 1); +void AnimationNodeTransition::_validate_property(PropertyInfo &p_property) const { + if (p_property.name.begins_with("input_")) { + String n = p_property.name.get_slicec('/', 0).get_slicec('_', 1); if (n != "count") { int idx = n.to_int(); if (idx >= enabled_inputs) { - property.usage = PROPERTY_USAGE_NONE; + p_property.usage = PROPERTY_USAGE_NONE; } } } - - AnimationNode::_validate_property(property); } void AnimationNodeTransition::_bind_methods() { diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index d35ff04f30..9ce6f93d6c 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -67,7 +67,7 @@ public: AnimationNodeAnimation(); protected: - void _validate_property(PropertyInfo &property) const override; + void _validate_property(PropertyInfo &p_property) const; static void _bind_methods(); private: @@ -304,7 +304,7 @@ class AnimationNodeTransition : public AnimationNodeSync { protected: static void _bind_methods(); - void _validate_property(PropertyInfo &property) const override; + void _validate_property(PropertyInfo &p_property) const; public: virtual void get_parameter_list(List *r_list) const override; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 09ec086564..37bb0916ff 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -174,8 +174,8 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const { return true; } -void AnimationPlayer::_validate_property(PropertyInfo &property) const { - if (property.name == "current_animation") { +void AnimationPlayer::_validate_property(PropertyInfo &p_property) const { + if (p_property.name == "current_animation") { List names; for (const KeyValue &E : animation_set) { @@ -191,10 +191,8 @@ void AnimationPlayer::_validate_property(PropertyInfo &property) const { hint += E->get(); } - property.hint_string = hint; + p_property.hint_string = hint; } - - Node::_validate_property(property); } void AnimationPlayer::_get_property_list(List *p_list) const { diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index b6d8dab1ed..caf1387ff0 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -311,7 +311,7 @@ private: protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; - virtual void _validate_property(PropertyInfo &property) const override; + void _validate_property(PropertyInfo &p_property) const; void _get_property_list(List *p_list) const; void _notification(int p_what); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 14cf64afad..7dbe892299 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -399,9 +399,9 @@ void AnimationNode::_set_filters(const Array &p_filters) { } } -void AnimationNode::_validate_property(PropertyInfo &property) const { - if (!has_filter() && (property.name == "filter_enabled" || property.name == "filters")) { - property.usage = PROPERTY_USAGE_NONE; +void AnimationNode::_validate_property(PropertyInfo &p_property) const { + if (!has_filter() && (p_property.name == "filter_enabled" || p_property.name == "filters")) { + p_property.usage = PROPERTY_USAGE_NONE; } } diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index 99851d140e..ee51a54557 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -111,7 +111,7 @@ protected: static void _bind_methods(); - void _validate_property(PropertyInfo &property) const override; + void _validate_property(PropertyInfo &p_property) const; GDVIRTUAL0RC(Dictionary, _get_child_nodes) GDVIRTUAL0RC(Array, _get_parameter_list) -- cgit v1.2.3