diff --git a/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java b/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java index 228711e9..76e7ac6a 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/compat/ClothConfig.java @@ -306,6 +306,16 @@ public static Screen genConfigScreen(Screen parent) { .build() ); + advanced.addEntry( + entryBuilder.startBooleanToggle( + localized("config", "mock_battery_data"), + config.mockBatteryData() + ) + .setDefaultValue(defaultConfig.mockBatteryData()) + .setSaveConsumer(config::setMockBatteryData) + .build() + ); + return builder.build(); } diff --git a/platforms/common/src/main/java/dynamic_fps/impl/config/DynamicFPSConfig.java b/platforms/common/src/main/java/dynamic_fps/impl/config/DynamicFPSConfig.java index d44c5c05..c7aa65a7 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/config/DynamicFPSConfig.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/config/DynamicFPSConfig.java @@ -12,6 +12,7 @@ public final class DynamicFPSConfig { private BatteryTrackerConfig batteryTracker; private VolumeTransitionConfig volumeTransitionSpeed; private boolean downloadNatives; + private boolean mockBatteryData; @SerializedName("states") private Map configs; @@ -72,6 +73,14 @@ public void setDownloadNatives(boolean value) { this.downloadNatives = value; } + public boolean mockBatteryData() { + return this.mockBatteryData; + } + + public void setMockBatteryData(boolean value) { + this.mockBatteryData = value; + } + public void save() { Serialization.save(); } diff --git a/platforms/common/src/main/java/dynamic_fps/impl/feature/battery/BatteryTracker.java b/platforms/common/src/main/java/dynamic_fps/impl/feature/battery/BatteryTracker.java index 483a6d5a..b4db3334 100644 --- a/platforms/common/src/main/java/dynamic_fps/impl/feature/battery/BatteryTracker.java +++ b/platforms/common/src/main/java/dynamic_fps/impl/feature/battery/BatteryTracker.java @@ -31,15 +31,27 @@ public class BatteryTracker { private static final Duration updateInterval = Duration.of(15, ChronoUnit.SECONDS); public static int charge() { - return charge; + if (DynamicFPSConfig.INSTANCE.mockBatteryData()) { + return 64; + } else { + return charge; + } } public static State status() { - return status; + if (DynamicFPSConfig.INSTANCE.mockBatteryData()) { + return State.CHARGING; + } else { + return status; + } } public static boolean hasBatteries() { - return !batteries.isEmpty(); + if (DynamicFPSConfig.INSTANCE.mockBatteryData()) { + return true; + } else { + return !batteries.isEmpty(); + } } public static void init() { diff --git a/platforms/common/src/main/resources/assets/dynamic_fps/data/default_config.json b/platforms/common/src/main/resources/assets/dynamic_fps/data/default_config.json index 3ba0b56c..36ccd02d 100644 --- a/platforms/common/src/main/resources/assets/dynamic_fps/data/default_config.json +++ b/platforms/common/src/main/resources/assets/dynamic_fps/data/default_config.json @@ -64,5 +64,6 @@ "run_garbage_collector": false } }, - "download_natives": true + "download_natives": true, + "mock_battery_data": false } diff --git a/platforms/common/src/main/resources/assets/dynamic_fps/lang/en_us.json b/platforms/common/src/main/resources/assets/dynamic_fps/lang/en_us.json index af528541..4ba7252e 100644 --- a/platforms/common/src/main/resources/assets/dynamic_fps/lang/en_us.json +++ b/platforms/common/src/main/resources/assets/dynamic_fps/lang/en_us.json @@ -79,6 +79,8 @@ "config.dynamic_fps.download_natives_description_0": "Using the battery features requires an additional library.", "config.dynamic_fps.download_natives_description_1": "Set whether the mod may download this component on your behalf.", + "config.dynamic_fps.mock_battery_data": "Use mock battery data", + "key.dynamic_fps.toggle_forced": "Force Unfocused Mode (Toggle)", "key.dynamic_fps.toggle_disabled": "Disable Dynamic FPS (Toggle)", "gui.dynamic_fps.hud.reducing": "Dynamic FPS: Forcing Reduced FPS",