From 54e5f1bf371b881c5ebca871bee748d035cb8a7e Mon Sep 17 00:00:00 2001 From: MaD_CaT Date: Wed, 7 Feb 2024 10:15:30 +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=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D1=80=D0=B0=D1=81=D0=BA=D1=80=D0=B0=D1=81?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=81=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B0=D0=BD=D1=82=D0=B5=D0=BD=D0=BD=20=D0=B2=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BD=D1=8B=D0=B5=20=D1=86=D0=B2=D0=B5=D1=82=D0=B0=20(?= =?UTF-8?q?=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=20=D1=81=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B0,=20=D0=BD=D0=B0=D0=B7=D0=BD=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BC=D0=B5=D1=85=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project.godot | 4 ++ scenes/bip/bip.gd | 1 - scenes/работа/работа.gd | 118 +++++++++++++++++++++++++++++++------- scenes/работа/работа.tscn | 43 +++++++++----- scripts/interfer.gd | 1 + scripts/signaller.gd | 4 ++ scripts/threats.gd | 8 ++- shaders/antenas.tres | 37 +++++++----- 8 files changed, 167 insertions(+), 49 deletions(-) diff --git a/project.godot b/project.godot index ba405654..e8afb7d6 100644 --- a/project.godot +++ b/project.godot @@ -28,6 +28,10 @@ interfer/resend_timeout=1000.0 config/map_image_size_rto=Vector2i(512, 512) config/map_image_size_rls=Vector2i(1024, 1024) interfer/center_offset=Vector2(0, 25) +interfer/default_color0=Vector3(0.38, 0.47, 0.51) +interfer/default_color1=Vector3(0.39, 0.44, 0.5) +interfer/select_color=Vector3(1, 1, 1) +interfer/interfer_color=Vector3(0.58, 0.47, 0.51) [autoload] diff --git a/scenes/bip/bip.gd b/scenes/bip/bip.gd index 9a06c4f3..64a44568 100644 --- a/scenes/bip/bip.gd +++ b/scenes/bip/bip.gd @@ -20,7 +20,6 @@ func set_ecm_visible(value: bool): $ecm_done.visible = value func _on_bip_gui_input(event): - print_debug(event) if event is InputEventMouseButton and event.pressed: match event.button_index: MOUSE_BUTTON_LEFT: diff --git a/scenes/работа/работа.gd b/scenes/работа/работа.gd index 246bb65e..7b88d116 100644 --- a/scenes/работа/работа.gd +++ b/scenes/работа/работа.gd @@ -36,13 +36,14 @@ signal drag_begin ## Вызывается в момент начала пе signal drag_continue ## Вызывается во время продолжения перетаскивания signal drag_end ## Вызывается в момент завершения перетаскивания +## Границы секторов блоков ФС по пеленгу const fs_sectors: Dictionary = { 0: [0.0, 90.0], - 1: [90.0, 180.0], + 3: [90.0, 180.0], 2: [180.0, 270.0], - 3: [270.0, 360.0] -} + 1: [270.0, 360.0] } +## Границы секторов блоков ФС по частоте в режиме РТО const fs_band_rto: Dictionary = { 0: [200.0, 250.0], 1: [250.0, 300.0], @@ -50,9 +51,9 @@ const fs_band_rto: Dictionary = { 3: [350.0, 400.0], 4: [400.0, 450.0], 5: [450.0, 500.0], - 6: [500.0, 550.0], -} + 6: [500.0, 550.0] } +## Границы секторов блоков ФС по частоте в режиме РЛС const fs_band_rls: Dictionary = { 0: [480.0, 490.0], 1: [490.0, 500.0], @@ -60,10 +61,25 @@ const fs_band_rls: Dictionary = { 3: [510.0, 520.0], 4: [520.0, 530.0], 5: [530.0, 540.0], - 6: [540.0, 550.0], -} + 6: [540.0, 550.0] } -var fs_band = fs_band_rto + +const fs_freq: Dictionary = { + 0: [400.0, 1200.0], + 1: [1200.0, 2000.0], + 2: [2000.0, 2800.0], + 3: [2800.0, 3600.0], + 4: [3600.0, 4400.0], + 5: [4400.0, 5200.0], + 6: [5200.0, 6000.0] } + + +var fs_band = fs_band_rto # Текущий режим блоков ФС по частоте +var fs_default_colors: Array # Цвета по умолчанию для блоков ФС +var fs_colors: Array # Текущие цвета блоков ФС +var fs_selected: Array # Массив выбранных секторов +var th_selected: bool = false # Флаг, того, что выбрана цель. + ## Состояние перетаскивания enum DragFSM { DRAG, ## В процессе @@ -76,9 +92,11 @@ enum DragFSM { func on_threats_resized(threats: Dictionary): $count_all_pad/count_all.text = '%02d' % threats.size() +## Обработчик выбора цели func on_threat_selected(th, ecm_btns): on_rto_threat_sel(th.id, ecm_btns) +## Обработчик нажатия на кнопку вид func on_button_view_toggled(toggled: bool): signaller.emit_signal('map_mode_changed', int(toggled)) if toggled: @@ -109,10 +127,12 @@ func _ready(): max_zoom = ProjectSettings.get_setting('application/config/map_maximum_zoom', 19) drag_fsm = DragFSM.OFF $btn_zoom.set_meta('zoom', min_zoom - 1) - $btn_strob.button_connect('pressed', Callable(self, 'on_button_strobe_pressed')) + var btns_select: Array = $btns_select.get_children() + btns_select.any(func(btn): btn.button_connect('pressed', Callable(self, 'on_button_select').bind(btn, btns_select))) $btn_view.button_connect('toggled', Callable(self, 'on_button_view_toggled')) var nodes: Array = get_tree().get_nodes_in_group('группа-режим-помехи') nodes.any(func(btn): btn.button_connect('pressed', Callable(self, 'on_button_pressed').bind(btn, nodes))) + set_def_colors() threats.connect('threat_new', Callable(self, 'on_threat_new')) threats.connect('threat_lost', Callable(self, 'on_threat_lost')) threats.connect('threats_resized', Callable(self, 'on_threats_resized')) @@ -126,6 +146,7 @@ func _ready(): signaller.connect('interfer_off_all', Callable(self, 'interfer_off_all')) interfer.connect('interfer_update', Callable(self, 'on_interfer_new')) + func on_enter_tree() -> void: call_deferred('_on_btn_scale_pressed') call_deferred('on_button_strobe_pressed') @@ -141,7 +162,7 @@ func map_threat_to_bip(th: threats.Threat, bip: Control): radius_internal, radius_outter, freq_low, - freq_high) + freq_high) - bip.size / 2 ## Обработчик сигнала обновления цели @@ -161,9 +182,9 @@ func on_interfer_new(ecm): bip.set_ecm_visible(true) else: bip.set_ecm_visible(false) else: - print_debug() bip.set_ecm_visible(false) bip.set_track_visible(false) + set_fs_color(ecm) ## Обработчик выключения всех помех @@ -199,6 +220,9 @@ func on_rto_threat_sel(th_id, ecm_btns): item.set_sel_visible(false) for btn in ecm_btns: btn.set_disabled(false) + th_selected = true + await get_tree().create_timer(0.2).timeout + th_selected = false ## Обработчик снятия выбора РТО цели @@ -215,10 +239,16 @@ func on_rto_threat_unsel(th_id, ecm_btns): ## Обработчик нажатия кнопки "Строб". Управляет отображением строба func on_button_strobe_pressed() -> void: - drag_fsm = DragFSM.IDLE if $btn_strob.is_pressed() else DragFSM.OFF + drag_fsm = DragFSM.IDLE if $btns_select/btn_strob.is_pressed() else DragFSM.OFF $canvas.set_strob_visible(drag_fsm == DragFSM.IDLE) +## Поведение радиокнопок в группе. Управляет состоянием кнопок выбора целей +func on_button_select(btn_this, btn_others) -> void: + for btn_other in btn_others: btn_other.set_pressed(btn_this == btn_other) + on_button_strobe_pressed() + + ## Поведение радиокнопок в группе. Управляет состоянием кнопок в радиогруппе func on_button_pressed(btn_this, btn_others) -> void: for btn_other in btn_others: btn_other.set_pressed(btn_this == btn_other) @@ -299,7 +329,8 @@ func _input(event) -> void: drag_fsm = DragFSM.DRAG emit_signal('drag_begin', event) else: - sel_fs_sector(event) + if (event.button_index == MOUSE_BUTTON_LEFT) and (not $btns_select/btn_strob.pressed): + sel_fs_sector(event) drag_fsm = DragFSM.IDLE emit_signal('drag_end', event) @@ -332,18 +363,63 @@ func sel_fs_sector(event): var distance: float = event.position.distance_to(center + center_offset) var sector: int var band: int + var has_band: bool = false for sec in fs_sectors.values(): if angle >= sec[0] and angle <= sec[1]: sector = fs_sectors.find_key(sec) for diap in fs_band.values(): if distance >= diap[0] and distance <= diap[1]: band = fs_band.find_key(diap) - var colors: Array = [] - var color0 = Vector3(0.38, 0.47, 0.51) - var color1 = Vector3(0.39, 0.44, 0.50) - for i in range(14): - colors.append(color0) - colors.append(color1) - $canvas.set_band_colors(colors) - print_debug(sector, band) + has_band = true + if not has_band: + return + var fs_index = band * 4 + sector + var select_color: Vector3 = ProjectSettings.get_setting('application/interfer/select_color', Vector3(1.0, 1.0, 1.0)) + if not th_selected: + if len(fs_selected) > 0: + for fs_sector in fs_selected: + fs_colors[fs_sector[0]] = fs_sector[1] + fs_selected.clear() + fs_selected.append([fs_index, fs_colors[fs_index]]) + fs_colors[fs_index] = select_color + $canvas.set_band_colors(fs_colors) + signaller.emit_signal('rto_threat_unsel_all') + +## Закрашивание по умолчанию блоков ФС цветами из настроек +func set_def_colors(): + var color0: Vector3 = ProjectSettings.get_setting('application/interfer/default_color0', Vector3(0.38, 0.47, 0.51)) + var color1: Vector3 = ProjectSettings.get_setting('application/interfer/default_color1', Vector3(0.39, 0.44, 0.50)) + var col_arr: Array = [color0, color1] + var col = false + for i in range(7): + for j in range (4): + fs_default_colors.append(col_arr[int(col)]) + col = not col + col = not col + fs_colors = fs_default_colors + $canvas.set_band_colors(fs_default_colors) + + +func set_fs_color(ecm): + var color_ecm: Vector3 = ProjectSettings.get_setting('application/interfer/interfer_color', Vector3(0.58, 0.47, 0.51)) + var sector: int + var band: int + var angle: float = ecm.kni + 45.0 + if angle > 360.0: + angle -= 360.0 + for sec in fs_sectors.values(): + if float(angle) >= sec[0] and float(angle) <= sec[1]: + sector = fs_sectors.find_key(sec) + for diap in fs_freq.values(): + if ecm.params.has('freq'): + if ecm.params['freq'] >= diap[0] and ecm.params['freq'] <= diap[1]: + band = fs_freq.find_key(diap) + var fs_index = band * 4 + sector + var fs_is_selected: bool = false + for item in fs_selected: + if fs_index == item[0]: + fs_is_selected = true + if not fs_is_selected: + fs_colors[fs_index] = color_ecm + $canvas.set_band_colors(fs_colors) diff --git a/scenes/работа/работа.tscn b/scenes/работа/работа.tscn index 39a23b90..6f0cccc5 100644 --- a/scenes/работа/работа.tscn +++ b/scenes/работа/работа.tscn @@ -25,10 +25,10 @@ col_red = Color(1, 0.568627, 0.431373, 0.239216) drag_scale_band = 0.05 drag_scale_width = 0.5 freq_high = 6000.0 -freq_low = 200.0 +freq_low = 400.0 radius_center = Vector2(560, 560) radius_internal = 200.0 -radius_outter = 400.0 +radius_outter = 350.0 strob_max_band = 15.538 strob_max_width = 90.0 strob_min_band = 0.1 @@ -104,17 +104,6 @@ size_flags_horizontal = 3 size_flags_vertical = 3 text = "Автомат" -[node name="btn_strob" parent="." instance=ExtResource("8_k0iv2")] -layout_mode = 2 -offset_left = 1034.0 -offset_top = 67.0 -offset_right = 1108.0 -offset_bottom = 121.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -tooltip_text = "Кнопка для выбора сектора при помощи клика мышкой" -text = "Строб" - [node name="btn_view" parent="." instance=ExtResource("8_k0iv2")] layout_mode = 2 offset_left = 874.0 @@ -135,6 +124,34 @@ metadata/zoom = 4 [node name="canvas" parent="." instance=ExtResource("11_b6su4")] +[node name="btns_select" type="GridContainer" parent="."] +layout_mode = 0 +offset_left = 1034.0 +offset_top = 65.0 +offset_right = 1108.0 +offset_bottom = 181.0 + +[node name="btn_strob" parent="btns_select" instance=ExtResource("8_k0iv2")] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = "Кнопка для выбора сектора при помощи клика мышкой" +text = "Строб" + +[node name="btn_threats" parent="btns_select" instance=ExtResource("8_k0iv2")] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = "Кнопка для выбора сектора при помощи клика мышкой" +text = "Цель" + +[node name="btn_fs_sector" parent="btns_select" instance=ExtResource("8_k0iv2")] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tooltip_text = "Кнопка для выбора сектора при помощи клика мышкой" +text = "Сектор" + [connection signal="drag_begin" from="." to="." method="_on_drag_begin"] [connection signal="drag_continue" from="." to="." method="_on_drag_continue"] [connection signal="pressed" from="btn_zoom" to="." method="_on_btn_scale_pressed"] diff --git a/scripts/interfer.gd b/scripts/interfer.gd index f6488946..ede10998 100644 --- a/scripts/interfer.gd +++ b/scripts/interfer.gd @@ -100,6 +100,7 @@ func _ready(): signaller.connect('interfer_new', Callable(self, 'send_ecm').bind(unit)) signaller.connect('interfer_off_all', Callable(self, 'on_interfer_off_all').bind(unit, ecms)) + # Проверяет состояние отправки пакета и если не доставлен, повторяет отправку func on_timer_check_state(unit, ecms, resend_timeout): var tick = Time.get_ticks_msec() diff --git a/scripts/signaller.gd b/scripts/signaller.gd index 7b2a1f49..27cffad9 100644 --- a/scripts/signaller.gd +++ b/scripts/signaller.gd @@ -32,6 +32,10 @@ signal rto_threat_sel (th_id: int) signal rto_threat_unsel (th_id: int) +## Вызывается, когда пользователь снимает выделение со всех целей +signal rto_threat_unsel_all () + + ## Вызывается, когда пользователь выбирает помеху ## [param btn] - Нажатая кнопка помехи. signal interfer_init (btn: PanelContainer) diff --git a/scripts/threats.gd b/scripts/threats.gd index b83a4b9b..98ce1832 100644 --- a/scripts/threats.gd +++ b/scripts/threats.gd @@ -55,6 +55,7 @@ func _ready() -> void: timer_check_lost.start(repsettings.ThreatParams.time_lost / 1000.0) signaller.connect('rto_threat_sel', Callable(self, 'on_rto_threat_sel').bind(threats)) signaller.connect('rto_threat_unsel', Callable(self, 'on_rto_threat_unsel').bind(threats)) + signaller.connect('rto_threat_unsel_all', Callable(self, 'on_rto_threat_unsel_all').bind(threats)) signaller.connect('threat_selected', Callable(self, 'on_threat_selected').bind(threats)) signaller.connect('interfer_init', Callable(self, 'on_interfer_init').bind(threats)) @@ -74,6 +75,12 @@ func on_timer_check_lost(time_lost: int, threats: Dictionary): func on_rto_threat_unsel(th_id, threats): threats[th_id].selected = false +## Снимает выделение со всех целей +func on_rto_threat_unsel_all(threats): + for th in threats.values(): + signaller.emit_signal('rto_threat_unsel', th.id) + + ## Выбирает цель, если нажать по отметке цели. func on_rto_threat_sel(th_id, threats): on_threat_selected(threats[th_id], threats) @@ -95,7 +102,6 @@ func on_interfer_init(btn, threats): signaller.emit_signal('interfer_create', btn, sel_threats) - ## Производит приём целей func on_data_capsrpb_received(unit: capsrpb.CapsRpb, threats: Dictionary): if not unit.json_dic.has('ts'): return diff --git a/shaders/antenas.tres b/shaders/antenas.tres index 4b51e8fd..87248d14 100644 --- a/shaders/antenas.tres +++ b/shaders/antenas.tres @@ -41,7 +41,6 @@ const float ant_band_r1_4[] = {450.0, 530.0}; const float ant_band_r1_5[] = {500.0, 540.0}; const float ant_band_r1_6[] = {550.0, 550.0}; -const vec4 ant_band_colors[] = {vec4(0.38, 0.47, 0.51, 0.4),vec4(0.38, 0.47, 0.51, 0.4), vec4(0.38, 0.47, 0.51, 0.4), vec4(0.38, 0.47, 0.51, 0.4)}; uniform vec3 ant_band_c[28]; const float d4 = 90.0; @@ -65,14 +64,26 @@ void sector(inout vec4 c, vec2 uv, vec2 center, float a, float da, float r0, flo } -void antenas(inout vec4 c, vec2 uv, vec2 p0, int cnt, float r0, float r1, vec4 c0, vec4 c1) +void antenas(inout vec4 c, vec2 uv, vec2 p0, int cnt, float r0, float r1, inout int index) { float da = 180.0 / float(cnt); for (int i = -cnt; i <= cnt; i ++) { + vec4 col; + int j = index; + if (i == 2) + { + index--; + j = index - 3; + } + col.x = ant_band_c[j].x; + col.y = ant_band_c[j].y; + col.z = ant_band_c[j].z; + index++; + col.a = 0.5; float v = float(i & 1); - vec4 col = v * c0 + (1.0f - v) * c1; - sector(c, uv, p0, float(i) * da, da, r0, r1, col); + vec4 color = v * col + (1.0f - v) * col; + sector(c, uv, p0, float(i) * da, da, r0, r1, color); } } @@ -88,15 +99,15 @@ void fragment() ivec2 isz = textureSize(TEXTURE, 0); vec2 uv = UV * vec2(float(isz.x), float(isz.y)); // координаты текущей точки в пикселях COLOR = vec4(0, 0, 0, 0); //texture(TEXTURE, UV); // Цвет текущей точки - + int index = 0; // Сетка антенн - antenas(COLOR, uv, pc0, ant_band_count_0, ant_band_r0_0[mode], ant_band_r1_0[mode], color1, color0); - antenas(COLOR, uv, pc0, ant_band_count_1, ant_band_r0_1[mode], ant_band_r1_1[mode], color0, color1); - antenas(COLOR, uv, pc0, ant_band_count_2, ant_band_r0_2[mode], ant_band_r1_2[mode], color1, color0); - antenas(COLOR, uv, pc0, ant_band_count_3, ant_band_r0_3[mode], ant_band_r1_3[mode], color0, color1); - antenas(COLOR, uv, pc0, ant_band_count_4, ant_band_r0_4[mode], ant_band_r1_4[mode], color1, color0); - antenas(COLOR, uv, pc0, ant_band_count_5, ant_band_r0_5[mode], ant_band_r1_5[mode], color0, color1); - antenas(COLOR, uv, pc0, ant_band_count_6, ant_band_r0_6[mode], ant_band_r1_6[mode], color1, color0); + antenas(COLOR, uv, pc0, ant_band_count_0, ant_band_r0_0[mode], ant_band_r1_0[mode], index); + antenas(COLOR, uv, pc0, ant_band_count_1, ant_band_r0_1[mode], ant_band_r1_1[mode], index); + antenas(COLOR, uv, pc0, ant_band_count_2, ant_band_r0_2[mode], ant_band_r1_2[mode], index); + antenas(COLOR, uv, pc0, ant_band_count_3, ant_band_r0_3[mode], ant_band_r1_3[mode], index); + antenas(COLOR, uv, pc0, ant_band_count_4, ant_band_r0_4[mode], ant_band_r1_4[mode], index); + antenas(COLOR, uv, pc0, ant_band_count_5, ant_band_r0_5[mode], ant_band_r1_5[mode], index); + antenas(COLOR, uv, pc0, ant_band_count_6, ant_band_r0_6[mode], ant_band_r1_6[mode], index); } " @@ -110,4 +121,4 @@ shader_parameter/radius_inner_0 = 200.0 shader_parameter/radius_inner_1 = 480.0 shader_parameter/radius_outter = 550.0 shader_parameter/mode = 0 -shader_parameter/ant_band_c = PackedVector3Array(0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5) +shader_parameter/ant_band_c = PackedVector3Array(0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5, 0.38, 0.47, 0.51, 0.39, 0.44, 0.5)