Доработка. Теперь только для Godot4

This commit is contained in:
sasha80
2023-06-13 14:14:17 +03:00
parent 196298d220
commit d57ddc2f63
27 changed files with 934 additions and 886 deletions

1
.gitignore vendored
View File

@@ -18,3 +18,4 @@ mono_crash.*.json
/build/ /build/
/html/ /html/
/commit.gd /commit.gd
/.godot/

33
DejaVuSans.ttf.import Normal file
View File

@@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://bxsp7iobid6r8"
path="res://.godot/imported/DejaVuSans.ttf-9b3237397afd1f73977bc4b24b10964d.fontdata"
[deps]
source_file="res://DejaVuSans.ttf"
dest_files=["res://.godot/imported/DejaVuSans.ttf-9b3237397afd1f73977bc4b24b10964d.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

View File

@@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://bmpyjokeeeq8l"
path="res://.godot/imported/DejaVuSansCondensed.ttf-cf82d94147dd2c629554494e5fd511f4.fontdata"
[deps]
source_file="res://DejaVuSansCondensed.ttf"
dest_files=["res://.godot/imported/DejaVuSansCondensed.ttf-cf82d94147dd2c629554494e5fd511f4.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

View File

@@ -1,10 +1,10 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=2 format=2]
[ext_resource path="res://nine-patch.png" type="Texture" id=1] [ext_resource path="res://nine-patch.png" type="Texture2D" id=1]
[node name="NinePatchRect" type="NinePatchRect"] [node name="NinePatchRect" type="NinePatchRect"]
margin_right = 42.0 offset_right = 42.0
margin_bottom = 33.0 offset_bottom = 33.0
texture = ExtResource( 1 ) texture = ExtResource( 1 )
draw_center = false draw_center = false
patch_margin_left = 8 patch_margin_left = 8

View File

@@ -1,12 +1,11 @@
extends Node2D extends Node2D
export (String, FILE) var MENU_SCENE_FILE = 'res://меню.tscn' const MENU_SCENE_FILE: String = 'res://меню.tscn'
# Адрес имитатора # Адрес имитатора
const MAIN_ADDR = [ '10.1.1.5', 50005 ] const MAIN_ADDR = [ 'localhost', 50005 ]
const DST_ADDR = [ '10.1.1.79', 50079 ] const DST_ADDR = [ 'localhost', 50079 ]
const TABLE_ROW_HIGHT = 34 # Высота строки таблицы в пикселях const TABLE_ROW_HIGHT = 34 # Высота строки таблицы в пикселях

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/edit-add-0.png-caa21a9bbc05466cba52fa8d3bc8c950.stex" uid="uid://cex4jiu1pcj3x"
path="res://.godot/imported/edit-add-0.png-caa21a9bbc05466cba52fa8d3bc8c950.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://edit-add-0.png" source_file="res://edit-add-0.png"
dest_files=[ "res://.import/edit-add-0.png-caa21a9bbc05466cba52fa8d3bc8c950.stex" ] dest_files=["res://.godot/imported/edit-add-0.png-caa21a9bbc05466cba52fa8d3bc8c950.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/edit-add-1.png-8bbd18fd95c5b5bd62e9c26d8f22f02b.stex" uid="uid://cx746np1wexnd"
path="res://.godot/imported/edit-add-1.png-8bbd18fd95c5b5bd62e9c26d8f22f02b.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://edit-add-1.png" source_file="res://edit-add-1.png"
dest_files=[ "res://.import/edit-add-1.png-8bbd18fd95c5b5bd62e9c26d8f22f02b.stex" ] dest_files=["res://.godot/imported/edit-add-1.png-8bbd18fd95c5b5bd62e9c26d8f22f02b.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" uid="uid://bwqivxm0vit47"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://icon.png" source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

View File

@@ -1,6 +1,6 @@
[gd_resource type="DynamicFont" load_steps=2 format=2] [gd_resource type="FontFile" load_steps=2 format=2]
[ext_resource path="res://DejaVuSansCondensed.ttf" type="DynamicFontData" id=1] [ext_resource path="res://DejaVuSansCondensed.ttf" type="FontFile" id=1]
[resource] [resource]
size = 20 size = 20

32
main.gd
View File

@@ -1,30 +1,30 @@
extends Node2D extends Node2D
var sock = PacketPeerUDP.new() var sock = PacketPeerUDP.new()
onready var header_threads = get_node('tabs/threats/header_t') @onready var header_threads = get_node('tabs/threats/header_t')
onready var table_threads = get_node('tabs/threats/table_t') @onready var table_threads = get_node('tabs/threats/table_t')
onready var btn_add_threads = get_node('tabs/threats/btn_add') @onready var btn_add_threads = get_node('tabs/threats/btn_add')
onready var btn_del_threads = get_node('tabs/threats/btn_del') @onready var btn_del_threads = get_node('tabs/threats/btn_del')
onready var header_pomehi = get_node('tabs/pomehi/header_p') @onready var header_pomehi = get_node('tabs/pomehi/header_p')
onready var table_pomehi = get_node('tabs/pomehi/table_p') @onready var table_pomehi = get_node('tabs/pomehi/table_p')
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
sock.listen(Consts.MAIN_ADDR[1], Consts.MAIN_ADDR[0]) sock.bind(Consts.MAIN_ADDR[1], Consts.MAIN_ADDR[0])
sock.set_dest_address(Consts.DST_ADDR[0], Consts.DST_ADDR[1]) sock.set_dest_address(Consts.DST_ADDR[0], Consts.DST_ADDR[1])
Threats.init_treats(header_threads, table_threads, btn_add_threads, btn_del_threads) Threats.init_treats(header_threads, table_threads, btn_add_threads, btn_del_threads)
Pomehi.init_pomehi(header_pomehi, table_pomehi) Pomehi.init_pomehi(header_pomehi, table_pomehi)
var timer = Timer.new() var timer = Timer.new()
timer.connect('timeout',self,'on_timeout',[]) timer.connect('timeout', Callable(self, 'on_timeout').bind())
add_child(timer) #to process add_child(timer) #to process
timer.start(1) #to start timer.start(1) #to start
func on_timeout(): func on_timeout():
sock.put_packet(Threats.get_threats_data()) sock.put_packet(Threats.get_threats_data())
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): #func _process(delta):
# pass # pass

View File

@@ -1,7 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2] [gd_resource type="Environment" load_steps=2 format=3 uid="uid://sjt0ts5hhqrl"]
[sub_resource type="ProceduralSky" id=1] [sub_resource type="Sky" id="1"]
[resource] [resource]
background_mode = 2 background_mode = 2
background_sky = SubResource( 1 ) sky = SubResource("1")

View File

@@ -1,69 +1,66 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=5 format=3 uid="uid://87gtvqd7bbje"]
[ext_resource path="res://table.gd" type="Script" id=1] [ext_resource type="Script" path="res://main.gd" id="1_kt06w"]
[ext_resource path="res://main.gd" type="Script" id=2] [ext_resource type="Script" path="res://table.gd" id="2_k7rc6"]
[ext_resource path="res://edit-add-0.png" type="Texture" id=3] [ext_resource type="Texture2D" uid="uid://cex4jiu1pcj3x" path="res://edit-add-0.png" id="3_pruca"]
[ext_resource path="res://edit-add-1.png" type="Texture" id=4] [ext_resource type="Texture2D" uid="uid://cx746np1wexnd" path="res://edit-add-1.png" id="4_3d2wd"]
[node name="main" type="Node2D"] [node name="main" type="Node2D"]
script = ExtResource( 2 ) script = ExtResource("1_kt06w")
[node name="tabs" type="TabContainer" parent="."] [node name="tabs" type="TabContainer" parent="."]
margin_right = 1594.0 offset_right = 1594.0
margin_bottom = 897.0 offset_bottom = 897.0
tab_align = 0
[node name="threats" type="Panel" parent="tabs"] [node name="threats" type="Panel" parent="tabs"]
anchor_right = 1.0 layout_mode = 2
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 42.0
margin_right = -4.0
margin_bottom = -4.0
[node name="table_t" type="GridContainer" parent="tabs/threats"] [node name="table_t" type="GridContainer" parent="tabs/threats"]
layout_mode = 0
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_top = 100.0 offset_top = 100.0
margin_right = 1.0 offset_right = 1.0
margin_bottom = 10.0 offset_bottom = 10.0
script = ExtResource( 1 ) script = ExtResource("2_k7rc6")
[node name="header_t" type="GridContainer" parent="tabs/threats"] [node name="header_t" type="GridContainer" parent="tabs/threats"]
margin_top = 57.0 layout_mode = 0
margin_right = 1584.0 offset_top = 57.0
margin_bottom = 96.0 offset_right = 1584.0
script = ExtResource( 1 ) offset_bottom = 96.0
script = ExtResource("2_k7rc6")
[node name="btn_add" type="TextureButton" parent="tabs/threats"] [node name="btn_add" type="TextureButton" parent="tabs/threats"]
margin_left = 1533.0 layout_mode = 0
margin_top = -2.0 offset_left = 1533.0
margin_right = 1581.0 offset_top = -2.0
margin_bottom = 46.0 offset_right = 1581.0
texture_normal = ExtResource( 3 ) offset_bottom = 46.0
texture_pressed = ExtResource( 4 ) texture_normal = ExtResource("3_pruca")
texture_pressed = ExtResource("4_3d2wd")
[node name="btn_del" type="TextureButton" parent="tabs/threats"] [node name="btn_del" type="TextureButton" parent="tabs/threats"]
margin_left = 1487.0 layout_mode = 0
margin_top = 3.0 offset_left = 1487.0
margin_right = 1527.0 offset_top = 3.0
margin_bottom = 43.0 offset_right = 1527.0
offset_bottom = 43.0
[node name="pomehi" type="Panel" parent="tabs"] [node name="pomehi" type="Panel" parent="tabs"]
visible = false visible = false
margin_left = 4.0 layout_mode = 2
margin_top = 42.0
margin_right = 1590.0
margin_bottom = 893.0
[node name="table_p" type="GridContainer" parent="tabs/pomehi"] [node name="table_p" type="GridContainer" parent="tabs/pomehi"]
margin_top = 100.0 layout_mode = 0
margin_right = 1587.0 offset_top = 100.0
margin_bottom = 861.0 offset_right = 1587.0
script = ExtResource( 1 ) offset_bottom = 861.0
script = ExtResource("2_k7rc6")
[node name="header_p" type="GridContainer" parent="tabs/pomehi"] [node name="header_p" type="GridContainer" parent="tabs/pomehi"]
margin_top = 57.0 layout_mode = 0
margin_right = 32.0 offset_top = 57.0
margin_bottom = 96.0 offset_right = 32.0
script = ExtResource( 1 ) offset_bottom = 96.0
script = ExtResource("2_k7rc6")

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/nine-patch.png-57e7212ba67c39e7fc9011f4afa7baae.stex" uid="uid://bkjlwivmtq1rp"
path="res://.godot/imported/nine-patch.png-57e7212ba67c39e7fc9011f4afa7baae.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://nine-patch.png" source_file="res://nine-patch.png"
dest_files=[ "res://.import/nine-patch.png-57e7212ba67c39e7fc9011f4afa7baae.stex" ] dest_files=["res://.godot/imported/nine-patch.png-57e7212ba67c39e7fc9011f4afa7baae.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

141
pomehi.gd
View File

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

View File

@@ -6,12 +6,13 @@
; [section] ; section goes between [] ; [section] ; section goes between []
; param=value ; assign values to parameters ; param=value ; assign values to parameters
config_version=4 config_version=5
[application] [application]
config/name="Imi Skysens" config/name="Imi Skysens"
run/main_scene="res://main.tscn" run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.1")
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload] [autoload]
@@ -24,15 +25,14 @@ Tools="*res://tools.gd"
[display] [display]
window/size/width=1600 window/size/viewport_width=1600
window/size/height=900 window/size/viewport_height=900
window/stretch/mode="2d" window/stretch/mode="2d"
window/stretch/aspect="keep"
[gui] [gui]
common/drop_mouse_on_gui_input_disabled=true
theme/custom_font="res://main-font.tres" theme/custom_font="res://main-font.tres"
common/drop_mouse_on_gui_input_disabled=true
[physics] [physics]
@@ -40,4 +40,4 @@ common/enable_pause_aware_picking=true
[rendering] [rendering]
environment/default_environment="res://main.tres" environment/defaults/default_environment="res://main.tres"

