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());
}
Aggregations