diff options
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/hud/interfaces')
| -rw-r--r-- | src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java index 121c258..ebc5459 100644 --- a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java +++ b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java @@ -5,8 +5,9 @@ import io.polyfrost.oneconfig.renderer.Renderer; import java.awt.*; public abstract class BasicHud { - public int normalX; - public int normalY; + public double xUnscaled = 0; + public double yUnscaled = 0; + public float scale = 1; public int paddingX = 5; public int paddingY = 5; public boolean background = true; @@ -26,23 +27,37 @@ public abstract class BasicHud { return getHeight(scale); } - public void drawAll(int x, int y, float scale) { - drawBackGround(x, y, scale); - draw(x, y, scale); + public void drawAll(float x, float y, float scale) { + drawBackground(x, y, scale); + draw((int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale); } - public void drawExampleAll(int x, int y, float scale) { - drawBackGround(x, y, scale); - drawExample(x, y, scale); + public void drawExampleAll(float x, float y, float scale) { + drawBackground(x, y, scale); + drawExample((int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale); } public void drawExample(int x, int y, float scale) { draw(x, y, scale); } - private void drawBackGround(int x, int y, float scale) { - Renderer.drawRoundRect(x - paddingX * scale / 2f, y - paddingY * scale / 2f, - getWidth(scale) + paddingX * scale, getHeight(scale) + paddingY * scale, - (2 * scale), new Color(0, 0, 0, 100).getRGB()); + private void drawBackground(float x, float y, float scale) { + Renderer.drawRoundRect((int) x, (int) y, + (int) (getWidth(scale) + paddingX * scale), (int) (getHeight(scale) + paddingY * scale), + (int) (2 * scale), new Color(0, 0, 0, 120).getRGB()); + } + + public float getXScaled(int screenWidth) { + if (xUnscaled <= 0.5) { + return (int) (screenWidth * xUnscaled); + } + return (float) (screenWidth - (1d - xUnscaled) * screenWidth - (getWidth(scale) + paddingX * scale)); + } + + public float getYScaled(int screenHeight) { + if (yUnscaled <= 0.5) { + return (int) (screenHeight * yUnscaled); + } + return (float) (screenHeight - (1d - yUnscaled) * screenHeight - (getHeight(scale) + paddingY * scale)); } } |
