extends Node var id_array: Array # Массив id целей var pomehi : Dictionary # Словарь целей var msg_counter : int = 0 # Счётчик отправленных пакетов const TableCellType1 = preload('res://ячейка-1.tscn') const TableCellType2 = preload('res://кнопка-3.tscn') const TableCellType3 = preload('res://кнопка-4.tscn') const TableCellType4 = preload('res://заголовок.tscn') const TableCellType5 = preload('res://ячейка-2.tscn') const TableCellType6 = preload('res://кнопка-5.tscn') # Индекс колонки: 0 1 2 3 4 5 6 const TABLE_HEADERS = [ 'Индекс', 'Состояние', 'Помеха', 'Мощность', 'Кур. уг.', 'Частота', 'Ш. диап.'] const TABLE_HEADER_TYPES = [ TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4] const TABLE_HEADER_ALIGNMENTS = [ HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] const TABLE_ROW_TYPES = [ TableCellType1, TableCellType6, TableCellType1, TableCellType1, TableCellType1, TableCellType1, TableCellType1] const TABLE_ROW_ALIGNMENTS = [ HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER] const TABLE_COLUMN_SIZES = [ 82, 120, 82, 100, 82, 90, 150] const COLUMN_ISPP = 0 # Индекс сейанса постановки помехи const COLUMN_SVK = 1 # Состояние выполнения помехи const COLUMN_KRP = 2 # Помеха const COLUMN_POWP = 3 # Мощность излучения const COLUMN_KNI = 4 # Курсовой угол const COLUMN_FREQ = 5 # Частота const COLUMN_WIDTH = 6 # Ширина диапазона # Индексы колонок, которым можно задавать выравнивание текста const TABLE_ALLIGNED_COLUMNS = [ COLUMN_ISPP, COLUMN_KRP, COLUMN_POWP, COLUMN_KNI, COLUMN_FREQ, COLUMN_WIDTH, ] # Состояние выполнения команды поставновки помехи const SVK = ['<неопр.>', 'fhss', 'lfm', 'const'] # Номера колонок const COLUMN_OPT = [[COLUMN_SVK, SVK]] const COLUMN_OPT_BTN = [COLUMN_SVK] const ID_ARRAY_LEN = 100 # Размер пула номеров целей # Помеха class Pomeha: # параметры цели, второе значение, разрешение отправки. var ispp : String var svk : int var krp : String var powp : String var kni : String var freq : String var width : String func _init(args : Array): ispp = '%s' % args[0] krp = '%s' % args[1] powp = '%s' % args[2] kni = '%s' % args[3] freq = '%s' % args[4] width = '%s' % args[5] func update_rows(): var new_rows: Array = [] new_rows.append('%s' % ispp) new_rows.append('%s' % svk) new_rows.append('%s' % krp) new_rows.append('%s' % powp) new_rows.append('%s' % kni) new_rows.append('%s' % freq) new_rows.append('%s' % width) return new_rows func selector_color_proc(_i_row: int): return Consts.COLOR_ACCENT * Consts.COLOR_HALF_ALPHA func init_table(table: Table, sizes: Array): for i_row in table.get_rows_count(): table.set_nodes_min_size(i_row, sizes) table.set_selector_color_proc(self, 'selector_color_proc') func init_opt_btns(row : int, table): for item in COLUMN_OPT: var i_col = item[0] var opt_arr = item[1] var cell = table.get_node2(i_col, row) for opt in opt_arr: cell.add_item(opt) cell.select(0) func init_pomehi(header, table): # Инициализация вкладки с целями header.add_row(TABLE_HEADER_TYPES) header.set_rows_text([TABLE_HEADERS]) on_btn_add(table) init_table(header, TABLE_COLUMN_SIZES) init_table(table, TABLE_COLUMN_SIZES) table.align_to_left_bottom(header, Vector2(0, 2)) table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table)) table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [table]) func on_btn_add(table): var pomeha : = Pomeha.new([1,2,3,4,5,6]) pomehi['%d' % 1] = pomeha var row = pomeha.update_rows() table.add_row(TABLE_ROW_TYPES) table.set_row_text(table.get_rows_count()-1, row) init_opt_btns(table.get_rows_count()-1, table) table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, []) func on_row_pressed(i_row: int, table): pass