Search in sources :

Example 1 with VideoMode

use of net.minecraft.client.util.VideoMode 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)1 Optional (java.util.Optional)1 SliderControlExtended (me.flashyreese.mods.sodiumextra.client.gui.options.control.SliderControlExtended)1 ControlValueFormatterExtended (me.flashyreese.mods.sodiumextra.common.util.ControlValueFormatterExtended)1 SodiumGameOptionPages (me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages)1 me.jellysquid.mods.sodium.client.gui.options (me.jellysquid.mods.sodium.client.gui.options)1 MinecraftOptionsStorage (me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 VideoMode (net.minecraft.client.util.VideoMode)1 Window (net.minecraft.client.util.Window)1 TranslatableText (net.minecraft.text.TranslatableText)1 Final (org.spongepowered.asm.mixin.Final)1 Mixin (org.spongepowered.asm.mixin.Mixin)1 Shadow (org.spongepowered.asm.mixin.Shadow)1 At (org.spongepowered.asm.mixin.injection.At)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 CallbackInfoReturnable (org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable)1 LocalCapture (org.spongepowered.asm.mixin.injection.callback.LocalCapture)1