Добавление анимации кнопки запуска контроля
This commit is contained in:
79
scenes/контроль/control_prd.gd
Normal file
79
scenes/контроль/control_prd.gd
Normal file
@@ -0,0 +1,79 @@
|
||||
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()
|
||||
1
scenes/контроль/control_prd.gd.uid
Normal file
1
scenes/контроль/control_prd.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://xjs7owe2iexn
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://lwmw4egynmd1"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://lwmw4egynmd1"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bar8k5qef7kch" path="res://data/УФ.png" id="2_0nvm1"]
|
||||
[ext_resource type="Script" uid="uid://q3gmpsqspjfp" path="res://scenes/контроль/внешний.gd" id="2_8r80x"]
|
||||
@@ -17,6 +17,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://00871pb6moln" path="res://data/прогресс-фон-1.png" id="9_w6m6a"]
|
||||
[ext_resource type="Texture2D" uid="uid://c1k856fxhrjnh" path="res://data/прогресс-заполнение-1.png" id="10_lbx5w"]
|
||||
[ext_resource type="Script" uid="uid://bncy1x53jp73d" path="res://scenes/контроль/connect_pribor.gd" id="11_u7tym"]
|
||||
[ext_resource type="Script" uid="uid://xjs7owe2iexn" path="res://scenes/контроль/control_prd.gd" id="18_lbx5w"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_iqgf5"]
|
||||
script/source = "extends Panel
|
||||
@@ -1687,6 +1688,7 @@ offset_right = 1326.0
|
||||
offset_bottom = 104.0
|
||||
focus_mode = 0
|
||||
text = "Запуск контроля"
|
||||
script = ExtResource("18_lbx5w")
|
||||
|
||||
[connection signal="toggled" from="pribor_prd_n_1" to="pribor_prd_n_1" method="_on_toggled"]
|
||||
[connection signal="toggled" from="pribor_uf" to="pribor_uf" method="_on_toggled"]
|
||||
|
||||
Reference in New Issue
Block a user