package net.minecraft.client;

import net.minecraft.client.resources.language.I18n;
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 cxx) {
        this(cxx, cxx.findBestMonitor());
    }
    
    private FullscreenResolutionProgressOption(final Window cxx, @Nullable final Monitor cxp) {
        Optional<VideoMode> optional4;
        double double5;
        String string6;
        super("options.fullscreen.resolution", -1.0, (cxp != null) ? ((double)(cxp.getModeCount() - 1)) : -1.0, 1.0f, dbr -> {
            if (cxp == null) {
                return Double.valueOf(-1.0);
            }
            else {
                optional4 = cxx.getPreferredFullscreenVideoMode();
                return Double.valueOf(optional4.map(cxw -> Double.valueOf(cxp.getVideoModeIndex(cxw))).orElse(-1.0));
            }
        }, (dbr, double4) -> {
            if (cxp != null) {
                if (double4 == -1.0) {
                    cxx.setPreferredFullscreenVideoMode(Optional.<VideoMode>empty());
                }
                else {
                    cxx.setPreferredFullscreenVideoMode(Optional.<VideoMode>of(cxp.getMode(double4.intValue())));
                }
            }
        }, (dbr, dbt) -> {
            if (cxp == null) {
                return I18n.get("options.fullscreen.unavailable");
            }
            else {
                double5 = dbt.get(dbr);
                string6 = dbt.getCaption();
                if (double5 == -1.0) {
                    return string6 + I18n.get("options.fullscreen.current");
                }
                else {
                    return cxp.getMode((int)double5).toString();
                }
            }
        });
    }
}
