package com.acethewildfire.acesbs.screen.custom;

import com.acethewildfire.acesbs.AcesBS;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class EntropicEvisceratorScreen extends HandledScreen<EntropicEvisceratorScreenHandler> {

    public static final Identifier GUI_TEXTURE =
            Identifier.of(AcesBS.MOD_ID, "textures/gui/entropic_eviscerator/entropic_eviscerator_gui.png");
    public static final Identifier EVISCERATE_TEXTURE =
            Identifier.of(AcesBS.MOD_ID, "textures/gui/eviscerate_progress.png");

    public EntropicEvisceratorScreen(EntropicEvisceratorScreenHandler handler, PlayerInventory inventory, Text title) {
        super(handler, inventory, title);
    }

    @Override
    protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
        RenderSystem.setShader(GameRenderer::getPositionTexProgram);
        RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
        RenderSystem.setShaderTexture(0, GUI_TEXTURE);

        int x = (width - backgroundWidth) / 2;
        int y = (height - backgroundHeight) / 2;

        context.drawTexture(GUI_TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight);

//        renderProgressArrow(context, x, y);
        renderEviscerateProgress(context, x, y);
    }

//    private void renderProgressArrow(DrawContext context, int x, int y) {
//
//        if(handler.isCrafting()) {
//            context.drawTexture(ARROW_TEXTURE, x + 79, y + 35, 0, 0,
//                    handler.getScaledArrowProgress(), 16, 24, 16);
//        }
//    }

    private void renderEviscerateProgress(DrawContext context, int x, int y) {
        if(handler.isCooking()) {
            context.drawTexture(EVISCERATE_TEXTURE, x + 80, y + 35, 0, 0,
                    16, handler.getScaledEviscerateProgress(), 16, 16);
        }
    }

    @Override
    public void render(DrawContext context, int mouseX, int mouseY, float delta) {
        super.render(context, mouseX, mouseY, delta);
        drawMouseoverTooltip(context, mouseX, mouseY);
    }

}
