using Godot;
using System;

public partial class Principal : Control
{
	[Export] Panel sub; 
	[Export] Panel credit;
	[Export] AnimationPlayer anim;
	bool play_pressed = false;
	bool enter = false;
	

	Node parent;
	
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
		GetTree().Paused = false;
		parent = GetParent();
		sub.Visible = false;
        
    }

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
		if(play_pressed && Input.IsActionJustPressed("valid") && !enter)
		{
			enter = true;
			anim.Play("play2");
		}else if (enter && Input.IsActionJustPressed("valid"))
		{
			Input.MouseMode = Input.MouseModeEnum.Hidden;
			
			parent.Call("ToCityFunc");
		}

	}

	public void EnterPressed()
	{
		sub.Visible = true;
	}

	public void creditEnter()
	{
		credit.Visible = true;
		sub.Visible = false;
	}

	public void CreditExit()
	{
		credit.Visible = false;
		sub.Visible = true;
	}

	public void PlayPressed()
	{
		if (!play_pressed)
		{
			play_pressed = true;
			anim.Play("play");
		}
		//parent.Call("ToCityFunc");
		
	}

	public void ExitGlobPressed()
	{
		GetTree().Quit();
	}
}
