Доработка, поворот целей на заданный угол по нажатию кнопки, либо таймеру. Кнопка загрузки начального состояния целей.
This commit is contained in:
45
threats.gd
45
threats.gd
@@ -266,7 +266,7 @@ class Threat:
|
||||
return value
|
||||
|
||||
|
||||
func init_treats(table, btn_add, btn_del, btn_save): # Инициализация вкладки с целями
|
||||
func init_treats(table, nodes): # Инициализация вкладки с целями
|
||||
for i in range(ID_ARRAY_LEN): # Заполняет массив ID целей
|
||||
id_array.append(i+1)
|
||||
table.set_header(TABLE_HEADER_TYPES)
|
||||
@@ -278,10 +278,15 @@ func init_treats(table, btn_add, btn_del, btn_save): # Инициализ
|
||||
table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table))
|
||||
table.connect_columns(self, 'text_submitted', 'on_edit_entry', TABLE_ENTRY_COLUMNS, [])
|
||||
table.connect_columns(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [])
|
||||
btn_add.connect('button_up', Callable(self, 'on_btn_add').bind(table))
|
||||
btn_del.connect('button_up', Callable(self, 'on_btn_del').bind(table))
|
||||
btn_save.connect('button_up', Callable(self, 'on_btn_save'))
|
||||
|
||||
nodes.btn_add.connect('button_up', Callable(self, 'on_btn_add').bind(table))
|
||||
nodes.btn_del.connect('button_up', Callable(self, 'on_btn_del').bind(table))
|
||||
nodes.btn_save.connect('button_up', Callable(self, 'on_btn_save'))
|
||||
nodes.btn_load.connect('pressed', Callable(self, 'on_btn_load').bind(table))
|
||||
nodes.btn_rt.connect('pressed', Callable(self, 'on_rotate_th').bind(nodes.entry_rt, table))
|
||||
var timer = Timer.new()
|
||||
timer.connect('timeout', Callable(self, 'on_timeout').bind(nodes.entry_rt, table, nodes.chkbx_rt))
|
||||
add_child(timer) #to process
|
||||
timer.start(1) #to start
|
||||
|
||||
func load_treats(table):
|
||||
var file = FileAccess.open('user://save.json', FileAccess.READ)
|
||||
@@ -467,3 +472,33 @@ func set_ticks(treat):
|
||||
var tick = Time.get_ticks_msec()
|
||||
var cell = g_table.get_node2(COLUMN_TICK, treat.row_id)
|
||||
cell.text = str(treat.set_tick(str(tick%60000)))
|
||||
|
||||
|
||||
func on_rotate_th(entry, table):
|
||||
if entry.text.is_valid_float():
|
||||
for th in treats.values():
|
||||
var aoa = th.row.aoa[0]
|
||||
aoa += float(entry.text)
|
||||
if aoa > 360.0:
|
||||
aoa -= 360.0
|
||||
elif aoa < 0:
|
||||
aoa += 360.0
|
||||
th.set_aoa(str(aoa))
|
||||
var node_aoa = table.get_node2(1, th.row_id)
|
||||
if th.row.aoa[1]:
|
||||
node_aoa.text = str(th.row.aoa[0])
|
||||
else:
|
||||
print_debug('Угол поворота целей задан не верно')
|
||||
|
||||
|
||||
func on_timeout(entry, table, chkbx_rt):
|
||||
if chkbx_rt.button_pressed:
|
||||
on_rotate_th(entry, table)
|
||||
|
||||
|
||||
func on_btn_load(table):
|
||||
for i in table.get_rows_count():
|
||||
var cell = table.get_node2(0, 0)
|
||||
treats.erase(cell.text)
|
||||
table.remove_row(0)
|
||||
load_treats(table)
|
||||
|
||||
Reference in New Issue
Block a user