using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.UI;

public class HomeSrceen : MonoBehaviour
{
    public Button primaryButton;
    public Button playButton;
    public Button shopButton;
    public Button homeButton;
    public Button battlepassButton;
    public Button settingsButton;
    public Button selectButton;
    public Button profileButton;
    public Button missionButton;

    public GameObject homeScreen;
    public GameObject selectionScreen;
    public GameObject battlepassScreen;
    public GameObject settingsScreen;
    public GameObject shopScreen;
    public GameObject modeScreen;
    public GameObject profileScreen;
    public GameObject setModeScreen;
    public GameObject missionScreen;

    private GameObject activeScreen;

    public ModeSelection modeSelectionScript;

    public GameObject singlePlayerEventSystem;

    private void Awake()
    {
        primaryButton.Select();
        playButton.onClick.AddListener(OnPlayButtonClick);
        shopButton.onClick.AddListener(OnShopButtonClick);
        homeButton.onClick.AddListener(OnHomeButtonClick);
        battlepassButton.onClick.AddListener(OnBattlePassButtonClick);
        settingsButton.onClick.AddListener(OnSettingsButtonClick);
        selectButton.onClick.AddListener(OnSelectButtonClick);
        profileButton.onClick.AddListener(OnProfileButtonClick);
        missionButton.onClick.AddListener(OnMissionButtonClick);
        // Set the initial active screen to home screen
        activeScreen = homeScreen;
        activeScreen.SetActive(true);
    }
    
    private void OnEnable()
    {
        primaryButton.Select();
    }

    public void OnPlayButtonClick()
    {
        ActivateScreen(setModeScreen);
    }

    public void TestButton()
    {
        gameObject.SetActive(true);
    }
    
    public void OnShopButtonClick()
    {
        // ActivateScreen(shopScreen);
    }

    public void OnHomeButtonClick()
    {
        
        ActivateScreen(homeScreen);
    }

    public void OnBattlePassButtonClick()
    {
        //ActivateScreen(battlepassScreen);
    }

    public void OnSettingsButtonClick()
    {
        ActivateScreen(settingsScreen);
    }

    public void OnSelectButtonClick()
    {
        // ActivateScreen(selectionScreen);
    }

    public void OnProfileButtonClick()
    {
        ActivateScreen(profileScreen);
    }

    public void OnMissionButtonClick()
    {
        ActivateScreen(missionScreen);
    }

    public void ActivateScreen(GameObject screen)
    {
        homeScreen.SetActive(false);
        selectionScreen.SetActive(false);
        battlepassScreen.SetActive(false);
        settingsScreen.SetActive(false);
        shopScreen.SetActive(false);
        modeScreen.SetActive(false);
        profileScreen.SetActive(false);
        missionScreen.SetActive(false);

        screen.SetActive(true);
    }
}