From d8704fdf5d74c36146b0f171327e8e3e2ba4d8be Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 6 May 2024 16:30:10 +0300 Subject: [PATCH] Change tag color, text and size in AnimationTagUI.gd --- src/Classes/Project.gd | 9 +-------- src/UI/Timeline/AnimationTagUI.gd | 17 +++++++++++++++++ src/UI/Timeline/AnimationTagUI.tscn | 22 +++++++++------------- src/UI/Timeline/AnimationTimeline.gd | 7 +------ 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 2fae6ddc8..d344d2481 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -488,17 +488,10 @@ func _animation_tags_changed(value: Array[AnimationTag]) -> void: for tag in animation_tags: var tag_c: Container = animation_tag_node.instantiate() - Global.tag_container.add_child(tag_c) tag_c.tag = tag + Global.tag_container.add_child(tag_c) var tag_position := Global.tag_container.get_child_count() - 1 Global.tag_container.move_child(tag_c, tag_position) - tag_c.get_node("Label").text = tag.name - tag_c.get_node("Label").modulate = tag.color - tag_c.get_node("Line2D").default_color = tag.color - tag_c.position = tag.get_position() - tag_c.custom_minimum_size.x = tag.get_minimum_size() - tag_c.get_node("Line2D").points[2] = Vector2(tag_c.custom_minimum_size.x, 0) - tag_c.get_node("Line2D").points[3] = Vector2(tag_c.custom_minimum_size.x, 32) _set_timeline_first_and_last_frames() diff --git a/src/UI/Timeline/AnimationTagUI.gd b/src/UI/Timeline/AnimationTagUI.gd index 6736c881b..1253559ea 100644 --- a/src/UI/Timeline/AnimationTagUI.gd +++ b/src/UI/Timeline/AnimationTagUI.gd @@ -1,3 +1,20 @@ extends VBoxContainer var tag: AnimationTag + + +func _ready() -> void: + if not is_instance_valid(tag): + return + $Label.text = tag.name + $Line2D.default_color = tag.color + $Label.modulate = tag.color + update_position_and_size() + + +func update_position_and_size() -> void: + position = tag.get_position() + custom_minimum_size.x = tag.get_minimum_size() + size.x = custom_minimum_size.x + $Line2D.points[2] = Vector2(custom_minimum_size.x, 0) + $Line2D.points[3] = Vector2(custom_minimum_size.x, 32) diff --git a/src/UI/Timeline/AnimationTagUI.tscn b/src/UI/Timeline/AnimationTagUI.tscn index 3a1f5e60b..441ff4265 100644 --- a/src/UI/Timeline/AnimationTagUI.tscn +++ b/src/UI/Timeline/AnimationTagUI.tscn @@ -1,26 +1,22 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://dxjxve3gmc8h4"] -[ext_resource path="res://src/UI/Timeline/AnimationTagUI.gd" type="Script" id=1] +[ext_resource type="Script" path="res://src/UI/Timeline/AnimationTagUI.gd" id="1"] [node name="AnimationTagUI" type="VBoxContainer"] +custom_minimum_size = Vector2(39, 32) offset_right = 39.0 offset_bottom = 32.0 -custom_minimum_size = Vector2( 39, 32 ) -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} +script = ExtResource("1") [node name="Line2D" type="Line2D" parent="."] -points = PackedVector2Array( 0, 32, 0, 0, 39, 0, 39, 32 ) +points = PackedVector2Array(0, 32, 0, 0, 39, 0, 39, 32) width = 1.0 +joint_mode = 2 +begin_cap_mode = 2 +end_cap_mode = 2 [node name="Label" type="Label" parent="."] -offset_left = 7.0 -offset_right = 32.0 -offset_bottom = 32.0 +layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 3 text = "Idle" -align = 1 -valign = 1 diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 876d5535c..df4003250 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -218,12 +218,7 @@ func _cel_size_changed(value: int) -> void: frame_id.size.x = cel_size for tag_c: Control in Global.tag_container.get_children(): - var tag: AnimationTag = tag_c.tag - tag_c.position = tag.get_position() - tag_c.custom_minimum_size.x = tag.get_minimum_size() - tag_c.size.x = tag_c.custom_minimum_size.x - tag_c.get_node("Line2D").points[2] = Vector2(tag_c.custom_minimum_size.x, 0) - tag_c.get_node("Line2D").points[3] = Vector2(tag_c.custom_minimum_size.x, 32) + tag_c.update_position_and_size() func _on_blend_modes_item_selected(index: int) -> void: