2025-12-02 21:00:10 +00:00
|
|
|
extends Node2D
|
|
|
|
|
|
2025-12-03 02:56:54 +00:00
|
|
|
var current_interaction_area = null
|
2025-12-04 03:30:37 +00:00
|
|
|
signal dialogue_continue
|
|
|
|
|
signal choice_made
|
2025-12-03 02:56:54 +00:00
|
|
|
|
2025-12-03 04:37:20 +00:00
|
|
|
func _ready() -> void:
|
2025-12-04 03:30:37 +00:00
|
|
|
$UI/Control/Dialogue.visible = false
|
2025-12-03 04:37:20 +00:00
|
|
|
|
2025-12-02 21:00:10 +00:00
|
|
|
func _process(delta: float) -> void:
|
2025-12-03 02:56:54 +00:00
|
|
|
if current_interaction_area:
|
|
|
|
|
$UI/Control/Interact.visible = true
|
|
|
|
|
$UI/Control/Interact/End.text = "TO " + (current_interaction_area.interact_text)
|
2025-12-02 21:00:10 +00:00
|
|
|
|
|
|
|
|
if Input.is_action_just_pressed("interact"):
|
2025-12-04 03:30:37 +00:00
|
|
|
if "_interact" in current_interaction_area.get_parent(): current_interaction_area.get_parent()._interact($PlayerGround)
|
2025-12-02 21:00:10 +00:00
|
|
|
else:
|
2025-12-03 02:56:54 +00:00
|
|
|
$UI/Control/Interact.visible = false
|
2025-12-04 03:30:37 +00:00
|
|
|
|
|
|
|
|
func dialogue(text: String) -> void:
|
|
|
|
|
$UI/Control/Dialogue/InputIcon.visible = false
|
|
|
|
|
$UI/Control/Dialogue.visible = true
|
|
|
|
|
|
|
|
|
|
var displayed_text = ""
|
|
|
|
|
|
|
|
|
|
var i = 0
|
|
|
|
|
while i < text.length():
|
|
|
|
|
displayed_text = displayed_text + text[i]
|
|
|
|
|
|
|
|
|
|
$UI/Control/Dialogue/Label.text = displayed_text
|
|
|
|
|
|
|
|
|
|
await get_tree().create_timer(0.05).timeout
|
|
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
|
|
$UI/Control/Dialogue/InputIcon.visible = true
|
|
|
|
|
|
|
|
|
|
await dialogue_continue
|
|
|
|
|
|
|
|
|
|
$UI/Control/Dialogue.visible = false
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
func make_choice(options: Dictionary = {}) -> void:
|
|
|
|
|
$UI/Control/DialogueOptions.visible = true
|
|
|
|
|
|
|
|
|
|
$UI/Control/DialogueOptions/Button.grab_focus()
|
|
|
|
|
|
|
|
|
|
var dialogue_select_button_scene = preload("res://scenes/dialogue_select_button.tscn")
|
|
|
|
|
|
|
|
|
|
for n in $UI/Control/DialogueOptions.get_children(): if n.is_class("Button"): n.free()
|
|
|
|
|
|
|
|
|
|
var first_button = null
|
|
|
|
|
var last_button = null
|
|
|
|
|
|
|
|
|
|
for n in options.keys():
|
|
|
|
|
var dialogue_select_button = dialogue_select_button_scene.instantiate()
|
|
|
|
|
|
|
|
|
|
dialogue_select_button.name = n
|
|
|
|
|
dialogue_select_button.text = options[n]
|
|
|
|
|
|
|
|
|
|
$UI/Control/DialogueOptions.add_child(dialogue_select_button)
|
|
|
|
|
|
|
|
|
|
if !first_button: first_button = dialogue_select_button
|
|
|
|
|
last_button = dialogue_select_button
|
|
|
|
|
|
|
|
|
|
first_button.focus_neighbor_top = NodePath(last_button.get_path())
|
|
|
|
|
|
|
|
|
|
last_button.focus_neighbor_bottom = NodePath(first_button.get_path())
|
|
|
|
|
|
|
|
|
|
first_button.grab_focus()
|
|
|
|
|
|
|
|
|
|
await dialogue_continue
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
|
|
|
if event.is_action_pressed("dialogue_continue"):
|
|
|
|
|
|
|
|
|
|
dialogue_continue.emit()
|