A Text Dialog box that can be shown with text at the bottom of the screen. It optionally supports getting input from the player in the form of single answer multiple choice questions, multiple answer multiple choice questions, and free form input questions.
The TextDialog
node is loaded as a child of the autoloaded UI
node.
A Frame represents all of the information that the dialog box needs in order to render a single box worth of text. The available frames types are listed below:
TextFrame
: Display textInputFrame
: Display text, and ask for freeform inputMultipleAnswerFrame
: Display text, and present checkboxes to select fromMultipleChoiceFrame
: Display text, and present buttons to select from# Let's start with a a simple TextFrame var frame1: TextFrame = TextFrame.new() frame1.text = "This is example text." # And make a slightly more complicated MultipleChoiceFrame var frame2: MultipleChoiceFrame = MultipleChoiceFrame.new() frame2.text = "This is an example question." frame2.choices = ["How is this a question?", "Okay"]
After all of the frames have been created you can send them all to the dialog and tell it to start displaying them.
# Add the frames UI.get_node("TextDialog") UI.get_node("TextDialog").add_frame(frame1) UI.get_node("TextDialog").add_frame(frame2) # Set our settings UI.get_node("TextDialog").pause_game = true # Begin displaying UI.get_node("TextDialog").display()
After the dialog is displayed you might want to continue to interact with it, such as to get the player selected inputs, or to add additional frames to the queue. The Text Dialog provides a number of useful Signals to accomplish this.
The two most useful of these are dismissed
and no_more_frames
. The
dismissed
signal is fired off when the dialog box is finished will all
frames and has closed. The no_more_frames
signal is fired off just before
that as a last chance to add more frames to the queue before the dialog is
dismissed.
Both of these signals are easily interacted with using yield.
# Yield until just the last moment yield(UI.get_node("TextDialog"), "no_more_frames") # Did they question the question? if (frame2.selected_choice == "How is this a question?"): # Let's give them a response var frame3: TextFrame = TextFrame.new() frame3.text = "It isn't." UI.get_node("TextDialog").add_frame(frame2)
Frame related signals:
frame_started
current_frame_number: int
and current_frame
frame_ended
current_frame_number: int
and current_frame
dismissed
no_more_frames
self
Other signals:
text_drawn
current_frame_number: int
and current_frame
multiple_choice_selected
MultipleChoiceFrame
is submittedcurrent_frame_number: int
and current_frame
multiple_answer_selected
MultipleAnswerFrame
is submittedcurrent_frame_number: int
and current_frame
input_submitted
InputFrame
is submittedcurrent_frame_number: int
and current_frame
next_button_clicked
TextFrame
is submittedpause_game: bool
current_frame: int
base_rate: float
config_adjustment
to determine how fast text is writtenbutton_texture: Texture
alt_button_texture: Texture
text: String
text: String
choices: Array
selected_choice: String
text: String
choices: Array
selected_choice: Array
text: String
invalid_response_text: String
response_text: String
validation_function: FuncRef
validation(response_text: String, frame: InputFrame) → bool