Initial commit

This commit is contained in:
Bad Manners 2024-03-14 00:53:46 -03:00
commit 7becdd23b6
989 changed files with 28526 additions and 0 deletions

View file

@ -0,0 +1,64 @@
extends CanvasLayer
var is_textbox_visible: bool = false
var is_textbox_expanded: bool = false
func is_ready() -> bool:
return $AnimationPlayer.current_animation == "" or $AnimationPlayer.current_animation == "textbox_idle"
func is_idle() -> bool:
return $AnimationPlayer.current_animation == "textbox_idle"
func skip():
if $AnimationPlayer.current_animation == "write_text" or $AnimationPlayer.current_animation == "collapse_textbox" or $AnimationPlayer.current_animation == "expand_textbox":
$AnimationPlayer.seek(0.9999, true)
func await_pending_animations():
if not is_ready():
await $AnimationPlayer.animation_finished
func show_textbox():
# await await_pending_animations()
$AnimationPlayer.play("show_textbox")
await $AnimationPlayer.animation_finished
func hide_textbox():
# await await_pending_animations()
$AnimationPlayer.play_backwards("show_textbox")
await $AnimationPlayer.animation_finished
func expand_textbox():
# await await_pending_animations()
$AnimationPlayer.play("expand_textbox")
await $AnimationPlayer.animation_finished
func collapse_textbox():
# await await_pending_animations()
$AnimationPlayer.play("collapse_textbox")
await $AnimationPlayer.animation_finished
func ready_textbox():
$AnimationPlayer.play("textbox_idle")
func disable_textbox():
$AnimationPlayer.play("disable_textbox")
func enable_textbox():
if $AnimationPlayer.current_animation == "disable_textbox":
$AnimationPlayer.stop()
func write_text(speaker_text: String, speaker_name: String = ""):
var text_label: RichTextLabel = $MarginContainer/VBoxContainer/TextContainer/Text/TextLabel
text_label.visible_characters = 0
text_label.text = speaker_text
if speaker_name:
$MarginContainer/VBoxContainer/NameContainer/Name/NameLabel.text = speaker_name
$MarginContainer/VBoxContainer/NameContainer.visible = true
else:
$MarginContainer/VBoxContainer/NameContainer.visible = false
$MarginContainer/VBoxContainer/NameContainer/Name/NameLabel.text = ""
# Characters per second
var animation_speed = 48.0 / text_label.get_total_character_count()
$AnimationPlayer.play("write_text", -1, animation_speed)
await $AnimationPlayer.animation_finished