2020-05-01 19:17:05 +00:00
|
|
|
class_name LayerButton
|
2020-02-10 22:06:24 +00:00
|
|
|
extends Button
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2020-01-18 19:06:47 +00:00
|
|
|
var i := 0
|
2020-03-08 19:57:22 +00:00
|
|
|
var visibility_button : BaseButton
|
2020-03-09 01:26:13 +00:00
|
|
|
var lock_button : BaseButton
|
2020-03-14 19:40:10 +00:00
|
|
|
var linked_button : BaseButton
|
2020-03-08 19:57:22 +00:00
|
|
|
var label : Label
|
|
|
|
var line_edit : LineEdit
|
2019-12-05 23:48:29 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
func _ready() -> void:
|
2020-03-08 19:57:22 +00:00
|
|
|
visibility_button = Global.find_node_by_name(self, "VisibilityButton")
|
2020-03-09 01:26:13 +00:00
|
|
|
lock_button = Global.find_node_by_name(self, "LockButton")
|
2020-03-14 19:40:10 +00:00
|
|
|
linked_button = Global.find_node_by_name(self, "LinkButton")
|
2020-03-08 19:57:22 +00:00
|
|
|
label = Global.find_node_by_name(self, "Label")
|
|
|
|
line_edit = Global.find_node_by_name(self, "LineEdit")
|
2020-05-03 00:13:08 +00:00
|
|
|
var theme_type := Global.theme_type
|
|
|
|
if theme_type == "Gold":
|
2020-05-03 23:38:41 +00:00
|
|
|
theme_type = "Dark"
|
2020-03-08 19:57:22 +00:00
|
|
|
|
2020-01-19 18:03:32 +00:00
|
|
|
if Global.layers[i][1]:
|
2020-05-03 00:13:08 +00:00
|
|
|
visibility_button.get_child(0).texture = load("res://Assets/Graphics/%s_themes/layers/layer_visible.png" % theme_type.to_lower())
|
|
|
|
visibility_button.get_child(0).rect_size = Vector2(24, 14)
|
|
|
|
visibility_button.get_child(0).rect_position = Vector2(4, 9)
|
2019-12-27 18:24:44 +00:00
|
|
|
else:
|
2020-05-03 00:13:08 +00:00
|
|
|
visibility_button.get_child(0).texture = load("res://Assets/Graphics/%s_themes/layers/layer_invisible.png" % theme_type.to_lower())
|
|
|
|
visibility_button.get_child(0).rect_size = Vector2(24, 8)
|
|
|
|
visibility_button.get_child(0).rect_position = Vector2(4, 12)
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2020-03-09 01:26:13 +00:00
|
|
|
if Global.layers[i][2]:
|
2020-05-03 00:13:08 +00:00
|
|
|
lock_button.get_child(0).texture = load("res://Assets/Graphics/%s_themes/layers/lock.png" % theme_type.to_lower())
|
2020-03-09 01:26:13 +00:00
|
|
|
else:
|
2020-05-03 00:13:08 +00:00
|
|
|
lock_button.get_child(0).texture = load("res://Assets/Graphics/%s_themes/layers/unlock.png" % theme_type.to_lower())
|
2020-03-09 01:26:13 +00:00
|
|
|
|
2020-03-14 19:40:10 +00:00
|
|
|
if Global.layers[i][4]: # If new layers will be linked
|
2020-05-03 00:13:08 +00:00
|
|
|
linked_button.get_child(0).texture = load("res://Assets/Graphics/%s_themes/layers/linked_layer.png" % theme_type.to_lower())
|
2020-03-14 19:40:10 +00:00
|
|
|
else:
|
2020-05-03 00:13:08 +00:00
|
|
|
linked_button.get_child(0).texture = load("res://Assets/Graphics/%s_themes/layers/unlinked_layer.png" % theme_type.to_lower())
|
2020-03-14 19:40:10 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2019-12-27 18:24:44 +00:00
|
|
|
func _input(event : InputEvent) -> void:
|
2020-03-09 15:17:20 +00: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-05 23:48:29 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2019-11-06 16:39:23 +00:00
|
|
|
func _on_LayerContainer_pressed() -> void:
|
2020-03-04 23:13:59 +00:00
|
|
|
pressed = !pressed
|
2020-03-09 15:17:20 +00:00
|
|
|
label.visible = false
|
|
|
|
line_edit.visible = true
|
|
|
|
line_edit.editable = true
|
|
|
|
line_edit.grab_focus()
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-03-09 15:17:20 +00:00
|
|
|
func _on_LineEdit_focus_exited() -> void:
|
|
|
|
save_layer_name(line_edit.text)
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-03-09 15:17:20 +00:00
|
|
|
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 15:35:54 +00:00
|
|
|
Global.layers_changed_skip = true
|
2020-03-09 15:17:20 +00:00
|
|
|
Global.layers[i][0] = new_name
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
func _on_VisibilityButton_pressed() -> void:
|
2020-03-14 19:40:10 +00:00
|
|
|
Global.layers[i][1] = !Global.layers[i][1]
|
2019-12-27 18:24:44 +00:00
|
|
|
Global.canvas.update()
|
2020-03-09 01:26:13 +00:00
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-03-09 01:26:13 +00:00
|
|
|
func _on_LockButton_pressed() -> void:
|
2020-03-14 19:40:10 +00:00
|
|
|
Global.layers[i][2] = !Global.layers[i][2]
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2020-03-14 19:40:10 +00:00
|
|
|
func _on_LinkButton_pressed() -> void:
|
|
|
|
Global.layers[i][4] = !Global.layers[i][4]
|
2020-03-21 22:30:10 +00:00
|
|
|
if Global.layers[i][4] && !Global.layers[i][5]:
|
2020-03-18 00:56:29 +00:00
|
|
|
Global.layers[i][5].append(Global.canvas)
|
2020-03-18 01:07:35 +00:00
|
|
|
Global.layers[i][3].get_child(Global.current_frame)._ready()
|