[gd_scene load_steps=11 format=3 uid="uid://p2suppildvq0"]

[ext_resource type="Texture2D" uid="uid://ce3qpf070wgd2" path="res://pictures/состояние-исправности-0.png" id="1_2n7he"]
[ext_resource type="Texture2D" uid="uid://cgtg4gbqnuxrc" path="res://pictures/nine-patch-round.png" id="2_4b43i"]
[ext_resource type="Texture2D" uid="uid://byweg7pgt8o4h" path="res://pictures/состояние-исправности-1.png" id="2_38t58"]
[ext_resource type="Texture2D" uid="uid://dkef6xwxwdxi8" path="res://pictures/эмс-бланк.png" id="3_4kmgr"]
[ext_resource type="Texture2D" uid="uid://bvikuv0lbvou8" path="res://pictures/состояние-исправности-2.png" id="3_i2t3v"]
[ext_resource type="Texture2D" uid="uid://b15flrfytxkop" path="res://pictures/эмс-бланк-пост.png" id="4_omove"]
[ext_resource type="Texture2D" uid="uid://ijdfo2mml54" path="res://pictures/эмс-бланк-перем.png" id="5_jia67"]

[sub_resource type="GDScript" id="GDScript_fbktk"]
script/source = "@tool

extends Control


@export var margins: Array[int] = [8, 8, 5, 8]  # top, left, bottom, right


@export var textures: Array[Texture]


@export var self_size: Vector2i = Vector2i(50, 150):
    set(v):
        self_size = v
        size = v
        $np_rect.size = v
        _resize_children()
    get: return size


@export var fname: String:
    set(v):
        fname = v
        $lbl_fname.text = v


@export var rname: String:
    set(v):
        rname = v
        $lbl_rname.text = v


func _resize_children() -> void:
    $lbl_rname.size.x = size.x
    $lbl_rname.position.y = margins[0]
    $lbl_fname.size.y = size.x
    $lbl_fname.position.y = size.y / 2 + $lbl_fname.size.x / 2
    $txr_state.position.x = size.x / 2 - ($txr_state.size.x * $txr_state.scale.x) / 2
    $txr_state.position.y = size.y - $txr_state.size.y * $txr_state.scale.x - margins[2]


func _on_nine_patch_rect_resized() -> void:
    size = $np_rect.size
    self_size = $np_rect.size
    _resize_children()


func _on_resized() -> void:
    $np_rect.size = size
    self_size = size
    _resize_children()


@export var state: int:
    set(v):
        v = 0 if v < 0 else v
        v %= textures.size()
        state = v
        $txr_state.texture = textures[v]
    get:
        return state
"

[sub_resource type="ShaderMaterial" id="ShaderMaterial_45ast"]

[sub_resource type="SpriteFrames" id="SpriteFrames_nofpw"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_4kmgr")
}, {
"duration": 1.0,
"texture": ExtResource("4_omove")
}, {
"duration": 1.0,
"texture": ExtResource("5_jia67")
}, {
"duration": 1.0,
"texture": null
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]

[node name="yelement_v" type="Control"]
editor_description = "Элемент замены из ЗИП"
layout_mode = 3
anchors_preset = 0
offset_right = 50.0
offset_bottom = 150.0
script = SubResource("GDScript_fbktk")
margins = Array[int]([8, 8, 8, 8])
textures = Array[Texture]([ExtResource("1_2n7he"), ExtResource("2_38t58"), ExtResource("3_i2t3v")])
metadata/ref_des = ""
metadata/dec_num = ""

[node name="lbl_rname" type="Label" parent="."]
layout_mode = 0
offset_top = 8.0
offset_right = 50.0
offset_bottom = 34.0
theme_override_colors/font_color = Color(0.991, 0.991, 0.991, 0.675)
theme_override_font_sizes/font_size = 17
text = "A1"
horizontal_alignment = 1
vertical_alignment = 1

[node name="lbl_fname" type="Label" parent="."]
self_modulate = Color(1, 1, 1, 0.627451)
layout_mode = 0
offset_top = 123.0
offset_right = 94.0
offset_bottom = 173.0
rotation = -1.5708
theme_override_font_sizes/font_size = 17
text = "Ячейка"
horizontal_alignment = 1
vertical_alignment = 1

[node name="txr_state" type="TextureRect" parent="."]
material = SubResource("ShaderMaterial_45ast")
layout_mode = 0
offset_left = 14.0
offset_top = 110.0
offset_right = 256.0
offset_bottom = 352.0
scale = Vector2(0.1, 0.1)
size_flags_vertical = 6
texture = ExtResource("1_2n7he")
stretch_mode = 2
metadata/_edit_lock_ = true

[node name="np_rect" type="NinePatchRect" parent="."]
layout_mode = 0
offset_right = 50.0
offset_bottom = 150.0
texture = ExtResource("2_4b43i")
region_rect = Rect2(0, 0, 63, 63)
patch_margin_left = 16
patch_margin_top = 16
patch_margin_right = 16
patch_margin_bottom = 16
metadata/_edit_lock_ = true

[node name="SZI_x" type="AnimatedSprite2D" parent="."]
visible = false
position = Vector2(524, 454)
sprite_frames = SubResource("SpriteFrames_nofpw")
metadata/_edit_lock_ = true

[connection signal="resized" from="." to="." method="_on_resized"]
[connection signal="resized" from="np_rect" to="." method="_on_nine_patch_rect_resized"]
