2024-01-20 12:17:43 +00:00
|
|
|
class_name Dialogue extends Node
|
|
|
|
|
|
|
|
@export var speaker_click : AudioStreamPlayer2D
|
|
|
|
@export var soundArray_clicks : Array[AudioStream]
|
|
|
|
@export var dialogueUI : Label
|
|
|
|
@export var dialogueUI_backdrop : ColorRect
|
|
|
|
@export var dialogueSpeed : float
|
|
|
|
@export var incrementDelay : float
|
|
|
|
|
|
|
|
var dealerLowPitched = false
|
|
|
|
var elapsed = 0
|
|
|
|
var moving = false
|
|
|
|
var looping = false
|
2024-04-05 10:52:30 +01:00
|
|
|
var origscale_backdrop
|
2024-01-20 12:17:43 +00:00
|
|
|
|
|
|
|
func _ready():
|
2024-04-05 10:52:30 +01:00
|
|
|
origscale_backdrop = dialogueUI_backdrop.scale
|
2024-01-20 12:17:43 +00:00
|
|
|
speaker_click.stream = soundArray_clicks[3]
|
|
|
|
|
|
|
|
func ShowText_ForDuration(activeText : String, showDuration : float):
|
2024-04-05 10:52:30 +01:00
|
|
|
if(dialogueUI_backdrop.scale != origscale_backdrop): dialogueUI_backdrop.scale = origscale_backdrop
|
2024-01-20 12:17:43 +00:00
|
|
|
looping = false
|
|
|
|
dialogueUI.visible_characters = 0
|
|
|
|
dialogueUI.text = activeText
|
|
|
|
dialogueUI.visible = true
|
|
|
|
dialogueUI_backdrop.visible = true
|
|
|
|
looping = true
|
|
|
|
TickText()
|
|
|
|
await get_tree().create_timer(showDuration, false).timeout
|
|
|
|
looping = false
|
|
|
|
dialogueUI.visible = false
|
|
|
|
dialogueUI_backdrop.visible = false
|
|
|
|
|
2024-04-05 10:52:30 +01:00
|
|
|
var scaling = false
|
2024-01-20 12:17:43 +00:00
|
|
|
func ShowText_Forever(activeText : String):
|
2024-04-05 10:52:30 +01:00
|
|
|
if (scaling):
|
|
|
|
dialogueUI_backdrop.scale = Vector2(17.209, dialogueUI_backdrop.scale.y)
|
|
|
|
else: dialogueUI_backdrop.scale = origscale_backdrop
|
|
|
|
|
2024-01-20 12:17:43 +00:00
|
|
|
looping = false
|
|
|
|
dialogueUI.visible_characters = 0
|
|
|
|
dialogueUI.text = activeText
|
|
|
|
dialogueUI.visible = true
|
|
|
|
dialogueUI_backdrop.visible = true
|
|
|
|
looping = true
|
|
|
|
TickText()
|
2024-04-05 10:52:30 +01:00
|
|
|
scaling = false
|
2024-01-20 12:17:43 +00:00
|
|
|
|
|
|
|
func ShowDealerInspectionText():
|
2024-04-05 10:52:30 +01:00
|
|
|
if(dialogueUI_backdrop.scale != origscale_backdrop): dialogueUI_backdrop.scale = origscale_backdrop
|
|
|
|
ShowText_Forever(tr("INTERESTING"))
|
2024-01-20 12:17:43 +00:00
|
|
|
|
|
|
|
func HideText():
|
|
|
|
looping = false
|
|
|
|
dialogueUI.visible = false
|
|
|
|
dialogueUI_backdrop.visible = false
|
|
|
|
pass
|
|
|
|
|
|
|
|
func TickText():
|
|
|
|
while(looping):
|
|
|
|
dialogueUI.visible_characters += 1
|
|
|
|
if (!dealerLowPitched): speaker_click.pitch_scale = randf_range(0.5, .6)
|
|
|
|
else: speaker_click.pitch_scale = randf_range(.2, .3)
|
|
|
|
speaker_click.play()
|
|
|
|
if (dialogueUI.visible_ratio >= 1):
|
|
|
|
looping = false
|
|
|
|
await get_tree().create_timer(incrementDelay, false).timeout
|
|
|
|
pass
|
|
|
|
pass
|