Sfoglia il codice sorgente

Fix the +1 button to insert keyframes in Sprite and Sprite3D, closes #5422

Juan Linietsky 9 anni fa
parent
commit
7c1ab42571

+ 1 - 1
scene/2d/animated_sprite.cpp

@@ -318,7 +318,7 @@ void AnimatedSprite::_validate_property(PropertyInfo& property) const {
 
 	if (property.name=="frame") {
 
-		property.hint=PROPERTY_HINT_RANGE;
+		property.hint=PROPERTY_HINT_SPRITE_FRAME;
 
 		if (frames->has_animation(animation)) {
 			property.hint_string="0,"+itos(frames->get_frame_count(animation)-1)+",1";

+ 11 - 0
scene/2d/sprite.cpp

@@ -288,6 +288,17 @@ Rect2 Sprite::get_item_rect() const {
 }
 
 
+
+void Sprite::_validate_property(PropertyInfo& property) const {
+
+	if (property.name=="frame") {
+
+		property.hint=PROPERTY_HINT_SPRITE_FRAME;
+
+		property.hint_string="0,"+itos(vframes*hframes-1)+",1";
+	}
+}
+
 void Sprite::_bind_methods() {
 
 	ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture);

+ 2 - 0
scene/2d/sprite.h

@@ -61,6 +61,8 @@ protected:
 
 	static void _bind_methods();;
 
+	virtual void _validate_property(PropertyInfo& property) const;
+
 public:
 
 	virtual void edit_set_pivot(const Point2& p_pivot);

+ 11 - 0
scene/3d/sprite_3d.cpp

@@ -585,6 +585,17 @@ Rect2 Sprite3D::get_item_rect() const {
 	return Rect2(ofs,s);
 }
 
+
+void Sprite3D::_validate_property(PropertyInfo& property) const {
+
+	if (property.name=="frame") {
+
+		property.hint=PROPERTY_HINT_SPRITE_FRAME;
+
+		property.hint_string="0,"+itos(vframes*hframes-1)+",1";
+	}
+}
+
 void Sprite3D::_bind_methods() {
 
 	ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite3D::set_texture);

+ 2 - 0
scene/3d/sprite_3d.h

@@ -158,6 +158,8 @@ class Sprite3D : public SpriteBase3D {
 protected:
 	virtual void _draw();
 	static void _bind_methods();
+
+	virtual void _validate_property(PropertyInfo& property) const;
 public:
 
 

+ 1 - 1
tools/editor/editor_resource_preview.cpp

@@ -336,7 +336,7 @@ void EditorResourcePreview::_bind_methods() {
 	ADD_SIGNAL(MethodInfo("preview_invalidated",PropertyInfo(Variant::STRING,"path")));
 }
 
-bool EditorResourcePreview::check_for_invalidation(const String& p_path) {
+void EditorResourcePreview::check_for_invalidation(const String& p_path) {
 
 	preview_mutex->lock();
 

+ 1 - 1
tools/editor/editor_resource_preview.h

@@ -121,7 +121,7 @@ public:
 	void queue_edited_resource_preview(const Ref<Resource>& p_path, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata);
 
 	void add_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator);
-	bool check_for_invalidation(const String& p_path);
+	void check_for_invalidation(const String& p_path);
 
 	EditorResourcePreview();
 	~EditorResourcePreview();

+ 1 - 3
tools/editor/property_editor.cpp

@@ -2981,10 +2981,8 @@ void PropertyEditor::update_tree() {
 				else
 					item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE_EXPRESSION );
 
-				if (p.hint==PROPERTY_HINT_SPRITE_FRAME) {
-					item->set_range_config(1,0,99999,1);
 
-				} else if (p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) {
+				if (p.hint==PROPERTY_HINT_SPRITE_FRAME || p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) {
 
 					int c = p.hint_string.get_slice_count(",");
 					float min=0,max=100,step=1;