using System.Threading.Tasks;
using Godot;

namespace Cirno.Scripts.UI;

public partial class IntroLogos : CanvasLayer
{
    [Export]
    public float TransitionTime = 4f;
    
    [Export]
    public StringName IntroScenePath;

    private bool _isTransitioning = false;
    
    public override void _Ready()
    {
        OptionsMenu.LoadSettings();
        _ = AutoTransition();
    }

    public override void _Process(double delta)
    {
        if (_isTransitioning) return;
        if (Input.IsAnythingPressed())
        {
            _isTransitioning = true;
            GlobalState.Instance.GotoScene(IntroScenePath);
        }
    }

    private async Task AutoTransition()
    {
        await Task.Delay((int)(TransitionTime * 1000));
        if (_isTransitioning) return;
        _isTransitioning = true;
        GlobalState.Instance.GotoScene(IntroScenePath);
    }
}