Search in sources :

Example 1 with SliderControl

use of me.jellysquid.mods.sodium.client.gui.options.control.SliderControl in project sodium-fabric by CaffeineMC.

the class SodiumGameOptionPages method general.

public static OptionPage general() {
    List<OptionGroup> groups = new ArrayList<>();
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(int.class, vanillaOpts).setName("View Distance").setTooltip("The view distance controls how far away terrain will be rendered. Lower distances mean that less terrain will be " + "rendered, improving frame rates.").setControl(option -> new SliderControl(option, 2, 32, 1, ControlValueFormatter.quanity("Chunks"))).setBinding((options, value) -> options.viewDistance = value, options -> options.viewDistance).setImpact(OptionImpact.HIGH).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).add(OptionImpl.createBuilder(boolean.class, vanillaOpts).setName("V-Sync").setTooltip("If enabled, the game's frame rate will be synchronized to the monitor's refresh rate, making for a generally smoother experience " + "at the expense of overall input latency. This setting might reduce performance if your system is too slow.").setControl(TickBoxControl::new).setBinding(new VanillaBooleanOptionBinding(net.minecraft.client.options.Option.VSYNC)).setImpact(OptionImpact.VARIES).build()).add(OptionImpl.createBuilder(int.class, vanillaOpts).setName("FPS Limit").setTooltip("Limits the maximum number of frames per second. In effect, this will throttle the game and can be useful when you want to conserve " + "battery life or multi-task between other applications.").setControl(option -> new SliderControl(option, 5, 300, 5, ControlValueFormatter.quanity("FPS"))).setBinding((opts, value) -> {
        opts.maxFps = value;
        MinecraftClient.getInstance().getWindow().setFramerateLimit(value);
    }, opts -> opts.maxFps).build()).add(OptionImpl.createBuilder(boolean.class, vanillaOpts).setName("Fullscreen").setTooltip("If enabled, the game will display in full-screen.").setControl(TickBoxControl::new).setBinding((opts, value) -> {
        opts.fullscreen = value;
        MinecraftClient client = MinecraftClient.getInstance();
        Window window = client.getWindow();
        if (window != null && window.isFullscreen() != opts.fullscreen) {
            window.toggleFullscreen();
            // The client might not be able to enter full-screen mode
            opts.fullscreen = window.isFullscreen();
        }
    }, (opts) -> opts.fullscreen).build()).build());
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(int.class, vanillaOpts).setName("Brightness").setTooltip("Controls the brightness (gamma) of the game.").setControl(opt -> new SliderControl(opt, 0, 100, 1, ControlValueFormatter.percentage())).setBinding((opts, value) -> opts.gamma = value * 0.01D, (opts) -> (int) (opts.gamma / 0.01D)).build()).add(OptionImpl.createBuilder(boolean.class, sodiumOpts).setName("Clouds").setTooltip("Controls whether or not clouds will be visible.").setControl(TickBoxControl::new).setBinding((opts, value) -> opts.quality.enableClouds = value, (opts) -> opts.quality.enableClouds).setImpact(OptionImpact.LOW).build()).add(OptionImpl.createBuilder(ParticlesOption.class, vanillaOpts).setName("Particles").setTooltip("Controls the maximum number of particles which can be present on screen at any one time.").setControl(opt -> new CyclingControl<>(opt, ParticlesOption.values(), new String[] { "All", "Decreased", "Minimal" })).setBinding((opts, value) -> opts.particles = value, (opts) -> opts.particles).setImpact(OptionImpact.MEDIUM).build()).build());
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(boolean.class, vanillaOpts).setName("View Bobbing").setTooltip("If enabled, the player's view will sway and bob when moving around. Players who suffer from motion sickness can benefit from disabling this.").setControl(TickBoxControl::new).setBinding(new VanillaBooleanOptionBinding(net.minecraft.client.options.Option.VIEW_BOBBING)).build()).add(OptionImpl.createBuilder(AttackIndicator.class, vanillaOpts).setName("Attack Indicator").setTooltip("Controls where the Attack Indicator is displayed on screen.").setControl(opts -> new CyclingControl<>(opts, AttackIndicator.values(), new String[] { "Off", "Crosshair", "Hotbar" })).setBinding((opts, value) -> opts.attackIndicator = value, (opts) -> opts.attackIndicator).build()).build());
    return new OptionPage("General", ImmutableList.copyOf(groups));
}
Also used : TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) VanillaBooleanOptionBinding(me.jellysquid.mods.sodium.client.gui.options.binding.compat.VanillaBooleanOptionBinding) MinecraftOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage) me.jellysquid.mods.sodium.client.gui.options(me.jellysquid.mods.sodium.client.gui.options) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) ParticlesOption(net.minecraft.client.options.ParticlesOption) GlVertexArray(me.jellysquid.mods.sodium.client.render.gl.GlVertexArray) ArrayList(java.util.ArrayList) SodiumOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage) Window(net.minecraft.client.util.Window) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) MinecraftClient(net.minecraft.client.MinecraftClient) ControlValueFormatter(me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter) AttackIndicator(net.minecraft.client.options.AttackIndicator) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl) Window(net.minecraft.client.util.Window) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) VanillaBooleanOptionBinding(me.jellysquid.mods.sodium.client.gui.options.binding.compat.VanillaBooleanOptionBinding) ArrayList(java.util.ArrayList) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) MinecraftClient(net.minecraft.client.MinecraftClient) ParticlesOption(net.minecraft.client.options.ParticlesOption) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl)

