Skip to content

Commit

Permalink
Only enable Fullscreen Resolution option on Windows
Browse files Browse the repository at this point in the history
Additionally, adjust the rendering of the controls
to be less confusing when disabled, and provide an
explanation as to what the option does.
  • Loading branch information
jellysquid3 committed Sep 15, 2024
1 parent 5d72634 commit 888d922
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mojang.blaze3d.platform.Monitor;
import com.mojang.blaze3d.platform.VideoMode;
import com.mojang.blaze3d.platform.Window;
import net.caffeinemc.mods.sodium.client.compatibility.environment.OsUtils;
import net.caffeinemc.mods.sodium.client.gl.arena.staging.MappedStagingBuffer;
import net.caffeinemc.mods.sodium.client.gl.device.RenderDevice;
import net.caffeinemc.mods.sodium.client.gui.options.*;
Expand Down Expand Up @@ -94,7 +95,7 @@ public static OptionPage general() {
.build())
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(Component.translatable("options.fullscreen.resolution"))
.setTooltip(Component.translatable("options.fullscreen.resolution"))
.setTooltip(Component.translatable("sodium.options.fullscreen_resolution.tooltip"))
.setControl(option -> new SliderControl(option, 0, null != monitor? monitor.getModeCount(): 0, 1, ControlValueFormatter.resolution()))
.setBinding((options, value) -> {
if (null != monitor) {
Expand All @@ -109,7 +110,7 @@ public static OptionPage general() {
return optional.map((videoMode) -> monitor.getVideoModeIndex(videoMode) + 1).orElse(0);
}
})
.setImpact(OptionImpact.HIGH)
.setEnabled(() -> OsUtils.getOs() == OsUtils.OperatingSystem.WIN && Minecraft.getInstance().getWindow().findBestMonitor() != null)
.setFlags(OptionFlag.REQUIRES_VIDEOMODE_RELOAD)
.build())
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.caffeinemc.mods.sodium.client.gui.options.control;

import com.mojang.blaze3d.platform.Monitor;
import net.caffeinemc.mods.sodium.client.compatibility.environment.OsUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;

Expand All @@ -10,9 +11,10 @@ static ControlValueFormatter guiScale() {
}

static ControlValueFormatter resolution() {
Monitor monitor = Minecraft.getInstance().getWindow().findBestMonitor();
return (v) -> {
if (null == monitor) {
Monitor monitor = Minecraft.getInstance().getWindow().findBestMonitor();

if (OsUtils.getOs() != OsUtils.OperatingSystem.WIN || monitor == null) {
return Component.translatable("options.fullscreen.unavailable");
} else if (0 == v) {
return Component.translatable("options.fullscreen.current");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import com.mojang.blaze3d.platform.InputConstants;
import net.caffeinemc.mods.sodium.client.gui.options.Option;
import net.caffeinemc.mods.sodium.client.util.Dim2i;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.util.Mth;
import org.apache.commons.lang3.Validate;

Expand Down Expand Up @@ -81,7 +82,15 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
int sliderWidth = this.sliderBounds.getWidth();
int sliderHeight = this.sliderBounds.getHeight();

Component label = this.formatter.format(this.option.getValue());
var label = this.formatter.format(this.option.getValue())
.copy();

if (!this.option.isAvailable()) {
label.setStyle(Style.EMPTY
.withColor(ChatFormatting.GRAY)
.withItalic(true));
}

int labelWidth = this.font.width(label);

boolean drawSlider = this.option.isAvailable() && (this.hovered || this.isFocused());
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/sodium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"sodium.options.brightness.tooltip": "Controls the minimum brightness in the world. When increased, darker areas of the world will appear brighter. This does not affect the brightness of already well-lit areas.",
"sodium.options.gui_scale.tooltip": "Sets the maximum scale factor to be used for the user interface. If \"auto\" is used, then the largest scale factor will always be used.",
"sodium.options.fullscreen.tooltip": "If enabled, the game will display in full-screen (if supported).",
"sodium.options.fullscreen_resolution.tooltip": "The monitor resolution and refresh rate to be used when in fullscreen mode. Changing this option may interfere with other applications and cause a delay when switching between applications.\n\nThis is only supported on the Windows operating system.",
"sodium.options.v_sync.tooltip": "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.",
"sodium.options.fps_limit.tooltip": "Limits the maximum number of frames per second. This can help reduce battery usage and system load when multi-tasking. If VSync is enabled, this option will be ignored unless it is lower than your display's refresh rate.",
"sodium.options.view_bobbing.tooltip": "If enabled, the player's view will sway and bob when moving around. Players who experience motion sickness while playing may benefit from disabling this.",
Expand Down

0 comments on commit 888d922

Please sign in to comment.