Search in sources :

Example 1 with SliderControlExtended

use of me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended in project sodium-extra-fabric by FlashyReese.

the class SodiumExtraGameOptionPages method render.

public static OptionPage render() {
    List<OptionGroup> groups = new ArrayList<>();
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(int.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.fog")).setTooltip(new TranslatableText("sodium-extra.option.fog.tooltip")).setControl(option -> new SliderControlExtended(option, 0, 33, 1, ControlValueFormatterExtended.fogDistance(), false)).setBinding((options, value) -> options.renderSettings.fogDistance = value, options -> options.renderSettings.fogDistance).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("sodium-extra.option.light_updates")).setTooltip(new TranslatableText("sodium-extra.option.light_updates.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.lightUpdates = value, options -> options.renderSettings.lightUpdates).build()).build());
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("entity.minecraft.item_frame")).setTooltip(new TranslatableText("sodium-extra.option.item_frames.tooltip")).setControl(TickBoxControl::new).setBinding((opts, value) -> opts.renderSettings.itemFrame = value, opts -> opts.renderSettings.itemFrame).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("entity.minecraft.armor_stand")).setTooltip(new TranslatableText("sodium-extra.option.armor_stands.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.armorStand = value, options -> options.renderSettings.armorStand).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("entity.minecraft.painting")).setTooltip(new TranslatableText("sodium-extra.option.paintings.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.painting = value, options -> options.renderSettings.painting).setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD).build()).add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts).setName(new TranslatableText("block.minecraft.piston")).setTooltip(new TranslatableText("sodium-extra.option.piston.tooltip")).setControl(TickBoxControl::new).setBinding((options, value) -> options.renderSettings.piston = value, options -> options.renderSettings.piston).build()).build());
    return new OptionPage(new TranslatableText("sodium-extra.option.render"), 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) SliderControlExtended(me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended)

Example 2 with SliderControlExtended

use of me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended in project sodium-extra-fabric by FlashyReese.

the class MixinSodiumGameOptionPages method general.

@Inject(method = "general", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup;createBuilder()Lme/jellysquid/mods/sodium/client/gui/options/OptionGroup$Builder;", ordinal = 1, shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILSOFT, remap = false)
private static void general(CallbackInfoReturnable<OptionPage> cir, List<OptionGroup> groups) {
    Window window = MinecraftClient.getInstance().getWindow();
    groups.add(OptionGroup.createBuilder().add(OptionImpl.createBuilder(int.class, vanillaOpts).setName(new TranslatableText("options.fullscreen.resolution")).setTooltip(new TranslatableText("sodium-extra.option.resolution.tooltip")).setControl(option -> new SliderControlExtended(option, 0, window.getMonitor() != null ? window.getMonitor().getVideoModeCount() : 0, 1, ControlValueFormatterExtended.resolution(), false)).setBinding((options, value) -> {
        if (window.getMonitor() != null) {
            if (value == 0) {
                window.setVideoMode(Optional.empty());
            } else {
                window.setVideoMode(Optional.of(window.getMonitor().getVideoMode(value - 1)));
            }
        }
    }, options -> {
        if (window.getMonitor() == null) {
            return 0;
        } else {
            Optional<VideoMode> optional = window.getVideoMode();
            return optional.map((videoMode) -> window.getMonitor().findClosestVideoModeIndex(videoMode) + 1).orElse(0);
        }
    }).setFlags(OptionFlag.REQUIRES_GAME_RESTART).setImpact(OptionImpact.HIGH).build()).build());
}
Also used : Window(net.minecraft.client.util.Window) TranslatableText(net.minecraft.text.TranslatableText) SliderControlExtended(me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended) SodiumGameOptionPages(me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages) MinecraftOptionsStorage(me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage) me.jellysquid.mods.sodium.client.gui.options(me.jellysquid.mods.sodium.client.gui.options) Inject(org.spongepowered.asm.mixin.injection.Inject) TranslatableText(net.minecraft.text.TranslatableText) VideoMode(net.minecraft.client.util.VideoMode) Final(org.spongepowered.asm.mixin.Final) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) Window(net.minecraft.client.util.Window) List(java.util.List) Mixin(org.spongepowered.asm.mixin.Mixin) ControlValueFormatterExtended(me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended) Shadow(org.spongepowered.asm.mixin.Shadow) Optional(java.util.Optional) MinecraftClient(net.minecraft.client.MinecraftClient) LocalCapture(org.spongepowered.asm.mixin.injection.callback.LocalCapture) At(org.spongepowered.asm.mixin.injection.At) SliderControlExtended(me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended) VideoMode(net.minecraft.client.util.VideoMode) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

List (java.util.List)2 SliderControlExtended (me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended)2 ControlValueFormatterExtended (me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended)2 me.jellysquid.mods.sodium.client.gui.options (me.jellysquid.mods.sodium.client.gui.options)2 MinecraftOptionsStorage (me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage)2 MinecraftClient (net.minecraft.client.MinecraftClient)2 TranslatableText (net.minecraft.text.TranslatableText)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 SodiumExtraOptionsStorage (me.flashyreese.mods.sodiumextra.client.gui.options.storage.SodiumExtraOptionsStorage)1 SodiumGameOptionPages (me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages)1 ControlValueFormatter (me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter)1 CyclingControl (me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl)1 SliderControl (me.jellysquid.mods.sodium.client.gui.options.control.SliderControl)1 TickBoxControl (me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl)1 VideoMode (net.minecraft.client.util.VideoMode)1 Window (net.minecraft.client.util.Window)1 Final (org.spongepowered.asm.mixin.Final)1 Mixin (org.spongepowered.asm.mixin.Mixin)1