Рефактор. Большое перемещение файлов

This commit is contained in:
sasha80
2023-12-11 09:59:04 +03:00
parent 4df74abd14
commit 2208a07929
77 changed files with 360 additions and 362 deletions

View File

@@ -0,0 +1,38 @@
[gd_scene load_steps=4 format=3 uid="uid://b1o10yvgjpb0j"]
[ext_resource type="Texture2D" uid="uid://cs6i1xwx0pmdk" path="res://data/рамка-панели.png" id="1_q1ow7"]
[ext_resource type="Script" path="res://table/table.gd" id="2_82yax"]
[ext_resource type="Script" path="res://scenes/frame-ecm-params/scroll-ecm-params.gd" id="2_sm6tk"]
[node name="frm_ecm_params" type="NinePatchRect"]
size_flags_horizontal = 3
size_flags_vertical = 3
texture = ExtResource("1_q1ow7")
patch_margin_left = 15
patch_margin_top = 30
patch_margin_right = 15
patch_margin_bottom = 10
[node name="header" type="Label" parent="."]
clip_contents = true
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 22.0
grow_horizontal = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "Параметры сеанса"
horizontal_alignment = 1
vertical_alignment = 1
[node name="scroll" type="ScrollContainer" parent="."]
layout_mode = 0
offset_left = 4.0
offset_top = 25.0
offset_right = 476.0
offset_bottom = 256.0
script = ExtResource("2_sm6tk")
[node name="table" type="GridContainer" parent="scroll"]
layout_mode = 2
script = ExtResource("2_82yax")

View File

@@ -0,0 +1,97 @@
extends ScrollContainer
## Отображает список параметров помехи в таблице.
const CellLineEdit = preload('res://table/ячейка-2.tscn') ## Ячейка таблицы.
const TableHeader = preload('res://table/header.tscn') ## Ячейка заголовок таблицы.
const TABLE_HEADER = [ TableHeader, TableHeader ] ## Описание ряда заголовка.
const TABLE_ROW = [ CellLineEdit, CellLineEdit ] ## Описание ряда.
const TABLE_HEADERS_TEXT = ['Параметр', 'Значение' ] ## Назания колонок.
const TABLE_COLUMN_SIZE = [ 370, 85 ] ## Ширины колонок.
const TABLE_PARAMS = {
'kni': [0, 'Курсовой улог, гр.', false, 0.0, 360.0],
'powp': [1, 'Мощность, %', true, 0.0, 100.0],
'freq': [2, 'Частота, МГц', true, 400.0, 6000.0],
'width': [3, 'Занимая полоса частот, МГц', true, 0.0, 120.0],
'dur': [4, 'Длительность импульса, мкс', true, 0.0, 1000000.0],
'period': [5, 'Период повтора, мкс', true, 0.0, 1000000.0] }
func init_table():
for i in TABLE_PARAMS.size(): $table.add_row(TABLE_ROW)
for key in TABLE_PARAMS.keys():
var p = TABLE_PARAMS[key]
$table.set_node_text(0, p[0], p[1])
$table.set_node_alligment(0, p[0], HORIZONTAL_ALIGNMENT_LEFT)
$table.set_node_editable(0, p[0], false)
$table.set_node_editable(1, p[0], false)
$table.set_node_user_data(1, p[0], key)
$table.connect_columns(self, 'text_submitted', 'on_edit_entry', [1], [])
$table.set_columns_min_size(TABLE_COLUMN_SIZE)
$table.set_meta('id', 0)
# Called when the node enters the scene tree for the first time.
func _ready():
signaller.connect('interfer_selected', Callable(self, 'on_interfer_selected'))
signaller.connect('rto_threat_unsel', Callable(self, 'on_rto_threat_unsel'))
call_deferred('init_table')
func on_edit_entry(text : String, entry):
var ecm = $table.get_meta('ecm')
if $table.has_meta('ecm') == false: return
var indexis = $table.get_key_indexes(entry[0].name)
var row_i = indexis[1]
var param = $table.get_node_user_data(1, row_i)
var p = TABLE_PARAMS[param]
var old_val = ecm.get_value(param)
var val = check_value(text, p[3], p[4], old_val)
ecm.set_value(val, param)
signaller.emit_signal('interfer_new', ecm)
func check_value(val, min_val, max_val, old_val):
if val.is_valid_float():
if float(val) < min_val: return min_val
if float(val) > max_val: return max_val
return float(val)
else: return old_val
func on_interfer_selected(ecm):
if ecm != null:
$table.set_meta('ecm', ecm)
else:
$table.set_meta('ecm', null)
on_ecm_update()
func on_ecm_update():
for item in range(len(TABLE_PARAMS)):
$table.set_node_text(1, item, '')
$table.set_node_editable(1, item, false)
if $table.has_meta('ecm') == false: return
var ecm: interfer.Interfer = $table.get_meta('ecm')
var mnms = tools.get_members_names(ecm)
for item in ecm['params'].keys():
mnms.append(item)
for member_name in mnms:
if not TABLE_PARAMS.has(member_name): continue
var p = TABLE_PARAMS[member_name]
var val = ecm.get_value(member_name)
$table.set_node_text(1, p[0], '%s' % val)
$table.set_node_editable(1, p[0], p[2])
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func on_rto_threat_unsel(_th_id):
for item in range(len(TABLE_PARAMS)):
$table.set_node_text(1, item, '')
$table.set_node_editable(1, item, false)