538
table.gd
View File

@@ -1,10 +1,10 @@
tool @tool
extends GridContainer extends GridContainer
export (Color) var _selector_color = Color(1.0, 1.0, 1.0, 1.0) @export var _selector_color: Color = Color(1.0, 1.0, 1.0, 1.0)
export (int, 1, 256) var columns_count = 1 setget _set_columns_count @export var columns_count: int = 1: set = _set_columns_count
export (int, 1, 256) var rows_count = 1 setget _set_rows_count @export var rows_count: int = 1: set = _set_rows_count
export (String, FILE) var node_type_file = 'res://ячейка-1.tscn' @export var node_type_file: String = 'res://ячейка-1.tscn'
const Selector = preload('res://Selector.tscn') const Selector = preload('res://Selector.tscn')
const INDEX_FORMAT = '%02d_%02d' const INDEX_FORMAT = '%02d_%02d'
const NODE_PREFIX = 'NODE_' const NODE_PREFIX = 'NODE_'
@@ -18,118 +18,114 @@ const CONNECTED_KEY_FORMAT = CONN_PREFIX + INDEX_FORMAT
const ROW_SELECTOR_KEY_FORMAT = SLCT_PREFIX + INDEX_FORMAT const ROW_SELECTOR_KEY_FORMAT = SLCT_PREFIX + INDEX_FORMAT
var nodes: = {} var nodes: = {}
var selector_color_proc: FuncRef var selector_color_proc: Callable
var selector_size_proc: FuncRef var selector_size_proc: Callable
signal row_pressed(i_row) # Вызывается при нажатии кнопкой мыши на строку signal row_pressed(i_row) # Вызывается при нажатии кнопкой мыши на строку
const MAX_INDEX = 99 # Максимальное значение индекса для колонки и строки. Связано с форматом ключа const MAX_INDEX = 99 # Максимальное значение индекса для колонки и строки. Связано с форматом ключа
func align_to_left_bottom(header, gap: = Vector2(0, 0)): func align_to_left_bottom(header, gap: = Vector2(0, 0)):
""" Выравнивает по нижнему левому углу. Используется для выравнивания по заголовку """ """ Выравнивает по нижнему левому углу. Используется для выравнивания по заголовку """
rect_position.x = header.rect_position.x + gap.x position.x = header.position.x + gap.x
rect_position.y = header.rect_position.y + header.rect_size.y + gap.y position.y = header.position.y + header.size.y + gap.y
func _assert_meta(i_col: int, i_row: int, pname: String, node): func _assert_meta(i_col: int, i_row: int, pname: String, node):
assert(node.has_meta(pname), 'ошибка: нет мета-свойства \"%s\" у ячейки (%s): колонка:%d ряд:%d' % [pname, typeof(node), i_col, i_row]) assert(node.has_meta(pname)) #,'ошибка: нет мета-свойства \"%s\" у ячейки (%s): колонка:%d ряд:%d' % [pname, typeof(node), i_col, i_row])
func _set_columns_count(cc: int): func _set_columns_count(cc: int):
columns_count = cc columns_count = cc
func _set_rows_count(rc: int): func _set_rows_count(rc: int):
rows_count = rc rows_count = rc
func set_node_meta(i_col: int, i_row: int, pname: String, val) -> void: func set_node_meta(i_col: int, i_row: int, pname: String, val) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var node = nodes[key] var node = nodes[key]
node.set_meta(pname, val) node.set_meta(pname, val)
func get_node_meta(i_col: int, i_row: int, pname: String): func get_node_meta(i_col: int, i_row: int, pname: String):
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var node = nodes[key] var node = nodes[key]
_assert_meta(i_col, i_row, pname, node) _assert_meta(i_col, i_row, pname, node)
return node.get_meta(pname) return node.get_meta(pname)
func set_node_property(i_col: int, i_row: int, pname: String, val) -> void: func set_node_property(i_col: int, i_row: int, pname: String, val) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var node = nodes[key] var node = nodes[key]
node.set(pname, val) node.set(pname, val)
func get_node_property(i_col: int, i_row: int, pname: String): func get_node_property(i_col: int, i_row: int, pname: String):
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var node = nodes[key] var node = nodes[key]
return node.get(pname) return node.get(pname)
func get_node_key(format: String, i_col: int, i_row: int) -> String: func get_node_key(format: String, i_col: int, i_row: int) -> String:
var key: String = format % [i_row, i_col] var key: String = format % [i_row, i_col]
assert(nodes.has(key), 'ошибка: нет такой ячейки: колонка:%d ряд:%d' % [i_col, i_row]) assert(nodes.has(key)) #,'ошибка: нет такой ячейки: колонка:%d ряд:%d' % [i_col, i_row])
return key return key
func get_key_indexes(key: String) -> Array: func get_key_indexes(key: String) -> Array:
var tokens: = key.split('_') var tokens: = key.split('_')
assert(tokens.size() == 3, 'ошибка: неверный ключ: \"%s\"' % key) assert(tokens.size() == 3) #,'ошибка: неверный ключ: \"%s\"' % key)
return [int(tokens[2]), int(tokens[1])] return [int(tokens[2]), int(tokens[1])]
func set_columns_min_size(sizes: Array) -> void: func set_columns_min_size(sizes: Array) -> void:
for i_row in get_rows_count(): for i_row in get_rows_count():
set_nodes_min_size(i_row, sizes) set_nodes_min_size(i_row, sizes)
func set_columns_aligment(alignments: Array) -> void: func set_columns_aligment(alignments: Array) -> void:
for i_row in get_rows_count(): for i_row in get_rows_count():
for i_col in alignments.size(): for i_col in alignments.size():
set_node_alligment(i_col, i_row, alignments[i_col]) set_node_alligment(i_col, i_row, alignments[i_col])
func _input(event) -> void: func _input(event) -> void:
if event is InputEventMouseButton: if event is InputEventMouseButton:
if not event.pressed: if not event.pressed:
return return
if event.position.x < rect_position.x: if event.position.x < position.x:
emit_signal('focus_exited') emit_signal('focus_exited')
return return
if event.position.x > (rect_position.x + rect_size.x): if event.position.x > (position.x + size.x):
emit_signal('focus_exited') emit_signal('focus_exited')
return return
if event.position.y < rect_position.y: if event.position.y < position.y:
emit_signal('focus_exited') emit_signal('focus_exited')
return return
if event.position.y > (rect_position.y + rect_size.y): if event.position.y > (position.y + size.y):
emit_signal('focus_exited') emit_signal('focus_exited')
return return
var rows_count: = get_rows_count() var rows_count: = get_rows_count()
var parent = get_parent() var parent = get_parent()
var y0 = parent.rect_position.y var y0 = parent.position.y
for i_row in rows_count: for i_row in rows_count:
var rect = [0, 0, 0, 0] var rect = [0, 0, 0, 0]
get_node_rect(0, i_row, rect) get_node_rect(0, i_row, rect)
var y = rect[1] + rect_position.y + y0 var y = rect[1] + position.y + y0
if event.position.y < y: if event.position.y < y:
continue continue
if event.position.y > (y + rect[3]): if event.position.y > (y + rect[3]):
continue continue
emit_signal('row_pressed', i_row) emit_signal('row_pressed', i_row)
break break
func _init() -> void: func _init() -> void:
selector_color_proc = FuncRef.new() selector_color_proc = Callable(self, 'default_selector_color_proc')
selector_color_proc.set_instance(self) assert(selector_color_proc.is_valid())
selector_color_proc.function = 'default_selector_color_proc' selector_size_proc = Callable(self, 'default_selector_size_proc')
assert(selector_color_proc.is_valid()) assert(selector_size_proc.is_valid())
selector_size_proc = FuncRef.new()
selector_size_proc.set_instance(self)
selector_size_proc.function = 'default_selector_size_proc'
assert(selector_size_proc.is_valid())
func default_selector_color_proc(i_row: int): func default_selector_color_proc(i_row: int):
@@ -137,286 +133,284 @@ func default_selector_color_proc(i_row: int):
func set_selector_color_proc(instance: Object, function: String) -> void: func set_selector_color_proc(instance: Object, function: String) -> void:
selector_color_proc.set_instance(instance) selector_color_proc = Callable(instance, function)
selector_color_proc.function = function assert(selector_color_proc.is_valid())
assert(selector_color_proc.is_valid())
func set_selector_size_proc(instance: Object, function: String) -> void: func set_selector_size_proc(instance: Object, function: String) -> void:
selector_size_proc.set_instance(instance) selector_size_proc = Callable(instance, function)
selector_size_proc.function = function assert(selector_size_proc.is_valid())
assert(selector_size_proc.is_valid())
func default_selector_size_proc(i_row: int, rect: Array) -> void: func default_selector_size_proc(i_row: int, rect: Array) -> void:
get_node_rect(0, i_row, rect) get_node_rect(0, i_row, rect)
rect[0] = rect[0] + rect_position.x - 1 rect[0] = rect[0] + position.x - 1
rect[1] = rect[1] + rect_position.y - 4 rect[1] = rect[1] + position.y - 4
rect[2] = rect_size.x + 2 rect[2] = size.x + 2
rect[3] = rect[3] + 8 rect[3] = rect[3] + 8
func clear_rows_selected(): func clear_rows_selected():
var rows_count: = get_rows_count() var rows_count: = get_rows_count()
for i_row in rows_count: for i_row in rows_count:
set_row_selected(i_row, false) set_row_selected(i_row, false)
func set_row_selected(i_row: int, selected: bool = true) -> void: func set_row_selected(i_row: int, selected: bool = true) -> void:
var key: = ROW_SELECTOR_KEY_FORMAT % [i_row, 0] var key: = ROW_SELECTOR_KEY_FORMAT % [i_row, 0]
var parent = get_parent() var parent = get_parent()
if nodes.has(key) and (not selected): if nodes.has(key) and (not selected):
var selector = nodes[key] var selector = nodes[key]
parent.remove_child(selector) parent.remove_child(selector)
selector.queue_free() selector.queue_free()
nodes.erase(key) nodes.erase(key)
elif (not nodes.has(key)) and selected: elif (not nodes.has(key)) and selected:
var selector = Selector.instance() var selector = Selector.instantiate()
var rect: = [0, 0, 0, 0] var rect: = [0, 0, 0, 0]
selector_size_proc.call_func(i_row, rect) selector_size_proc.call(i_row, rect)
selector.rect_position.x = rect[0] selector.position.x = rect[0]
selector.rect_position.y = rect[1] selector.position.y = rect[1]
selector.rect_size.x = rect[2] selector.size.x = rect[2]
selector.rect_size.y = rect[3] selector.size.y = rect[3]
selector.modulate = selector_color_proc.call_func(i_row) selector.modulate = selector_color_proc.call(i_row)
nodes[key] = selector nodes[key] = selector
parent.add_child(selector) parent.add_child(selector)
func is_row_selected(i_row: int) -> bool: func is_row_selected(i_row: int) -> bool:
var key: = get_node_key(ROW_SELECTOR_KEY_FORMAT, 0, i_row) var key: = get_node_key(ROW_SELECTOR_KEY_FORMAT, 0, i_row)
return nodes.has(key) return nodes.has(key)
func get_selected_rows(rows: Array) -> void: func get_selected_rows(rows: Array) -> void:
for key in nodes.keys(): for key in nodes.keys():
if SLCT_PREFIX in key: if SLCT_PREFIX in key:
var indexes = get_key_indexes(key) var indexes = get_key_indexes(key)
rows.append(indexes[1]) rows.append(indexes[1])
func get_rows_count() -> int: func get_rows_count() -> int:
var rows_count: int = 0 var rows_count: int = 0
for key in nodes: for key in nodes:
rows_count += int(NODE_PREFIX in key) rows_count += int(NODE_PREFIX in key)
return rows_count / columns return rows_count / columns
func get_node2(i_col: int, i_row: int) -> Node: func get_node2(i_col: int, i_row: int) -> Node:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
return nodes[key] return nodes[key]
func set_node_user_data(i_col: int, i_row: int, user_data: Object) -> void: func set_node_user_data(i_col: int, i_row: int, user_data: Object) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[key] = user_data nodes[key] = user_data
func add_row(row_types: Array) -> void: func add_row(row_types: Array) -> void:
assert(row_types.size() < MAX_INDEX, 'ошибка: слишком много колонок, больше %d' % (MAX_INDEX + 1)) assert(row_types.size() < MAX_INDEX, 'ошибка: слишком много колонок, больше %d' % (MAX_INDEX + 1))
set_columns(row_types.size()) set_columns(row_types.size())
var rows_count: int = get_rows_count() var rows_count: int = get_rows_count()
assert(rows_count < MAX_INDEX, 'ошибка: слишком много рядов, больше %d' % (MAX_INDEX + 1)) assert(rows_count < MAX_INDEX, 'ошибка: слишком много рядов, больше %d' % (MAX_INDEX + 1))
for i_col in columns: for i_col in columns:
var node = row_types[i_col].instance() var node = row_types[i_col].instantiate()
var key: String = NODE_KEY_FORMAT % [rows_count, i_col] var key: String = NODE_KEY_FORMAT % [rows_count, i_col]
node.name = key node.name = key
add_child(node) add_child(node)
nodes[key] = node nodes[key] = node
func get_node_user_data(i_col: int, i_row: int) -> Object: func get_node_user_data(i_col: int, i_row: int) -> Object:
var key: = get_node_key(DATA_KEY_FORMAT, i_col, i_row) var key: = get_node_key(DATA_KEY_FORMAT, i_col, i_row)
return nodes[key] return nodes[key]
func remove_row(i_row: int): func remove_row(i_row: int):
var sel_key: String = ROW_SELECTOR_KEY_FORMAT % [i_row, 0] var sel_key: String = ROW_SELECTOR_KEY_FORMAT % [i_row, 0]
if nodes.has(sel_key): if nodes.has(sel_key):
var selector = nodes[sel_key] var selector = nodes[sel_key]
get_parent().remove_child(selector) get_parent().remove_child(selector)
selector.queue_free() selector.queue_free()
nodes.erase(sel_key) nodes.erase(sel_key)
for i_col in columns: for i_col in columns:
var node_key: String = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var node_key: String = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var conn_key: String = CONNECTED_KEY_FORMAT % [i_row, i_col] var conn_key: String = CONNECTED_KEY_FORMAT % [i_row, i_col]
var data_key: String = DATA_KEY_FORMAT % [i_row, i_col] var data_key: String = DATA_KEY_FORMAT % [i_row, i_col]
var node = nodes[node_key] var node = nodes[node_key]
nodes.erase(node_key) nodes.erase(node_key)
remove_child(node) remove_child(node)
node.queue_free() node.queue_free()
if nodes.has(data_key): if nodes.has(data_key):
nodes.erase(data_key) nodes.erase(data_key)
if nodes.has(conn_key): if nodes.has(conn_key):
var conn = nodes[conn_key] var conn = nodes[conn_key]
var callback = conn[0] var callback = conn[0]
var dest_node = conn[1] var dest_node = conn[1]
node.disconnect('pressed', dest_node, callback) node.disconnect('pressed', Callable(dest_node, callback))
nodes.erase(conn_key) nodes.erase(conn_key)
func rehash(swaps: Array): func rehash(swaps: Array):
""" Переназначает ключи в соответствии с размерами таблицы. """ Переназначает ключи в соответствии с размерами таблицы.
После вызова swaps содержит массив пар [<прежний ключ>, <текущий ключ>] """ После вызова swaps содержит массив пар [<прежний ключ>, <текущий ключ>] """
assert(not swaps.size(), 'ошибка: swaps не пустой') assert(not swaps.size()) #,'ошибка: swaps не пустой')
var nodes_copy = {} var nodes_copy = {}
var i_col = 0 var i_col = 0
var i_row = 0 var i_row = 0
for key0 in nodes: for key0 in nodes:
if NODE_PREFIX in key0: if NODE_PREFIX in key0:
var node_key1: String = NODE_KEY_FORMAT % [i_row, i_col] var node_key1: String = NODE_KEY_FORMAT % [i_row, i_col]
nodes_copy[node_key1] = nodes[key0] nodes_copy[node_key1] = nodes[key0]
swaps.append([key0, node_key1]) swaps.append([key0, node_key1])
var indxs = get_key_indexes(key0) var indxs = get_key_indexes(key0)
var slct_key0: String = ROW_SELECTOR_KEY_FORMAT % [indxs[1], indxs[0]] var slct_key0: String = ROW_SELECTOR_KEY_FORMAT % [indxs[1], indxs[0]]
if nodes.has(slct_key0): if nodes.has(slct_key0):
var slct_key1: String = ROW_SELECTOR_KEY_FORMAT % [i_row, i_col] var slct_key1: String = ROW_SELECTOR_KEY_FORMAT % [i_row, i_col]
nodes_copy[slct_key1] = nodes[slct_key0] nodes_copy[slct_key1] = nodes[slct_key0]
var conn_key0: String = CONNECTED_KEY_FORMAT % [indxs[1], indxs[0]] var conn_key0: String = CONNECTED_KEY_FORMAT % [indxs[1], indxs[0]]
if nodes.has(conn_key0): if nodes.has(conn_key0):
var conn_key1: String = CONNECTED_KEY_FORMAT % [i_row, i_col] var conn_key1: String = CONNECTED_KEY_FORMAT % [i_row, i_col]
nodes_copy[conn_key1] = nodes[conn_key0] nodes_copy[conn_key1] = nodes[conn_key0]
var data_key0: String = DATA_KEY_FORMAT % [indxs[1], indxs[0]] var data_key0: String = DATA_KEY_FORMAT % [indxs[1], indxs[0]]
if nodes.has(data_key0): if nodes.has(data_key0):
var data_key1: String = DATA_KEY_FORMAT % [i_row, i_col] var data_key1: String = DATA_KEY_FORMAT % [i_row, i_col]
nodes_copy[data_key1] = nodes[data_key0] nodes_copy[data_key1] = nodes[data_key0]
i_col += 1 i_col += 1
if i_col == columns: if i_col == columns:
i_col = 0 i_col = 0
i_row += 1 i_row += 1
nodes.clear() nodes.clear()
nodes.merge(nodes_copy) nodes.merge(nodes_copy)
func clear_rows() -> void: func clear_rows() -> void:
""" Удаляет все строки таблицы """ """ Удаляет все строки таблицы """
var rows_count: int = get_rows_count() var rows_count: int = get_rows_count()
for i_row in rows_count: for i_row in rows_count:
remove_row(i_row) remove_row(i_row)
func set_callbacks(dest_node: Node, event_name: String, callback: String, clmns: Array, user_data: Array) -> void:
""" Настраивает обратные вызовы для колонок. func set_callbacks(dest_node: Node, event_name: String, callback: String, clmns: Array, user_data: Array) -> void:
:dest_node: Получатель события """ Настраивает обратные вызовы для колонок.
:event_name: Имя события :dest_node: Получатель события
:callback: Имя функции получателя события :event_name: Имя события
:clmns: Индексы колонок :callback: Имя функции получателя события
:user_data: Аргументы функции получателя события """ :clmns: Индексы колонок
var rows_count = get_rows_count() :user_data: Аргументы функции получателя события """
for i_row in rows_count: var rows_count = get_rows_count()
for i_col in clmns: for i_row in rows_count:
assert(i_col >= 0 and i_col < columns, 'ошибка: нет колонки %d' % i_col) for i_col in clmns:
var node_key: String = NODE_KEY_FORMAT % [i_row, i_col] assert(i_col >= 0 and i_col < columns) #,'ошибка: нет колонки %d' % i_col)
var conn_key: String = CONNECTED_KEY_FORMAT % [i_row, i_col] var node_key: String = NODE_KEY_FORMAT % [i_row, i_col]
var node = nodes[node_key] var conn_key: String = CONNECTED_KEY_FORMAT % [i_row, i_col]
if nodes.has(conn_key): var node = nodes[node_key]
var conn = nodes[conn_key] if nodes.has(conn_key):
var prev_callback = conn[0] var conn = nodes[conn_key]
var prev_dest_node = conn[1] var prev_callback = conn[0]
node.disconnect(event_name, prev_dest_node, prev_callback) var prev_dest_node = conn[1]
assert (OK == node.connect(event_name, dest_node, callback, [node] + user_data)) node.disconnect(event_name, Callable(prev_dest_node, prev_callback))
nodes[conn_key] = [callback, dest_node] assert (OK == node.connect(event_name, Callable(dest_node, callback).bind([node] + user_data)))
nodes[conn_key] = [callback, dest_node]
func set_rows_text(rows: Array) -> void: func set_rows_text(rows: Array) -> void:
for i_row in rows.size(): for i_row in rows.size():
for i_col in columns: for i_col in columns:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var node = nodes[key] var node = nodes[key]
node.text = rows[i_row][i_col] node.text = rows[i_row][i_col]
func set_nodes_min_size(i_row: int, sizes: Array) -> void: func set_nodes_min_size(i_row: int, sizes: Array) -> void:
for i_col in columns: for i_col in columns:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var node = nodes[key] var node = nodes[key]
node.rect_min_size.x = sizes[i_col] node.custom_minimum_size.x = sizes[i_col]
node.rect_size.x = sizes[i_col] node.size.x = sizes[i_col]
func set_node_text(i_col: int, i_row: int, val: String) -> void: func set_node_text(i_col: int, i_row: int, val: String) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[key].text = val nodes[key].text = val
func set_rows_state(rows: Array) -> void: func set_rows_state(rows: Array) -> void:
for i_row in rows.size(): for i_row in rows.size():
for i_col in columns: for i_col in columns:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[name].pressed = rows[i_row][i_col] nodes[name].button_pressed = rows[i_row][i_col]
func set_node_state(i_col: int, i_row: int, val: bool) -> void: func set_node_state(i_col: int, i_row: int, val: bool) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[key].pressed = val nodes[key].button_pressed = val
func set_node_frame(i_col: int, i_row: int, name: String, val: int) -> void: func set_node_frame(i_col: int, i_row: int, name: String, val: int) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var node = nodes[key] var node = nodes[key]
var sprite = node.get_node(name) var sprite = node.get_node(name)
sprite.frame = val sprite.frame = val
func set_node_editable(i_col: int, i_row: int, val: bool) -> void: func set_node_editable(i_col: int, i_row: int, val: bool) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[key].editable = val nodes[key].editable = val
func set_node_alligment(i_col: int, i_row: int, val: int) -> void: func set_node_alligment(i_col: int, i_row: int, val: int) -> void:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[key].align = val nodes[key].align = val
func set_row_alligments(i_row: int, aligns: Array) -> void: func set_row_alligments(i_row: int, aligns: Array) -> void:
for i_col in columns: for i_col in columns:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[key].align = aligns[i_col] nodes[key].align = aligns[i_col]
func get_row_text(i_row: int) -> Array: func get_row_text(i_row: int) -> Array:
var row: = [] var row: = []
for i_col in columns: for i_col in columns:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
row.append(nodes[key].text) row.append(nodes[key].text)
return row return row
func set_row_text(i_row: int, row: Array, i_begin: int = 0) -> void: func set_row_text(i_row: int, row: Array, i_begin: int = 0) -> void:
for i_col in row.size(): for i_col in row.size():
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
nodes[key].text = row[i_col] nodes[key].text = row[i_col]
func get_rows_text() -> Array: func get_rows_text() -> Array:
var rows_count: = get_rows_count() var rows_count: = get_rows_count()
var rows: = [] var rows: = []
for i_row in rows_count: for i_row in rows_count:
var row = get_row_text(i_row) var row = get_row_text(i_row)
rows.append(row) rows.append(row)
return rows return rows
func get_row(i_row: int) -> Array: func get_row(i_row: int) -> Array:
var row: = [] var row: = []
for i_col in columns: for i_col in columns:
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
row.append(nodes[key]) row.append(nodes[key])
return row return row
func get_node_rect(i_col: int, i_row: int, rect: Array) -> void: func get_node_rect(i_col: int, i_row: int, rect: Array) -> void:
assert(rect.size() >= 4, 'ошибка: мало элементов для возврата результата') assert(rect.size() >= 4) #,'ошибка: мало элементов для возврата результата')
var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row) var key: = get_node_key(NODE_KEY_FORMAT, i_col, i_row)
var cell = nodes[key] var cell = nodes[key]
rect[0] = cell.rect_position.x rect[0] = cell.position.x
rect[1] = cell.rect_position.y rect[1] = cell.position.y
rect[2] = cell.rect_size.x rect[2] = cell.size.x
rect[3] = cell.rect_size.y rect[3] = cell.size.y

