class_name frm_ecm_list extends NinePatchRect


const srn_sectors: Dictionary = {
    'srni1': [12, 13, 14, 15, 16, 17, 18, 19] }

const jtids_sectors: Dictionary = {
    'svi1': [4, 5, 6, 7, 8, 9, 10, 11] }

const kupd_sectors: Dictionary = {
    'lchm1': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 21, 22, 23, 24, 25, 26, 27] }

const panika_sectors: Dictionary = {
    'lchm1': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 21, 22, 23, 24, 25, 26, 27],
    'srni1': [12, 13, 14, 15, 16, 17, 18, 19] }


## Called when the node enters the scene tree for the first time.
func _ready():
    var nodes: Array = get_tree().get_nodes_in_group('группа-принудительно')
    $grd_forced/btn_cancel.button_connect('pressed', Callable(self, 'on_btn_cancel_pressed').bind($grd_forced/btn_cancel, nodes))
    nodes.any(func(btn): btn.button_connect('pressed', Callable(self, 'on_btn_pressed').bind(btn, nodes)))


func on_btn_cancel_pressed(btn, nodes):
    signaller.emit_signal('interfer_off_all')
    await get_tree().create_timer(0.1).timeout
    btn.pressed = false
    nodes.any(func(btn_node): btn_node.pressed = false)


func on_btn_pressed(btn_this, btn_others):
    for btn_other in btn_others: btn_other.set_pressed(btn_this == btn_other)
    signaller.emit_signal('interfer_off_all')
    signaller.emit_signal('rto_threat_unsel_all')
    if btn_this == $grd_forced/btn_panika:
        signaller.emit_signal('interfer_prinuditelno', panika_sectors)
    elif btn_this == $grd_forced/btn_jtids:
        signaller.emit_signal('interfer_prinuditelno', jtids_sectors)
    elif btn_this == $grd_forced/btn_kupd:
        signaller.emit_signal('interfer_prinuditelno', kupd_sectors)
    elif btn_this == $grd_forced/btn_srn:
        signaller.emit_signal('interfer_prinuditelno', srn_sectors)
