2019-11-06 18:39:23 +02:00
|
|
|
class_name LayerContainer
|
2020-02-11 00:06:24 +02:00
|
|
|
extends Button
|
2019-08-18 12:28:38 +03:00
|
|
|
|
2020-01-18 21:06:47 +02:00
|
|
|
var i := 0
|
2020-03-08 21:57:22 +02:00
|
|
|
var visibility_button : BaseButton
|
2020-03-09 03:26:13 +02:00
|
|
|
var lock_button : BaseButton
|
2020-03-14 21:40:10 +02:00
|
|
|
var linked_button : BaseButton
|
2020-03-08 21:57:22 +02:00
|
|
|
var label : Label
|
|
|
|
var line_edit : LineEdit
|
2019-12-06 01:48:29 +02:00
|
|
|
|
2019-08-18 12:28:38 +03:00
|
|
|
func _ready() -> void:
|
2020-03-08 21:57:22 +02:00
|
|
|
visibility_button = Global.find_node_by_name(self, "VisibilityButton")
|
2020-03-09 03:26:13 +02:00
|
|
|
lock_button = Global.find_node_by_name(self, "LockButton")
|
2020-03-14 21:40:10 +02:00
|
|
|
linked_button = Global.find_node_by_name(self, "LinkButton")
|
2020-03-08 21:57:22 +02:00
|
|
|
label = Global.find_node_by_name(self, "Label")
|
|
|
|
line_edit = Global.find_node_by_name(self, "LineEdit")
|
|
|
|
|
2020-01-19 20:03:32 +02:00
|
|
|
if Global.layers[i][1]:
|
2019-12-27 20:24:44 +02:00
|
|
|
visibility_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Layer_Visible.png" % Global.theme_type)
|
|
|
|
visibility_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Layer_Visible_Hover.png" % Global.theme_type)
|
|
|
|
else:
|
|
|
|
visibility_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Layer_Invisible.png" % Global.theme_type)
|
|
|
|
visibility_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Layer_Invisible_Hover.png" % Global.theme_type)
|
2019-08-18 12:28:38 +03:00
|
|
|
|
2020-03-09 03:26:13 +02:00
|
|
|
if Global.layers[i][2]:
|
|
|
|
lock_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Lock.png" % Global.theme_type)
|
|
|
|
lock_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Lock_Hover.png" % Global.theme_type)
|
|
|
|
else:
|
|
|
|
lock_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Unlock.png" % Global.theme_type)
|
|
|
|
lock_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Unlock_Hover.png" % Global.theme_type)
|
|
|
|
|
2020-03-14 21:40:10 +02:00
|
|
|
if Global.layers[i][4]: # If new layers will be linked
|
|
|
|
linked_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Linked_Layer.png" % Global.theme_type)
|
|
|
|
linked_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Linked_Layer_Hover.png" % Global.theme_type)
|
|
|
|
else:
|
|
|
|
linked_button.texture_normal = load("res://Assets/Graphics/%s Themes/Layers/Unlinked_Layer.png" % Global.theme_type)
|
|
|
|
linked_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Unlinked_Layer_Hover.png" % Global.theme_type)
|
|
|
|
|
2019-12-27 20:24:44 +02:00
|
|
|
func _input(event : InputEvent) -> void:
|
2020-03-09 17:17:20 +02:00
|
|
|
if (event.is_action_released("ui_accept") or event.is_action_released("ui_cancel")) and line_edit.visible and event.scancode != KEY_SPACE:
|
|
|
|
save_layer_name(line_edit.text)
|
2019-12-06 01:48:29 +02:00
|
|
|
|
2019-11-06 18:39:23 +02:00
|
|
|
func _on_LayerContainer_pressed() -> void:
|
2020-03-05 01:13:59 +02:00
|
|
|
pressed = !pressed
|
2020-03-09 17:17:20 +02:00
|
|
|
label.visible = false
|
|
|
|
line_edit.visible = true
|
|
|
|
line_edit.editable = true
|
|
|
|
line_edit.grab_focus()
|
|
|
|
|
|
|
|
func _on_LineEdit_focus_exited() -> void:
|
|
|
|
save_layer_name(line_edit.text)
|
|
|
|
|
|
|
|
func save_layer_name(new_name : String) -> void:
|
|
|
|
label.visible = true
|
|
|
|
line_edit.visible = false
|
|
|
|
line_edit.editable = false
|
|
|
|
label.text = new_name
|
2020-04-06 18:35:54 +03:00
|
|
|
Global.layers_changed_skip = true
|
2020-03-09 17:17:20 +02:00
|
|
|
Global.layers[i][0] = new_name
|
2019-08-18 12:28:38 +03:00
|
|
|
|
|
|
|
func _on_VisibilityButton_pressed() -> void:
|
2020-03-14 21:40:10 +02:00
|
|
|
Global.layers[i][1] = !Global.layers[i][1]
|
2019-12-27 20:24:44 +02:00
|
|
|
Global.canvas.update()
|
2020-03-09 03:26:13 +02:00
|
|
|
|
|
|
|
func _on_LockButton_pressed() -> void:
|
2020-03-14 21:40:10 +02:00
|
|
|
Global.layers[i][2] = !Global.layers[i][2]
|
|
|
|
|
|
|
|
func _on_LinkButton_pressed() -> void:
|
|
|
|
Global.layers[i][4] = !Global.layers[i][4]
|
2020-03-22 00:30:10 +02:00
|
|
|
if Global.layers[i][4] && !Global.layers[i][5]:
|
2020-03-18 02:56:29 +02:00
|
|
|
Global.layers[i][5].append(Global.canvas)
|
2020-03-18 03:07:35 +02:00
|
|
|
Global.layers[i][3].get_child(Global.current_frame)._ready()
|