#nullable enable
using System.Collections.Generic;
using Content.Client.UserInterface.AdminMenu.Tabs;
using Content.Shared.Administration.AdminMenu;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;

namespace Content.Client.UserInterface.AdminMenu
{
    [GenerateTypedNameReferences]
    public partial class AdminMenuWindow : SS14Window
    {
        [Dependency] private readonly IGameHud? _gameHud = default!;

        public event PlayerTab.PlayerListRefresh? OnPlayerListRefresh
        {
            add => PlayerTabControl.OnPlayerListRefresh += value;
            remove => PlayerTabControl.OnPlayerListRefresh -= value;
        }

        public AdminMenuWindow()
        {
            MinSize = SetSize = (500, 250);
            Title = Loc.GetString("Admin Menu");
            RobustXamlLoader.Load(this);
            IoCManager.InjectDependencies(this);
            MasterTabContainer.SetTabTitle(0, Loc.GetString("Admin"));
            MasterTabContainer.SetTabTitle(1, Loc.GetString("Adminbus"));
            MasterTabContainer.SetTabTitle(2, Loc.GetString("Atmos"));
            MasterTabContainer.SetTabTitle(3, Loc.GetString("Round"));
            MasterTabContainer.SetTabTitle(4, Loc.GetString("Server"));
            MasterTabContainer.SetTabTitle(5, Loc.GetString("Players"));
        }

        protected override void EnteredTree()
        {
            base.EnteredTree();
            if (_gameHud != null)
                _gameHud.AdminButtonDown = true;
        }

        protected override void ExitedTree()
        {
            base.ExitedTree();
            if (_gameHud != null)
                _gameHud.AdminButtonDown = false;
        }

        public void RefreshPlayerList(IEnumerable<AdminMenuPlayerListMessage.PlayerInfo> players)
        {
            PlayerTabControl.RefreshPlayerList(players);
        }
    }
}
