package net.minecraft.client;

import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import com.mojang.blaze3d.platform.VideoMode;
import java.util.Optional;
import javax.annotation.Nullable;
import com.mojang.blaze3d.platform.Monitor;
import com.mojang.blaze3d.platform.Window;

public class FullscreenResolutionProgressOption extends ProgressOption {
    public FullscreenResolutionProgressOption(final Window dgy) {
        this(dgy, dgy.findBestMonitor());
    }
    
    private FullscreenResolutionProgressOption(final Window dgy, @Nullable final Monitor dgq) {
        Optional<VideoMode> optional4;
        double double5;
        MutableComponent mx6;
        super("options.fullscreen.resolution", -1.0, (dgq != null) ? ((double)(dgq.getModeCount() - 1)) : -1.0, 1.0f, dmb -> {
            if (dgq == null) {
                return Double.valueOf(-1.0);
            }
            else {
                optional4 = dgy.getPreferredFullscreenVideoMode();
                return Double.valueOf(optional4.map(dgx -> Double.valueOf(dgq.getVideoModeIndex(dgx))).orElse(-1.0));
            }
        }, (dmb, double4) -> {
            if (dgq != null) {
                if (double4 == -1.0) {
                    dgy.setPreferredFullscreenVideoMode(Optional.<VideoMode>empty());
                }
                else {
                    dgy.setPreferredFullscreenVideoMode(Optional.<VideoMode>of(dgq.getMode(double4.intValue())));
                }
            }
        }, (dmb, dmd) -> {
            if (dgq == null) {
                return new TranslatableComponent("options.fullscreen.unavailable");
            }
            else {
                double5 = dmd.get(dmb);
                mx6 = dmd.createCaption();
                if (double5 == -1.0) {
                    return mx6.append(new TranslatableComponent("options.fullscreen.current"));
                }
                else {
                    return mx6.append(dgq.getMode((int)double5).toString());
                }
            }
        });
    }
}
