Files
uarep-ctl/scenes/контроль/элемент-я.tscn

195 lines
5.7 KiB
Plaintext

[gd_scene load_steps=12 format=3 uid="uid://btpc78gucr57f"]
[ext_resource type="Texture2D" uid="uid://c6nve6f8sfyj2" path="res://data/состояние-исправности-0.png" id="3_dktys"]
[ext_resource type="Texture2D" uid="uid://dnreyfh3cd1k2" path="res://data/состояние-исправности-1.png" id="3_t4y6r"]
[ext_resource type="Texture2D" uid="uid://c6booa8753u5t" path="res://data/состояние-исправности-2.png" id="4_bdhnj"]
[ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="4_or1kj"]
[sub_resource type="GDScript" id="GDScript_rmhe2"]
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)
@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[v]
@export var fname: String:
set(v):
fname = v
if is_inside_tree():
$margin/vbox/grid/fname.text = v
@export var rname: String:
set(v):
rname = v
if is_inside_tree():
$margin/vbox/grid/rname.text = v
@export var alignment: int:
set(v):
if is_inside_tree():
$margin/vbox.alignment = v
func _ready() -> void: call_deferred('_on_resized')
func _on_resized() -> void:
$rect.size = size
$margin.size = size
func _enter_tree() -> void:
if Engine.is_editor_hint(): return
var unit_any = network.get_unit_instance(unit_name)
unit_any.connect('data_received', Callable(self, 'on_data_received'))
unit_any.connect('line_changed', Callable(self, 'on_line_changed'))
$margin/vbox.alignment = alignment
$margin/vbox/grid/fname.text = fname
$margin/vbox/grid/rname.text = rname
$margin/vbox/grid/state.texture = textures[state]
func _exit_tree() -> void:
if Engine.is_editor_hint(): return
var unit_any = network.get_unit_instance(unit_name)
unit_any.disconnect('data_received', Callable(self, 'on_data_received'))
unit_any.disconnect('line_changed', Callable(self, 'on_line_changed'))
"
[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_ya" type="Control"]
editor_description = "Элемент замены из ЗИП"
custom_minimum_size = Vector2(32, 32)
layout_mode = 3
anchors_preset = 0
offset_right = 180.0
offset_bottom = 155.0
script = SubResource("GDScript_rmhe2")
textures = [ExtResource("3_dktys"), ExtResource("3_t4y6r"), ExtResource("4_bdhnj")]
[node name="rect" type="NinePatchRect" parent="."]
layout_mode = 2
offset_right = 180.0
offset_bottom = 155.0
size_flags_horizontal = 3
size_flags_vertical = 3
texture = ExtResource("4_or1kj")
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
offset_right = 180.0
offset_bottom = 155.0
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
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("3_dktys")
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
horizontal_alignment = 1
vertical_alignment = 1
[node name="rname" type="Label" parent="margin/vbox/grid"]
layout_mode = 2
size_flags_horizontal = 10
size_flags_vertical = 6
theme_override_font_sizes/font_size = 22
horizontal_alignment = 2
vertical_alignment = 1
[node name="button" type="Button" parent="."]
layout_mode = 2
offset_right = 180.0
offset_bottom = 155.0
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"]