From 10ad2e490879f2cd7616e4d1ef53526f91a26b90 Mon Sep 17 00:00:00 2001 From: sasha80 Date: Wed, 23 Aug 2023 15:49:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0.=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=86=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/scroll-params.gd | 23 +++++++++-------------- scenes/scroll-threats.gd | 8 +++++--- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/scenes/scroll-params.gd b/scenes/scroll-params.gd index 447d1b6f..e70d43dc 100644 --- a/scenes/scroll-params.gd +++ b/scenes/scroll-params.gd @@ -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 diff --git a/scenes/scroll-threats.gd b/scenes/scroll-threats.gd index fc7be87c..edbb1342 100644 --- a/scenes/scroll-threats.gd +++ b/scenes/scroll-threats.gd @@ -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