Search in sources :

Example 1 with ConfigCategory

use of me.shedaniel.clothconfig2.api.ConfigCategory in project SeedcrackerX by 19MisterX98.

the class ConfigScreen method getConfigScreenByCloth.

public Screen getConfigScreenByCloth(Screen parent) {
    ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(new TranslatableText("title")).setDefaultBackgroundTexture(new Identifier("minecraft:textures/block/blackstone.png")).setTransparentBackground(true);
    ConfigEntryBuilder eb = builder.entryBuilder();
    // =============================CONFIG========================
    ConfigCategory settings = builder.getOrCreateCategory(new TranslatableText("settings"));
    settings.addEntry(eb.startBooleanToggle(new TranslatableText("settings.active"), config.active).setSaveConsumer(val -> config.active = val).build());
    settings.addEntry(eb.startBooleanToggle(new TranslatableText("settings.database"), config.databaseSubmits).setTooltip(new TranslatableText("settings.database.tooltip")).setSaveConsumer(val -> config.databaseSubmits = val).build());
    settings.addEntry(eb.startBooleanToggle(new TranslatableText("settings.hideNameDatabase"), config.anonymusSubmits).setSaveConsumer(val -> config.anonymusSubmits = val).build());
    settings.addEntry(eb.startDropdownMenu(new TranslatableText("settings.version"), DropdownMenuBuilder.TopCellElementBuilder.of(config.getVersion(), MCVersion::fromString)).setSelections(getSupportedVersions()).setSuggestionMode(false).setDefaultValue(config.getVersion()).setSaveConsumer(config::setVersion).build());
    settings.addEntry(eb.startTextDescription(new LiteralText("==============")).build());
    settings.addEntry(eb.startTextDescription(new TranslatableText("settings.visuals")).build());
    settings.addEntry(eb.startEnumSelector(new TranslatableText("settings.outline"), Config.RenderType.class, config.render).setSaveConsumer(val -> config.render = val).build());
    settings.addEntry(eb.startTextDescription(new LiteralText("==============")).build());
    settings.addEntry(eb.startTextDescription((new TranslatableText("settings.finderToggles"))).build());
    for (Finder.Type finder : Finder.Type.values()) {
        settings.addEntry(eb.startBooleanToggle(new TranslatableText(finder.nameKey), finder.enabled.get()).setSaveConsumer(val -> finder.enabled.set(val)).build());
    }
    settings.addEntry(eb.startTextDescription(new LiteralText("==============")).build());
    settings.addEntry(eb.startBooleanToggle(new TranslatableText("settings.antiXrayMode"), config.antiXrayBypass).setSaveConsumer(val -> config.antiXrayBypass = val).build());
    settings.addEntry(eb.startTextDescription(new TranslatableText("settings.antiAntiXrayExplained")).build());
    // =============================INFO========================
    ConfigCategory info = builder.getOrCreateCategory(new TranslatableText("info"));
    // Clear data
    info.addEntry(eb.startBooleanToggle(new TranslatableText("info.clearData"), false).setSaveConsumer(val -> {
        if (val) {
            SeedCracker.get().reset();
        }
    }).build());
    // List worldseeds
    Set<Long> worldSeeds = SeedCracker.get().getDataStorage().getTimeMachine().worldSeeds;
    if (!worldSeeds.isEmpty()) {
        SubCategoryBuilder world = eb.startSubCategory(new TranslatableText("info.worldSeeds"));
        for (long worldSeed : worldSeeds) {
            world.add(eb.startTextField(new LiteralText(""), String.valueOf(worldSeed)).build());
        }
        info.addEntry(world.setExpanded(true).build());
    } else {
        info.addEntry(eb.startTextDescription(new TranslatableText("info.noWorldSeeds")).build());
    }
    // List structureseeds
    Set<Long> structureSeeds = SeedCracker.get().getDataStorage().getTimeMachine().structureSeeds;
    if (!structureSeeds.isEmpty()) {
        SubCategoryBuilder struc = eb.startSubCategory(new TranslatableText("info.structureSeeds"));
        for (long structureSeed : structureSeeds) {
            struc.add(eb.startTextField(new LiteralText(""), String.valueOf(structureSeed)).build());
        }
        info.addEntry(struc.setExpanded(true).build());
    } else {
        info.addEntry(eb.startTextDescription(new TranslatableText("info.noStructureSeeds")).build());
    }
    if (config.debug) {
        // List pillarseeds
        List<Integer> pillarSeeds = SeedCracker.get().getDataStorage().getTimeMachine().pillarSeeds;
        if (pillarSeeds != null) {
            SubCategoryBuilder pillar = eb.startSubCategory(new TranslatableText("info.pillarSeeds"));
            for (long structureSeed : pillarSeeds) {
                pillar.add(eb.startTextField(new LiteralText(""), String.valueOf(structureSeed)).build());
            }
            info.addEntry(pillar.setExpanded(true).build());
        } else {
            info.addEntry(eb.startTextDescription(new TranslatableText("info.noPillarSeeds")).build());
        }
        // Hashed seed
        HashedSeedData hashedSeed = SeedCracker.get().getDataStorage().hashedSeedData;
        if (hashedSeed != null) {
            info.addEntry(eb.startTextField(new TranslatableText("info.hashedSeed"), String.valueOf(hashedSeed.getHashedSeed())).build());
        } else {
            info.addEntry(eb.startTextDescription(new TranslatableText("info.noHashedSeed")).build());
        }
    }
    builder.setSavingRunnable(Config::save);
    return builder.build();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Finder(kaptainwutax.seedcrackerX.finder.Finder) HashedSeedData(kaptainwutax.seedcrackerX.cracker.HashedSeedData) SubCategoryBuilder(me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder) Identifier(net.minecraft.util.Identifier) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) LiteralText(net.minecraft.text.LiteralText)

