You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a layout doesn't have enough buttons for choices it will only use the ones that it has available and log the "The layout you are using doesn't have enough Choice Buttons" error.
How possible it would be that instead of having the layout scene full of buttons, instantiate the amount buttons required into the scene as it is created?
There are 2 ways I see this being solved:
When reaching a choice, create enough buttons as there are options.
When creating the layout scene, read the timeline and spawn the amount equal to the largest choice.
An ideal default structure (based on the centered choices) that solves the issue of not being able to display all choices if there are too many buttons could be that all buttons are spawned in a VBoxContainer which is a child of a ScrollContainer that is set to reach the top and bottom of the screen (Layout VCenterWide).
A few ideas on how to integrate it into the current system:
Allow the user to select a DialogicNode_ChoiceButton scene as a default button to instantiate. If not provided have a default button scene. (choice_button_path)
Provide a virtual method that is called with the amount of buttons required to instantiate. That way the behaviour can be customized and an user can, through code, control exactly where and how the buttons are going to be added.
As an example (with the number of buttons that are going to be needed):
# This is the default function
func _add_choice_buttons(button_amount:int) -> void:
for _rq_btn in range(button_amount):
$Choices.add_child(load(choice_layer.choice_button_path).instantiate())
Another option which could allow for a bit more control through code is pass the node to be added. This could allow to check through code WHAT the button is and add it as a child to a node.
# This function is called to add a button into the scene
func _add_choice_button(button_instance:DialogicNode_ChoiceButton) -> void:
# An user can do evaluation or other stuff here first
$Choices.add_child(button_instance)
And (If I understand how it works correctly) instead of iterating through all the existing buttons in the choices subsystem in show_choice, one could instantiate the button there set all the values and pass it to the layout to be added.
This solves a few things:
The issue of not having enough buttons on the layout.
Provides an easy way to customize the buttons through a single instance
Provides a way to control where and how the buttons are created
Prevents unecessary instancing of buttons when they aren't required.
Hey @Ketei, thanks for the proposal.
I think the best way (most modular) to handle this is to have a signal that is sent BEFORE choices are shown (something like Dialogic.Choices.about_to_show_question, with the usualy choice-info) and then the layout can react to that and instance more choice buttons if needed.
I guess we could modify the default choice layer to work this way too. Generally as long as there is no real need, re-instancing the buttons every time seems like a waste, cause hiding them is more performant then adding new nodes, so I think this should only be done if there is a good reason. Having too many choices to show is a rare problem because at some point it mostly just looks really bad. But having a way to react to choices before they are processed could be useful for other stuff too I think.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When a layout doesn't have enough buttons for choices it will only use the ones that it has available and log the "The layout you are using doesn't have enough Choice Buttons" error.
How possible it would be that instead of having the layout scene full of buttons, instantiate the amount buttons required into the scene as it is created?
There are 2 ways I see this being solved:
An ideal default structure (based on the centered choices) that solves the issue of not being able to display all choices if there are too many buttons could be that all buttons are spawned in a VBoxContainer which is a child of a ScrollContainer that is set to reach the top and bottom of the screen (Layout VCenterWide).
A few ideas on how to integrate it into the current system:
choice_button_path
)As an example (with the number of buttons that are going to be needed):
Another option which could allow for a bit more control through code is pass the node to be added. This could allow to check through code WHAT the button is and add it as a child to a node.
And (If I understand how it works correctly) instead of iterating through all the existing buttons in the choices subsystem in
show_choice
, one could instantiate the button there set all the values and pass it to the layout to be added.This solves a few things:
Beta Was this translation helpful? Give feedback.
All reactions