aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java27
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestHud.java20
2 files changed, 31 insertions, 16 deletions
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();
}
}