Example 2 with ConfigCategory

use of me.shedaniel.clothconfig2.api.ConfigCategory in project mineclub-expanded by Blobanium.

the class ClothConfigScreen method createConfig.

public static Screen createConfig(Screen parent) {
    final ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(new TranslatableText("mineclub-expanded.config"));
    // Serialise the config into the config file. This will be called last after all variables are updated.
    builder.setSavingRunnable(ConfigReader::onConfigSave);
    ConfigEntryBuilder entryBuilder = builder.entryBuilder();
    ConfigCategory general = builder.getOrCreateCategory(new TranslatableText("mineclub-expanded.category.main"));
    ConfigCategory presence = builder.getOrCreateCategory(new TranslatableText("mineclub-expanded.category.presence"));
    ConfigCategory outbid = builder.getOrCreateCategory(new TranslatableText("mineclub-expanded.category.outbid"));
    ConfigCategory autoreconnect = builder.getOrCreateCategory(new TranslatableText("mineclub-expanded.category.autoreconnect"));
    ConfigCategory serial = builder.getOrCreateCategory(new TranslatableText("mineclub-expanded.category.serial"));
    general.addEntry(entryBuilder.startBooleanToggle(DynamicModMenuTranslatable.getDiscordRPTranslatable(), ConfigReader.richPresence).setDefaultValue(false).setTooltip(DynamicModMenuTranslatable.getDiscordRPDescriptionTranslatable()).requireRestart().setSaveConsumer(newValue -> ConfigReader.richPresence = newValue).build());
    presence.addEntry(entryBuilder.startStringDropdownMenu(new TranslatableText("mineclub-expanded.config.presencedetail"), ConfigReader.rpCustomDetails).setDefaultValue("Compact").setSuggestionMode(false).setSelections(Lists.newArrayList("Compact", "ServerIP", "Username", "Mod Version")).setTooltip(new TranslatableText("mineclub-expanded.config.presencedetail.description")).setSaveConsumer(newValue -> ConfigReader.rpCustomDetails = newValue).build());
    presence.addEntry(entryBuilder.startTextDescription(new TranslatableText("mineclub-expanded.configtext.presence")).build());
    general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("mineclub-expanded.config.outbidsound"), ConfigReader.outbidNotification).setDefaultValue(false).setTooltip(new TranslatableText("mineclub-expanded.config.outbidsound.description")).setSaveConsumer(newValue -> ConfigReader.outbidNotification = newValue).build());
    outbid.addEntry(entryBuilder.startIntSlider(new TranslatableText("mineclub-expanded.config.outbidvolume"), ConfigReader.outbidVolume, 0, 200).setDefaultValue(100).setTooltip(new TranslatableText("mineclub-expanded.config.outbidvolume.description")).setSaveConsumer(newValue -> ConfigReader.outbidVolume = newValue).build());
    outbid.addEntry(entryBuilder.startTextDescription(new TranslatableText("mineclub-expanded.configtext.outbid")).build());
    general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("mineclub-expanded.config.autogg"), ConfigReader.autogg).setDefaultValue(false).setTooltip(new TranslatableText("mineclub-expanded.config.autogg.description")).setSaveConsumer(newValue -> ConfigReader.autogg = newValue).build());
    general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("mineclub-expanded.config.autoreconnect"), ConfigReader.autoReconnect).setDefaultValue(false).setTooltip(new TranslatableText("mineclub-expanded.config.autoreconnect.description")).setSaveConsumer(newValue -> ConfigReader.autoReconnect = newValue).build());
    autoreconnect.addEntry(entryBuilder.startIntSlider(new TranslatableText("mineclub-expanded.config.autoreconnectattempts"), ConfigReader.autoReconnectAttempts, 1, 20).setDefaultValue(3).setTooltip(new TranslatableText("mineclub-expanded.config.autoreconnectattempts.description")).setSaveConsumer(newValue -> ConfigReader.autoReconnectAttempts = newValue).build());
    autoreconnect.addEntry(entryBuilder.startIntSlider(new TranslatableText("mineclub-expanded.config.autoreconnectseconds"), ConfigReader.autoReconnectSeconds, 1, 60).setDefaultValue(5).setTooltip(new TranslatableText("mineclub-expanded.config.autoreconnectseconds.description")).setSaveConsumer(newValue -> ConfigReader.autoReconnectSeconds = newValue).build());
    autoreconnect.addEntry(entryBuilder.startTextDescription(new TranslatableText("mineclub-expanded.configtext.autoreconnect")).build());
    general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("mineclub-expanded.config.expressconnect"), ConfigReader.expressConnect).setDefaultValue(false).setTooltip(new TranslatableText("mineclub-expanded.config.expressconnect.description")).setSaveConsumer(newValue -> ConfigReader.expressConnect = newValue).build());
    general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("mineclub-expanded.config.hideserialid"), ConfigReader.hideSerialID).setDefaultValue(false).setTooltip(new TranslatableText("mineclub-expanded.config.hideserialid.description")).setSaveConsumer(newValue -> ConfigReader.hideSerialID = newValue).build());
    serial.addEntry(entryBuilder.startStringDropdownMenu(new TranslatableText("mineclub-expanded.config.serialcolor"), ConfigReader.serialColor).setDefaultValue("White").setSuggestionMode(false).setSelections(Lists.newArrayList("White", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow")).setTooltip(new TranslatableText("mineclub-expanded.config.serialcolor.description")).setSaveConsumer(newValue -> ConfigReader.serialColor = newValue).build());
    serial.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("mineclub-expanded.config.showdigits"), ConfigReader.showDigits).setDefaultValue(false).setTooltip(new TranslatableText("mineclub-expanded.config.showdigits.description")).setSaveConsumer(newValue -> ConfigReader.showDigits = newValue).build());
    if (MineclubExpanded.debugmode) {
        ConfigCategory debug = builder.getOrCreateCategory(new TranslatableText("mineclub-expanded.category.debug"));
        debug.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("mineclub-expanded.config.debug.asyncticks"), ConfigReader.debugAsyncTicks).setDefaultValue(false).setTooltip(new TranslatableText("mineclub-expanded.config.debug.asyncticks.description")).setSaveConsumer(newValue -> ConfigReader.debugAsyncTicks = newValue).build());
        debug.addEntry(entryBuilder.startIntSlider(new TranslatableText("mineclub-expanded.config.debug.asynctickthreads"), ConfigReader.debugAsyncTickThreads, 1, Runtime.getRuntime().availableProcessors()).setDefaultValue(2).setTooltip(new TranslatableText("mineclub-expanded.config.debug.asynctickthreads.description")).setSaveConsumer(newValue -> ConfigReader.debugAsyncTickThreads = newValue).build());
    }
    return builder.build();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder)