Example 2 with SliderControl

use of me.jellysquid.mods.sodium.client.gui.options.control.SliderControl in project sodium-extra-fabric by FlashyReese.

the class SodiumExtraGameOptionPages method extra.

public static OptionPage extra() {
    List<OptionGroup> groups = new ArrayList<>();
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(boolean.class, vanillaOpts).setName(new TranslatableText("sodium-extra.option.gl_debug_verbosity")).setTooltip(new TranslatableText("sodium-extra.option.gl_debug_verbosity.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.glDebugVerbosity = value ? 1 : 0, options -> options.glDebugVerbosity == 1).build()).add(OptionImpl.createBuilder(boolean.class, SodiumExtraGameOptionPages.sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.use_fast_random")).setTooltip(new TranslatableText("sodium-extra.option.use_fast_random.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.extraSettings.useFastRandom = value, options -> options.extraSettings.useFastRandom).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.reduce_resolution_on_mac")).setTooltip(new TranslatableText("sodium-extra.option.reduce_resolution_on_mac.tooltip")).setEnabled(MinecraftClient.IS_SYSTEM_MAC).setImpact(OptionImpact.HIGH).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.extraSettings.reduceResolutionOnMac = value, opts -> opts.extraSettings.reduceResolutionOnMac).build()).build());
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(SodiumExtraGameOptions.OverlayCorner.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.overlay_corner")).setTooltip(new TranslatableText("sodium-extra.option.overlay_corner.tooltip")).setControl(option -> new CyclingControl<>(option, SodiumExtraGameOptions.OverlayCorner.class)).setBinding((opts, value) -> opts.extraSettings.overlayCorner = value, opts -> opts.extraSettings.overlayCorner).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.show_fps")).setTooltip(new TranslatableText("sodium-extra.option.show_fps.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.extraSettings.showFps = value, opts -> opts.extraSettings.showFps).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.show_fps_extended")).setTooltip(new TranslatableText("sodium-extra.option.show_fps_extended.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.extraSettings.showFPSExtended = value, opts -> opts.extraSettings.showFPSExtended).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.show_coordinates")).setTooltip(new TranslatableText("sodium-extra.option.show_coordinates.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.extraSettings.showCoords = value, opts -> opts.extraSettings.showCoords).build()).add(OptionImpl.createBuilder(int.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.cloud_height")).setTooltip(new TranslatableText("sodium-extra.option.cloud_height.tooltip")).setControl(option -> new SliderControl(option, -64, 319, 1, ControlValueFormatter.number())).setBinding((options, value) -> options.extraSettings.cloudHeight = value, options -> options.extraSettings.cloudHeight).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.toasts")).setTooltip(new TranslatableText("sodium-extra.option.toasts.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.extraSettings.toasts = value, options -> options.extraSettings.toasts).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.instant_sneak")).setTooltip(new TranslatableText("sodium-extra.option.instant_sneak.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.extraSettings.instantSneak = value, options -> options.extraSettings.instantSneak).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.prevent_shaders")).setTooltip(new TranslatableText("sodium-extra.option.prevent_shaders.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.extraSettings.preventShaders = value, options -> options.extraSettings.preventShaders).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).build());
    return new OptionPage(new TranslatableText("sodium-extra.option.extras"), ImmutableList.copyOf(groups));
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) SliderControlExtended(me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) MinecraftOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage) me.jellysquid.mods.sodium.client.gui.options(me.jellysquid.mods.sodium.client.gui.options) SodiumExtraOptionsStorage(me.flashyreese.mods.sodiumextra.client.gui.options.storage.SodiumExtraOptionsStorage) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ControlValueFormatterExtended(me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended) MinecraftClient(net.minecraft.client.MinecraftClient) ControlValueFormatter(me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl) ArrayList(java.util.ArrayList) TickBoxControl(me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl)

