From 604e8dc87599a8073c6591d905021e3a83e6911b Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 13 Dec 2024 04:17:40 +0300 Subject: [PATCH] refactor --- PRD_MP550.tscn | 253 ++++++++++++++++++++++++++++--------------------- scripts/PRD.gd | 28 +++++- 2 files changed, 167 insertions(+), 114 deletions(-) diff --git a/PRD_MP550.tscn b/PRD_MP550.tscn index 937c427..46fa920 100644 --- a/PRD_MP550.tscn +++ b/PRD_MP550.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=39 format=3 uid="uid://cvor2jm4xk3ha"] +[gd_scene load_steps=41 format=3 uid="uid://cvor2jm4xk3ha"] [ext_resource type="Script" path="res://scripts/PRD.gd" id="1_v273n"] [ext_resource type="Script" path="res://table/table.gd" id="2_vmbyo"] @@ -42,18 +42,18 @@ corner_radius_bottom_left = 3 corner_detail = 3 anti_aliasing = false -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2vbj6"] -bg_color = Color(0.388235, 0.227451, 0.290196, 1) +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_o0too"] +bg_color = Color(0.223529, 0.168627, 0.223529, 1) [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dm3xa"] -bg_color = Color(0.388235, 0.227451, 0.290196, 1) +bg_color = Color(0.224534, 0.169766, 0.224571, 1) [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_h7n4k"] content_margin_left = 6.0 content_margin_top = 5.0 content_margin_right = 6.0 content_margin_bottom = 5.0 -bg_color = Color(0.128625, 0.147, 0.177625, 1) +bg_color = Color(0.356863, 0.278431, 0.356863, 1) border_color = Color(0.1155, 0.132, 0.1595, 1) corner_radius_top_left = 3 corner_radius_top_right = 3 @@ -73,7 +73,7 @@ anti_aliasing = false [sub_resource type="Theme" id="Theme_k5ur4"] Button/styles/disabled = SubResource("StyleBoxFlat_ewq4n") Button/styles/focus = SubResource("StyleBoxFlat_wlyk3") -Button/styles/hover = SubResource("StyleBoxFlat_2vbj6") +Button/styles/hover = SubResource("StyleBoxFlat_o0too") Button/styles/normal = SubResource("StyleBoxFlat_dm3xa") Button/styles/pressed = SubResource("StyleBoxFlat_h7n4k") TabContainer/styles/panel = SubResource("StyleBoxTexture_h8aei") @@ -81,6 +81,12 @@ TabContainer/styles/tab_focus = SubResource("StyleBoxTexture_d322q") TabContainer/styles/tab_selected = SubResource("StyleBoxTexture_8j02b") TabContainer/styles/tabbar_background = SubResource("StyleBoxTexture_ls6vm") +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pxarn"] +bg_color = Color(0.356863, 0.278431, 0.356863, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p247y"] +bg_color = Color(0.356863, 0.278431, 0.356863, 1) + [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_rh6pm"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_x11tp"] @@ -97,11 +103,6 @@ TabContainer/styles/tabbar_background = SubResource("StyleBoxTexture_ls6vm") [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_tn8m6"] -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ovl8a"] -bg_color = Color(0.388235, 0.227451, 0.290196, 1) -corner_detail = 1 -anti_aliasing = false - [sub_resource type="SpriteFrames" id="SpriteFrames_vex4t"] animations = [{ "frames": [{ @@ -156,56 +157,80 @@ shader_parameter/turn = 0.785 [sub_resource type="GradientTexture2D" id="GradientTexture2D_0pk2o"] gradient = SubResource("Gradient_ki0n7") +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_ooo4i"] + [node name="Node2D" type="Node2D"] script = ExtResource("1_v273n") [node name="Background" type="ColorRect" parent="."] offset_right = 1941.0 offset_bottom = 988.0 +theme = SubResource("Theme_k5ur4") color = Color(0.356863, 0.278431, 0.356863, 1) metadata/_edit_lock_ = true -[node name="Litera_2_4_6" type="ColorRect" parent="Background"] -visible = false +[node name="side_panel" type="ColorRect" parent="Background"] layout_mode = 0 -offset_top = 54.0 -offset_right = 1941.0 -offset_bottom = 344.0 +offset_right = 216.0 +offset_bottom = 988.0 color = Color(0.586231, 0.481877, 0.585869, 1) +[node name="select_prd" type="Button" parent="Background/side_panel"] +offset_top = 120.0 +offset_right = 216.0 +offset_bottom = 156.0 +focus_mode = 0 +mouse_default_cursor_shape = 2 +theme_override_font_sizes/font_size = 14 +theme_override_styles/pressed = SubResource("StyleBoxFlat_pxarn") +toggle_mode = true +button_pressed = true +text = "ПРД" + +[node name="select_control" type="Button" parent="Background/side_panel"] +offset_top = 160.0 +offset_right = 216.0 +offset_bottom = 196.0 +focus_mode = 0 +mouse_default_cursor_shape = 2 +theme_override_font_sizes/font_size = 14 +theme_override_styles/pressed = SubResource("StyleBoxFlat_p247y") +toggle_mode = true +text = "КОНТРОЛЬ" + +[node name="select_ems_g" type="Button" parent="Background/side_panel"] +offset_top = 200.0 +offset_right = 216.0 +offset_bottom = 236.0 +focus_mode = 0 +mouse_default_cursor_shape = 2 +theme_override_font_sizes/font_size = 14 +theme_override_styles/pressed = SubResource("StyleBoxFlat_p247y") +toggle_mode = true +text = "ЭМС Г" + [node name="Litera_3_5_7" type="ColorRect" parent="Background"] visible = false layout_mode = 0 -offset_top = 352.0 +offset_top = 48.0 offset_right = 1941.0 -offset_bottom = 656.0 +offset_bottom = 352.0 color = Color(0.669446, 0.567301, 0.66881, 1) [node name="Litera_1" type="ColorRect" parent="Background"] visible = false layout_mode = 0 -offset_top = 647.0 +offset_top = 359.0 offset_right = 2182.0 -offset_bottom = 793.0 +offset_bottom = 638.0 color = Color(0.669446, 0.567301, 0.66881, 1) -[node name="select_dev" type="ScrollContainer" parent="."] -offset_left = 24.0 -offset_top = 22.0 -offset_right = 387.0 -offset_bottom = 54.0 -metadata/_edit_lock_ = true - -[node name="select_dev" type="GridContainer" parent="select_dev"] -layout_mode = 2 -script = ExtResource("2_vmbyo") -metadata/_edit_lock_ = true - [node name="ISA" type="Label" parent="."] offset_left = 1244.0 offset_top = 11.0 offset_right = 1495.0 offset_bottom = 34.0 +metadata/_edit_lock_ = true [node name="read_isa" type="Button" parent="."] offset_left = 1104.0 @@ -213,10 +238,12 @@ offset_top = 7.0 offset_right = 1229.0 offset_bottom = 38.0 text = "Прочитать ISA" +metadata/_edit_lock_ = true [node name="TabContainer" type="TabContainer" parent="."] +offset_left = 216.0 offset_top = 39.0 -offset_right = 1941.0 +offset_right = 1989.0 offset_bottom = 917.0 theme = SubResource("Theme_k5ur4") theme_override_colors/font_unselected_color = Color(0, 0, 0, 0.0392157) @@ -231,38 +258,27 @@ theme_override_styles/tab_unselected = SubResource("StyleBoxTexture_17le6") tab_alignment = 2 current_tab = 1 tab_focus_mode = 0 +metadata/_edit_lock_ = true [node name="ControlPanel" type="Panel" parent="TabContainer"] visible = false layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxTexture_tn8m6") metadata/_tab_index = 0 - -[node name="control_button" type="Button" parent="TabContainer/ControlPanel"] -offset_left = 8.0 -offset_top = 40.0 -offset_right = 102.0 -offset_bottom = 68.0 -focus_mode = 0 -mouse_default_cursor_shape = 2 -theme = SubResource("Theme_k5ur4") -theme_override_font_sizes/font_size = 14 -theme_override_styles/pressed = SubResource("StyleBoxFlat_ovl8a") -toggle_mode = true -button_pressed = true -text = "КОНТРОЛЬ" +metadata/_edit_lock_ = true [node name="Controlpanel" type="ColorRect" parent="TabContainer/ControlPanel"] -offset_left = 102.0 +visible = false +offset_left = 216.0 offset_top = 40.0 -offset_right = 449.0 -offset_bottom = 596.0 +offset_right = 1867.0 +offset_bottom = 734.0 color = Color(0.390334, 0.227948, 0.288326, 1) [node name="control_dev" type="ScrollContainer" parent="TabContainer/ControlPanel"] -offset_left = 126.0 +offset_left = 240.0 offset_top = 50.0 -offset_right = 461.0 +offset_right = 575.0 offset_bottom = 634.0 [node name="control_tbl" type="GridContainer" parent="TabContainer/ControlPanel/control_dev"] @@ -299,13 +315,13 @@ metadata/_edit_lock_ = true layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxTexture_7u7p7") metadata/_tab_index = 1 +metadata/_edit_lock_ = true [node name="scroll1" type="ScrollContainer" parent="TabContainer/PRD"] -offset_left = 985.0 -offset_top = 3.0 -offset_right = 1348.0 -offset_bottom = 284.0 -metadata/_edit_lock_ = true +offset_left = 969.0 +offset_top = 27.0 +offset_right = 1332.0 +offset_bottom = 308.0 [node name="table1" type="GridContainer" parent="TabContainer/PRD/scroll1"] layout_mode = 2 @@ -313,11 +329,10 @@ script = ExtResource("2_vmbyo") metadata/_edit_lock_ = true [node name="scroll2" type="ScrollContainer" parent="TabContainer/PRD"] -offset_left = 985.0 -offset_top = 307.0 -offset_right = 1348.0 -offset_bottom = 595.0 -metadata/_edit_lock_ = true +offset_left = 969.0 +offset_top = 331.0 +offset_right = 1332.0 +offset_bottom = 619.0 [node name="table2" type="GridContainer" parent="TabContainer/PRD/scroll2"] layout_mode = 2 @@ -325,17 +340,17 @@ script = ExtResource("2_vmbyo") metadata/_edit_lock_ = true [node name="LABEL" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = -7.0 -offset_right = 876.0 -offset_bottom = 16.0 +offset_left = 482.0 +offset_top = 17.0 +offset_right = 764.0 +offset_bottom = 40.0 text = "ЛИТЕРА 2! ПРД-Н!" [node name="Zapret" type="Button" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 21.0 -offset_right = 712.0 -offset_bottom = 55.0 +offset_left = 482.0 +offset_top = 45.0 +offset_right = 600.0 +offset_bottom = 79.0 focus_mode = 0 mouse_default_cursor_shape = 2 theme_override_styles/pressed = SubResource("StyleBoxTexture_otisn") @@ -344,17 +359,17 @@ text = " Запрет СИ2" metadata/litera = 48 [node name="LABEL2" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 305.0 -offset_right = 876.0 -offset_bottom = 328.0 +offset_left = 482.0 +offset_top = 329.0 +offset_right = 764.0 +offset_bottom = 352.0 text = "ЛИТЕРА 3! ПРД-Н!" [node name="Zapret2" type="Button" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 333.0 -offset_right = 712.0 -offset_bottom = 367.0 +offset_left = 482.0 +offset_top = 357.0 +offset_right = 600.0 +offset_bottom = 391.0 focus_mode = 0 mouse_default_cursor_shape = 2 theme_override_styles/pressed = SubResource("StyleBoxTexture_otisn") @@ -363,60 +378,60 @@ text = " Запрет СИ3" metadata/litera = 49 [node name="Label_luch" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 76.0 -offset_right = 876.0 -offset_bottom = 99.0 +offset_left = 482.0 +offset_top = 100.0 +offset_right = 764.0 +offset_bottom = 123.0 text = "Номер и направление луча" [node name="LUCH" type="OptionButton" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 108.0 -offset_right = 712.0 -offset_bottom = 139.0 +offset_left = 482.0 +offset_top = 132.0 +offset_right = 600.0 +offset_bottom = 163.0 item_count = 2 popup/item_0/text = "Что-то" popup/item_1/text = "Что-то" popup/item_1/id = 1 [node name="Modul" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 378.0 -offset_right = 738.0 -offset_bottom = 401.0 +offset_left = 482.0 +offset_top = 402.0 +offset_right = 626.0 +offset_bottom = 425.0 text = "Модуляция" [node name="DKM2" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 159.0 -offset_right = 736.0 -offset_bottom = 182.0 +offset_left = 482.0 +offset_top = 183.0 +offset_right = 624.0 +offset_bottom = 206.0 text = "ДКМ ДОУ 2" [node name="DKM3" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 407.0 -offset_right = 736.0 -offset_bottom = 430.0 +offset_left = 482.0 +offset_top = 431.0 +offset_right = 624.0 +offset_bottom = 454.0 text = "ДКМ ДОУ 3" [node name="FGOZ2" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 182.0 -offset_right = 767.0 -offset_bottom = 205.0 +offset_left = 482.0 +offset_top = 206.0 +offset_right = 655.0 +offset_bottom = 229.0 text = "ФГОЗ 2" [node name="FGOZ3" type="Label" parent="TabContainer/PRD"] -offset_left = 594.0 -offset_top = 430.0 -offset_right = 767.0 -offset_bottom = 453.0 +offset_left = 482.0 +offset_top = 454.0 +offset_right = 655.0 +offset_bottom = 477.0 text = "ФГОЗ 3" [node name="PSK" type="Sprite2D" parent="TabContainer/PRD"] material = ExtResource("3_3syd3") -position = Vector2(1388.25, 5) +position = Vector2(1276.25, 29) scale = Vector2(0.247968, 0.234167) texture = SubResource("PlaceholderTexture2D_723du") offset = Vector2(800, 600) @@ -444,7 +459,7 @@ metadata/_edit_lock_ = true [node name="PSK2" type="Sprite2D" parent="TabContainer/PRD"] material = ExtResource("3_3syd3") -position = Vector2(1388, 302) +position = Vector2(1276, 326) scale = Vector2(0.247968, 0.234167) texture = SubResource("PlaceholderTexture2D_723du") offset = Vector2(800, 600) @@ -470,5 +485,25 @@ scale = Vector2(21.8765, 21.6782) texture = SubResource("GradientTexture2D_0pk2o") metadata/_edit_lock_ = true +[node name="select_dev" type="ScrollContainer" parent="TabContainer/PRD"] +offset_left = 12.0 +offset_top = 64.0 +offset_right = 375.0 +offset_bottom = 96.0 + +[node name="select_dev" type="GridContainer" parent="TabContainer/PRD/select_dev"] +layout_mode = 2 +script = ExtResource("2_vmbyo") +metadata/_edit_lock_ = true + +[node name="EMS_G" type="Panel" parent="TabContainer"] +visible = false +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxTexture_ooo4i") +metadata/_tab_index = 2 +metadata/_edit_lock_ = true + +[connection signal="pressed" from="Background/side_panel/select_prd" to="." method="_on_prd_select"] +[connection signal="pressed" from="Background/side_panel/select_control" to="." method="_on_control_button"] +[connection signal="pressed" from="Background/side_panel/select_ems_g" to="." method="_on_emsg_select"] [connection signal="pressed" from="read_isa" to="." method="_on_read_isa_pressed"] -[connection signal="toggled" from="TabContainer/ControlPanel/control_button" to="." method="_on_control_button"] diff --git a/scripts/PRD.gd b/scripts/PRD.gd index 5fcdaf6..15566f0 100644 --- a/scripts/PRD.gd +++ b/scripts/PRD.gd @@ -26,7 +26,7 @@ func _ready() -> void: node_select2.set_node_text(1, 0, 'Температура') # Выбор прибора для подключения - var node_select_device = $select_dev/select_dev + var node_select_device = $TabContainer/PRD/select_dev/select_dev draw_tabl(node_select_device, Constants.SELECT_DEVICE, Constants.SELECT_DEVICE.size()) var get_select_device = node_select_device.get_node2(1, 0) @@ -212,13 +212,31 @@ func set_frame(node: Node, val: int): node.set_frame(val) #return binary_string -func _on_control_button(toggled_on: bool) -> void: - $TabContainer/ControlPanel/control_dev.visible = toggled_on - $TabContainer/ControlPanel/Controlpanel.visible = toggled_on +func _on_prd_select() -> void: + $TabContainer.current_tab = 1 + $Background/side_panel/select_prd.button_pressed = true + $Background/side_panel/select_control.button_pressed = false + $Background/side_panel/select_ems_g.button_pressed = false +func _on_control_button() -> void: + $TabContainer.current_tab = 0 + $Background/side_panel/select_control.button_pressed = true + $Background/side_panel/select_prd.button_pressed = false + $Background/side_panel/select_ems_g.button_pressed = false + #$TabContainer/ControlPanel/control_dev.visible = toggled_on + #$TabContainer/ControlPanel/Controlpanel.visible = toggled_on + + +func _on_emsg_select() -> void: + $TabContainer.current_tab = 2 + $Background/side_panel/select_ems_g.button_pressed = true + $Background/side_panel/select_control.button_pressed = false + $Background/side_panel/select_prd.button_pressed = false + + func on_btn_select(intem_from_sector): - var node_select_device = $select_dev/select_dev + var node_select_device = $TabContainer/PRD/select_dev/select_dev var get_select_device = node_select_device.get_node2(1, 0) var meta = get_select_device.get_item_metadata(intem_from_sector) Network.address = meta[0]