Files
uarep-ctl/scenes/контроль/control_prd.gd

80 lines
2.1 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends Button
var base_style: StyleBoxFlat
var tween
var pulsing: bool = false
var original_text: String
func _ready():
original_text = text
_setup_styles()
_setup_signals()
func _setup_styles() -> void:
if get("theme_override_styles/disabled") == null:
base_style = StyleBoxFlat.new()
base_style.border_color = Color(1.0, 0.5, 0.0)
base_style.border_width_top = 4
base_style.border_width_bottom = 4
base_style.border_width_left = 4
base_style.border_width_right = 4
base_style.bg_color = Color(0.2, 0.2, 0.2)
set("theme_override_styles/disabled", base_style)
else:
base_style = get("theme_override_styles/disabled")
set("theme_override_colors/font_disabled_color", Color(1.0, 1.0, 1.0))
func _setup_signals() -> void:
connect("pressed", Callable(self, "_on_pressed"))
if not signaller:
return
var signals_to_connect := ["режим_работа", "режим_журнал", "режим_эмс", "режим_настройки", "режим_контроль"]
for signal_name in signals_to_connect:
if signaller.has_signal(signal_name):
signaller.connect(signal_name, Callable(self, "_on_status_change"))
func _on_pressed():
disabled = true
text = "Идет выполнение контроля"
_start_pulse()
func _start_pulse():
if pulsing:
return
pulsing = true
tween = create_tween()
tween.set_loops()
var color1 = Color(1.0, 0.5, 0.0) # оранжевый
var color2 = Color(0.4, 0.4, 0.4) # серый
tween.tween_property(base_style, "border_color", color2, 0.5)\
.set_trans(Tween.TRANS_SINE)\
.set_ease(Tween.EASE_IN_OUT)
tween.tween_property(base_style, "border_color", color1, 0.5)\
.set_trans(Tween.TRANS_SINE)\
.set_ease(Tween.EASE_IN_OUT)
func _stop_pulse():
if tween:
tween.kill()
tween = null
base_style.border_color = Color(1.0, 0.5, 0.0)
pulsing = false
disabled = false
text = original_text
func _on_status_change():
_stop_pulse()
func _exit_tree() -> void:
if tween:
tween.kill()