using UnityEngine;
using Subsystems;
using GeoSus.Client;
using System.ComponentModel;


namespace Subsystems
{
    public class GameManager_UI
    {
        private GameClient _gameClient;
        private Canvas _CreateJoinLobby;
        private Canvas _InLobby;
        public GameManager_UI(GameClient gameClient, Canvas CreateJoinLobby, Canvas InLobby)
        {
            _gameClient = gameClient;
            _CreateJoinLobby = CreateJoinLobby;
            _InLobby = InLobby;
            _CreateJoinLobby.enabled = true;
            _InLobby.enabled = false;
        }
        public void UpdateLobbyUI()
        {
            _InLobby.enabled = true;
            _CreateJoinLobby.enabled = false;
            var playerList = _InLobby.transform.Find("PlayerList").GetComponent<TMPro.TMP_Text>();
            playerList.text = "";
            foreach (var player in _gameClient.CurrentLobbyState.Players)
            {
                playerList.text += player.DisplayName + "\n";
            }
            _InLobby.transform.Find("JoinCode").GetComponent<TMPro.TMP_Text>().text = _gameClient.CurrentLobbyState.JoinCode;
        }
    }
}
