2024-05-27 19:54:22 -04:00
|
|
|
class_name CreditsMenu extends Control
|
|
|
|
|
|
|
|
@onready var data: Data = $/root/Root/Data
|
|
|
|
@onready var titleScreen: Control = $/root/Root/MainMenu/TitleScreen
|
2024-05-27 22:05:50 -04:00
|
|
|
@onready var animationPlayer: AnimationPlayer = $"../AnimationPlayer"
|
2024-05-27 19:54:22 -04:00
|
|
|
@onready var creditTemplate: PackedScene = load("res://Scenes/credit.tscn")
|
|
|
|
|
2024-05-27 22:05:50 -04:00
|
|
|
@export var spawnTimer: float = 2
|
2024-05-27 19:54:22 -04:00
|
|
|
@export var credits: Array[Credit]
|
|
|
|
|
2024-05-27 22:05:50 -04:00
|
|
|
var timerTarget: float = 0
|
2024-05-27 19:54:22 -04:00
|
|
|
var timer: float = 0
|
|
|
|
var credIndex = 0
|
|
|
|
var running: bool = false
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
|
|
|
if (!running): return
|
|
|
|
timer += delta
|
2024-05-27 22:05:50 -04:00
|
|
|
if (timer >= timerTarget):
|
|
|
|
timer -= timerTarget
|
2024-05-27 19:54:22 -04:00
|
|
|
var credit: CreditTemplate = creditTemplate.instantiate()
|
|
|
|
credit.creditInfo = credits[credIndex]
|
|
|
|
self.add_child(credit)
|
2024-05-27 22:05:50 -04:00
|
|
|
timerTarget = 5 + (2 + credits[credIndex].description.size() + credits[credIndex].links.size()) * spawnTimer
|
|
|
|
print(timerTarget)
|
2024-05-27 19:54:22 -04:00
|
|
|
credIndex += 1
|
|
|
|
if (credIndex >= credits.size()): credIndex = 0
|
|
|
|
|
|
|
|
func _on_home_pressed():
|
2024-05-27 22:05:50 -04:00
|
|
|
animationPlayer.play_backwards("creditsTransition")
|
|
|
|
|
|
|
|
func animFinished(s: String):
|
|
|
|
if (s == "creditsTransition" && !self.visible):
|
|
|
|
running = false
|
|
|
|
credIndex = 0
|
|
|
|
timer = 0
|
|
|
|
timerTarget = 0
|
|
|
|
for child: Control in self.get_children():
|
|
|
|
if (!(child is CreditTemplate)): continue
|
|
|
|
child.queue_free()
|
2024-05-27 19:54:22 -04:00
|
|
|
|
|
|
|
func toggle():
|
|
|
|
running = !running
|