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.
TextDialog node is loaded as a child of the autoloaded
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 text
InputFrame: Display text, and ask for freeform input
MultipleAnswerFrame: Display text, and present checkboxes to select from
MultipleChoiceFrame: 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 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
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:
config_adjustmentto determine how fast text is written
validation(response_text: String, frame: InputFrame) → bool