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