mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-27 15:43:02 +00:00
FPS pacer work (#2086)
This commit is contained in:
1 parent
6f054a09a9
commit
2845c9e078
44 files changed
+3304
-491
No files matched your search
@@ -19,6 +19,9 @@ import java.util.Locale;
|
||||
|
||||
public record FrameRateOptions(Option<VSyncMode> vsync, Option<Integer> maxFramerate) {
|
||||
|
||||
public static final int MIN_FRAMERATE = 5;
|
||||
public static final int MAX_FRAMERATE = 260;
|
||||
|
||||
public static FrameRateOptions create(MinecraftOptionsStorage vanillaOpts, SodiumOptionsStorage sodiumOpts) {
|
||||
final VSyncMode[] allowed = selectableModes();
|
||||
final String[] names = modeNames(VSyncMode.values());
|
||||
@@ -40,7 +43,7 @@ public record FrameRateOptions(Option<VSyncMode> vsync, Option<Integer> maxFrame
|
||||
final OptionImpl<GameSettings, Integer> maxFramerate = OptionImpl.createBuilder(int.class, vanillaOpts)
|
||||
.setName(I18n.format("options.framerateLimit"))
|
||||
.setTooltip(I18n.format("sodium.options.fps_limit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 5, 260, 1, ControlValueFormatter.fpsLimit()))
|
||||
.setControl(option -> new SliderControl(option, MIN_FRAMERATE, MAX_FRAMERATE, 1, ControlValueFormatter.fpsLimit()))
|
||||
.setBinding((opts, value) -> opts.limitFramerate = value, opts -> opts.limitFramerate)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.jellysquid.mods.sodium.client.gui;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -15,6 +16,7 @@ import com.cardinalstar.cubicchunks.api.compat.CubicChunksVideoSettings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.rendering.FpsReducer;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.MultiDrawModeResolver;
|
||||
import com.gtnewhorizons.angelica.rendering.culling.GpuCulling;
|
||||
import com.gtnewhorizons.angelica.config.GpuCullingMode;
|
||||
@@ -56,6 +58,13 @@ public class SodiumGameOptionPages {
|
||||
private static final int MIN_RENDER_AHEAD = 0;
|
||||
private static final int MAX_RENDER_AHEAD = 9;
|
||||
|
||||
private static <T> BiConsumer<SodiumGameOptions, T> reducerBinding(BiConsumer<SodiumGameOptions, T> setter) {
|
||||
return (opts, value) -> {
|
||||
setter.accept(opts, value);
|
||||
FpsReducer.markConfigChanged();
|
||||
};
|
||||
}
|
||||
|
||||
public static OptionPage general() {
|
||||
final List<OptionGroup> groups = new ArrayList<>();
|
||||
final OptionGroup.Builder firstGroupBuilder = OptionGroup.createBuilder();
|
||||
@@ -586,6 +595,91 @@ public class SodiumGameOptionPages {
|
||||
return new OptionPage(I18n.format("sodium.options.pages.performance"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
|
||||
public static OptionPage fpsReducer() {
|
||||
final List<OptionGroup> groups = new ArrayList<>();
|
||||
|
||||
final FrameRateOptions frameRate = FrameRateOptions.create(vanillaOpts, sodiumOpts);
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(frameRate.vsync())
|
||||
.add(frameRate.maxFramerate())
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.fps_reducer_enabled.name"))
|
||||
.setTooltip(I18n.format("sodium.options.fps_reducer_enabled.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.enabled = value),
|
||||
options -> options.reducer.enabled)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.unfocused_fps_limit.name"))
|
||||
.setTooltip(I18n.format("sodium.options.unfocused_fps_limit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, FrameRateOptions.MIN_FRAMERATE, FrameRateOptions.MAX_FRAMERATE, 1, ControlValueFormatter.fpsLimit()))
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.unfocusedFpsLimit = value),
|
||||
options -> options.reducer.unfocusedFpsLimit)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.unfocused_volume.name"))
|
||||
.setTooltip(I18n.format("sodium.options.unfocused_volume.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage()))
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.unfocusedVolume = value),
|
||||
options -> options.reducer.unfocusedVolume)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.minimized_volume.name"))
|
||||
.setTooltip(I18n.format("sodium.options.minimized_volume.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage()))
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.minimizedVolume = value),
|
||||
options -> options.reducer.minimizedVolume)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.idle_timeout.name"))
|
||||
.setTooltip(I18n.format("sodium.options.idle_timeout.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 0, 30, 1, ControlValueFormatter.quantityOrDisabled("sodium.options.idle_timeout.value", "sodium.options.idle_timeout.off")))
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.idleTimeoutMinutes = value),
|
||||
options -> options.reducer.idleTimeoutMinutes)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.idle_fps_limit.name"))
|
||||
.setTooltip(I18n.format("sodium.options.idle_fps_limit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, FrameRateOptions.MIN_FRAMERATE, FrameRateOptions.MAX_FRAMERATE, 1, ControlValueFormatter.fpsLimit()))
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.idleFpsLimit = value),
|
||||
options -> options.reducer.idleFpsLimit)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.idle_volume.name"))
|
||||
.setTooltip(I18n.format("sodium.options.idle_volume.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 0, 100, 1, ControlValueFormatter.percentage()))
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.idleVolume = value),
|
||||
options -> options.reducer.idleVolume)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.limit_menu_fps.name"))
|
||||
.setTooltip(I18n.format("sodium.options.limit_menu_fps.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding(reducerBinding((opts, value) -> opts.reducer.limitMenuFrameRate = value),
|
||||
options -> options.reducer.limitMenuFrameRate)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("sodium.options.pages.fps_reducer"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
|
||||
public static OptionImpl<GameSettings, Integer> anisotropicFilteringSlider(MinecraftOptionsStorage storage,
|
||||
Supplier<TextureFilterMode> mode, IntSupplier mipmapLevels) {
|
||||
final int min = SodiumGameOptions.minAnisotropyLevel();
|
||||
|
||||
@@ -38,6 +38,7 @@ public class SodiumGameOptions {
|
||||
public final QualitySettings quality = new QualitySettings();
|
||||
public final AdvancedSettings advanced = new AdvancedSettings();
|
||||
public final PerformanceSettings performance = new PerformanceSettings();
|
||||
public final ReducerSettings reducer = new ReducerSettings();
|
||||
private Path configPath;
|
||||
|
||||
public static void recordAtlasMipmapClamp(int requestedMipmapLevels, int actualMipmapLevels) {
|
||||
@@ -242,4 +243,15 @@ public class SodiumGameOptions {
|
||||
public boolean useCeleritasSmoothLighting = true;
|
||||
public TextureFilterMode textureFilterMode = TextureFilterMode.RGSS;
|
||||
}
|
||||
|
||||
public static class ReducerSettings {
|
||||
public boolean enabled = false;
|
||||
public int unfocusedFpsLimit = 10;
|
||||
public int unfocusedVolume = 100;
|
||||
public int minimizedVolume = 100;
|
||||
public int idleTimeoutMinutes = 5;
|
||||
public int idleFpsLimit = 30;
|
||||
public int idleVolume = 100;
|
||||
public boolean limitMenuFrameRate = true;
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ public class SodiumOptionsGUI extends ScrollableGuiScreen {
|
||||
this.pages.add(SodiumGameOptionPages.quality());
|
||||
this.pages.add(SodiumGameOptionPages.advanced());
|
||||
this.pages.add(SodiumGameOptionPages.performance());
|
||||
this.pages.add(SodiumGameOptionPages.fpsReducer());
|
||||
this.pages.add(SodiumGameOptionPages.appearance());
|
||||
this.pages.add(SodiumGameOptionPages.text());
|
||||
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gui.options.control;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.gui.FrameRateOptions;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -10,7 +11,7 @@ public interface ControlValueFormatter {
|
||||
}
|
||||
|
||||
static ControlValueFormatter fpsLimit() {
|
||||
return (v) -> (v == 260) ? I18n.format("options.framerateLimit.max") : I18n.format("options.framerate", v);
|
||||
return (v) -> (v == FrameRateOptions.MAX_FRAMERATE) ? I18n.format("options.framerateLimit.max") : I18n.format("options.framerate", v);
|
||||
}
|
||||
static ControlValueFormatter droppedItemLimitLimit() {
|
||||
return (v) -> (v == 2048) ? I18n.format("options.droppedItems.max") : I18n.format("options.droppedItems", v);
|
||||
|
||||
Reference in new issue
Block a user