package com.dairymoose.modernlife.blocks.gui;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@OnlyIn(Dist.CLIENT)
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/EaselSizeScreen.class */
public class EaselSizeScreen extends Screen {
    private static final Logger LOGGER = LogManager.getLogger();
    private static final ResourceLocation EASEL_SIZE_GUI = new ResourceLocation("modernlife", "textures/gui/gui_easel_optional.png");
    final int GUI_WIDTH = 132;
    final int GUI_HEIGHT = 175;
    public int chosenSize;
    public BlockPos pos;
    public Level level;
    private static final String PRINT_SIZE = "Canvas Resolution";

    private static Component getComponentForTitle(String title) {
        return new TextComponent(title).m_6270_(Style.EMPTY.withColor(TextColor.fromRgb(4210752)));
    }

    public EaselSizeScreen(Level level, BlockPos pos) {
        super(getComponentForTitle(PRINT_SIZE));
        this.GUI_WIDTH = 132;
        this.GUI_HEIGHT = 175;
        this.chosenSize = -1;
        this.level = level;
        this.pos = pos;
    }

    public boolean m_6348_(double p_94722_, double p_94723_, int p_94724_) {
        return super.m_6348_(p_94722_, p_94723_, p_94724_);
    }

    private void goToEaselScreen() {
        EaselScreen screen = new EaselScreen(this.level, this.pos);
        screen.setTextureSize(this.chosenSize, this.chosenSize);
        screen.setBlockPos(this.pos);
        Minecraft.getInstance().setScreen(screen);
    }

    private void goToEaselCustomSizeScreen() {
        EaselCustomSizeScreen screen = new EaselCustomSizeScreen(this.level, this.pos);
        Minecraft.getInstance().setScreen(screen);
    }

    protected void init() {
        int startX = ((this.width - 132) / 2) + 13;
        int startY = ((this.height - 175) / 2) + 25;
        addRenderableWidget(new ImageButton(startX, startY + 0, 106, 20, 150, 0, 20, EASEL_SIZE_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen.1
            C00841() {
            }

            public void onPress(Button arg0) {
                EaselSizeScreen.this.chosenSize = 16;
                EaselSizeScreen.this.goToEaselScreen();
            }
        }));
        addRenderableWidget(new ImageButton(startX, startY + 24, 106, 20, 150, 40, 20, EASEL_SIZE_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen.2
            C00852() {
            }

            public void onPress(Button arg0) {
                EaselSizeScreen.this.chosenSize = 32;
                EaselSizeScreen.this.goToEaselScreen();
            }
        }));
        addRenderableWidget(new ImageButton(startX, startY + 48, 106, 20, 150, 80, 20, EASEL_SIZE_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen.3
            C00863() {
            }

            public void onPress(Button arg0) {
                EaselSizeScreen.this.chosenSize = 64;
                EaselSizeScreen.this.goToEaselScreen();
            }
        }));
        addRenderableWidget(new ImageButton(startX, startY + 72, 106, 20, 150, 120, 20, EASEL_SIZE_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen.4
            C00874() {
            }

            public void onPress(Button arg0) {
                EaselSizeScreen.this.chosenSize = 128;
                EaselSizeScreen.this.goToEaselScreen();
            }
        }));
        addRenderableWidget(new ImageButton(startX, startY + 96, 106, 20, 150, 160, 20, EASEL_SIZE_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen.5
            C00885() {
            }

            public void onPress(Button arg0) {
                EaselSizeScreen.this.chosenSize = 256;
                EaselSizeScreen.this.goToEaselScreen();
            }
        }));
        addRenderableWidget(new ImageButton(startX, startY + 120, 106, 20, 150, 200, 20, EASEL_SIZE_GUI, new Button.OnPress() { // from class: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen.6
            C00896() {
            }

            public void onPress(Button arg0) {
                EaselSizeScreen.this.goToEaselCustomSizeScreen();
            }
        }));
    }

    /* renamed from: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen$1 */
    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/EaselSizeScreen$1.class */
    class C00841 implements Button.OnPress {
        C00841() {
        }

        public void onPress(Button arg0) {
            EaselSizeScreen.this.chosenSize = 16;
            EaselSizeScreen.this.goToEaselScreen();
        }
    }

    /* renamed from: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen$2 */
    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/EaselSizeScreen$2.class */
    class C00852 implements Button.OnPress {
        C00852() {
        }

        public void onPress(Button arg0) {
            EaselSizeScreen.this.chosenSize = 32;
            EaselSizeScreen.this.goToEaselScreen();
        }
    }

    /* renamed from: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen$3 */
    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/EaselSizeScreen$3.class */
    class C00863 implements Button.OnPress {
        C00863() {
        }

        public void onPress(Button arg0) {
            EaselSizeScreen.this.chosenSize = 64;
            EaselSizeScreen.this.goToEaselScreen();
        }
    }

    /* renamed from: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen$4 */
    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/EaselSizeScreen$4.class */
    class C00874 implements Button.OnPress {
        C00874() {
        }

        public void onPress(Button arg0) {
            EaselSizeScreen.this.chosenSize = 128;
            EaselSizeScreen.this.goToEaselScreen();
        }
    }

    /* renamed from: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen$5 */
    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/EaselSizeScreen$5.class */
    class C00885 implements Button.OnPress {
        C00885() {
        }

        public void onPress(Button arg0) {
            EaselSizeScreen.this.chosenSize = 256;
            EaselSizeScreen.this.goToEaselScreen();
        }
    }

    /* renamed from: com.dairymoose.modernlife.blocks.gui.EaselSizeScreen$6 */
    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/EaselSizeScreen$6.class */
    class C00896 implements Button.OnPress {
        C00896() {
        }

        public void onPress(Button arg0) {
            EaselSizeScreen.this.goToEaselCustomSizeScreen();
        }
    }

    public boolean isPauseScreen() {
        return false;
    }

    private void drawCenteredStringNoShadow(PoseStack p_238472_0_, Font p_238472_1_, Component p_238472_2_, int p_238472_3_, int p_238472_4_, int p_238472_5_) {
        FormattedCharSequence lvt_6_1_ = p_238472_2_.getVisualOrderText();
        p_238472_1_.draw(p_238472_0_, lvt_6_1_, p_238472_3_ - (p_238472_1_.width(lvt_6_1_) / 2), p_238472_4_, p_238472_5_);
    }

    public void render(PoseStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
        RenderSystem.setShader(GameRenderer::getPositionTexShader);
        RenderSystem.setShaderTexture(0, EASEL_SIZE_GUI);
        int lvt_5_1_ = (this.width - 132) / 2;
        int lvt_6_1_ = (this.height - 175) / 2;
        m_93228_(p_230430_1_, lvt_5_1_, lvt_6_1_, 0, 0, 132, 175);
        drawCenteredStringNoShadow(p_230430_1_, this.minecraft.font, this.title, lvt_5_1_ + 66, lvt_6_1_ + 5, 0);
        super.render(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_);
    }
}
