diff --git a/data/кнопка-внешние-0.png b/data/кнопка-внешние-0.png new file mode 100644 index 00000000..9e33a0ad Binary files /dev/null and b/data/кнопка-внешние-0.png differ diff --git a/data/кнопка-внешние-0.png.import b/data/кнопка-внешние-0.png.import new file mode 100644 index 00000000..96a43a8e --- /dev/null +++ b/data/кнопка-внешние-0.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bb80aigvv648i" +path="res://.godot/imported/кнопка-внешние-0.png-e1c8d55052eea7718633f8a54303eafa.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://data/кнопка-внешние-0.png" +dest_files=["res://.godot/imported/кнопка-внешние-0.png-e1c8d55052eea7718633f8a54303eafa.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index c8cecac8..899f9c22 100644 --- a/project.godot +++ b/project.godot @@ -117,6 +117,7 @@ folder_colors={ "res://scenes/grid-buttons-ecm/": "blue", "res://scenes/grid-side-panel/": "blue", "res://scenes/pribor-afsp/": "purple", +"res://scenes/pribor-externals/": "purple", "res://scenes/pribor-prd-k/": "purple", "res://scenes/pribor-prd-n/": "purple", "res://scenes/pribor-prd-v/": "purple", diff --git a/scenes/pribor-externals/externals.gd b/scenes/pribor-externals/externals.gd new file mode 100644 index 00000000..4e525d40 --- /dev/null +++ b/scenes/pribor-externals/externals.gd @@ -0,0 +1,16 @@ +@tool +class_name pribor_externals extends 'res://scenes/контроль/прибор.gd' +var UnitPanel = load('res://scenes/контроль/элемент-ю.tscn') + + +func _ready() -> void: + if Engine.is_editor_hint(): + return + for unit_inst in network.units.values(): + var unit_panel = UnitPanel.instantiate() + unit_panel.fname = unit_inst.name + $grid.add_child(unit_panel) + + +func on_line_changed(unit_inst): + pass diff --git a/scenes/pribor-externals/externals.gd.uid b/scenes/pribor-externals/externals.gd.uid new file mode 100644 index 00000000..ff00f2c0 --- /dev/null +++ b/scenes/pribor-externals/externals.gd.uid @@ -0,0 +1 @@ +uid://beb41qdahkdp5 diff --git a/scenes/pribor-externals/externals.tscn b/scenes/pribor-externals/externals.tscn new file mode 100644 index 00000000..830053fe --- /dev/null +++ b/scenes/pribor-externals/externals.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3 uid="uid://dwgvv4b4a5t1"] + +[ext_resource type="Script" uid="uid://beb41qdahkdp5" path="res://scenes/pribor-externals/externals.gd" id="1_pacm1"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_pacm1"] + +[node name="externals" type="PanelContainer"] +offset_left = 71.0 +offset_top = 75.0 +offset_right = 756.0 +offset_bottom = 964.0 +theme_override_styles/panel = SubResource("StyleBoxEmpty_pacm1") +script = ExtResource("1_pacm1") + +[node name="grid" type="GridContainer" parent="."] +layout_mode = 2 diff --git a/scenes/контроль/кнопка-прибора.gd b/scenes/контроль/кнопка-прибора.gd index 4575a6ca..d8418b6d 100644 --- a/scenes/контроль/кнопка-прибора.gd +++ b/scenes/контроль/кнопка-прибора.gd @@ -5,9 +5,12 @@ extends Node @export var state_colors: Array func _on_toggled(toggled_on): $frame.visible = toggled_on +func _enter_tree() -> void: $label.self_modulate = state + @export var state: int: set(v): v = 0 if v < 0 else v % state_colors.size() state = v - $label.self_modulate = state_colors[v] + if is_inside_tree(): + $label.self_modulate = state_colors[v] diff --git a/scenes/контроль/контроль.gd b/scenes/контроль/контроль.gd index 46283e2f..24ade4cf 100644 --- a/scenes/контроль/контроль.gd +++ b/scenes/контроль/контроль.gd @@ -6,6 +6,7 @@ extends Panel #TODO: рефактор: заменить подчёркивание на тире const PRIBORS_RES = \ { + 'externals': ['res://scenes/pribor-externals/externals.tscn', 'Контроль подключения внешних систем'], 'pribor_prd_k_1': ['res://scenes/pribor-prd-k/pribor-prd-k.tscn', 'Контроль исправности прибора ПРД-К 1'], 'pribor_prd_k_2': ['res://scenes/pribor-prd-k/pribor-prd-k.tscn', 'Контроль исправности прибора ПРД-К 2'], 'pribor_prd_k_3': ['res://scenes/pribor-prd-k/pribor-prd-k.tscn', 'Контроль исправности прибора ПРД-К 3'], diff --git a/scenes/контроль/контроль.tscn b/scenes/контроль/контроль.tscn index a6c4fb8b..790d066d 100644 --- a/scenes/контроль/контроль.tscn +++ b/scenes/контроль/контроль.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=16 format=3 uid="uid://lwmw4egynmd1"] +[gd_scene load_steps=17 format=3 uid="uid://lwmw4egynmd1"] [ext_resource type="Script" uid="uid://b0wcp76bbl2jx" path="res://scenes/контроль/контроль.gd" id="1_x5d6w"] [ext_resource type="Texture2D" uid="uid://bar8k5qef7kch" path="res://data/УФ.png" id="2_0nvm1"] +[ext_resource type="Texture2D" uid="uid://bb80aigvv648i" path="res://data/кнопка-внешние-0.png" id="2_oysma"] [ext_resource type="Script" uid="uid://bj4nndrurbunl" path="res://scenes/контроль/кнопка-прибора.gd" id="3_4pt7j"] [ext_resource type="Texture2D" uid="uid://dkqlvd750pplc" path="res://data/СПТ.png" id="3_hhadv"] [ext_resource type="Texture2D" uid="uid://b0o8jhb5jbrev" path="res://data/рамка-1.png" id="4_rasbe"] @@ -38,6 +39,59 @@ grow_vertical = 2 script = ExtResource("1_x5d6w") metadata/_edit_lock_ = true +[node name="externals" type="TextureButton" parent="." groups=["pribor_buttons"]] +editor_description = "Кнопка для отображения внешних соединений." +layout_mode = 0 +offset_left = 1435.0 +offset_top = 32.0 +offset_right = 1691.0 +offset_bottom = 288.0 +scale = Vector2(0.5, 0.5) +size_flags_horizontal = 15 +size_flags_vertical = 15 +toggle_mode = true +action_mode = 0 +texture_normal = ExtResource("2_oysma") +stretch_mode = 0 +script = ExtResource("3_4pt7j") +state_colors = [Color(1, 1, 1, 1), Color(0, 0.74, 0.37, 1), Color(0.854902, 0.0705882, 0.0705882, 1)] + +[node name="label" type="Label" parent="externals"] +self_modulate = Color(0, 0, 0, 0) +layout_mode = 0 +offset_left = 58.0 +offset_top = -26.0 +offset_right = 219.0 +offset_bottom = -7.0 +text = "Внешние подключения" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="frame" type="NinePatchRect" parent="externals"] +visible = false +self_modulate = Color(0.890196, 0.486275, 0.196078, 1) +layout_mode = 0 +offset_left = -32.0 +offset_top = -12.0 +offset_right = 123.0 +offset_bottom = 111.0 +scale = Vector2(2, 2) +texture = ExtResource("4_rasbe") +region_rect = Rect2(-3, -3, 89, 89) +patch_margin_left = 16 +patch_margin_top = 16 +patch_margin_right = 16 +patch_margin_bottom = 16 + +[node name="connect_pribor" type="AnimatedSprite2D" parent="externals"] +modulate = Color(0.498039, 0.498039, 0.498039, 1) +light_mask = 3 +position = Vector2(47.9999, 30) +scale = Vector2(1.23077, 1.25) +sprite_frames = SubResource("SpriteFrames_foasq") +frame_progress = 0.72355 +script = ExtResource("11_u7tym") + [node name="pribor_uf" type="TextureButton" parent="." groups=["pribor_buttons"]] editor_description = "Кнопка для выбора прибора." layout_mode = 0 @@ -1005,6 +1059,7 @@ text = "Контроль исправности прибора" horizontal_alignment = 1 vertical_alignment = 1 +[connection signal="toggled" from="externals" to="externals" method="_on_toggled"] [connection signal="toggled" from="pribor_uf" to="pribor_uf" method="_on_toggled"] [connection signal="toggled" from="pribor_rtr" to="pribor_rtr" method="_on_toggled"] [connection signal="toggled" from="pribor_afsp_1" to="pribor_afsp_1" method="_on_toggled"] diff --git a/scenes/контроль/элемент-ю.tscn b/scenes/контроль/элемент-ю.tscn new file mode 100644 index 00000000..5a37e844 --- /dev/null +++ b/scenes/контроль/элемент-ю.tscn @@ -0,0 +1,163 @@ +[gd_scene load_steps=13 format=3 uid="uid://xj4vbivv3xwp"] + +[ext_resource type="Texture2D" uid="uid://c6nve6f8sfyj2" path="res://data/состояние-исправности-0.png" id="2_isu4f"] +[ext_resource type="Texture2D" uid="uid://dnreyfh3cd1k2" path="res://data/состояние-исправности-1.png" id="3_07yc3"] +[ext_resource type="Texture2D" uid="uid://c6booa8753u5t" path="res://data/состояние-исправности-2.png" id="4_348cs"] +[ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="5_qwfg5"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_hu2vd"] + +[sub_resource type="GDScript" id="GDScript_3rlfa"] +script/source = "extends Control + +@export var textures: Array +@export var unit_name: String = '' + + +enum STATE_VAL { + NONE = 0, + GOOD = 1, + ERROR = 2 } + + +signal pressed(control: PanelContainer) + + +func _on_button_pressed(): emit_signal('pressed', self) +func _ready() -> void: call_deferred('_on_resized') + + +@export var state: int: + set(v): + state = tools.clip_value(v, 0, textures.size() - 1) + if is_inside_tree(): + $margin/vbox/grid/state.texture = textures[state] + + +@export var fname: String: + set(v): + fname = v + if is_inside_tree(): + $margin/vbox/grid/fname.text = v + + +func _on_resized() -> void: + $rect.size = size + $margin.size = size + + +func _enter_tree() -> void: + if Engine.is_editor_hint(): return + $margin/vbox/grid/fname.text = fname + $margin/vbox/grid/state.texture = textures[state] + + +func _exit_tree() -> void: + if Engine.is_editor_hint(): return + pass +" + +[sub_resource type="GDScript" id="GDScript_45hqb"] +script/source = "@tool + +extends MarginContainer + + +func _enter_tree() -> void: + margins = [8, 8, 8, 8] + + +@export var margins: Array: + set(vals): + add_theme_constant_override('margin_top', vals[0]) + add_theme_constant_override('margin_left', vals[1]) + add_theme_constant_override('margin_bottom', vals[2]) + add_theme_constant_override('margin_right', vals[3]) + get: + var vals = [0, 0, 0, 0] + vals[0] = get_theme_constant('margin_top') + vals[1] = get_theme_constant('margin_left') + vals[2] = get_theme_constant('margin_bottom') + vals[3] = get_theme_constant('margin_right') + return vals +" + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_evx06"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_emtms"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xxyaa"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_cd4fw"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ox0yw"] + +[node name="yelement_yu" type="PanelContainer"] +editor_description = "Элемент замены из ЗИП" +custom_minimum_size = Vector2(32, 32) +offset_right = 264.0 +offset_bottom = 55.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +theme_override_styles/panel = SubResource("StyleBoxEmpty_hu2vd") +script = SubResource("GDScript_3rlfa") +textures = [ExtResource("2_isu4f"), ExtResource("3_07yc3"), ExtResource("4_348cs")] + +[node name="rect" type="NinePatchRect" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +texture = ExtResource("5_qwfg5") +draw_center = false +region_rect = Rect2(0, 0, 63, 63) +patch_margin_left = 17 +patch_margin_top = 17 +patch_margin_right = 17 +patch_margin_bottom = 15 + +[node name="margin" type="MarginContainer" parent="."] +layout_mode = 2 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 8 +script = SubResource("GDScript_45hqb") +margins = [8, 8, 8, 8] + +[node name="vbox" type="VBoxContainer" parent="margin"] +layout_mode = 2 + +[node name="grid" type="GridContainer" parent="margin/vbox"] +layout_mode = 2 +size_flags_vertical = 3 +columns = 3 + +[node name="state" type="TextureRect" parent="margin/vbox/grid"] +custom_minimum_size = Vector2(24, 24) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +texture = ExtResource("2_isu4f") +expand_mode = 1 + +[node name="fname" type="Label" parent="margin/vbox/grid"] +self_modulate = Color(1, 1, 1, 0.627451) +layout_mode = 2 +size_flags_horizontal = 2 +size_flags_vertical = 6 +theme_override_font_sizes/font_size = 17 +text = "<Название>" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="button" type="Button" parent="."] +custom_minimum_size = Vector2(100, 32) +layout_mode = 2 +theme_override_styles/focus = SubResource("StyleBoxEmpty_evx06") +theme_override_styles/disabled = SubResource("StyleBoxEmpty_emtms") +theme_override_styles/hover = SubResource("StyleBoxEmpty_xxyaa") +theme_override_styles/pressed = SubResource("StyleBoxEmpty_cd4fw") +theme_override_styles/normal = SubResource("StyleBoxEmpty_ox0yw") + +[connection signal="resized" from="." to="." method="_on_resized"] +[connection signal="pressed" from="button" to="." method="_on_button_pressed"]