#nullable enable
using Robust.Client.AutoGenerated;
using Robust.Client.Placement;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;

namespace Content.Client.UserInterface.AdminMenu.Tabs.AdminbusTab
{
    [GenerateTypedNameReferences]
    public partial class AdminbusTab : Control
    {
        protected override void EnteredTree()
        {
            // For the SpawnEntitiesButton and SpawnTilesButton we need to do the press manually
            // TODO: This will probably need some command check at some point
            SpawnEntitiesButton.OnPressed += SpawnEntitiesButtonOnOnPressed;
            SpawnTilesButton.OnPressed += SpawnTilesButtonOnOnPressed;
        }

        private static void SpawnEntitiesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
        {
            var manager = IoCManager.Resolve<IAdminMenuManager>();
            var window = new EntitySpawnWindow(IoCManager.Resolve<IPlacementManager>(),
                IoCManager.Resolve<IPrototypeManager>(),
                IoCManager.Resolve<IResourceCache>());
            manager.OpenCommand(window);
        }

        private static void SpawnTilesButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
        {
            var manager = IoCManager.Resolve<IAdminMenuManager>();
            var window = new TileSpawnWindow(IoCManager.Resolve<ITileDefinitionManager>(),
                IoCManager.Resolve<IPlacementManager>(),
                IoCManager.Resolve<IResourceCache>());
            manager.OpenCommand(window);
        }
    }
}
