2019-11-06 16:39:23 +00:00
|
|
|
class_name LayerContainer
|
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
|
2019-09-03 19:51:14 +00:00
|
|
|
# warning-ignore:unused_class_variable
|
2019-08-18 09:28:38 +00:00
|
|
|
var currently_selected := false
|
2020-03-08 19:57:22 +00:00
|
|
|
var visibility_button : BaseButton
|
|
|
|
var label : Label
|
|
|
|
var line_edit : LineEdit
|
2019-12-05 23:48:29 +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")
|
|
|
|
label = Global.find_node_by_name(self, "Label")
|
|
|
|
line_edit = Global.find_node_by_name(self, "LineEdit")
|
|
|
|
|
2020-01-19 18:03:32 +00:00
|
|
|
if Global.layers[i][1]:
|
2019-12-27 18:24:44 +00: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 09:28:38 +00:00
|
|
|
|
2019-12-27 18:24:44 +00:00
|
|
|
func _input(event : InputEvent) -> void:
|
2019-12-15 03:11:32 +00:00
|
|
|
if event.is_action_released("ui_accept") && line_edit.visible && event.scancode != KEY_SPACE:
|
2019-12-05 23:48:29 +00:00
|
|
|
label.visible = true
|
|
|
|
line_edit.visible = false
|
|
|
|
line_edit.editable = false
|
2020-02-28 23:23:45 +00:00
|
|
|
var new_text : String = line_edit.text
|
|
|
|
label.text = new_text
|
|
|
|
Global.layers[i][0] = new_text
|
2019-12-05 23:48:29 +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
|
2019-12-05 23:48:29 +00:00
|
|
|
var label_initially_visible : bool = label.visible
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2020-03-04 23:13:59 +00:00
|
|
|
if label_initially_visible:
|
|
|
|
label.visible = false
|
|
|
|
line_edit.visible = true
|
|
|
|
line_edit.editable = true
|
|
|
|
line_edit.grab_focus()
|
|
|
|
else:
|
|
|
|
label.visible = true
|
|
|
|
line_edit.visible = false
|
|
|
|
line_edit.editable = false
|
2019-08-18 09:28:38 +00:00
|
|
|
|
|
|
|
func _on_VisibilityButton_pressed() -> void:
|
2020-01-19 18:03:32 +00:00
|
|
|
if Global.layers[i][1]:
|
|
|
|
Global.layers[i][1] = false
|
2019-12-21 01:02:57 +00:00
|
|
|
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 09:28:38 +00:00
|
|
|
else:
|
2020-01-19 18:03:32 +00:00
|
|
|
Global.layers[i][1] = true
|
2019-12-21 01:02:57 +00: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)
|
2019-12-27 18:24:44 +00:00
|
|
|
Global.canvas.update()
|