Работа в процессе
This commit is contained in:
@@ -2,14 +2,31 @@
|
||||
|
||||
extends PanelContainer
|
||||
|
||||
@export var text: String = '': get = get_text, set = set_text
|
||||
@export var texture_state0: Texture2D = preload('res://data/кнопка-квадрат-0.png'): set = _state_set_texture
|
||||
@export var texture_state1: Texture2D = preload('res://data/кнопка-квадрат-1.png'): set = _state_set_texture
|
||||
@export var pressed: bool = false: get = is_pressed, set = set_pressed
|
||||
@export var toggle_mode: bool = false: get = is_toggle_mode, set = set_toggle_mode
|
||||
|
||||
func _state_set_texture(val: Texture2D): $state.set_texture(val)
|
||||
func _state_get_texture(): return $state.get_texture()
|
||||
@export var texture_state0: Texture2D = preload('res://data/кнопка-квадрат-0.png'):
|
||||
set(val): $state.set_texture(val)
|
||||
|
||||
|
||||
@export var texture_state1: Texture2D = preload('res://data/кнопка-квадрат-1.png'):
|
||||
set(val): $state.set_texture(val)
|
||||
|
||||
|
||||
@export var text: String = '':
|
||||
set(val): $button.set_text(val)
|
||||
get: return $button.get_text()
|
||||
|
||||
|
||||
@export var pressed: bool = false:
|
||||
set(val): $button.set_pressed(val)
|
||||
get: return $button.is_pressed()
|
||||
|
||||
|
||||
@export var toggle_mode: bool = false:
|
||||
set(val):
|
||||
if is_inside_tree():
|
||||
$button.set_toggle_mode(val)
|
||||
get: return $button.is_toggle_mode()
|
||||
|
||||
|
||||
func set_text (val: String): $button.set_text(val)
|
||||
func set_pressed (val: bool): $button.set_pressed(val)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://lwmw4egynmd1" path="res://scenes/контроль.tscn" id="2_h2mc4"]
|
||||
|
||||
[node name="tab_switch" type="TabContainer"]
|
||||
offset_top = -2.0
|
||||
offset_top = 0.0
|
||||
offset_right = 1600.0
|
||||
offset_bottom = 1200.0
|
||||
|
||||
|
||||
125
scenes/работа.gd
125
scenes/работа.gd
@@ -1,35 +1,63 @@
|
||||
extends Panel
|
||||
|
||||
const RADIO_GROUPE_NAMES = \
|
||||
['btn_off', 'btn_p4', 'btn_p5', 'btn_p6', 'btn_p7',
|
||||
'btn_p8', 'btn_p9', 'btn_p10', 'btn_p11', 'btn_p12',
|
||||
'btn_p13', 'btn_p14', 'btn_p15', 'btn_p16', 'btn_auto_rfi']
|
||||
@export_color_no_alpha var col_red
|
||||
@export_color_no_alpha var col_grey
|
||||
|
||||
enum DRAG_FSM { IDLE, DRAG }
|
||||
var radio_groupe: Array
|
||||
var drag_pos_begin: Vector2
|
||||
var drag_fsm: DRAG_FSM
|
||||
var drag_button: MouseButton
|
||||
var pc0: Vector2
|
||||
var ant_dir_width_begin: float
|
||||
var ant_dir_begin: float
|
||||
""" Состояние перетаскивания """
|
||||
|
||||
var drag_pos_begin: Vector2
|
||||
""" Точка начала перетаскивания """
|
||||
|
||||
var drag_fsm: DRAG_FSM = DRAG_FSM.IDLE
|
||||
""" Текущее состояние перетаскивания """
|
||||
|
||||
var drag_button: MouseButton
|
||||
""" Кнопка мыши нажатая при перетаскивании """
|
||||
|
||||
var ant_width_begin: float
|
||||
""" Ширина ДН антенны в момент начала перетаскивания """
|
||||
|
||||
var ant_dir_begin: float
|
||||
""" Направление антенны в момент начала перетаскивания """
|
||||
|
||||
var ant_center: Vector2
|
||||
""" Центр антенн """
|
||||
|
||||
signal drag_begin
|
||||
""" Вызывается в момент начала перетаскивания """
|
||||
|
||||
signal drag_continue
|
||||
""" Вызывается во время продолжения перетаскивания """
|
||||
|
||||
signal drag_end
|
||||
""" Вызывается в момент завершения перетаскивания """
|
||||
|
||||
signal full_screen
|
||||
""" Вызывается при смене режима окна полный экран - оконный """
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$btn_strobe.button_connect('pressed', Callable(self, 'on_button_stobe_pressed'))
|
||||
$canvas/animator.play('вращение')
|
||||
$'рамка-режим/btn_off'.set_pressed(true)
|
||||
var nodes = $'рамка-режим'.get_children()
|
||||
pc0 = $canvas.material.get('shader_parameter/pc0')
|
||||
ant_center = $canvas.material.get('shader_parameter/pc0')
|
||||
$canvas.material.set('shader_parameter/ap_ant_col', col_grey)
|
||||
var nodes: = get_tree().get_nodes_in_group('группа-режим-помехи')
|
||||
for btn in nodes:
|
||||
if btn.name in RADIO_GROUPE_NAMES:
|
||||
radio_groupe.append(btn)
|
||||
btn.button_connect('pressed', Callable(self, '_on_button_pressed').bind(btn))
|
||||
btn.button_connect('pressed', Callable(self, 'on_button_pressed').bind(btn, nodes))
|
||||
|
||||
|
||||
func _on_button_pressed(btn):
|
||||
func on_button_stobe_pressed():
|
||||
if $btn_strobe.is_pressed():
|
||||
$canvas.material.set('shader_parameter/ap_ant_col', col_red)
|
||||
else:
|
||||
$canvas.material.set('shader_parameter/ap_ant_col', col_grey)
|
||||
|
||||
|
||||
func on_button_pressed(btn_this, btn_others):
|
||||
# поведение радиокнопок в группе
|
||||
for btn0 in radio_groupe:
|
||||
btn0.set_pressed(btn0 == btn)
|
||||
for btn_other in btn_others: btn_other.set_pressed(btn_this == btn_other)
|
||||
|
||||
|
||||
func hypot(x: float, y: float) -> float:
|
||||
@@ -46,37 +74,62 @@ func map_xy_ang(pos0: Vector2, pos: Vector2) -> Vector2:
|
||||
return Vector2(ang, radius)
|
||||
|
||||
|
||||
func get_ant_width(position: Vector2, prev: float) -> float:
|
||||
var radp: Vector2 = map_xy_ang(pc0, position)
|
||||
var ap_ant_w: float = prev + (drag_pos_begin.y - position.y) / 5.0
|
||||
func get_ant_width(pos: Vector2, prev: float) -> float:
|
||||
var ap_ant_w: float = prev + (drag_pos_begin.y - pos.y) / 5.0
|
||||
if ap_ant_w < 5.0: ap_ant_w = 5.0
|
||||
if ap_ant_w > 90.0: ap_ant_w = 90.0
|
||||
return ap_ant_w
|
||||
|
||||
|
||||
func set_ant_dir(position: Vector2):
|
||||
var radp: Vector2 = map_xy_ang(pc0, position)
|
||||
func set_ant_dir(pos: Vector2):
|
||||
var radp: Vector2 = map_xy_ang(ant_center, pos)
|
||||
if radp.y < 600:
|
||||
$canvas.material.set('shader_parameter/sec_var', radp.x)
|
||||
|
||||
|
||||
func _on_drag_continue(event):
|
||||
if drag_button == MOUSE_BUTTON_RIGHT:
|
||||
var ap_ant_w: float = get_ant_width(event.position, ant_width_begin)
|
||||
$canvas.material.set('shader_parameter/ap_ant_w', ap_ant_w)
|
||||
elif drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
|
||||
|
||||
func _on_drag_begin(event):
|
||||
drag_pos_begin = event.position
|
||||
if drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
elif drag_button == MOUSE_BUTTON_RIGHT:
|
||||
ant_width_begin = $canvas.material.get('shader_parameter/ap_ant_w')
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseMotion:
|
||||
if drag_fsm == DRAG_FSM.DRAG:
|
||||
if drag_button == MOUSE_BUTTON_RIGHT:
|
||||
var ap_ant_w: float = get_ant_width(event.position, ant_dir_width_begin)
|
||||
$canvas.material.set('shader_parameter/ap_ant_w', ap_ant_w)
|
||||
elif drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
if event is InputEventMouseButton:
|
||||
emit_signal('drag_continue', event)
|
||||
elif event is InputEventMouseButton:
|
||||
drag_button = event.button_index
|
||||
if event.pressed:
|
||||
if drag_fsm == DRAG_FSM.IDLE:
|
||||
drag_fsm = DRAG_FSM.DRAG
|
||||
drag_pos_begin = event.position
|
||||
if drag_button == MOUSE_BUTTON_LEFT:
|
||||
set_ant_dir(event.position)
|
||||
elif drag_button == MOUSE_BUTTON_RIGHT:
|
||||
ant_dir_width_begin = $canvas.material.get('shader_parameter/ap_ant_w')
|
||||
emit_signal('drag_begin', event)
|
||||
else:
|
||||
drag_fsm = DRAG_FSM.IDLE
|
||||
emit_signal('drag_end', event)
|
||||
elif event is InputEventKey:
|
||||
if event.pressed and event.physical_keycode == KEY_F11:
|
||||
emit_signal('full_screen')
|
||||
|
||||
|
||||
func toggle_full_screen(id: int):
|
||||
var mode = DisplayServer.window_get_mode(id)
|
||||
if mode == DisplayServer.WINDOW_MODE_FULLSCREEN:
|
||||
mode = DisplayServer.WINDOW_MODE_WINDOWED
|
||||
else:
|
||||
mode = DisplayServer.WINDOW_MODE_FULLSCREEN
|
||||
DisplayServer.window_set_mode(mode, id)
|
||||
|
||||
|
||||
func _on_full_screen():
|
||||
toggle_full_screen(1)
|
||||
toggle_full_screen(0)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
[node name="Работа" type="Panel"]
|
||||
script = ExtResource("1_6kl7p")
|
||||
col_red = Color(1, 0.568627, 0.431373, 1)
|
||||
col_grey = Color(0.6, 0.6, 0.6, 1)
|
||||
|
||||
[node name="canvas" parent="." instance=ExtResource("2_jfiel")]
|
||||
|
||||
@@ -20,7 +22,7 @@ offset_right = 1589.0
|
||||
offset_bottom = 1162.0
|
||||
text = "Режим помехи"
|
||||
|
||||
[node name="btn_off" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_off" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 30.0
|
||||
@@ -28,7 +30,7 @@ offset_right = 100.0
|
||||
offset_bottom = 80.0
|
||||
text = "Откл"
|
||||
|
||||
[node name="btn_p4" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p4" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 110.0
|
||||
offset_top = 210.0
|
||||
@@ -36,7 +38,7 @@ offset_right = 200.0
|
||||
offset_bottom = 260.0
|
||||
text = "13"
|
||||
|
||||
[node name="btn_p5" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p5" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 10.0
|
||||
@@ -47,7 +49,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "12"
|
||||
|
||||
[node name="btn_p6" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p6" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 210.0
|
||||
offset_top = 150.0
|
||||
@@ -55,7 +57,7 @@ offset_right = 300.0
|
||||
offset_bottom = 200.0
|
||||
text = "10"
|
||||
|
||||
[node name="btn_p7" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p7" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 310.0
|
||||
offset_top = 150.0
|
||||
@@ -63,7 +65,7 @@ offset_right = 400.0
|
||||
offset_bottom = 200.0
|
||||
text = "11"
|
||||
|
||||
[node name="btn_p8" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p8" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 110.0
|
||||
offset_top = 150.0
|
||||
@@ -71,7 +73,7 @@ offset_right = 200.0
|
||||
offset_bottom = 200.0
|
||||
text = "9"
|
||||
|
||||
[node name="btn_p9" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p9" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 150.0
|
||||
@@ -79,7 +81,7 @@ offset_right = 100.0
|
||||
offset_bottom = 200.0
|
||||
text = "8"
|
||||
|
||||
[node name="btn_p10" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p10" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 310.0
|
||||
@@ -90,7 +92,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "7"
|
||||
|
||||
[node name="btn_p11" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p11" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 310.0
|
||||
offset_top = 30.0
|
||||
@@ -98,7 +100,7 @@ offset_right = 399.0
|
||||
offset_bottom = 80.0
|
||||
text = "3"
|
||||
|
||||
[node name="btn_p12" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p12" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 10.0
|
||||
@@ -109,7 +111,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "4"
|
||||
|
||||
[node name="btn_p13" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p13" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 110.0
|
||||
@@ -120,7 +122,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "5"
|
||||
|
||||
[node name="btn_p14" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p14" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 210.0
|
||||
@@ -131,7 +133,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "6"
|
||||
|
||||
[node name="btn_p15" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p15" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
offset_left = 210.0
|
||||
@@ -142,7 +144,7 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "2"
|
||||
|
||||
[node name="btn_p16" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_p16" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 110.0
|
||||
offset_top = 30.0
|
||||
@@ -150,7 +152,7 @@ offset_right = 200.0
|
||||
offset_bottom = 80.0
|
||||
text = "1"
|
||||
|
||||
[node name="btn_auto_rfi" parent="рамка-режим" instance=ExtResource("12_pcemc")]
|
||||
[node name="btn_auto_rfi" parent="рамка-режим" groups=["группа-режим-помехи"] instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 210.0
|
||||
offset_top = 210.0
|
||||
@@ -744,12 +746,20 @@ horizontal_alignment = 1
|
||||
|
||||
[node name="btn_auto_threat" parent="." instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 983.0
|
||||
offset_left = 980.0
|
||||
offset_top = 1101.0
|
||||
offset_right = 1172.0
|
||||
offset_bottom = 1153.0
|
||||
offset_right = 1170.0
|
||||
offset_bottom = 1151.0
|
||||
text = "Автоматически"
|
||||
|
||||
[node name="btn_strobe" parent="." instance=ExtResource("12_pcemc")]
|
||||
layout_mode = 0
|
||||
offset_left = 980.0
|
||||
offset_top = 30.0
|
||||
offset_right = 1170.0
|
||||
offset_bottom = 80.0
|
||||
text = "Строб"
|
||||
|
||||
[node name="надпись-выбор-цели" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
offset_left = 983.0
|
||||
@@ -758,3 +768,7 @@ offset_right = 1172.0
|
||||
offset_bottom = 1098.0
|
||||
text = "Выбор цели"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[connection signal="drag_begin" from="." to="." method="_on_drag_begin"]
|
||||
[connection signal="drag_continue" from="." to="." method="_on_drag_continue"]
|
||||
[connection signal="full_screen" from="." to="." method="_on_full_screen" flags=3]
|
||||
|
||||
@@ -5,12 +5,12 @@ extends NinePatchRect
|
||||
|
||||
@export var horizontal_alignment: HorizontalAlignment = HorizontalAlignment.HORIZONTAL_ALIGNMENT_CENTER:
|
||||
get: return $header.horizontal_alignment
|
||||
set(align): $header.horizontal_alignment = align
|
||||
set(val): $header.horizontal_alignment = val
|
||||
|
||||
|
||||
@export var vertical_alignment: VerticalAlignment = VerticalAlignment.VERTICAL_ALIGNMENT_CENTER:
|
||||
get: return $header.vertical_alignment
|
||||
set(align): $header.vertical_alignment = align
|
||||
set(val): $header.vertical_alignment = val
|
||||
|
||||
|
||||
@export var text: String = 'caption text':
|
||||
|
||||
Reference in New Issue
Block a user