From 8d64665451283ceb2abe9991e3d74e5f2cb27102 Mon Sep 17 00:00:00 2001 From: sasha80 Date: Wed, 23 Aug 2023 11:53:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/scroll-threats.gd | 11 ++++++----- scripts/threats.gd | 2 +- table/table.gd | 5 +++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scenes/scroll-threats.gd b/scenes/scroll-threats.gd index 07f1af1e..fc7be87c 100644 --- a/scenes/scroll-threats.gd +++ b/scenes/scroll-threats.gd @@ -1,6 +1,6 @@ extends ScrollContainer -## Отображение списка целей в таблицу. +## Отображает список целей в таблице. const CellLineEdit = preload('res://scenes/ячейка-2.tscn') ## Ячейка таблицы. @@ -11,12 +11,14 @@ const TABLE_HEADER = [ TableHeader, TableHeader, TableHeader, Tabl const TABLE_ROW = [ CellLineEdit, CellLineEdit, CellLineEdit, CellLineEdit ] ## Описание ряда. const TABLE_COLUMN_PARAM = ['id', 'aoa', 'freq', 'proto' ] ## Параметры цели отображаемые в таблице. const TABLE_HEADERS_TEXT = ['Номер', 'Пеленг', 'Частота, МГц', 'Протокол' ] ## Заголовки таблицы. -const TABLE_COLUMN_SIZE = [ 65, 145, 145, 90 ] ## Ширины колонок. +const TABLE_COLUMN_SIZE = [ 65, 145, 145, 90 ] ## Ширины колонок. -func on_row_pressed(i_row: int): +## Вызывается при нажатии указателем мыши на выбранный ряд. +func on_row_pressed(i_row: int, table_index: Dictionary): $table.clear_rows_selected() $table.set_row_selected(i_row, true) + signaller.emit_signal('threat_selected', table_index) func init_table(): @@ -24,7 +26,6 @@ func init_table(): $table.set_header_text(TABLE_HEADERS_TEXT) $table.set_columns_min_size(TABLE_COLUMN_SIZE) $table.pin_header(self, get_parent()) - $table.connect('row_pressed', Callable(self, 'on_row_pressed')) func _ready() -> void: @@ -36,7 +37,7 @@ func _ready() -> void: call_deferred('init_table') -## Перестраивает индекс таблицы +## Перестраивает индекс таблицы. Вызывать при удалении строки func rehash(table_index: Dictionary): var rows_count = $table.get_rows_count() for i_row in rows_count: diff --git a/scripts/threats.gd b/scripts/threats.gd index fa54a70c..c5d4da32 100644 --- a/scripts/threats.gd +++ b/scripts/threats.gd @@ -41,7 +41,7 @@ signal threat_lost(threats: Dictionary, th: Threat) signal threat_update(threats: Dictionary, th: Threat) -var threats = {} ## Список целей. Индекс - <источник цели>:<номер цели> Источник цели может быть: 'RPB', 'SIGMA', 'RLKS', 'MP405' +var threats = {} ## Список целей. Индекс - <номер цели> func _ready() -> void: diff --git a/table/table.gd b/table/table.gd index 531b3ed5..1c6360fc 100644 --- a/table/table.gd +++ b/table/table.gd @@ -2,7 +2,7 @@ class_name GDTable extends GridContainer ## Виджет "Таблица" -@export var node_gap: = Vector2(0.0, 0.0) ## Зазор между ячейками, который не возможно вычислить или получить +@export var node_gap: = Vector2(0.0, 0.0) ## Зазор между ячейками, который невозможно вычислить или получить @export var selector_color: = Color(1.0, 1.0, 1.0, 1.0) ## Окрашивающий цвет для селектора выбранного ряда @export var selector_key_down: Key = KEY_DOWN ## Клавиша увеличения индекса выбранного ряда @export var selector_key_up: Key = KEY_UP ## Клавиша уменьшения индекса выбранного ряда @@ -166,7 +166,8 @@ func get_node_key(format: String, i_col: int, i_row: int) -> String: return key -## +## Возвращает массив с индексом ячейки. +## [b][0][/b] - индекс колонки, [b][1][/b] - индекс строки func get_key_indexes(key: String) -> Array: var tokens: = key.split('_') assert(tokens.size() == 3, 'ошибка: неверный ключ: \"%s\"' % key)