Доработка. Отображение парметров цели в таблице

This commit is contained in:
sasha80
2023-08-23 11:51:57 +03:00
parent c7db91903d
commit 86032ec3d6
3 changed files with 43 additions and 8 deletions

View File

@@ -5,11 +5,20 @@ const CellLineEdit = preload('res://scenes/ячейка-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 = [ 222, 222 ] ## Ширины колонок.
const TABLE_HEADER = [ TableHeader, TableHeader ] ## Описание ряда заголовка.
const TABLE_ROW = [ CellLineEdit, CellLineEdit ] ## Описание ряда.
const TABLE_HEADERS_TEXT = ['Параметр', 'Значение' ] ## Назания колонок.
const TABLE_COLUMN_SIZE = [ 380, 75 ] ## Ширины колонок.
## Параметры цели для отображения в таблице.[br]
## [b]val[0][/b] - Индекс строки.[br][b]val[1][/b] - Содержание.
const TABLE_PARAMS = {
'baud': [0, 'Модуляционная скорость, бод'],
'freqm': [1, 'Режим смены частоты.'],
'power': [2, 'Уровень сигнала, дБм.'],
'tmod': [3, 'Тип модуляции'],
'width': [4, 'Занимая полоса частот, МГц.'],
'rkrp': [5, 'Рекомендуемая помеха'] }
func init_table():
@@ -18,11 +27,39 @@ func init_table():
$table.set_columns_min_size(TABLE_COLUMN_SIZE)
$table.pin_header(self, get_parent())
$table.connect('row_pressed', Callable(self, 'on_row_pressed'))
for i in TABLE_PARAMS.size(): $table.add_row(TABLE_ROW)
for p in TABLE_PARAMS.values():
$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_meta('id', 0)
func _ready() -> void:
signaller.connect('threat_selected', Callable(self, 'on_threat_selected'))
Threats.connect('threat_update', Callable(self, 'on_threat_update'))
call_deferred('init_table')
func on_threat_update(threats, th): print_debug()
## Обрабатывает сигнал [signal Threats.threat_update].
## Обновляет отображение только для выбранной цели.
func on_threat_update(threats, th):
var id = $table.get_meta('id')
if id == 0:
$table.set_meta('id', th.id)
on_threat_selected(threats, th)
elif (id != 0) and (id == th.id):
on_threat_selected(threats, th)
## Обрабатывает сигнал [signal Threats.threat_selected]
func on_threat_selected(threats, th):
print_debug(th.id)
$table.set_meta('id', th.id)
var mnms = Tools.get_members_names(th)
for member_name in mnms:
if not TABLE_PARAMS.has(member_name): continue
var p = TABLE_PARAMS[member_name]
var val = th.get(member_name)
$table.set_node_text(1, p[0], '%s' % val)

View File

@@ -32,6 +32,7 @@ func _ready() -> void:
Threats.connect('threat_new', Callable(self, 'on_threat_new').bind(table_index))
Threats.connect('threat_lost', Callable(self, 'on_threat_lost').bind(table_index))
Threats.connect('threat_update', Callable(self, 'on_threat_update').bind(table_index))
$table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table_index))
call_deferred('init_table')

View File

@@ -98,7 +98,6 @@ script = ExtResource("6_tict0")
[node name="table" type="GridContainer" parent="grd_side/frm_ths_params/scroll"]
layout_mode = 2
columns = 4
script = ExtResource("6_fpdpm")
[node name="frm_ecm_list" type="NinePatchRect" parent="grd_side"]
@@ -132,7 +131,6 @@ offset_bottom = 285.0
[node name="table" type="GridContainer" parent="grd_side/frm_ecm_list/scroll"]
layout_mode = 2
columns = 4
script = ExtResource("6_fpdpm")
[node name="frm_ecm_params" type="NinePatchRect" parent="grd_side"]
@@ -166,7 +164,6 @@ offset_bottom = 282.0
[node name="table" type="GridContainer" parent="grd_side/frm_ecm_params/scroll"]
layout_mode = 2
columns = 4
script = ExtResource("6_fpdpm")
[node name="canvas" parent="." instance=ExtResource("3_fppu7")]