Доработка. Теперь только для Godot4
This commit is contained in:
3
main.gd
3
main.gd
@@ -11,6 +11,9 @@ var sock = PacketPeerUDP.new()
|
|||||||
|
|
||||||
# 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():
|
||||||
|
call_deferred('_redy_defered')
|
||||||
|
|
||||||
|
func _redy_defered():
|
||||||
sock.bind(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)
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ func init_pomehi(header, table): # Инициализация вкладк
|
|||||||
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', Callable(self, 'on_row_pressed').bind(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])
|
|
||||||
|
|
||||||
|
|
||||||
func on_btn_add(table):
|
func on_btn_add(table):
|
||||||
|
|||||||
20
table.gd
20
table.gd
@@ -243,11 +243,11 @@ func remove_row(i_row: int):
|
|||||||
|
|
||||||
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]
|
if node.is_connected(conn):
|
||||||
var dest_node = conn[1]
|
node.disconnect('pressed', conn)
|
||||||
node.disconnect('pressed', Callable(dest_node, callback))
|
|
||||||
nodes.erase(conn_key)
|
nodes.erase(conn_key)
|
||||||
|
|
||||||
|
|
||||||
@@ -306,17 +306,19 @@ func set_callbacks(dest_node: Node, event_name: String, callback: String, clmns:
|
|||||||
var rows_count = get_rows_count()
|
var rows_count = get_rows_count()
|
||||||
for i_row in rows_count:
|
for i_row in rows_count:
|
||||||
for i_col in clmns:
|
for i_col in clmns:
|
||||||
assert(i_col >= 0 and i_col < columns) #,'ошибка: нет колонки %d' % i_col)
|
assert(i_col >= 0 and i_col < columns,'ошибка: нет колонки %d' % i_col)
|
||||||
var node_key: String = NODE_KEY_FORMAT % [i_row, i_col]
|
var node_key: String = NODE_KEY_FORMAT % [i_row, i_col]
|
||||||
var conn_key: String = CONNECTED_KEY_FORMAT % [i_row, i_col]
|
var conn_key: String = CONNECTED_KEY_FORMAT % [i_row, i_col]
|
||||||
var node = nodes[node_key]
|
var node = nodes[node_key]
|
||||||
if nodes.has(conn_key):
|
if nodes.has(conn_key):
|
||||||
var conn = nodes[conn_key]
|
var conn = nodes[conn_key]
|
||||||
var prev_callback = conn[0]
|
if node.is_connected(event_name, conn):
|
||||||
var prev_dest_node = conn[1]
|
node.disconnect(event_name, conn)
|
||||||
node.disconnect(event_name, Callable(prev_dest_node, prev_callback))
|
nodes.erase(conn_key)
|
||||||
assert (OK == node.connect(event_name, Callable(dest_node, callback).bind([node] + user_data)))
|
|
||||||
nodes[conn_key] = [callback, dest_node]
|
var conn = Callable(dest_node, callback).bind([node])
|
||||||
|
assert (OK == node.connect(event_name, conn))
|
||||||
|
nodes[conn_key] = conn
|
||||||
|
|
||||||
|
|
||||||
func set_rows_text(rows: Array) -> void:
|
func set_rows_text(rows: Array) -> void:
|
||||||
|
|||||||
@@ -273,8 +273,8 @@ func init_treats(header, table, btn_add, btn_del): # Инициализа
|
|||||||
g_table = table
|
g_table = table
|
||||||
table.align_to_left_bottom(header, Vector2(0, 2))
|
table.align_to_left_bottom(header, Vector2(0, 2))
|
||||||
table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table))
|
table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table))
|
||||||
table.set_callbacks(self, 'text_submitted', '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, [])
|
||||||
btn_add.connect('button_up', Callable(self, 'on_btn_add').bind(table))
|
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_del.connect('button_up', Callable(self, 'on_btn_del').bind(table))
|
||||||
|
|
||||||
@@ -402,5 +402,6 @@ func get_threats_data():
|
|||||||
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 = JSON.new().stringify(data_to_json)
|
var json = JSON.new().stringify(data_to_json)
|
||||||
|
print_debug(json)
|
||||||
var pac = json.to_utf8_buffer()
|
var pac = json.to_utf8_buffer()
|
||||||
return pac
|
return pac
|
||||||
|
|||||||
Reference in New Issue
Block a user