Example 3 with ConfigCategory

use of me.shedaniel.clothconfig2.api.ConfigCategory in project canvas by vram-guild.

the class Configurator method display.

@SuppressWarnings({ "unchecked", "rawtypes" })
private static Screen display() {
    reloadTerrain = false;
    reloadShaders = false;
    final ConfigBuilder builder = ConfigBuilder.create().setParentScreen(screenIn).setTitle("config.canvas.title").setSavingRunnable(Configurator::saveUserInput);
    // FEATURES
    final ConfigCategory features = builder.getOrCreateCategory("config.canvas.category.features");
    features.addEntry(new BooleanListEntry("config.canvas.value.item_render", itemShaderRender, "config.canvas.reset", () -> DEFAULTS.itemShaderRender, b -> itemShaderRender = b, () -> Optional.of(I18n.translate("config.canvas.help.item_render").split(";"))));
    features.addEntry(new BooleanListEntry("config.canvas.value.hardcore_darkness", hardcoreDarkness, "config.canvas.reset", () -> DEFAULTS.hardcoreDarkness, b -> {
        hardcoreDarkness = b;
        reloadShaders = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.hardcore_darkness").split(";"))));
    features.addEntry(new BooleanListEntry("config.canvas.value.subtle_fog", subtleFog, "config.canvas.reset", () -> DEFAULTS.subtleFog, b -> {
        subtleFog = b;
        reloadShaders = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.subtle_fog").split(";"))));
    // LIGHTING
    final ConfigCategory lighting = builder.getOrCreateCategory("config.canvas.category.lighting");
    lighting.addEntry(new BooleanListEntry("config.canvas.value.light_smoothing", lightSmoothing, "config.canvas.reset", () -> DEFAULTS.lightSmoothing, b -> {
        lightSmoothing = b;
        reloadTerrain = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.light_smoothing").split(";"))));
    lighting.addEntry(new BooleanListEntry("config.canvas.value.hd_lightmaps", hdLightmaps, "config.canvas.reset", () -> DEFAULTS.hdLightmaps, b -> {
        hdLightmaps = b;
        reloadTerrain = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.hd_lightmaps").split(";"))));
    lighting.addEntry(new BooleanListEntry("config.canvas.value.more_lightmap", moreLightmap, "config.canvas.reset", () -> DEFAULTS.moreLightmap, b -> moreLightmap = b, () -> Optional.of(I18n.translate("config.canvas.help.more_lightmap").split(";"))));
    lighting.addEntry(new BooleanListEntry("config.canvas.value.lightmap_noise", lightmapNoise, "config.canvas.reset", () -> DEFAULTS.lightmapNoise, b -> {
        lightmapNoise = b;
        reloadShaders = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.lightmap_noise").split(";"))));
    lighting.addEntry(new EnumListEntry("config.canvas.value.diffuse_shading", DiffuseMode.class, diffuseShadingMode, "config.canvas.reset", () -> DEFAULTS.diffuseShadingMode, (b) -> {
        diffuseShadingMode = (DiffuseMode) b;
        reloadShaders = true;
    }, a -> a.toString(), () -> Optional.of(I18n.translate("config.canvas.help.diffuse_shading").split(";"))));
    lighting.addEntry(new EnumListEntry("config.canvas.value.ao_shading", AoMode.class, aoShadingMode, "config.canvas.reset", () -> DEFAULTS.aoShadingMode, (b) -> {
        aoShadingMode = (AoMode) b;
        reloadShaders = true;
    }, a -> a.toString(), () -> Optional.of(I18n.translate("config.canvas.help.ao_shading").split(";"))));
    lighting.addEntry(new IntegerSliderEntry("config.canvas.value.lightmap_delay_frames", 0, 20, maxLightmapDelayFrames, "config.canvas.reset", () -> DEFAULTS.maxLightmapDelayFrames, b -> maxLightmapDelayFrames = b, () -> Optional.of(I18n.translate("config.canvas.help.lightmap_delay_frames").split(";"))));
    // TWEAKS
    final ConfigCategory tweaks = builder.getOrCreateCategory("config.canvas.category.tweaks");
    // tweaks.addOption(new BooleanListEntry("config.canvas.value.compact_gpu_formats", enableCompactGPUFormats, "config.canvas.reset",
    // () -> DEFAULTS.enableCompactGPUFormats, b -> enableCompactGPUFormats = b,
    // () -> Optional.of(I18n.translate("config.canvas.help.compact_gpu_formats").split(";"))));
    tweaks.addEntry(new LongListEntry("config.canvas.value.min_chunk_budget", minChunkBudgetNanos, "config.canvas.reset", () -> DEFAULTS.minChunkBudgetNanos, l -> minChunkBudgetNanos = l, () -> Optional.of(I18n.translate("config.canvas.help.min_chunk_budget").split(";"))));
    tweaks.addEntry(new BooleanListEntry("config.canvas.value.chunk_occlusion", fastChunkOcclusion, "config.canvas.reset", () -> DEFAULTS.fastChunkOcclusion, b -> fastChunkOcclusion = b, () -> Optional.of(I18n.translate("config.canvas.help.chunk_occlusion").split(";"))));
    tweaks.addEntry(new BooleanListEntry("config.canvas.value.batch_chunk_render", batchedChunkRender, "config.canvas.reset", () -> DEFAULTS.batchedChunkRender, b -> batchedChunkRender = b, () -> Optional.of(I18n.translate("config.canvas.help.batch_chunk_render").split(";"))));
    // tweaks.addOption(new BooleanListEntry("config.canvas.value.vanilla_chunk_matrix", disableVanillaChunkMatrix, "config.canvas.reset",
    // () -> DEFAULTS.disableVanillaChunkMatrix, b -> disableVanillaChunkMatrix = b,
    // () -> Optional.of(I18n.translate("config.canvas.help.vanilla_chunk_matrix").split(";"))));
    tweaks.addEntry(new BooleanListEntry("config.canvas.value.adjust_vanilla_geometry", preventDepthFighting, "config.canvas.reset", () -> DEFAULTS.preventDepthFighting, b -> {
        preventDepthFighting = b;
        reloadTerrain = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.adjust_vanilla_geometry").split(";"))));
    tweaks.addEntry(new BooleanListEntry("config.canvas.value.clamp_exterior_vertices", clampExteriorVertices, "config.canvas.reset", () -> DEFAULTS.clampExteriorVertices, b -> {
        clampExteriorVertices = b;
        reloadTerrain = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.clamp_exterior_vertices").split(";"))));
    tweaks.addEntry(new BooleanListEntry("config.canvas.value.fix_luminous_block_shade", fixLuminousBlockShading, "config.canvas.reset", () -> DEFAULTS.fixLuminousBlockShading, b -> {
        fixLuminousBlockShading = b;
        reloadTerrain = true;
    }, () -> Optional.of(I18n.translate("config.canvas.help.fix_luminous_block_shade").split(";"))));
    // tweaks.addOption(new BooleanListEntry("config.canvas.value.pad_translucent_formats", padTranslucentFormats, "config.canvas.reset",
    // () -> DEFAULTS.padTranslucentFormats, b -> {padTranslucentFormats = b; reloadTerrain = true;},
    // () -> Optional.of(I18n.translate("config.canvas.help.pad_translucent_formats").split(";"))));
    // DEBUG
    final ConfigCategory debug = builder.getOrCreateCategory("config.canvas.category.debug");
    debug.addEntry(new BooleanListEntry("config.canvas.value.shader_debug", shaderDebug, "config.canvas.reset", () -> DEFAULTS.shaderDebug, b -> shaderDebug = b, () -> Optional.of(I18n.translate("config.canvas.help.shader_debug").split(";"))));
    debug.addEntry(new BooleanListEntry("config.canvas.value.shader_debug_lightmap", lightmapDebug, "config.canvas.reset", () -> DEFAULTS.lightmapDebug, b -> lightmapDebug = b, () -> Optional.of(I18n.translate("config.canvas.help.shader_debug_lightmap").split(";"))));
    debug.addEntry(new BooleanListEntry("config.canvas.value.concise_errors", conciseErrors, "config.canvas.reset", () -> DEFAULTS.conciseErrors, b -> conciseErrors = b, () -> Optional.of(I18n.translate("config.canvas.help.concise_errors").split(";"))));
    debug.addEntry(new BooleanListEntry("config.canvas.value.log_machine_info", logMachineInfo, "config.canvas.reset", () -> DEFAULTS.logMachineInfo, b -> logMachineInfo = b, () -> Optional.of(I18n.translate("config.canvas.help.log_machine_info").split(";"))));
    debug.addEntry(new BooleanListEntry("config.canvas.value.log_gl_state_changes", logGlStateChanges, "config.canvas.reset", () -> DEFAULTS.logGlStateChanges, b -> logGlStateChanges = b, () -> Optional.of(I18n.translate("config.canvas.help.log_gl_state_changes").split(";"))));
    debug.addEntry(new BooleanListEntry("config.canvas.value.debug_native_allocation", debugNativeMemoryAllocation, "config.canvas.reset", () -> DEFAULTS.debugNativeMemoryAllocation, b -> debugNativeMemoryAllocation = b, () -> Optional.of(I18n.translate("config.canvas.help.debug_native_allocation").split(";"))));
    debug.addEntry(new BooleanListEntry("config.canvas.value.safe_native_allocation", safeNativeMemoryAllocation, "config.canvas.reset", () -> DEFAULTS.safeNativeMemoryAllocation, b -> safeNativeMemoryAllocation = b, () -> Optional.of(I18n.translate("config.canvas.help.safe_native_allocation").split(";"))));
    builder.setDoesConfirmSave(false);
    return builder.build();
}
Also used : FabricLoader(net.fabricmc.loader.api.FabricLoader) JsonObject(blue.endless.jankson.JsonObject) IntegerSliderEntry(me.shedaniel.clothconfig2.gui.entries.IntegerSliderEntry) EnumListEntry(me.shedaniel.clothconfig2.gui.entries.EnumListEntry) I18n(net.minecraft.client.resource.language.I18n) Environment(net.fabricmc.api.Environment) FileOutputStream(java.io.FileOutputStream) Jankson(blue.endless.jankson.Jankson) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) LongListEntry(me.shedaniel.clothconfig2.gui.entries.LongListEntry) Supplier(java.util.function.Supplier) File(java.io.File) GsonBuilder(com.google.gson.GsonBuilder) ShaderManager(grondag.canvas.material.ShaderManager) Screen(net.minecraft.client.gui.screen.Screen) Comment(blue.endless.jankson.Comment) Gson(com.google.gson.Gson) Optional(java.util.Optional) EnvType(net.fabricmc.api.EnvType) MinecraftClient(net.minecraft.client.MinecraftClient) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) BooleanListEntry(me.shedaniel.clothconfig2.gui.entries.BooleanListEntry) LongListEntry(me.shedaniel.clothconfig2.gui.entries.LongListEntry) IntegerSliderEntry(me.shedaniel.clothconfig2.gui.entries.IntegerSliderEntry) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) EnumListEntry(me.shedaniel.clothconfig2.gui.entries.EnumListEntry) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) BooleanListEntry(me.shedaniel.clothconfig2.gui.entries.BooleanListEntry)

Example 4 with ConfigCategory

use of me.shedaniel.clothconfig2.api.ConfigCategory in project CITResewn by SHsuperCM.

the class CITResewnConfigScreenFactory method create.

public static Screen create(Screen parent) {
    CITResewnConfig currentConfig = CITResewnConfig.INSTANCE(), defaultConfig = new CITResewnConfig();
    ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(new TranslatableText("config.citresewn.title")).setSavingRunnable(currentConfig::write);
    ConfigCategory category = builder.getOrCreateCategory(new LiteralText(""));
    ConfigEntryBuilder entryBuilder = builder.entryBuilder();
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.enabled.title"), currentConfig.enabled).setTooltip(new TranslatableText("config.citresewn.enabled.tooltip")).setSaveConsumer(newConfig -> {
        if (currentConfig.enabled != newConfig) {
            currentConfig.enabled = newConfig;
            MinecraftClient.getInstance().reloadResources();
        }
    }).setDefaultValue(defaultConfig.enabled).build());
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_errors.title"), currentConfig.mute_errors).setTooltip(new TranslatableText("config.citresewn.mute_errors.tooltip")).setSaveConsumer(newConfig -> currentConfig.mute_errors = newConfig).setDefaultValue(defaultConfig.mute_errors).build());
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.mute_warns.title"), currentConfig.mute_warns).setTooltip(new TranslatableText("config.citresewn.mute_warns.tooltip")).setSaveConsumer(newConfig -> currentConfig.mute_warns = newConfig).setDefaultValue(defaultConfig.mute_warns).build());
    category.addEntry(entryBuilder.startFloatField(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.title"), currentConfig.citenchantment_scroll_multiplier).setTooltip(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.tooltip")).setSaveConsumer(newConfig -> currentConfig.citenchantment_scroll_multiplier = newConfig).setDefaultValue(defaultConfig.citenchantment_scroll_multiplier).setMin(0f).build());
    category.addEntry(entryBuilder.startIntSlider(new TranslatableText("config.citresewn.cache_ms.title"), currentConfig.cache_ms / 50, 0, 5 * 20).setTooltip(new TranslatableText("config.citresewn.cache_ms.tooltip")).setSaveConsumer(newConfig -> currentConfig.cache_ms = newConfig * 50).setDefaultValue(currentConfig.cache_ms / 50).setTextGetter(ticks -> {
        if (ticks <= 1)
            return new TranslatableText("config.citresewn.cache_ms.ticks." + ticks).formatted(Formatting.AQUA);
        Formatting color = Formatting.DARK_RED;
        if (ticks <= 40)
            color = Formatting.RED;
        if (ticks <= 20)
            color = Formatting.GOLD;
        if (ticks <= 10)
            color = Formatting.DARK_GREEN;
        if (ticks <= 5)
            color = Formatting.GREEN;
        return new TranslatableText("config.citresewn.cache_ms.ticks.any", ticks).formatted(color);
    }).build());
    category.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("config.citresewn.broken_paths.title"), currentConfig.broken_paths).setTooltip(new TranslatableText("config.citresewn.broken_paths.tooltip")).setSaveConsumer(newConfig -> currentConfig.broken_paths = newConfig).setDefaultValue(defaultConfig.broken_paths).requireRestart().build());
    return builder.build();
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LiteralText(net.minecraft.text.LiteralText) Formatting(net.minecraft.util.Formatting) Screen(net.minecraft.client.gui.screen.Screen) TranslatableText(net.minecraft.text.TranslatableText) MinecraftClient(net.minecraft.client.MinecraftClient) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) Formatting(net.minecraft.util.Formatting) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) LiteralText(net.minecraft.text.LiteralText)

Example 5 with ConfigCategory

use of me.shedaniel.clothconfig2.api.ConfigCategory in project BedrockIfy by juancarloscp52.

the class SettingsGUI method getConfigScreen.

public Screen getConfigScreen(Screen parent, boolean isTransparent) {
    ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parent).setTitle(new TranslatableText("bedrockify.options.settings"));
    builder.setSavingRunnable(() -> Bedrockify.getInstance().saveSettings());
    ConfigCategory general = builder.getOrCreateCategory(new LiteralText("General"));
    ConfigEntryBuilder entryBuilder = builder.entryBuilder();
    SubCategoryBuilder bedrockOverlay = entryBuilder.startSubCategory(new TranslatableText("bedrockify.options.subCategory.bedrockOverlay"));
    bedrockOverlay.add(entryBuilder.startTextDescription(new TranslatableText("bedrockify.options.subCategory.bedrockOverlay.description")).build());
    bedrockOverlay.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.showCoordinates"), settings.showPositionHUD).setDefaultValue(true).setSaveConsumer(newValue -> settings.showPositionHUD = newValue).build());
    bedrockOverlay.add(entryBuilder.startSelector(new TranslatableText("bedrockify.options.showFPS"), new Byte[] { 0, 1, 2 }, settings.FPSHUD).setDefaultValue((byte) 0).setNameProvider((value) -> {
        switch(value) {
            case 0:
                return new TranslatableText("bedrockify.options.off");
            case 1:
                return new TranslatableText("bedrockify.options.withPosition");
            default:
                return new TranslatableText("bedrockify.options.underPosition");
        }
    }).setSaveConsumer((newValue) -> settings.FPSHUD = newValue).build());
    bedrockOverlay.add(entryBuilder.startIntSlider(new TranslatableText("bedrockify.options.coordinatesPosition"), settings.positionHUDHeight, 0, 100).setDefaultValue(50).setSaveConsumer((newValue) -> settings.positionHUDHeight = newValue).build());
    bedrockOverlay.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.showPaperDoll"), settings.showPaperDoll).setDefaultValue(true).setSaveConsumer(newValue -> settings.showPaperDoll = newValue).build());
    bedrockOverlay.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.showSavingOverlay"), settings.savingOverlay).setDefaultValue(true).setSaveConsumer(newValue -> settings.savingOverlay = newValue).build());
    general.addEntry(bedrockOverlay.build());
    SubCategoryBuilder guiImprovements = entryBuilder.startSubCategory(new TranslatableText("bedrockify.options.subCategory.visualImprovements"));
    guiImprovements.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.chatStyle"), settings.bedrockChat).setDefaultValue(true).setSaveConsumer(newValue -> settings.bedrockChat = newValue).setYesNoTextSupplier((value) -> value ? new TranslatableText("bedrockify.options.chatStyle.bedrock") : new TranslatableText("bedrockify.options.chatStyle.vanilla")).build());
    guiImprovements.add(entryBuilder.startIntSlider(new TranslatableText("bedrockify.options.screenSafeArea"), settings.screenSafeArea, 0, 30).setDefaultValue(0).setSaveConsumer((newValue) -> settings.screenSafeArea = newValue).build());
    guiImprovements.add(entryBuilder.startSelector(new TranslatableText("bedrockify.options.tooltips"), new Byte[] { 0, 1, 2 }, settings.heldItemTooltip).setDefaultValue((byte) 2).setNameProvider((value) -> {
        switch(value) {
            case 0:
                return new TranslatableText("bedrockify.options.off");
            case 1:
                return new TranslatableText("bedrockify.options.on");
            default:
                return new TranslatableText("bedrockify.options.withBackground");
        }
    }).setSaveConsumer((newValue) -> settings.heldItemTooltip = newValue).build());
    guiImprovements.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.inventoryHighlight"), settings.slotHighlight).setDefaultValue(true).setSaveConsumer(newValue -> settings.slotHighlight = newValue).build());
    guiImprovements.add(entryBuilder.startSelector(new TranslatableText("bedrockify.options.idleAnimation"), new Float[] { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 4.0f }, settings.idleAnimation).setDefaultValue(1.0f).setNameProvider((value) -> new LiteralText("x" + value)).setSaveConsumer((newValue) -> settings.idleAnimation = newValue).build());
    guiImprovements.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.eatingAnimations"), settings.eatingAnimations).setDefaultValue(true).setSaveConsumer(newValue -> settings.eatingAnimations = newValue).build());
    guiImprovements.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.pickupAnimations"), settings.pickupAnimations).setTooltip(wrapLines(new TranslatableText("bedrockify.options.pickupAnimations.tooltip"))).setDefaultValue(true).setSaveConsumer(newValue -> settings.pickupAnimations = newValue).build());
    guiImprovements.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.loadingScreen"), settings.loadingScreen).setDefaultValue(true).setSaveConsumer(newValue -> settings.loadingScreen = newValue).build());
    general.addEntry(guiImprovements.build());
    SubCategoryBuilder reachAround = entryBuilder.startSubCategory(new TranslatableText("bedrockify.options.subCategory.Reach-Around"));
    reachAround.add(entryBuilder.startTextDescription(new TranslatableText("bedrockify.options.subCategory.Reach-Around.description")).build());
    reachAround.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.reachAround"), settings.reacharound).setDefaultValue(true).setSaveConsumer(newValue -> settings.reacharound = newValue).build());
    reachAround.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.reachAround.multiplayer"), settings.reacharoundMultiplayer).setDefaultValue(true).setSaveConsumer(newValue -> settings.reacharoundMultiplayer = newValue).build());
    reachAround.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.reachAround.sneaking"), settings.reacharoundSneaking).setDefaultValue(true).setSaveConsumer(newValue -> settings.reacharoundSneaking = newValue).build());
    reachAround.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.reachAround.indicator"), settings.reacharoundIndicator).setDefaultValue(true).setSaveConsumer(newValue -> settings.reacharoundIndicator = newValue).build());
    reachAround.add(entryBuilder.startIntSlider(new TranslatableText("bedrockify.options.reachAround.pitch"), settings.reacharoundPitchAngle, 0, 90).setDefaultValue(25).setSaveConsumer(newValue -> settings.reacharoundPitchAngle = newValue).build());
    reachAround.add(entryBuilder.startIntSlider(new TranslatableText("bedrockify.options.reachAround.distance"), MathHelper.floor(settings.reacharoundBlockDistance * 100), 0, 100).setTextGetter((integer -> new LiteralText(String.valueOf(integer / 100d)))).setDefaultValue(75).setSaveConsumer(newValue -> settings.reacharoundBlockDistance = newValue / 100d).build());
    general.addEntry(reachAround.build());
    SubCategoryBuilder otherSettings = entryBuilder.startSubCategory(new TranslatableText("bedrockify.options.subCategory.other"));
    otherSettings.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.loadingScreenChunkMap"), settings.showChunkMap).setTooltip(wrapLines(new TranslatableText("bedrockify.options.loadingScreenChunkMap.tooltip"))).setDefaultValue(false).setSaveConsumer(newValue -> settings.showChunkMap = newValue).build());
    otherSettings.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.rotationalBackground"), settings.cubeMapBackground).setDefaultValue(true).setTooltip(wrapLines(new TranslatableText("bedrockify.options.rotationalBackground.tooltip"))).setSaveConsumer(newValue -> settings.cubeMapBackground = newValue).build());
    otherSettings.add(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.showBedrockIfyButton"), settings.bedrockIfyButton).setDefaultValue(true).setTooltip(wrapLines(new TranslatableText("bedrockify.options.showBedrockIfyButton.tooltip"))).setSaveConsumer(newValue -> settings.bedrockIfyButton = newValue).build());
    general.addEntry(otherSettings.build());
    general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText("bedrockify.options.recipes"), settings.bedrockRecipes).setTooltip(wrapLines(new TranslatableText("bedrockify.options.recipes.tooltip"))).setDefaultValue(true).setSaveConsumer(newValue -> settings.bedrockRecipes = newValue).build());
    return builder.setTransparentBackground(isTransparent).build();
}
Also used : BedrockifySettings(me.juancarloscp52.bedrockify.BedrockifySettings) SubCategoryBuilder(me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) Bedrockify(me.juancarloscp52.bedrockify.Bedrockify) MathHelper(net.minecraft.util.math.MathHelper) MinecraftClient(net.minecraft.client.MinecraftClient) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) net.minecraft.text(net.minecraft.text) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) ConfigCategory(me.shedaniel.clothconfig2.api.ConfigCategory) ConfigBuilder(me.shedaniel.clothconfig2.api.ConfigBuilder) ConfigEntryBuilder(me.shedaniel.clothconfig2.api.ConfigEntryBuilder) SubCategoryBuilder(me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder)

Aggregations

ConfigCategory (me.shedaniel.clothconfig2.api.ConfigCategory)7 ConfigBuilder (me.shedaniel.clothconfig2.api.ConfigBuilder)6 ConfigEntryBuilder (me.shedaniel.clothconfig2.api.ConfigEntryBuilder)5 MinecraftClient (net.minecraft.client.MinecraftClient)3 Screen (net.minecraft.client.gui.screen.Screen)3 TranslatableText (net.minecraft.text.TranslatableText)3 SubCategoryBuilder (me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder)2 Environment (net.fabricmc.api.Environment)2 LiteralText (net.minecraft.text.LiteralText)2 Identifier (net.minecraft.util.Identifier)2 Comment (blue.endless.jankson.Comment)1 Jankson (blue.endless.jankson.Jankson)1 JsonObject (blue.endless.jankson.JsonObject)1 HashBiMap (com.google.common.collect.HashBiMap)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 ShaderManager (grondag.canvas.material.ShaderManager)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 StandardCopyOption (java.nio.file.StandardCopyOption)1