From a651c8b71d2b30b0da3182de48a213ca94acae54 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Wed, 25 May 2022 21:44:31 +0700 Subject: TextHud --- .../java/cc/polyfrost/oneconfig/hud/TextHud.java | 27 ++++++++++++++++++++++ .../java/cc/polyfrost/oneconfig/test/TestHud.java | 20 ++++------------ 2 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java (limited to 'src/main/java/cc/polyfrost') diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java new file mode 100644 index 0000000..812ba50 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java @@ -0,0 +1,27 @@ +package cc.polyfrost.oneconfig.hud; + +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.lwjgl.RenderManager; + +public abstract class TextHud extends BasicHud { + public TextHud(boolean enabled, int x, int y) { + super(enabled, x, y); + } + + @Override + public int getWidth(float scale) { + return (int) (UMinecraft.getFontRenderer().getStringWidth(getText()) * scale); + } + + @Override + public int getHeight(float scale) { + return (int) (9 * scale); + } + + @Override + public void draw(int x, int y, float scale) { + RenderManager.drawScaledString(getText(), x, y, 0xffffff, false, scale); + } + + public abstract String getText(); +} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java index 7f1fb7f..d11340c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java @@ -1,27 +1,15 @@ package cc.polyfrost.oneconfig.test; -import cc.polyfrost.oneconfig.hud.BasicHud; -import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.hud.TextHud; import net.minecraft.client.Minecraft; -public class TestHud extends BasicHud { +public class TestHud extends TextHud { public TestHud(boolean enabled, int x, int y) { super(enabled, x, y); } @Override - public int getWidth(float scale) { - return (int) (UMinecraft.getFontRenderer().getStringWidth("FPS: " + Minecraft.getDebugFPS()) * scale); - } - - @Override - public int getHeight(float scale) { - return (int) (9 * scale); - } - - @Override - public void draw(int x, int y, float scale) { - RenderManager.drawScaledString("FPS: " + Minecraft.getDebugFPS(), x, y, 0xffffff, false, scale); + public String getText() { + return "FPS: " + Minecraft.getDebugFPS(); } } -- cgit