package jesse.keeblarcraft.gui.ShopKeeperGUI;

import jesse.keeblarcraft.ClientHelpers.Helper;
import jesse.keeblarcraft.gui.Generics.ClickableLayer;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class NewItemMenu extends ClickableLayer {
    private boolean isOpen = false;
    public NewItemMenu(Identifier texture, Text layerName, int width, int height, int startX, int startY) {
        super(texture, layerName, width, height, startX, startY);
//        System.out.println("Item menu created at coordinates X Y: " + this.getX() + " " + this.getY());
    }

    public void CloseMenu() {
        this.isOpen = false;
        this.visible = false;
        this.ClearDrawableSlots();
    }

    public void OpenMenu() {
        this.visible = true;
        this.isOpen = true;
        this.AddDrawableSlotByName("add_item_slot", true);
    }

    public void AddItem() {

    }

    public boolean IsOpen() {
        return this.isOpen;
    }

    @Override
    public void onClick(double x, double y) {
        // Check to see if user clicked the 'x' area (mark closed in case)
        // TODO: The coordinates for the 'X' button aren't known at the moment. For now just mark
        // TODO: top right of the image with a 5 pixel buffer
        if (this.visible && Helper.WithinBounds((this.getX() + this.getWidth() - 5), this.getY(), 5, 5, x, y)) {
            System.out.println("User clicked fake 'X' button");
//            this.isOpen = false;
            this.CloseMenu();
        }
    }

    @Override
    protected void appendClickableNarrations(NarrationMessageBuilder builder) {

    }
}
