2019-08-18 09:28:38 +00:00
|
|
|
extends PanelContainer
|
|
|
|
|
|
|
|
var i
|
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
|
|
|
|
var visibility_toggled := false
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
var stylebox = StyleBoxFlat.new()
|
|
|
|
stylebox.bg_color = Color("3d3b45")
|
|
|
|
add_stylebox_override("panel", stylebox)
|
|
|
|
changed_selection()
|
|
|
|
|
|
|
|
# warning-ignore:unused_argument
|
|
|
|
func _process(delta) -> void:
|
|
|
|
var mouse_pos := get_local_mouse_position() + rect_position
|
2019-09-25 19:59:48 +00:00
|
|
|
if Rect2(rect_position, rect_position + rect_size).has_point(mouse_pos) && !visibility_toggled:
|
2019-08-18 09:28:38 +00:00
|
|
|
if Input.is_action_just_pressed("left_mouse"):
|
|
|
|
Global.canvas.current_layer_index = i
|
|
|
|
changed_selection()
|
|
|
|
|
|
|
|
func changed_selection() -> void:
|
|
|
|
var parent = get_parent()
|
|
|
|
for child in parent.get_children():
|
|
|
|
if child is PanelContainer:
|
|
|
|
if Global.canvas.current_layer_index == child.i:
|
|
|
|
child.currently_selected = true
|
|
|
|
child.get_stylebox("panel").bg_color = Color("282532")
|
2019-10-25 14:38:38 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
if Global.canvas.current_layer_index < Global.canvas.layers.size() - 1:
|
|
|
|
Global.move_up_layer_button.disabled = false
|
2019-09-04 17:50:05 +00:00
|
|
|
Global.move_up_layer_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
2019-08-18 09:28:38 +00:00
|
|
|
else:
|
|
|
|
Global.move_up_layer_button.disabled = true
|
2019-09-04 17:50:05 +00:00
|
|
|
Global.move_up_layer_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
2019-10-25 14:38:38 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
if Global.canvas.current_layer_index > 0:
|
|
|
|
Global.move_down_layer_button.disabled = false
|
2019-09-04 17:50:05 +00:00
|
|
|
Global.move_down_layer_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
2019-08-18 09:28:38 +00:00
|
|
|
Global.merge_down_layer_button.disabled = false
|
2019-09-04 17:50:05 +00:00
|
|
|
Global.merge_down_layer_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
2019-08-18 09:28:38 +00:00
|
|
|
else:
|
|
|
|
Global.move_down_layer_button.disabled = true
|
2019-09-04 17:50:05 +00:00
|
|
|
Global.move_down_layer_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
2019-08-18 09:28:38 +00:00
|
|
|
Global.merge_down_layer_button.disabled = true
|
2019-09-04 17:50:05 +00:00
|
|
|
Global.merge_down_layer_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
2019-08-18 09:28:38 +00:00
|
|
|
else:
|
|
|
|
child.currently_selected = false
|
|
|
|
child.get_stylebox("panel").bg_color = Color("3d3b45")
|
|
|
|
|
|
|
|
func _on_VisibilityButton_pressed() -> void:
|
|
|
|
if Global.canvas.layers[i][3]:
|
|
|
|
Global.canvas.layers[i][3] = false
|
|
|
|
get_child(0).get_child(0).text = "I"
|
|
|
|
else:
|
|
|
|
Global.canvas.layers[i][3] = true
|
|
|
|
get_child(0).get_child(0).text = "V"
|
|
|
|
|
|
|
|
|
|
|
|
func _on_VisibilityButton_button_down() -> void:
|
|
|
|
visibility_toggled = true
|
|
|
|
|
|
|
|
func _on_VisibilityButton_button_up() -> void:
|
2019-10-25 14:38:38 +00:00
|
|
|
visibility_toggled = false
|