40 lines
1.1 KiB
GDScript
40 lines
1.1 KiB
GDScript
@tool
|
|
|
|
extends TextureButton
|
|
|
|
@export var state_colors: Array
|
|
|
|
func _on_toggled(toggled_on): $frame.visible = toggled_on
|
|
|
|
|
|
func _enter_tree() -> void:
|
|
$label.self_modulate = state_colors[state]
|
|
ProjectSettings.connect('settings_changed', _on_settings_changed)
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
ProjectSettings.disconnect('settings_changed', _on_settings_changed)
|
|
|
|
|
|
func _on_settings_changed():
|
|
if not is_inside_tree(): return
|
|
var white_color = ProjectSettings.get_setting('Схема прибора. Белый цвет', Color.LIGHT_GRAY)
|
|
var black_color = ProjectSettings.get_setting('Схема прибора. Чёрный цвет', Color.BLACK)
|
|
$pic_functional.material.set('shader_parameter/white', white_color)
|
|
$pic_functional.material.set('shader_parameter/black', black_color)
|
|
|
|
|
|
@export var state: int:
|
|
set(v):
|
|
v = 0 if v < 0 else v % state_colors.size()
|
|
state = v
|
|
if is_inside_tree():
|
|
$label.self_modulate = state_colors[v]
|
|
|
|
|
|
@export var show_functional: bool:
|
|
set(v):
|
|
show_functional = v
|
|
if is_inside_tree():
|
|
$pic_functional.visible = v
|