Skip to content

Commit

Permalink
Add option to display mock battery data for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Sep 8, 2024
1 parent ba8f848 commit 0032533
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public final class DynamicFPSConfig {
private BatteryTrackerConfig batteryTracker;
private VolumeTransitionConfig volumeTransitionSpeed;
private boolean downloadNatives;
private boolean mockBatteryData;

@SerializedName("states")
private Map<PowerState, Config> configs;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
"run_garbage_collector": false
}
},
"download_natives": true
"download_natives": true,
"mock_battery_data": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0032533

Please sign in to comment.