I would create a signal called new_world_requested
or whatever in Main
and optionally in UI
and the WindowDialog
depending how much decoupled you want them to be.
Now when the button is clicked, it emits the new_world_requested
signal from the UI
which is then forwarded up to Main
which is connected to the function generate_new_world
I supposed, in World
.
Pseudo code:
# CreateWorldDialog.gd
func _on_create_world_clicked():
emit_signal('new_world_requested`)
# or less decoupled
get_parent().emit_signal('new_world_requested`) # from UI
# even less decoupled
get_parent().get_parent().emit_signal('new_world_requested`) # directly from Main
# how to forward the signal if you use the one of the first two ways:
# put this in CreateWorldDialog.gd and UI.gd
func _ready():
connect(`new_world_requested`, get_parent(), 'emit_signal', [`new_world_requested`])