Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,21 @@ public static OptionPage general() {
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(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()))
// the max value of 1 when the monitor is not available prevents an exception from being thrown
.setControl(option -> new SliderControl(option, 0, null != monitor ? monitor.getModeCount() : 1, 1, ControlValueFormatter.resolution()))
.setBinding((options, value) -> {
if (null != monitor) {
window.setPreferredFullscreenVideoMode(0 == value? Optional.empty(): Optional.of(monitor.getMode(value - 1)));
window.setPreferredFullscreenVideoMode(0 == value ? Optional.empty() : Optional.of(monitor.getMode(value - 1)));
}
}, options -> {
if (null == monitor) {
return 0;
}
else {
} else {
Optional<VideoMode> optional = window.getPreferredFullscreenVideoMode();
return optional.map((videoMode) -> monitor.getVideoModeIndex(videoMode) + 1).orElse(0);
}
})
.setEnabled(() -> OsUtils.getOs() == OsUtils.OperatingSystem.WIN && Minecraft.getInstance().getWindow().findBestMonitor() != null)
.setEnabled(() -> monitor != null && monitor.getModeCount() > 0 && OsUtils.getOs() == OsUtils.OperatingSystem.WIN)
.setFlags(OptionFlag.REQUIRES_VIDEOMODE_RELOAD)
.build())
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static ControlValueFormatter resolution() {
return (v) -> {
Monitor monitor = Minecraft.getInstance().getWindow().findBestMonitor();

if (OsUtils.getOs() != OsUtils.OperatingSystem.WIN || monitor == null) {
if (monitor == null || OsUtils.getOs() != OsUtils.OperatingSystem.WIN) {
return Component.translatable("options.fullscreen.unavailable");
} else if (0 == v) {
return Component.translatable("options.fullscreen.current");
Expand Down