using Godot;
using System;

public partial class WinScreen : TextureRect
{
	[Export] public GameManager Manager;
	[Export] public Label TextLabel;
	
	public override void _Ready()
	{
		Visible = false;
	}

	public void Open()
	{
		Visible = true;

		TextLabel.Text =
			$"It took you\n{Manager.GetAttempts()} attempts\nand {Manager.GetFormattedTimeElapsed()}\nto finish the game.";
	}

	public override void _Input(InputEvent @event)
	{
		if (Visible && @event.IsActionPressed("ui_confirm"))
		{
			GetTree().ChangeSceneToFile("res://scenes/menu.tscn");
		}
	}
}