diff options
author | Robert Hernandez <killerjaguar26@gmail.com> | 2017-03-29 19:30:24 -0400 |
---|---|---|
committer | Robert Hernandez <killerjaguar26@gmail.com> | 2017-06-29 10:49:24 -0400 |
commit | f0f407e76eafdfe76b9439c7e527f085a6ff22d9 (patch) | |
tree | bcf8b3ecb7df8cee85de7a0611688cd14cafd1ab /scene | |
parent | 198bd9db02950d261c83b0c383fe737df3c5f152 (diff) |
Texture region now updates when changing an Atlas
- Removed atlas_changed signal for AtlasTexture
- Changes are now handled by _notify_change
- Removed unneccesary signal connections
- Texture preview now updates in real-time
Fixed TextureRegionEditor constantly regenerating
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/sprite.cpp | 1 | ||||
-rw-r--r-- | scene/gui/patch_9_rect.cpp | 1 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 1 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 10 |
4 files changed, 10 insertions, 3 deletions
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index 450f8e2474..c4590c100d 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -122,6 +122,7 @@ void Sprite::set_texture(const Ref<Texture> &p_texture) { update(); emit_signal("texture_changed"); item_rect_changed(); + _change_notify("texture"); } void Sprite::set_normal_map(const Ref<Texture> &p_texture) { diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/patch_9_rect.cpp index 735f36b55d..249090830d 100644 --- a/scene/gui/patch_9_rect.cpp +++ b/scene/gui/patch_9_rect.cpp @@ -99,6 +99,7 @@ void NinePatchRect::set_texture(const Ref<Texture> &p_tex) { */ minimum_size_changed(); emit_signal("texture_changed"); + _change_notify("texture"); } Ref<Texture> NinePatchRect::get_texture() const { diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 2714ffec10..c67f40782d 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -107,6 +107,7 @@ void StyleBoxTexture::set_texture(RES p_texture) { region_rect = Rect2(Point2(), texture->get_size()); emit_signal("texture_changed"); emit_changed(); + _change_notify("texture"); } RES StyleBoxTexture::get_texture() const { diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 171826cb2f..f6856b3539 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -830,7 +830,7 @@ void AtlasTexture::set_atlas(const Ref<Texture> &p_atlas) { return; atlas = p_atlas; emit_changed(); - emit_signal("atlas_changed"); + _change_notify("atlas"); } Ref<Texture> AtlasTexture::get_atlas() const { @@ -839,8 +839,11 @@ Ref<Texture> AtlasTexture::get_atlas() const { void AtlasTexture::set_region(const Rect2 &p_region) { + if (region == p_region) + return; region = p_region; emit_changed(); + _change_notify("region"); } Rect2 AtlasTexture::get_region() const { @@ -850,8 +853,11 @@ Rect2 AtlasTexture::get_region() const { void AtlasTexture::set_margin(const Rect2 &p_margin) { + if (margin == p_margin) + return; margin = p_margin; emit_changed(); + _change_notify("margin"); } Rect2 AtlasTexture::get_margin() const { @@ -870,8 +876,6 @@ void AtlasTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_margin", "margin"), &AtlasTexture::set_margin); ClassDB::bind_method(D_METHOD("get_margin"), &AtlasTexture::get_margin); - ADD_SIGNAL(MethodInfo("atlas_changed")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_atlas", "get_atlas"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region"), "set_region", "get_region"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "margin"), "set_margin", "get_margin"); |