Исправление. Размер пакета не верный
This commit is contained in:
70
scenes/контроль/элемент-я.gd
Normal file
70
scenes/контроль/элемент-я.gd
Normal file
@@ -0,0 +1,70 @@
|
||||
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'))
|
||||
1
scenes/контроль/элемент-я.gd.uid
Normal file
1
scenes/контроль/элемент-я.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://blnakmwyvinxm
|
||||
@@ -1,83 +1,11 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://btpc78gucr57f"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://blnakmwyvinxm" path="res://scenes/контроль/элемент-я.gd" id="1_ajips"]
|
||||
[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
|
||||
|
||||
@@ -120,7 +48,7 @@ layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 180.0
|
||||
offset_bottom = 155.0
|
||||
script = SubResource("GDScript_rmhe2")
|
||||
script = ExtResource("1_ajips")
|
||||
textures = [ExtResource("3_dktys"), ExtResource("3_t4y6r"), ExtResource("4_bdhnj")]
|
||||
|
||||
[node name="rect" type="NinePatchRect" parent="."]
|
||||
|
||||
Reference in New Issue
Block a user