diff --git a/project.godot b/project.godot index 89155ad68..42c9bc0d6 100644 --- a/project.godot +++ b/project.godot @@ -124,6 +124,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://src/UI/Timeline/LayerButton.gd" }, { +"base": "Label", +"class": "NotificationLabel", +"language": "GDScript", +"path": "res://src/UI/Nodes/NotificationLabel.gd" +}, { "base": "Resource", "class": "Palette", "language": "GDScript", @@ -238,6 +243,7 @@ _global_script_class_icons={ "Guide": "", "ImageEffect": "", "LayerButton": "", +"NotificationLabel": "", "Palette": "", "PaletteColor": "", "PaletteGrid": "", diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 8fca01480..3cd516c9f 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -148,7 +148,6 @@ var onion_skinning_blue_red := false var palettes := {} # Nodes -var notification_label_node := preload("res://src/UI/NotificationLabel/NotificationLabel.tscn") var pixel_layer_button_node: PackedScene = preload("res://src/UI/Timeline/PixelLayerButton.tscn") var group_layer_button_node: PackedScene = preload("res://src/UI/Timeline/GroupLayerButton.tscn") var pixel_cel_button_node: PackedScene = preload("res://src/UI/Timeline/PixelCelButton.tscn") @@ -411,7 +410,7 @@ func _initialize_keychain() -> void: func notification_label(text: String) -> void: - var notification: Label = notification_label_node.instance() + var notification := NotificationLabel.new() notification.text = tr(text) notification.rect_position = main_viewport.rect_global_position notification.rect_position.y += main_viewport.rect_size.y diff --git a/src/UI/NotificationLabel/NotificationLabel.gd b/src/UI/Nodes/NotificationLabel.gd similarity index 74% rename from src/UI/NotificationLabel/NotificationLabel.gd rename to src/UI/Nodes/NotificationLabel.gd index 03a6e3340..b14935dfc 100644 --- a/src/UI/NotificationLabel/NotificationLabel.gd +++ b/src/UI/Nodes/NotificationLabel.gd @@ -1,3 +1,4 @@ +class_name NotificationLabel extends Label @@ -5,7 +6,8 @@ func _ready() -> void: var tw := create_tween().set_parallel().set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT) tw.tween_property(self, "rect_position", Vector2(rect_position.x, rect_position.y - 100), 1) tw.tween_property(self, "modulate", Color(modulate.r, modulate.g, modulate.b, 0), 1) + tw.connect("finished", self, "_on_tween_finished") -func _on_Timer_timeout() -> void: +func _on_tween_finished() -> void: queue_free() diff --git a/src/UI/NotificationLabel/NotificationLabel.tscn b/src/UI/NotificationLabel/NotificationLabel.tscn deleted file mode 100644 index e93b03cbb..000000000 --- a/src/UI/NotificationLabel/NotificationLabel.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://src/UI/NotificationLabel/NotificationLabel.gd" type="Script" id=1] - -[node name="NotificationLabel" type="Label"] -margin_right = 116.0 -margin_bottom = 14.0 -custom_colors/font_color_shadow = Color( 0, 0, 0, 1 ) -text = "Undo: Notification" -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Timer" type="Timer" parent="."] -one_shot = true -autostart = true - -[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]