Basic dialog system working

This commit is contained in:
2026-03-16 08:57:53 +11:00
parent 336dd59dbb
commit b433c31261
7 changed files with 45 additions and 26 deletions

View File

@@ -3,16 +3,37 @@ extends Node
@export var dialogContainer: MarginContainer
@export var dialogTextLabel: RichTextLabel
func set_dialog(text: String, seconds: float = 1) -> void:
var _current_dialog_counter: int = 0
var _current_dialog_text: DialogText = null
var _current_dialog_seconds: float = 1
func set_dialog_text(dialog_text: DialogText, seconds: float = 1) -> void:
_current_dialog_counter = -1
_current_dialog_text = dialog_text
_current_dialog_seconds = seconds
_next_dialog_line()
func _next_dialog_line() -> void:
_current_dialog_counter += 1
set_dialog_line(_current_dialog_text.get_line_raw(_current_dialog_counter), _current_dialog_seconds)
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("ui_accept") and _current_dialog_text:
_next_dialog_line()
func set_dialog_line(text: String, seconds: float = 1) -> void:
dialogTextLabel.text = text
dialogTextLabel.visible_ratio = 0
var ratio: float = 0
if text.length() == 0:
dialogContainer.visible = false
return
%GameplayController.input_enabled = true
_current_dialog_text = null
return #a hacky way to clear the dialog box
else:
dialogContainer.visible = true
%GameplayController.input_enabled = false
var increment: float = (1 / seconds)/ 60.0