View File

@@ -1,7 +1,7 @@
extends Node extends Node
var id_array: Array # Массив id целей var id_array: Array # Массив id целей
var treats : Dictionary # Словарь целей var treats : Dictionary # Словарь целей
var msg_counter : int = 0 # Счётчик отправленных пакетов var msg_counter : int = 0 # Счётчик отправленных пакетов
const TableCellType1 = preload('res://ячейка-1.tscn') const TableCellType1 = preload('res://ячейка-1.tscn')
@@ -11,12 +11,12 @@ const TableCellType4 = preload('res://заголовок.tscn')
const TableCellType5 = preload('res://ячейка-2.tscn') const TableCellType5 = preload('res://ячейка-2.tscn')
const TableCellType6 = preload('res://кнопка-5.tscn') const TableCellType6 = preload('res://кнопка-5.tscn')
# Индекс колонки: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # Индекс колонки: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
const TABLE_HEADERS = ['ID Цели', 'Кур. уг.', 'Частота', 'Ш. диап.', 'Ампл.', 'T обнар.', 'Мод.', 'Реж. см. F', 'Ск. пер.', 'Протокол', 'Ст. дол.', 'Ст. шир.', 'Cт. выс.', 'Тек. дол.', 'Тек. шир.', 'Тек. выс.', ] const TABLE_HEADERS = ['ID Цели', 'Курc.град', 'Частота', 'Ш. диап.', 'Ампл.', 'T обнар.', 'Мод.', 'Реж. см. F', 'Ск. пер.', 'Протокол', 'Ст. дол.', 'Ст. шир.', 'Cт. выс.', 'Тек. дол.', 'Тек. шир.', 'Тек. выс.', ]
const TABLE_HEADER_TYPES = [ TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4] const TABLE_HEADER_TYPES = [ TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4, TableCellType4]
const TABLE_HEADER_ALIGNMENTS = [ HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER] 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, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, 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, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType6, TableCellType6, TableCellType5, TableCellType6, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType5] const TABLE_ROW_TYPES = [ TableCellType1, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType6, TableCellType6, TableCellType5, TableCellType6, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType5, TableCellType5]
const TABLE_ROW_ALIGNMENTS = [ HALIGN_CENTER, HALIGN_LEFT, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER, HALIGN_CENTER] const TABLE_ROW_ALIGNMENTS = [ HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_LEFT, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, HORIZONTAL_ALIGNMENT_CENTER, 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, 82, 82, 82, 82, 90, 150, 150, 80, 150, 82, 82, 82, 82, 82, 82] const TABLE_COLUMN_SIZES = [ 82, 82, 82, 82, 82, 90, 150, 150, 80, 150, 82, 82, 82, 82, 82, 82]
const COLUMN_ID = 0 # Идентификатор цели const COLUMN_ID = 0 # Идентификатор цели
@@ -26,7 +26,7 @@ const COLUMN_WIDTH = 3 # Ширина занимаемого диапазо
const COLUMN_POW = 4 # Уровень принимаемого сигнала, дБ const COLUMN_POW = 4 # Уровень принимаемого сигнала, дБ
const COLUMN_TICK = 5 # Относительное время обнаружения сигнала, мс. const COLUMN_TICK = 5 # Относительное время обнаружения сигнала, мс.
const COLUMN_TMOD = 6 # Вид модуляции const COLUMN_TMOD = 6 # Вид модуляции
const COLUMN_FREQM = 7 # Режим смены частоты. const COLUMN_FREQM = 7 # Режим смены частоты.
const COLUMN_BAUD = 8 # Скорость передачи данных, бит/с const COLUMN_BAUD = 8 # Скорость передачи данных, бит/с
const COLUMN_PROTO = 9 # Тип протокола источника сигнала. const COLUMN_PROTO = 9 # Тип протокола источника сигнала.
const COLUMN_SLON = 10 # Координаты старта, долгота в градусах const COLUMN_SLON = 10 # Координаты старта, долгота в градусах
@@ -38,366 +38,366 @@ const COLUMN_ALT = 15 # Текущая высота, метры
# Индексы колонок, которым можно задавать выравнивание текста # Индексы колонок, которым можно задавать выравнивание текста
const TABLE_ALLIGNED_COLUMNS = [ const TABLE_ALLIGNED_COLUMNS = [
COLUMN_ID, COLUMN_ID,
COLUMN_AOA, COLUMN_AOA,
COLUMN_FREQ, COLUMN_FREQ,
COLUMN_WIDTH, COLUMN_WIDTH,
COLUMN_POW, COLUMN_POW,
COLUMN_TICK, COLUMN_TICK,
COLUMN_BAUD, COLUMN_BAUD,
COLUMN_SLON, COLUMN_SLON,
COLUMN_SLAT, COLUMN_SLAT,
COLUMN_SALT, COLUMN_SALT,
COLUMN_LAT, COLUMN_LAT,
COLUMN_LON, COLUMN_LON,
COLUMN_ALT ] COLUMN_ALT ]
# Индексы колонок, в которых можно вводит текст # Индексы колонок, в которых можно вводит текст
const TABLE_ENTRY_COLUMNS = [ const TABLE_ENTRY_COLUMNS = [
COLUMN_AOA, COLUMN_AOA,
COLUMN_FREQ, COLUMN_FREQ,
COLUMN_WIDTH, COLUMN_WIDTH,
COLUMN_POW, COLUMN_POW,
COLUMN_TICK, COLUMN_TICK,
COLUMN_BAUD, COLUMN_BAUD,
COLUMN_SLON, COLUMN_SLON,
COLUMN_SLAT, COLUMN_SLAT,
COLUMN_SALT, COLUMN_SALT,
COLUMN_LAT, COLUMN_LAT,
COLUMN_LON, COLUMN_LON,
COLUMN_ALT ] COLUMN_ALT ]
# Типы модуляции # Типы модуляции
const MODE_TYPES = ['<неопр.>', 'am', 'ook', 'ask', 'fm', 'qpsk', 'oqpsk', 'pi4qpsk', 'qam16', const MODE_TYPES = ['<неопр.>', 'am', 'ook', 'ask', 'fm', 'qpsk', 'oqpsk', 'pi4qpsk', 'qam16',
'qam32', 'qam64', 'qam128', 'qam256', 'qam512', 'fsk', 'cpfsk', 'psk','ofdm'] 'qam32', 'qam64', 'qam128', 'qam256', 'qam512', 'fsk', 'cpfsk', 'psk','ofdm']
# Режим смены частоты # Режим смены частоты
const FREQM = ['<неопр.>', 'fhss', 'lfm', 'const'] const FREQM = ['<неопр.>', 'fhss', 'lfm', 'const']
# Протоколы радиомодема # Протоколы радиомодема
const M_PROTO = ['<неопр.>', '3dlink', 'skyhopperpro', 'picardiooem', 'solo7', 'j11', const M_PROTO = ['<неопр.>', '3dlink', 'skyhopperpro', 'picardiooem', 'solo7', 'j11',
'mavlink', 'ltm', 'hc12', 'df1', ] 'mavlink', 'ltm', 'hc12', 'df1', ]
# Номера колонок # Номера колонок
const COLUMN_OPT = [[COLUMN_TMOD, MODE_TYPES], [COLUMN_FREQM, FREQM], [COLUMN_PROTO, M_PROTO]] const COLUMN_OPT = [[COLUMN_TMOD, MODE_TYPES], [COLUMN_FREQM, FREQM], [COLUMN_PROTO, M_PROTO]]
const COLUMN_OPT_BTN = [COLUMN_TMOD, COLUMN_FREQM, COLUMN_PROTO] const COLUMN_OPT_BTN = [COLUMN_TMOD, COLUMN_FREQM, COLUMN_PROTO]
const ID_ARRAY_LEN = 100 # Размер пула номеров целей const ID_ARRAY_LEN = 100 # Размер пула номеров целей
# Цель # Цель
class Threat: class Threat:
# параметры цели, второе значение, разрешение отправки. # параметры цели, второе значение, разрешение отправки.
var row : Dictionary = { var row : Dictionary = {
'id':[0,true], 'id':[0,true],
'aoa':[10.0,true], 'aoa':[10.0,true],
'freq':[2480.0,true], 'freq':[2480.0,true],
'width':[20.0,true], 'width':[20.0,true],
'power':[20.0,true], 'power':[20.0,true],
'tick':[10,true], 'tick':[10,true],
'tmod':['',false], 'tmod':['',false],
'freqm':['',false], 'freqm':['',false],
'baud':[0.0,false], 'baud':[0.0,false],
'proto':['',false], 'proto':['',false],
'slon':[0.0,false], 'slon':[0.0,false],
'slat':[0.0,false], 'slat':[0.0,false],
'salt':[0.0,false], 'salt':[0.0,false],
'lat':[0.0,false], 'lat':[0.0,false],
'lon':[0.0,false], 'lon':[0.0,false],
'alt':[0.0,false], 'alt':[0.0,false],
} }
func _init(th_id : int):
row.id[0] = th_id
func get_data():
var data_to_send : Dictionary
for key in row.keys():
var value = row[key]
var data = value[0]
var need_send = value[1]
if need_send:
data_to_send[key] = data
return data_to_send
func update_rows():
var new_rows: Array = []
new_rows.append(_check_value(row.id))
new_rows.append(_check_value(row.aoa))
new_rows.append(_check_value(row.freq))
new_rows.append(_check_value(row.width))
new_rows.append(_check_value(row.power))
new_rows.append(_check_value(row.tick))
new_rows.append(_check_value(row.tmod))
new_rows.append(_check_value(row.freqm))
new_rows.append(_check_value(row.baud))
new_rows.append(_check_value(row.proto))
new_rows.append(_check_value(row.slon))
new_rows.append(_check_value(row.slat))
new_rows.append(_check_value(row.salt))
new_rows.append(_check_value(row.lat))
new_rows.append(_check_value(row.lon))
new_rows.append(_check_value(row.alt))
return new_rows
func _check_value(val):
if val[1]:
return String(val[0])
else:
return ''
func set_aoa(val):
var value = float(val)
value = Tools.check_low_high(value, 0, 360)
value = Tools.check_len(val, value)
row.aoa[0] = value
row.aoa[1] = Tools.check_empty(value)
return value
func set_freq(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.freq[0] = value
row.freq[1] = Tools.check_empty(value)
return value
func set_width(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.width[0] = value
row.width[1] = Tools.check_empty(value)
return value
func set_power(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.power[0] = value
row.power[1] = Tools.check_empty(value)
return value
func set_tick(val):
var value = int(val)
value = Tools.check_low_high(value, 0, 60000)
value = Tools.check_len(val, value)
row.tick[0] = value
row.tick[1] = Tools.check_empty(value)
return value
func set_baud(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.baud[0] = value
row.baud[1] = Tools.check_empty(value)
return value
func set_slon(val):
var value = float(val)
value = Tools.check_low_high(value, -90, 90)
value = Tools.check_len(val, value)
row.slon[0] = value
row.slon[1] = Tools.check_empty(value)
return value
func set_slat(val):
var value = float(val)
value = Tools.check_low_high(value, -180, 180)
value = Tools.check_len(val, value)
row.slat[0] = value
row.slat[1] = Tools.check_empty(value)
return value
func set_salt(val): func _init(th_id : int):
var value = float(val) row.id[0] = th_id
value = Tools.check_len(val, value)
row.salt[0] = value
row.salt[1] = Tools.check_empty(value)
return value
func set_lon(val): func get_data():
var value = float(val) var data_to_send : Dictionary
value = Tools.check_low_high(value, -90, 90) for key in row.keys():
value = Tools.check_len(val, value) var value = row[key]
row.lon[0] = value var data = value[0]
row.lon[1] = Tools.check_empty(value) var need_send = value[1]
return value if need_send:
data_to_send[key] = data
func set_lat(val): return data_to_send
var value = float(val)
value = Tools.check_low_high(value, -180, 180)
value = Tools.check_len(val, value)
row.lat[0] = value
row.lat[1] = Tools.check_empty(value)
return value
func set_alt(val):
var value = float(val)
value = Tools.check_len(val, value)
row.alt[0] = value
row.alt[1] = Tools.check_empty(value)
return value
func set_tmod(val): func update_rows():
var value = String(val) var new_rows: Array = []
row.tmod[0] = value new_rows.append(_check_value(row.id))
row.tmod[1] = false if value == '<неопр.>' else true new_rows.append(_check_value(row.aoa))
return value new_rows.append(_check_value(row.freq))
new_rows.append(_check_value(row.width))
func set_freqm(val): new_rows.append(_check_value(row.power))
var value = String(val) new_rows.append(_check_value(row.tick))
row.freqm[0] = value new_rows.append(_check_value(row.tmod))
row.freqm[1] = false if value == '<неопр.>' else true new_rows.append(_check_value(row.freqm))
return value new_rows.append(_check_value(row.baud))
new_rows.append(_check_value(row.proto))
func set_proto(val): new_rows.append(_check_value(row.slon))
var value = String(val) new_rows.append(_check_value(row.slat))
row.proto[0] = value new_rows.append(_check_value(row.salt))
row.proto[1] = false if value == '<неопр.>' else true new_rows.append(_check_value(row.lat))
return value new_rows.append(_check_value(row.lon))
new_rows.append(_check_value(row.alt))
return new_rows
func _check_value(val):
if val[1]:
return '%s' % val[0]
else:
return ''
func set_aoa(val):
var value = float(val)
value = Tools.check_low_high(value, 0, 360)
value = Tools.check_len(val, value)
row.aoa[0] = value
row.aoa[1] = Tools.check_empty(value)
return value
func set_freq(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.freq[0] = value
row.freq[1] = Tools.check_empty(value)
return value
func set_width(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.width[0] = value
row.width[1] = Tools.check_empty(value)
return value
func set_power(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.power[0] = value
row.power[1] = Tools.check_empty(value)
return value
func set_tick(val):
var value = int(val)
value = Tools.check_low_high(value, 0, 60000)
value = Tools.check_len(val, value)
row.tick[0] = value
row.tick[1] = Tools.check_empty(value)
return value
func set_baud(val):
var value = float(val)
value = Tools.check_negative(value)
value = Tools.check_len(val, value)
row.baud[0] = value
row.baud[1] = Tools.check_empty(value)
return value
func set_slon(val):
var value = float(val)
value = Tools.check_low_high(value, -90, 90)
value = Tools.check_len(val, value)
row.slon[0] = value
row.slon[1] = Tools.check_empty(value)
return value
func set_slat(val):
var value = float(val)
value = Tools.check_low_high(value, -180, 180)
value = Tools.check_len(val, value)
row.slat[0] = value
row.slat[1] = Tools.check_empty(value)
return value
func set_salt(val):
var value = float(val)
value = Tools.check_len(val, value)
row.salt[0] = value
row.salt[1] = Tools.check_empty(value)
return value
func set_lon(val):
var value = float(val)
value = Tools.check_low_high(value, -90, 90)
value = Tools.check_len(val, value)
row.lon[0] = value
row.lon[1] = Tools.check_empty(value)
return value
func set_lat(val):
var value = float(val)
value = Tools.check_low_high(value, -180, 180)
value = Tools.check_len(val, value)
row.lat[0] = value
row.lat[1] = Tools.check_empty(value)
return value
func set_alt_pressed(val):
var value = float(val)
value = Tools.check_len(val, value)
row.alt[0] = value
row.alt[1] = Tools.check_empty(value)
return value
func set_tmod(val):
var value = String(val)
row.tmod[0] = value
row.tmod[1] = false if value == '<неопр.>' else true
return value
func set_freqm(val):
var value = String(val)
row.freqm[0] = value
row.freqm[1] = false if value == '<неопр.>' else true
return value
func set_proto(val):
var value = String(val)
row.proto[0] = value
row.proto[1] = false if value == '<неопр.>' else true
return value
func init_treats(header, table, btn_add, btn_del): # Инициализация вкладки с целями func init_treats(header, table, btn_add, btn_del): # Инициализация вкладки с целями
for i in range(ID_ARRAY_LEN): # Заполняет массив ID целей for i in range(ID_ARRAY_LEN): # Заполняет массив ID целей
id_array.append(i+1) id_array.append(i+1)
header.add_row(TABLE_HEADER_TYPES) header.add_row(TABLE_HEADER_TYPES)
header.set_rows_text([TABLE_HEADERS]) header.set_rows_text([TABLE_HEADERS])
on_btn_add(table) on_btn_add(table)
init_table(header, TABLE_COLUMN_SIZES) init_table(header, TABLE_COLUMN_SIZES)
init_table(table, TABLE_COLUMN_SIZES) init_table(table, TABLE_COLUMN_SIZES)
table.align_to_left_bottom(header, Vector2(0, 2)) table.align_to_left_bottom(header, Vector2(0, 2))
table.connect('row_pressed', self, 'on_row_pressed', [table]) table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table))
table.set_callbacks(self, 'text_entered', 'on_edit_entry', TABLE_ENTRY_COLUMNS, [table]) table.set_callbacks(self, 'text_submitted', 'on_edit_entry', TABLE_ENTRY_COLUMNS, [table])
table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [table]) table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [table])
btn_add.connect('button_up', self, 'on_btn_add', [table]) btn_add.connect('button_up', Callable(self, 'on_btn_add').bind(table))
btn_del.connect('button_up', self, 'on_btn_del', [table]) btn_del.connect('button_up', Callable(self, 'on_btn_del').bind(table))
func selector_color_proc(_i_row: int): func selector_color_proc(_i_row: int):
return Consts.COLOR_ACCENT * Consts.COLOR_HALF_ALPHA return Consts.COLOR_ACCENT * Consts.COLOR_HALF_ALPHA
func init_table(table: Table, sizes: Array): func init_table(table: Table, sizes: Array):
for i_row in table.get_rows_count(): for i_row in table.get_rows_count():
table.set_nodes_min_size(i_row, sizes) table.set_nodes_min_size(i_row, sizes)
table.set_selector_color_proc(self, 'selector_color_proc') table.set_selector_color_proc(self, 'selector_color_proc')
func init_opt_btns(row : int, table): func init_opt_btns(row : int, table):
for item in COLUMN_OPT: for item in COLUMN_OPT:
var i_col = item[0] var i_col = item[0]
var opt_arr = item[1] var opt_arr = item[1]
var cell = table.get_node2(i_col, row) var cell = table.get_node2(i_col, row)
for opt in opt_arr: for opt in opt_arr:
cell.add_item(opt) cell.add_item(opt)
cell.select(0) cell.select(0)
func on_item_selected(item_num, node, table): func on_item_selected(item_num, node, table):
var optbtn_text = node.text var optbtn_text = node.text
var indexis = table.get_key_indexes(node.name) var indexis = table.get_key_indexes(node.name)
var row_i = indexis[1] var row_i = indexis[1]
var col_i = indexis[0] var col_i = indexis[0]
var cell = table.get_node2(0,row_i) var cell = table.get_node2(0,row_i)
var value = set_value(optbtn_text, cell.text, col_i) var value = set_value(optbtn_text, cell.text, col_i)
func on_edit_entry(text : String, entry, table): func on_edit_entry(text : String, entry, table):
var indexis = table.get_key_indexes(entry.name) var indexis = table.get_key_indexes(entry.name)
var row_i = indexis[1] var row_i = indexis[1]
var col_i = indexis[0] var col_i = indexis[0]
var cell = table.get_node2(0,row_i) var cell = table.get_node2(0,row_i)
var value = set_value(text, cell.text, col_i) var value = set_value(text, cell.text, col_i)
entry.text = String(value) entry.text = String(value)
func set_value(val : String, treat_id : String, column : int): func set_value(val : String, treat_id : String, column : int):
var treat = treats[treat_id] var treat = treats[treat_id]
match column: match column:
COLUMN_AOA: COLUMN_AOA:
return treat.set_aoa(val) return treat.set_aoa(val)
COLUMN_FREQ: COLUMN_FREQ:
return treat.set_freq(val) return treat.set_freq(val)
COLUMN_WIDTH: COLUMN_WIDTH:
return treat.set_width(val) return treat.set_width(val)
COLUMN_POW: COLUMN_POW:
return treat.set_power(val) return treat.set_power(val)
COLUMN_TICK: COLUMN_TICK:
return treat.set_tick(val) return treat.set_tick(val)
COLUMN_TMOD: COLUMN_TMOD:
return treat.set_tmod(val) return treat.set_tmod(val)
COLUMN_FREQM: COLUMN_FREQM:
return treat.set_freqm(val) return treat.set_freqm(val)
COLUMN_BAUD: COLUMN_BAUD:
return treat.set_baud(val) return treat.set_baud(val)
COLUMN_PROTO: COLUMN_PROTO:
return treat.set_proto(val) return treat.set_proto(val)
COLUMN_SLON: COLUMN_SLON:
return treat.set_slon(val) return treat.set_slon(val)
COLUMN_SLAT: COLUMN_SLAT:
return treat.set_slat(val) return treat.set_slat(val)
COLUMN_SALT: COLUMN_SALT:
return treat.set_salt(val) return treat.set_salt(val)
COLUMN_LAT: COLUMN_LAT:
return treat.set_lon(val) return treat.set_lon(val)
COLUMN_LON: COLUMN_LON:
return treat.set_lat(val) return treat.set_lat(val)
COLUMN_ALT: COLUMN_ALT:
return treat.set_alt(val) return treat.set_alt_pressed(val)
func on_row_pressed(i_row: int, table): func on_row_pressed(i_row: int, table):
table.clear_rows_selected() table.clear_rows_selected()
table.set_row_selected(i_row, true) table.set_row_selected(i_row, true)
func on_btn_add(table): func on_btn_add(table):
var id = pop_id() var id = pop_id()
var threat : = Threat.new(id) var threat : = Threat.new(id)
treats[String(id)] = threat treats['%d' % id] = threat
var row = threat.update_rows() var row = threat.update_rows()
table.add_row(TABLE_ROW_TYPES) table.add_row(TABLE_ROW_TYPES)
table.set_row_text(table.get_rows_count()-1, row) table.set_row_text(table.get_rows_count()-1, row)
init_opt_btns(table.get_rows_count()-1, table) init_opt_btns(table.get_rows_count()-1, table)
table.set_callbacks(self, 'text_entered', 'on_edit_entry', TABLE_ENTRY_COLUMNS, []) table.set_callbacks(self, 'text_submitted', 'on_edit_entry', TABLE_ENTRY_COLUMNS, [])
table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, []) table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [])
func on_btn_del(table): func on_btn_del(table):
var row_i = [] var row_i = []
table.get_selected_rows(row_i) table.get_selected_rows(row_i)
if len(row_i) > 0: if len(row_i) > 0:
var cell = table.get_node2(0, row_i[0]) var cell = table.get_node2(0, row_i[0])
treats.erase(cell.text) treats.erase(cell.text)
table.remove_row(row_i[0]) table.remove_row(row_i[0])
table.rehash([]) table.rehash([])
func pop_id(): func pop_id():
var id = 0 var id = 0
if len(id_array): if len(id_array):
id = id_array[0] id = id_array[0]
id_array.remove(0) id_array.remove_at(0)
return id return id
func push_id(id : int): func push_id(id : int):
id_array.append(id) id_array.append(id)
func get_threats_data(): func get_threats_data():
var data_to_json : Dictionary var data_to_json : Dictionary
data_to_json['ts'] = 5 data_to_json['ts'] = 5
msg_counter += 1 msg_counter += 1
data_to_json['ss'] = msg_counter data_to_json['ss'] = msg_counter
data_to_json['msvk'] = [] data_to_json['msvk'] = []
data_to_json['mis'] = [] data_to_json['mis'] = []
for key in treats: for key in treats:
var data = treats[key].get_data() var data = treats[key].get_data()
data_to_json['mis'].append(data) data_to_json['mis'].append(data)
var json = to_json(data_to_json) var json = JSON.new().stringify(data_to_json)
var pac = json.to_utf8() var pac = json.to_utf8_buffer()
return pac return pac

View File

@@ -4,12 +4,12 @@
bg_color = Color( 1, 0.596078, 0.4, 1 ) bg_color = Color( 1, 0.596078, 0.4, 1 )
[node name="heder" type="Label"] [node name="heder" type="Label"]
margin_right = 120.0 offset_right = 120.0
margin_bottom = 30.0 offset_bottom = 30.0
size_flags_horizontal = 15 size_flags_horizontal = 15
size_flags_vertical = 15 size_flags_vertical = 15
custom_colors/font_color = Color( 0.0313726, 0.105882, 0.184314, 1 ) theme_override_colors/font_color = Color( 0.0313726, 0.105882, 0.184314, 1 )
custom_styles/normal = SubResource( 1 ) theme_override_styles/normal = SubResource( 1 )
align = 1 align = 1
valign = 1 valign = 1
clip_text = true clip_text = true

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/индикатор-1-0.png-fc0a1949f86e54aad24513db3cf620a1.stex" uid="uid://dag8n0gknjwak"
path="res://.godot/imported/индикатор-1-0.png-fc0a1949f86e54aad24513db3cf620a1.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://индикатор-1-0.png" source_file="res://индикатор-1-0.png"
dest_files=[ "res://.import/индикатор-1-0.png-fc0a1949f86e54aad24513db3cf620a1.stex" ] dest_files=["res://.godot/imported/индикатор-1-0.png-fc0a1949f86e54aad24513db3cf620a1.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/индикатор-1-1.png-8b27c7b615854227f833f39bac77ddc2.stex" uid="uid://b3ext3w4ftgg2"
path="res://.godot/imported/индикатор-1-1.png-8b27c7b615854227f833f39bac77ddc2.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://индикатор-1-1.png" source_file="res://индикатор-1-1.png"
dest_files=[ "res://.import/индикатор-1-1.png-8b27c7b615854227f833f39bac77ddc2.stex" ] dest_files=["res://.godot/imported/индикатор-1-1.png-8b27c7b615854227f833f39bac77ddc2.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/кнопка-3-0.png-5f27389cf7d8b3614e031e6b8d168b3c.stex" uid="uid://cf0jds8v6lqin"
path="res://.godot/imported/кнопка-3-0.png-5f27389cf7d8b3614e031e6b8d168b3c.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://кнопка-3-0.png" source_file="res://кнопка-3-0.png"
dest_files=[ "res://.import/кнопка-3-0.png-5f27389cf7d8b3614e031e6b8d168b3c.stex" ] dest_files=["res://.godot/imported/кнопка-3-0.png-5f27389cf7d8b3614e031e6b8d168b3c.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap] [remap]
importer="texture" importer="texture"
type="StreamTexture" type="CompressedTexture2D"
path="res://.import/кнопка-3-1.png-d6f5584c24056a03a792e757c3c765b0.stex" uid="uid://ddxxauugcc14e"
path="res://.godot/imported/кнопка-3-1.png-d6f5584c24056a03a792e757c3c765b0.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
@@ -10,26 +11,24 @@ metadata={
[deps] [deps]
source_file="res://кнопка-3-1.png" source_file="res://кнопка-3-1.png"
dest_files=[ "res://.import/кнопка-3-1.png-d6f5584c24056a03a792e757c3c765b0.stex" ] dest_files=["res://.godot/imported/кнопка-3-1.png-d6f5584c24056a03a792e757c3c765b0.ctex"]
[params] [params]
compress/mode=0 compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_mode=0 compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 compress/channel_pack=0
flags/filter=true mipmaps/generate=false
flags/mipmaps=false mipmaps/limit=-1
flags/anisotropic=false roughness/mode=0
flags/srgb=2 roughness/src_normal=""
process/fix_alpha_border=true process/fix_alpha_border=true
process/premult_alpha=false process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false process/hdr_as_srgb=false
size_limit=0 process/hdr_clamp_exposure=false
detect_3d=true process/size_limit=0
svg/scale=1.0 detect_3d/compress_to=1

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://кнопка-3-1.png" type="Texture" id=1] [ext_resource path="res://кнопка-3-1.png" type="Texture2D" id=1]
[ext_resource path="res://кнопка-3-0.png" type="Texture" id=2] [ext_resource path="res://кнопка-3-0.png" type="Texture2D" id=2]
[node name="TextureButton" type="TextureButton"] [node name="TextureButton" type="TextureButton"]
modulate = Color( 1.5, 1.5, 1.5, 1 ) modulate = Color( 1.5, 1.5, 1.5, 1 )
margin_right = 140.0 offset_right = 140.0
margin_bottom = 34.0 offset_bottom = 34.0
toggle_mode = true toggle_mode = true
action_mode = 0 action_mode = 0
texture_normal = ExtResource( 2 ) texture_normal = ExtResource( 2 )

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://индикатор-1-1.png" type="Texture" id=1] [ext_resource path="res://индикатор-1-1.png" type="Texture2D" id=1]
[ext_resource path="res://индикатор-1-0.png" type="Texture" id=2] [ext_resource path="res://индикатор-1-0.png" type="Texture2D" id=2]
[node name="indicator_1" type="TextureButton"] [node name="indicator_1" type="TextureButton"]
modulate = Color( 1, 0.596078, 0.4, 1 ) modulate = Color( 1, 0.596078, 0.4, 1 )
margin_right = 35.0 offset_right = 35.0
margin_bottom = 29.0 offset_bottom = 29.0
toggle_mode = true toggle_mode = true
button_mask = 0 button_mask = 0
texture_normal = ExtResource( 2 ) texture_normal = ExtResource( 2 )

View File

@@ -1,5 +1,5 @@
[gd_scene format=2] [gd_scene format=2]
[node name="OptionButton" type="OptionButton"] [node name="OptionButton" type="OptionButton"]
margin_right = 80.0 offset_right = 80.0
margin_bottom = 34.0 offset_bottom = 34.0

View File

@@ -1,9 +1,9 @@
[gd_scene format=2] [gd_scene format=2]
[node name="Label" type="Label"] [node name="Label" type="Label"]
margin_right = 122.0 offset_right = 122.0
margin_bottom = 34.0 offset_bottom = 34.0
custom_colors/font_color = Color( 1, 0.596078, 0.4, 1 ) theme_override_colors/font_color = Color( 1, 0.596078, 0.4, 1 )
align = 1 align = 1
valign = 1 valign = 1
clip_text = true clip_text = true

View File

@@ -1,11 +1,11 @@
[gd_scene format=2] [gd_scene format=2]
[node name="LineEdit" type="LineEdit"] [node name="LineEdit" type="LineEdit"]
margin_right = 82.0 offset_right = 82.0
margin_bottom = 34.0 offset_bottom = 34.0
custom_colors/font_color = Color( 1, 0.596078, 0.4, 1 ) theme_override_colors/font_color = Color( 1, 0.596078, 0.4, 1 )
context_menu_enabled = false context_menu_enabled = false
shortcut_keys_enabled = false shortcut_keys_enabled = false
middle_mouse_paste_enabled = false middle_mouse_paste_enabled = false
caret_blink = true caret_blink = true
caret_blink_speed = 0.13 caret_blink_interval = 0.13