class_name AutosaveNotification
extends MarginContainer


@export var animation_player: AnimationPlayer


func _ready() -> void:
	SaveGameManager.autosave_start.connect(_on_autosave_start)
	SaveGameManager.autosave_complete.connect(_on_autosave_complete)
	visible = false

func _on_autosave_start() -> void:
	animation_player.play("spin")
	visible = true

func _on_autosave_complete() -> void:
	# This is for testing. The displaying of UI element is inconsistent.
	#   Sometimes I need to print(visible) to force it to show up, although I have no idea why that works. It might not actually be doing anything and is just randomish.
	#   TODO: Figure out what the hell is going on here
	#print(visible)
	await get_tree().create_timer(3).timeout

	animation_player.stop()
	visible = false