diff --git a/scenes/tabs-switch/tab-switch.tscn b/scenes/tabs-switch/tab-switch.tscn index addc892f..b1e913d0 100644 --- a/scenes/tabs-switch/tab-switch.tscn +++ b/scenes/tabs-switch/tab-switch.tscn @@ -7,7 +7,7 @@ [ext_resource type="PackedScene" uid="uid://dab6loryocc73" path="res://scenes/эмс/эмс.tscn" id="5_u71bh"] [ext_resource type="PackedScene" uid="uid://musb21x2u0xs" path="res://scenes/эмс2/эмс2.tscn" id="6_41d34"] [ext_resource type="PackedScene" uid="uid://bnptm4rlp60dq" path="res://scenes/настройки/настройки.tscn" id="6_i8iv3"] -[ext_resource type="Script" path="res://scenes/tabs-switch/lbl_ready.gd" id="8_tidwt"] +[ext_resource type="Script" uid="uid://q7k2yihg057j" path="res://scenes/tabs-switch/lbl_ready.gd" id="8_tidwt"] [ext_resource type="Script" uid="uid://roajn6c6wvc1" path="res://scenes/tabs-switch/тренаж_режим.gd" id="9_41d34"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tidwt"] diff --git a/scenes/контроль/кнопка-прибора.gd b/scenes/контроль/кнопка-прибора.gd index fb222cc9..2db67aef 100644 --- a/scenes/контроль/кнопка-прибора.gd +++ b/scenes/контроль/кнопка-прибора.gd @@ -4,6 +4,9 @@ extends TextureButton @onready var tween: Tween @export var state_colors: Array +var progress_tween: Tween = null +var current_timeout: float = 0.0 + func _ready(): toggle_mode = true @@ -23,7 +26,62 @@ func update_progress_bar(target_value) -> void: if tween: tween.kill() tween = create_tween() - tween.tween_property($control_progress, 'value', target_value, 0.3) + tween.tween_property($control_progress, 'value', target_value, 0.3 if target_value > 0 else 0.0) + + +# Функция для анимации прогресса от 0 до 100 за указанное время +func animate_progress_from_zero(time_req: float) -> void: + _reset_progress_animation() + + $control_progress.value = 0 + $control_progress.visible = true + + current_timeout = time_req + + progress_tween = create_tween() + progress_tween.set_trans(Tween.TRANS_LINEAR) + progress_tween.set_ease(Tween.EASE_IN_OUT) + + progress_tween.tween_method( + _update_progress_with_tooltip, # Метод для вызова каждый кадр + 0.0, # Начальное значение + $control_progress.max_value, # Конечное значение + time_req # Длительность + ) + progress_tween.finished.connect(_on_progress_animation_finished.bind()) + + +# Метод для обновления прогресса и tooltip во время анимации +func _update_progress_with_tooltip(value: float) -> void: + # Устанавливаем значение прогресс-бара + $control_progress.value = value + + # Вычисляем процент и обновляем tooltip + var max_val = $control_progress.get('max_value') + var percentage = (value / max_val) * 100.0 + $control_progress.tooltip_text = 'Процесс контроля %01d%%' % percentage + + +# Функция для полного сброса анимации +func _reset_progress_animation() -> void: + if progress_tween: + progress_tween.kill() + progress_tween = null + + $control_progress.value = 0 + current_timeout = 0.0 + + +# Функция вызывается при завершении анимации +func _on_progress_animation_finished() -> void: + $control_progress.visible = false + + +# Функция для принудительной остановки анимации с сохранением текущего значения +func stop_progress_animation() -> void: + if progress_tween: + progress_tween.stop() + progress_tween = null func _on_toggled(toggled_on): @@ -76,6 +134,8 @@ func _on_settings_changed(): set(v): progress_value = v if is_inside_tree(): + if progress_tween: + stop_progress_animation() update_progress_bar(v) var max_val = $control_progress.get('max_value') var percentage = (v / max_val) * 100.0 @@ -111,13 +171,10 @@ func _on_settings_changed(): @export var timeout_tween: float: - # Создаем твин для анимации с плавным началом и концом set(v): - $control_progress.value = 0.0 - var local_tween = create_tween() - local_tween.tween_property($control_progress, "value", v, v)\ - .set_trans(Tween.TRANS_SINE)\ - .set_ease(Tween.EASE_IN_OUT) + if v <= 0: + _reset_progress_animation() + $control_progress.visible = false + return - local_tween.tween_callback(func(): - $control_progress.visible = false) + animate_progress_from_zero(v) diff --git a/scenes/контроль/контроль.tscn b/scenes/контроль/контроль.tscn index 4d9e6faa..dc61ccc8 100644 --- a/scenes/контроль/контроль.tscn +++ b/scenes/контроль/контроль.tscn @@ -174,7 +174,8 @@ func on_pribor_press(pribor_path, header_text, pribor_node): # Вызов при отправке запроса на селфтест АФСП func on_sending_request(node: Node, time_req: float) -> void: - node.progress_max_value = time_req + node.progress_max_value = 100 + node.progress_value = 0 node.progress_visible = true node.timeout_tween = time_req @@ -569,7 +570,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(100, 0, 0, 1)] -timeout_tween = null metadata/online_proc = "on_line_changed" metadata/unit_name = ["уарэп-яу07-1н"] @@ -656,9 +656,9 @@ frame_progress = 0.72355 editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1188.0 -offset_top = 581.0 +offset_top = 576.0 offset_right = 1285.0 -offset_bottom = 743.0 +offset_bottom = 738.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -668,15 +668,14 @@ ignore_texture_size = true stretch_mode = 0 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-эмс"] metadata/online_proc = "on_line_changed" [node name="label" type="Label" parent="pribor_uf"] layout_mode = 0 -offset_left = 15.0 +offset_left = -12.0 offset_top = -44.0 -offset_right = 91.0 +offset_right = 108.0 offset_bottom = -25.0 text = "УФ" horizontal_alignment = 1 @@ -686,10 +685,10 @@ vertical_alignment = 1 visible = false self_modulate = Color(0.890196, 0.486275, 0.196078, 1) layout_mode = 0 -offset_left = -14.0 +offset_left = -20.0 offset_top = -30.0 -offset_right = 126.0 -offset_bottom = 200.0 +offset_right = 116.0 +offset_bottom = 179.0 texture = ExtResource("4_rasbe") region_rect = Rect2(-3, -3, 89, 89) patch_margin_left = 16 @@ -712,10 +711,10 @@ texture = ExtResource("11_gjf0t") [node name="control_progress" type="TextureProgressBar" parent="pribor_uf"] visible = false layout_mode = 0 -offset_left = 9.0 -offset_top = 191.0 -offset_right = 102.0 -offset_bottom = 201.0 +offset_left = 1.0 +offset_top = 176.0 +offset_right = 94.0 +offset_bottom = 186.0 size_flags_horizontal = 3 size_flags_vertical = 3 tooltip_text = " @@ -746,7 +745,7 @@ script = ExtResource("21_l5wui") [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_uf/panel_pribor"] light_mask = 3 -position = Vector2(11.4285, 12.8571) +position = Vector2(4.28552, 12.8571) scale = Vector2(0.6, 0.596) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 @@ -755,9 +754,9 @@ frame_progress = 0.72355 editor_description = "Кнопка для выбора прибора." layout_mode = 0 offset_left = 1058.0 -offset_top = 588.0 +offset_top = 580.0 offset_right = 1164.0 -offset_bottom = 744.0 +offset_bottom = 736.0 pivot_offset = Vector2(-10, -65) size_flags_horizontal = 15 size_flags_vertical = 15 @@ -767,16 +766,15 @@ texture_normal = ExtResource("3_hhadv") stretch_mode = 0 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = [&"уарэп-бпо-1", &"уарэп-бпо-2"] metadata/online_proc = "online_change_arr" [node name="label" type="Label" parent="pribor_rtr"] layout_mode = 0 -offset_left = 11.0 -offset_top = -49.0 -offset_right = 94.0 -offset_bottom = -30.0 +offset_left = -10.0 +offset_top = -48.0 +offset_right = 110.0 +offset_bottom = -29.0 text = "РТР" horizontal_alignment = 1 vertical_alignment = 1 @@ -785,10 +783,10 @@ vertical_alignment = 1 visible = false self_modulate = Color(0.890196, 0.486275, 0.196078, 1) layout_mode = 0 -offset_left = -13.0 +offset_left = -18.0 offset_top = -34.0 -offset_right = 117.0 -offset_bottom = 171.0 +offset_right = 118.0 +offset_bottom = 175.0 texture = ExtResource("4_rasbe") region_rect = Rect2(-3, -3, 89, 89) patch_margin_left = 16 @@ -845,7 +843,6 @@ ignore_texture_size = true stretch_mode = 0 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = [&"уарэп-афсп-левый"] metadata/online_proc = "on_line_changed" @@ -909,7 +906,8 @@ frame_progress = 0.72355 [node name="control_progress" type="TextureProgressBar" parent="pribor_afsp_1"] visible = false -offset_left = 15.0 +layout_mode = 0 +offset_left = -25.0 offset_top = 735.0 offset_right = 815.0 offset_bottom = 775.0 @@ -949,7 +947,6 @@ stretch_mode = 0 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = [&"уарэп-афсп-правый"] metadata/online_proc = "on_line_changed" @@ -1013,7 +1010,8 @@ frame_progress = 0.72355 [node name="control_progress" type="TextureProgressBar" parent="pribor_afsp_2"] visible = false -offset_left = 20.0 +layout_mode = 0 +offset_left = -15.0 offset_top = 735.0 offset_right = 825.0 offset_bottom = 775.0 @@ -1037,10 +1035,10 @@ tint_progress = Color(0.890196, 0.486275, 0.196078, 1) [node name="pribor_uyep" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 -offset_left = 1313.0 -offset_top = 584.0 -offset_right = 1394.0 -offset_bottom = 744.0 +offset_left = 1317.0 +offset_top = 575.0 +offset_right = 1398.0 +offset_bottom = 735.0 size_flags_horizontal = 15 size_flags_vertical = 15 toggle_mode = true @@ -1050,16 +1048,15 @@ ignore_texture_size = true stretch_mode = 0 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-щ3", "уарэп-спт25-1", "уарэп-спт25-2"] metadata/online_proc = "online_change_arr" [node name="label" type="Label" parent="pribor_uyep"] layout_mode = 0 -offset_left = 26.8566 -offset_top = -43.3276 -offset_right = 66.8566 -offset_bottom = -24.3276 +offset_left = -13.0 +offset_top = -43.0 +offset_right = 99.0 +offset_bottom = -24.0 text = "У-ЭП" horizontal_alignment = 1 vertical_alignment = 1 @@ -1068,10 +1065,10 @@ vertical_alignment = 1 visible = false self_modulate = Color(0.890196, 0.486275, 0.196078, 1) layout_mode = 0 -offset_left = -13.0 +offset_left = -21.0 offset_top = -29.0 -offset_right = 117.0 -offset_bottom = 199.0 +offset_right = 107.0 +offset_bottom = 180.0 texture = ExtResource("4_rasbe") region_rect = Rect2(-3, -3, 89, 89) patch_margin_left = 16 @@ -1105,7 +1102,7 @@ script = ExtResource("21_l5wui") [node name="connect_pribor" type="AnimatedSprite2D" parent="pribor_uyep/panel_pribor"] light_mask = 3 -position = Vector2(11.4285, 12.8571) +position = Vector2(-0.00012207, 12.8571) scale = Vector2(0.6, 0.596) sprite_frames = SubResource("SpriteFrames_foasq") frame_progress = 0.72355 @@ -1126,7 +1123,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-2в"] metadata/online_proc = "on_line_changed" @@ -1225,7 +1221,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-2н"] metadata/online_proc = "on_line_changed" @@ -1326,7 +1321,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-2к"] metadata/online_proc = "on_line_changed" @@ -1425,7 +1419,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-3в"] metadata/online_proc = "on_line_changed" @@ -1524,7 +1517,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-3н"] metadata/online_proc = "on_line_changed" @@ -1623,7 +1615,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 1, 0, 1), Color(1, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-3к"] metadata/online_proc = "on_line_changed" @@ -1722,7 +1713,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(100, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-1в"] metadata/online_proc = "on_line_changed" @@ -1820,7 +1810,6 @@ stretch_mode = 4 flip_h = true script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(100, 0, 0, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-1к"] metadata/online_proc = "on_line_changed" @@ -1918,7 +1907,6 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-4в"] metadata/online_proc = "on_line_changed" @@ -2016,7 +2004,6 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-4н"] metadata/online_proc = "on_line_changed" @@ -2114,7 +2101,6 @@ texture_normal = ExtResource("6_i1yfn") stretch_mode = 4 script = ExtResource("3_4pt7j") state_colors = [Color(1, 1, 1, 1), Color(0, 0.87, 0, 1), Color(0.65, 0.0715, 0.0715, 1)] -timeout_tween = null metadata/unit_name = ["уарэп-яу07-4к"] metadata/online_proc = "on_line_changed"