Доработка. Обновление параметров выбранной цели
This commit is contained in:
@@ -8,7 +8,7 @@ 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 = [ 380, 75 ] ## Ширины колонок.
|
||||
const TABLE_COLUMN_SIZE = [ 370, 85 ] ## Ширины колонок.
|
||||
|
||||
## Параметры цели для отображения в таблице.[br]
|
||||
## [b]val[0][/b] - Индекс строки.[br][b]val[1][/b] - Содержание.
|
||||
@@ -21,6 +21,12 @@ const TABLE_PARAMS = {
|
||||
'rkrp': [5, 'Рекомендуемая помеха'] }
|
||||
|
||||
|
||||
## Обрабатывает сигнал [signal Threats.threat_selected]
|
||||
func on_threat_selected(th):
|
||||
$table.set_meta('id', th.id)
|
||||
on_threat_update(null, th)
|
||||
|
||||
|
||||
func init_table():
|
||||
$table.set_header(TABLE_HEADER)
|
||||
$table.set_header_text(TABLE_HEADERS_TEXT)
|
||||
@@ -44,19 +50,8 @@ func _ready() -> void:
|
||||
|
||||
## Обрабатывает сигнал [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)
|
||||
func on_threat_update(_threats, th):
|
||||
if th.id != $table.get_meta('id'): return
|
||||
var mnms = Tools.get_members_names(th)
|
||||
for member_name in mnms:
|
||||
if not TABLE_PARAMS.has(member_name): continue
|
||||
|
||||
@@ -15,10 +15,11 @@ const TABLE_COLUMN_SIZE = [ 65, 145, 145, 90 ]
|
||||
|
||||
|
||||
## Вызывается при нажатии указателем мыши на выбранный ряд.
|
||||
func on_row_pressed(i_row: int, table_index: Dictionary):
|
||||
func on_row_pressed(i_row: int):
|
||||
$table.clear_rows_selected()
|
||||
$table.set_row_selected(i_row, true)
|
||||
signaller.emit_signal('threat_selected', table_index)
|
||||
var threat = $table.get_node_user_data(0, i_row)
|
||||
signaller.emit_signal('threat_selected', threat)
|
||||
|
||||
|
||||
func init_table():
|
||||
@@ -33,7 +34,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))
|
||||
$table.connect('row_pressed', Callable(self, 'on_row_pressed'))
|
||||
call_deferred('init_table')
|
||||
|
||||
|
||||
@@ -66,6 +67,7 @@ func on_threat_new(_threats, th, table_index):
|
||||
var row = map_th_to_row(th)
|
||||
$table.set_row_text(i_row, row)
|
||||
$table.set_row_editable(i_row, false)
|
||||
$table.set_node_user_data(0, i_row, th)
|
||||
table_index[th.id] = i_row
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user