package net.minecraft.client.gui.screens;

import java.util.Iterator;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.TranslatableComponent;
import java.util.Collection;
import com.google.common.collect.Lists;
import net.minecraft.client.gui.components.Checkbox;
import net.minecraft.network.chat.FormattedText;
import java.util.List;
import net.minecraft.network.chat.Component;
import javax.annotation.Nullable;

public class BackupConfirmScreen extends Screen {
    @Nullable
    private final Screen lastScreen;
    protected final Listener listener;
    private final Component description;
    private final boolean promptForCacheErase;
    private final List<FormattedText> lines;
    private Checkbox eraseCache;
    
    public BackupConfirmScreen(@Nullable final Screen dqs, final Listener a, final Component mr3, final Component mr4, final boolean boolean5) {
        super(mr3);
        this.lines = Lists.newArrayList();
        this.lastScreen = dqs;
        this.listener = a;
        this.description = mr4;
        this.promptForCacheErase = boolean5;
    }
    
    @Override
    protected void init() {
        super.init();
        this.lines.clear();
        this.lines.addAll(this.font.split(this.description, this.width - 50));
        final int n = this.lines.size() + 1;
        this.font.getClass();
        final int integer2 = n * 9;
        this.<Button>addButton(new Button(this.width / 2 - 155, 100 + integer2, 150, 20, new TranslatableComponent("selectWorld.backupJoinConfirmButton"), dni -> this.listener.proceed(true, this.eraseCache.selected())));
        this.<Button>addButton(new Button(this.width / 2 - 155 + 160, 100 + integer2, 150, 20, new TranslatableComponent("selectWorld.backupJoinSkipButton"), dni -> this.listener.proceed(false, this.eraseCache.selected())));
        this.<Button>addButton(new Button(this.width / 2 - 155 + 80, 124 + integer2, 150, 20, CommonComponents.GUI_CANCEL, dni -> this.minecraft.setScreen(this.lastScreen)));
        this.eraseCache = new Checkbox(this.width / 2 - 155 + 80, 76 + integer2, 150, 20, new TranslatableComponent("selectWorld.backupEraseCache"), false);
        if (this.promptForCacheErase) {
            this.<Checkbox>addButton(this.eraseCache);
        }
    }
    
    @Override
    public void render(final PoseStack dhl, final int integer2, final int integer3, final float float4) {
        this.renderBackground(dhl);
        this.drawCenteredString(dhl, this.font, this.title, this.width / 2, 50, 16777215);
        int integer4 = 70;
        for (final FormattedText mu8 : this.lines) {
            this.drawCenteredString(dhl, this.font, mu8, this.width / 2, integer4, 16777215);
            final int n = integer4;
            this.font.getClass();
            integer4 = n + 9;
        }
        super.render(dhl, integer2, integer3, float4);
    }
    
    @Override
    public boolean shouldCloseOnEsc() {
        return false;
    }
    
    @Override
    public boolean keyPressed(final int integer1, final int integer2, final int integer3) {
        if (integer1 == 256) {
            this.minecraft.setScreen(this.lastScreen);
            return true;
        }
        return super.keyPressed(integer1, integer2, integer3);
    }
    
    public interface Listener {
        void proceed(final boolean boolean1, final boolean boolean2);
    }
}
