浏览代码

Merge pull request #54646 from jmb462/fix-animatedsprite-animation-list

Fix AnimatedSprite2D & 3D animation list in inspector
Rémi Verschelde 3 年之前
父节点
当前提交
af692912d4
共有 2 个文件被更改,包括 14 次插入8 次删除
  1. 7 4
      scene/2d/animated_sprite_2d.cpp
  2. 7 4
      scene/3d/sprite_3d.cpp

+ 7 - 4
scene/2d/animated_sprite_2d.cpp

@@ -115,14 +115,17 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &p_property) const {
 		names.sort_custom<StringName::AlphCompare>();
 		names.sort_custom<StringName::AlphCompare>();
 
 
 		bool current_found = false;
 		bool current_found = false;
+		bool is_first_element = true;
 
 
-		for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-			if (E->prev()) {
+		for (const StringName &E : names) {
+			if (!is_first_element) {
 				p_property.hint_string += ",";
 				p_property.hint_string += ",";
+			} else {
+				is_first_element = false;
 			}
 			}
 
 
-			p_property.hint_string += String(E->get());
-			if (animation == E->get()) {
+			p_property.hint_string += String(E);
+			if (animation == E) {
 				current_found = true;
 				current_found = true;
 			}
 			}
 		}
 		}

+ 7 - 4
scene/3d/sprite_3d.cpp

@@ -1004,14 +1004,17 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &p_property) const {
 		names.sort_custom<StringName::AlphCompare>();
 		names.sort_custom<StringName::AlphCompare>();
 
 
 		bool current_found = false;
 		bool current_found = false;
+		bool is_first_element = true;
 
 
-		for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-			if (E->prev()) {
+		for (const StringName &E : names) {
+			if (!is_first_element) {
 				p_property.hint_string += ",";
 				p_property.hint_string += ",";
+			} else {
+				is_first_element = false;
 			}
 			}
 
 
-			p_property.hint_string += String(E->get());
-			if (animation == E->get()) {
+			p_property.hint_string += String(E);
+			if (animation == E) {
 				current_found = true;
 				current_found = true;
 			}
 			}
 		}
 		}