Improved signal handling

This commit is contained in:
Eduard Urbach 2024-02-06 21:55:22 +01:00
parent 4ad50e75db
commit fba99ed432
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -3,21 +3,12 @@ extends Control
signal chat_message_submitted(message: String) signal chat_message_submitted(message: String)
var signals := [ @export var login: Signal
"login", @export var logout: Signal
"logout", @export var ping_changed: Signal
"ping_changed", @export var download_changed: Signal
"download_changed", @export var upload_changed: Signal
"upload_changed", @export var message_received: Signal
"message_received",
]
var login: Signal
var logout: Signal
var ping_changed: Signal
var download_changed: Signal
var upload_changed: Signal
var message_received: Signal
func _enter_tree(): func _enter_tree():
if get_node_or_null("/root/Main"): if get_node_or_null("/root/Main"):
@ -34,6 +25,9 @@ func connect_main_scene():
message_received = %Chat.message_received message_received = %Chat.message_received
func connect_fake(): func connect_fake():
for signal_name in signals: for property in get_property_list():
set(signal_name, Signal(self, signal_name)) if property.type != TYPE_SIGNAL:
add_user_signal(signal_name) continue
add_user_signal(property.name)
set(property.name, Signal(self, property.name))