[gd_scene load_steps=7 format=3 uid="uid://bnlkbbn7b4a3k"]

[ext_resource type="Texture2D" uid="uid://cgtg4gbqnuxrc" path="res://pictures/nine-patch-round.png" id="1_lmmwb"]
[ext_resource type="Texture2D" uid="uid://dkef6xwxwdxi8" path="res://pictures/эмс-бланк.png" id="3_2trq1"]
[ext_resource type="Texture2D" uid="uid://b15flrfytxkop" path="res://pictures/эмс-бланк-пост.png" id="4_vgjvf"]
[ext_resource type="Texture2D" uid="uid://ijdfo2mml54" path="res://pictures/эмс-бланк-перем.png" id="5_1heoc"]

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

extends Control


@export var margins: Array[int] = [8, 8, 8, 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


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="SpriteFrames" id="SpriteFrames_nofpw"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_2trq1")
}, {
"duration": 1.0,
"texture": ExtResource("4_vgjvf")
}, {
"duration": 1.0,
"texture": ExtResource("5_1heoc")
}, {
"duration": 1.0,
"texture": null
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]

[node name="yelement_ems" type="Control"]
editor_description = "Элемент замены из ЗИП"
layout_mode = 3
anchors_preset = 0
offset_right = 50.0
offset_bottom = 150.0
script = SubResource("GDScript_fbktk")
textures = Array[Texture]([ExtResource("1_lmmwb"), ExtResource("1_lmmwb"), ExtResource("1_lmmwb")])
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 = 16
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="np_rect" type="NinePatchRect" parent="."]
layout_mode = 0
offset_right = 50.0
offset_bottom = 150.0
texture = ExtResource("1_lmmwb")
region_rect = Rect2(0, 0, 63, 63)
patch_margin_left = 16
patch_margin_top = 16
patch_margin_right = 16
patch_margin_bottom = 16

[node name="SZI_x" type="AnimatedSprite2D" parent="."]
position = Vector2(25, 155)
sprite_frames = SubResource("SpriteFrames_nofpw")

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