Skip to content

SubtitlesUI ​

Inherits: HUDUIElement < Control

The subtitles of the game: a container with the name of the speaker and the line that is said, at the bottom of the screen. It shows a line when something asks with show_subtitle() (a voice line that is played) and hides it when the line is over. Nothing shows while the player has subtitles off (Game Settings > Gameplay > Subtitles enabled). Style it in its scene: the panel, the two labels, their fonts and colors; nothing in the code decides how it looks.

Properties ​

boolshow_speaker_nametrue
floatminimum_seconds1.5
floatcharacters_per_second15.0

Methods ​

voidinitialize_ui( p_system_hub: GameHost.SystemHub )
boolare_subtitles_enabled()
boolshow_subtitle( text: String, speaker: String = "", duration: float = 0.0 )
voidhide_subtitle()
boolis_showing()

Property descriptions ​

bool show_speaker_name = true ​

Show the name of the speaker above the line (when there is one)

float minimum_seconds = 1.5 ​

The line stays at least this long (seconds), however short it is

float characters_per_second = 15.0 ​

When a line has no duration: the seconds it stays are the number of characters divided by this (reading speed)

Method descriptions ​

void initialize_ui( p_system_hub: GameHost.SystemHub ) ​

Sets the part up with the hub of the game systems: connects the signals it listens to and fills it.

bool are_subtitles_enabled() ​

Does the player want subtitles?

bool show_subtitle( text: String, speaker: String = "", duration: float = 0.0 ) ​

Shows a line. speaker is the name shown above it (empty = none). duration is how long it stays in seconds: 0 means as long as it takes to read (characters_per_second, never less than minimum_seconds); a line of a voice line passes the length of the sound. Another line replaces the one that shows. Returns false when nothing was shown (subtitles off, or no text).

void hide_subtitle() ​

Hides the line that shows.

bool is_showing() ​

Is a line showing?