using GraphicsManager.Enums;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using OpenTK.Graphics.ES20;
using OpenTK.Mathematics;

namespace Luski.GUI.MainScreen.UI;

public class LuskiContextMenu : BetterContextMenu
{
    public LuskiContextMenu()
    :base(Globals.ms.TextureManager.GetTextureResource("Context.png"))
    {
        Margins = new(5.ScaleInt());
        TextureDisplay = TextureDisplay.Center;
        SpaceBetweenObjects = 8.ScaleInt();
    }
    
    public Label AddLabel(string text, Color4 color)
    {
        return AddLabel(Globals.DefaultFont, text, color);
    }
    
    public Label AddLabel(string text)
    {
        Label l = AddLabel(Globals.DefaultFont, text, Color4.Gray);
        l.Clicked += o =>
        {
            HideContext(Window!);
            TryDraw();
            return Task.CompletedTask;
        };
        l.MouseEnter += o => 
        { 
            l.Color = Color4.White;
            TryDraw();
            return Task.CompletedTask;
        };
        l.MouseLeave += o => 
        { 
            l.Color = Color4.Gray;
            TryDraw();
            return Task.CompletedTask;
        };
        return l;
    }

    public new void AddLine()
    {
        AddLine(Color4.White, 1.ScaleInt());
    }
}