package net.halbear.skyboxmod.rendering.screen;

import net.halbear.skyboxmod.Config;
import net.halbear.skyboxmod.SkyboxMod;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
import net.minecraft.network.chat.Component;

public class ConfigScreen extends OptionsSubScreen {
    private final Screen lastScreen;

    private static OptionInstance<?>[] CloudOptions(Options options) {
        return new OptionInstance[]{Config.Instance.MinCloudSpeed(),Config.Instance.MaxCloudSpeed(), Config.Instance.MinScale(),Config.Instance.MaxScale(), Config.Instance.MinVerticalAngle(),Config.Instance.MaxVerticalAngle()};
    }

    private static OptionInstance<?>[] CelestialOptions(Options options) {
        return new OptionInstance[]{Config.Instance.SunScale(),Config.Instance.MoonScale()};
    }
    private static OptionInstance<?>[] GeneralOptions(Options options) {
        return new OptionInstance[]{Config.Instance.RenderCustomSun(),Config.Instance.RenderCustomMoon(),Config.Instance.RenderCustomSkybox(),Config.Instance.RenderCustomClouds()};
    }

    public ConfigScreen(Screen lastScreen,Options options) {
        SkyboxMod.LOGGER.debug("screen!");

        super(lastScreen,options,Component.literal("Skybox Configuration"));
        this.lastScreen = lastScreen;
    }


    @Override
    protected void addOptions() {
        this.list.addHeader(Component.translatable("hals_skybox_config.general_header"));
        this.list.addSmall(GeneralOptions(this.options));
        this.list.addHeader(Component.translatable("hals_skybox_config.celestial_header"));
        this.list.addSmall(CelestialOptions(this.options));
        this.list.addBig(Config.Instance.RenderSunTranslucent());
        this.list.addBig(Config.Instance.RenderMoonTranslucent());
        this.list.addHeader(Component.translatable("hals_skybox_config.cloud_header"));
        this.list.addBig(Config.Instance.CloudCount());
        this.list.addSmall(CloudOptions(this.options));
        this.list.addBig(Config.Instance.OpenCloudSprites());
    }


    @Override
    public void onClose() {
        this.minecraft.setScreen(this.lastScreen);
    }
}