Example 3 with SliderControl

use of me.jellysquid.mods.sodium.client.gui.options.control.SliderControl in project Iris by IrisShaders.

the class IrisSodiumOptions method createMaxShadowDistanceSlider.

public static OptionImpl<Options, Integer> createMaxShadowDistanceSlider(MinecraftOptionsStorage vanillaOpts) {
    OptionImpl<Options, Integer> maxShadowDistanceSlider = OptionImpl.createBuilder(int.class, vanillaOpts).setName("Max Shadow Distance").setTooltip("The shadow render distance controls how far away terrain can potentially be rendered in the shadow pass. Lower distances mean that less terrain will be " + "rendered, improving frame rates. This option cannot be changed on packs which explicitly specify a shadow render distance. The actual shadow render distance is capped by the " + "View Distance setting.").setControl(option -> new SliderControl(option, 0, 32, 1, ControlValueFormatter.quantity("Chunks"))).setBinding((options, value) -> {
        IrisVideoSettings.shadowDistance = value;
        try {
            Iris.getIrisConfig().save();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }, options -> IrisVideoSettings.getOverriddenShadowDistance(IrisVideoSettings.shadowDistance)).setImpact(OptionImpact.HIGH).setEnabled(true).build();
    ((OptionImplExtended) maxShadowDistanceSlider).iris$dynamicallyEnable(IrisVideoSettings::isShadowDistanceSliderEnabled);
    return maxShadowDistanceSlider;
}
Also used : Iris(net.coderbot.iris.Iris) OptionFlag(me.jellysquid.mods.sodium.client.gui.options.OptionFlag) Options(net.minecraft.client.Options) OptionImpl(me.jellysquid.mods.sodium.client.gui.options.OptionImpl) MinecraftOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage) CyclingControl(me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl) IOException(java.io.IOException) ControlValueFormatter(me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter) IrisVideoSettings(net.coderbot.iris.gui.option.IrisVideoSettings) OptionImpact(me.jellysquid.mods.sodium.client.gui.options.OptionImpact) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl) Options(net.minecraft.client.Options) IrisVideoSettings(net.coderbot.iris.gui.option.IrisVideoSettings) IOException(java.io.IOException) SliderControl(me.jellysquid.mods.sodium.client.gui.options.control.SliderControl)

Aggregations

ControlValueFormatter (me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter)3 CyclingControl (me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl)3 SliderControl (me.jellysquid.mods.sodium.client.gui.options.control.SliderControl)3 MinecraftOptionsStorage (me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage)3 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 me.jellysquid.mods.sodium.client.gui.options (me.jellysquid.mods.sodium.client.gui.options)2 TickBoxControl (me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl)2 MinecraftClient (net.minecraft.client.MinecraftClient)2 IOException (java.io.IOException)1 SliderControlExtended (me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended)1 SodiumExtraOptionsStorage (me.flashyreese.mods.sodiumextra.client.gui.options.storage.SodiumExtraOptionsStorage)1 ControlValueFormatterExtended (me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended)1 OptionFlag (me.jellysquid.mods.sodium.client.gui.options.OptionFlag)1 OptionImpact (me.jellysquid.mods.sodium.client.gui.options.OptionImpact)1 OptionImpl (me.jellysquid.mods.sodium.client.gui.options.OptionImpl)1 VanillaBooleanOptionBinding (me.jellysquid.mods.sodium.client.gui.options.binding.compat.VanillaBooleanOptionBinding)1 SodiumOptionsStorage (me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage)1 GlVertexArray (me.jellysquid.mods.sodium.client.render.gl.GlVertexArray)1