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


// Not used anymore, renamed to NewOnlineGameScript
public class StartOnlineGameButton : MonoBehaviour
{
    public Slider answerTimeSlider;
    public Slider daysToAnswerSlider;
    public Slider correctsToWinSlider;
    public GameObject invitePanel;

    [SerializeField] Button CategoriesButton;
    [SerializeField] GameObject SelectCategoriesPanel;
    

    private InvitePanelScript ips;
    private Button startButton;
    // Start is called before the first frame update
    void Start()
    {
        startButton = GetComponent<Button>();
        startButton.onClick.AddListener(StartNewOnlineGame);
        startButton.interactable = false;
        ips = invitePanel.GetComponent<InvitePanelScript>();

        CategoriesButton.onClick.AddListener(SelectCategories);
    }

    private void SelectCategories()
    {
        SelectCategoriesPanel.gameObject.SetActive(true);
    }

    // Update is called once per frame
    void Update()
    {
        if (ips.AreThereInvites()) {
            startButton.interactable = true;
        } 
        // TODO, make sure there are enough questions selected in categories
    }

    void StartNewOnlineGame() {
        List<InviteSearchResult> inviteUsers = ips.GetSelectedUsersForInvite();
        //OnlineDatabase.Instance.SetupNewOnlineGame((int)correctsToWinSlider.value, (int)daysToAnswerSlider.value, (int)correctsToWinSlider.value, inviteUsers);
        SceneManager.LoadScene("MainMenu");
    }
}
