Skip to content

Commit

Permalink
Merge pull request #102 from LostLuma/debug-info
Browse files Browse the repository at this point in the history
Add information about reduced frame rate to debug screen
  • Loading branch information
LostLuma authored Sep 2, 2023
2 parents de50a9a + 78048b7 commit 1a720fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/main/java/dynamic_fps/impl/mixin/DebugScreenOverlayMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dynamic_fps.impl.mixin;

import java.util.List;
import java.util.Locale;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import dynamic_fps.impl.DynamicFPSMod;
import dynamic_fps.impl.PowerState;
import net.minecraft.client.gui.components.DebugScreenOverlay;

@Mixin(DebugScreenOverlay.class)
public class DebugScreenOverlayMixin {
/*
* Insert information about effective frame rate below misleading FPS counter.
*/
@Inject(method = "getGameInformation", at = @At("RETURN"))
private void onGetGameInformation(CallbackInfoReturnable<List<String>> callbackInfo) {
var status = DynamicFPSMod.powerState();

if (status != PowerState.FOCUSED) {
var result = callbackInfo.getReturnValue();
int target = DynamicFPSMod.targetFrameRate();

result.add(2, String.format(Locale.ROOT, "§c[Dynamic FPS] FPS: %s P: %s§r", target, status.toString().toLowerCase()));
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/dynamic_fps.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [],
"client": [
"DebugScreenOverlayMixin",
"GameRendererMixin",
"GuiMixin",
"LoadingOverlayMixin",
Expand Down

0 comments on commit 1a720fe

Please sign in to comment.