Search in sources :

Example 1 with Window

use of net.minecraft.client.util.Window in project jGui by ReplayMod.

the class MouseUtils method getMousePos.

public static Point getMousePos() {
    // #if MC>=11400
    int mouseX = (int) mc.mouse.getX();
    int mouseY = (int) mc.mouse.getY();
    Window mainWindow = MCVer.newScaledResolution(mc);
    mouseX = (int) Math.round((double) mouseX * mainWindow.getScaledWidth() / mainWindow.getWidth());
    mouseY = (int) Math.round((double) mouseY * mainWindow.getScaledHeight() / mainWindow.getHeight());
    return new Point(mouseX, mouseY);
}
Also used : Window(net.minecraft.client.util.Window) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point) Point(de.johni0702.minecraft.gui.utils.lwjgl.Point)

Example 2 with Window

use of net.minecraft.client.util.Window 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 3 with Window

use of net.minecraft.client.util.Window 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

Window (net.minecraft.client.util.Window)3 List (java.util.List)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 ImmutableList (com.google.common.collect.ImmutableList)1 Point (de.johni0702.minecraft.gui.utils.lwjgl.Point)1 ArrayList (java.util.ArrayList)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 VanillaBooleanOptionBinding (me.jellysquid.mods.sodium.client.gui.options.binding.compat.VanillaBooleanOptionBinding)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 SodiumOptionsStorage (me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage)1 GlVertexArray (me.jellysquid.mods.sodium.client.render.gl.GlVertexArray)1 AttackIndicator (net.minecraft.client.options.AttackIndicator)1