Merge pull request #95124 from kleonc/skeleton2d_fix_set_get_always_returning_true

Fix `Skeleton2D.{_set|_get}` always returning true
This commit is contained in:
Rémi Verschelde 2024-08-19 14:34:09 +02:00
commit b1088047a0
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 20 additions and 28 deletions

View File

@ -39,19 +39,17 @@
#endif //TOOLS_ENABLED #endif //TOOLS_ENABLED
bool Bone2D::_set(const StringName &p_path, const Variant &p_value) { bool Bone2D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path; if (p_path == SNAME("auto_calculate_length_and_angle")) {
if (path.begins_with("auto_calculate_length_and_angle")) {
set_autocalculate_length_and_angle(p_value); set_autocalculate_length_and_angle(p_value);
} else if (path.begins_with("length")) { } else if (p_path == SNAME("length")) {
set_length(p_value); set_length(p_value);
} else if (path.begins_with("bone_angle")) { } else if (p_path == SNAME("bone_angle")) {
set_bone_angle(Math::deg_to_rad(real_t(p_value))); set_bone_angle(Math::deg_to_rad(real_t(p_value)));
} else if (path.begins_with("default_length")) { } else if (p_path == SNAME("default_length")) {
set_length(p_value); set_length(p_value);
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
else if (path.begins_with("editor_settings/show_bone_gizmo")) { else if (p_path == SNAME("editor_settings/show_bone_gizmo")) {
_editor_set_show_bone_gizmo(p_value); _editor_set_show_bone_gizmo(p_value);
} }
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
@ -63,19 +61,17 @@ bool Bone2D::_set(const StringName &p_path, const Variant &p_value) {
} }
bool Bone2D::_get(const StringName &p_path, Variant &r_ret) const { bool Bone2D::_get(const StringName &p_path, Variant &r_ret) const {
String path = p_path; if (p_path == SNAME("auto_calculate_length_and_angle")) {
if (path.begins_with("auto_calculate_length_and_angle")) {
r_ret = get_autocalculate_length_and_angle(); r_ret = get_autocalculate_length_and_angle();
} else if (path.begins_with("length")) { } else if (p_path == SNAME("length")) {
r_ret = get_length(); r_ret = get_length();
} else if (path.begins_with("bone_angle")) { } else if (p_path == SNAME("bone_angle")) {
r_ret = Math::rad_to_deg(get_bone_angle()); r_ret = Math::rad_to_deg(get_bone_angle());
} else if (path.begins_with("default_length")) { } else if (p_path == SNAME("default_length")) {
r_ret = get_length(); r_ret = get_length();
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
else if (path.begins_with("editor_settings/show_bone_gizmo")) { else if (p_path == SNAME("editor_settings/show_bone_gizmo")) {
r_ret = _editor_get_show_bone_gizmo(); r_ret = _editor_get_show_bone_gizmo();
} }
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
@ -518,23 +514,19 @@ Bone2D::~Bone2D() {
////////////////////////////////////// //////////////////////////////////////
bool Skeleton2D::_set(const StringName &p_path, const Variant &p_value) { bool Skeleton2D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path; if (p_path == SNAME("modification_stack")) {
if (path.begins_with("modification_stack")) {
set_modification_stack(p_value); set_modification_stack(p_value);
return true; return true;
} }
return true; return false;
} }
bool Skeleton2D::_get(const StringName &p_path, Variant &r_ret) const { bool Skeleton2D::_get(const StringName &p_path, Variant &r_ret) const {
String path = p_path; if (p_path == SNAME("modification_stack")) {
if (path.begins_with("modification_stack")) {
r_ret = get_modification_stack(); r_ret = get_modification_stack();
return true; return true;
} }
return true; return false;
} }
void Skeleton2D::_get_property_list(List<PropertyInfo> *p_list) const { void Skeleton2D::_get_property_list(List<PropertyInfo> *p_list) const {

View File

@ -69,13 +69,13 @@ SkinReference::~SkinReference() {
/////////////////////////////////////// ///////////////////////////////////////
bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path;
#ifndef DISABLE_DEPRECATED #ifndef DISABLE_DEPRECATED
if (path.begins_with("animate_physical_bones")) { if (p_path == SNAME("animate_physical_bones")) {
set_animate_physical_bones(p_value); set_animate_physical_bones(p_value);
return true;
} }
#endif #endif
String path = p_path;
if (!path.begins_with("bones/")) { if (!path.begins_with("bones/")) {
return false; return false;
@ -139,13 +139,13 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
} }
bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const { bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
String path = p_path;
#ifndef DISABLE_DEPRECATED #ifndef DISABLE_DEPRECATED
if (path.begins_with("animate_physical_bones")) { if (p_path == SNAME("animate_physical_bones")) {
r_ret = get_animate_physical_bones(); r_ret = get_animate_physical_bones();
return true;
} }
#endif #endif
String path = p_path;
if (!path.begins_with("bones/")) { if (!path.begins_with("bones/")) {
return false; return false;