Анимация кнопки "Запуск контроля". Доделать.
This commit is contained in:
65
scenes/контроль/control_prd.gd
Normal file
65
scenes/контроль/control_prd.gd
Normal file
@@ -0,0 +1,65 @@
|
||||
extends Button
|
||||
|
||||
var base_style: StyleBoxFlat
|
||||
var tween
|
||||
var pulsing: bool = false
|
||||
@onready var progress_bars := get_tree().get_nodes_in_group("control_progress")
|
||||
|
||||
|
||||
func _ready():
|
||||
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
|
||||
set("theme_override_styles/disabled", base_style)
|
||||
else:
|
||||
base_style = get("theme_override_styles/disabled")
|
||||
connect("pressed", Callable(self, "_on_pressed"))
|
||||
|
||||
|
||||
func _on_pressed():
|
||||
disabled = true
|
||||
_start_pulse()
|
||||
var callback = Callable(self, "_check_progress_end")
|
||||
for pb in progress_bars:
|
||||
if not pb.is_connected("value_changed", callback):
|
||||
pb.connect("value_changed", callback)
|
||||
|
||||
|
||||
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
|
||||
var callback = Callable(self, "_check_progress_end")
|
||||
for pb in progress_bars:
|
||||
if pb.is_connected("value_changed", callback):
|
||||
pb.disconnect("value_changed", callback)
|
||||
|
||||
|
||||
func _check_progress_end(value):
|
||||
for pb in progress_bars:
|
||||
if pb.value < pb.max_value:
|
||||
return
|
||||
_stop_pulse()
|
||||
1
scenes/контроль/control_prd.gd.uid
Normal file
1
scenes/контроль/control_prd.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cjj7pbbhk8q7c
|
||||
1
scripts/.gd.uid
Normal file
1
scripts/.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://durllxmhtejp1
|
||||
Reference in New Issue
Block a user