aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-04-04 14:51:34 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-04-04 14:51:34 +0200
commit1210e38c2ff569a28b20d7d0182557fbf386d524 (patch)
treefe1a32fd752a484eeaced6c7ee58fdaad159b412 /src/main
parentfe04136d705ca5f946ee8353c7f7c67e284c9ca5 (diff)
downloadOneConfig-1210e38c2ff569a28b20d7d0182557fbf386d524.tar.gz
OneConfig-1210e38c2ff569a28b20d7d0182557fbf386d524.tar.bz2
OneConfig-1210e38c2ff569a28b20d7d0182557fbf386d524.zip
temp
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java13
-rw-r--r--src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java33
2 files changed, 38 insertions, 8 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java b/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
index 262e36d..6e1ce6c 100644
--- a/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/hud/gui/HudGui.java
@@ -3,6 +3,7 @@ package io.polyfrost.oneconfig.hud.gui;
import io.polyfrost.oneconfig.hud.HudCore;
import io.polyfrost.oneconfig.hud.interfaces.BasicHud;
import io.polyfrost.oneconfig.renderer.Renderer;
+import io.polyfrost.oneconfig.test.TestHud;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
@@ -20,13 +21,15 @@ public class HudGui extends GuiScreen {
private boolean isScaling;
private int xOffset;
private int yOffset;
- private boolean wereKeypressesEnabled;
@Override
public void initGui() {
HudCore.editing = true;
- wereKeypressesEnabled = Keyboard.areRepeatEventsEnabled();
Keyboard.enableRepeatEvents(true);
+ for (BasicHud hud : HudCore.huds) {
+ hud.childRight = new TestHud();
+ hud.childRight.parent = hud;
+ }
}
@Override
@@ -56,8 +59,8 @@ public class HudGui extends GuiScreen {
editingHud.yUnscaled = (yFloat + (hud.getHeight(hud.scale) + hud.paddingY * hud.scale)) / (double) this.height;
}
- int width = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale);
- int height = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale);
+ int width = (int) (hud.getTotalWidth(hud.scale) + hud.paddingX * hud.scale);
+ int height = (int) (hud.getTotalHeight(hud.scale) + hud.paddingY * hud.scale);
int x = (int) hud.getXScaled(this.width);
int y = (int) hud.getYScaled(this.height);
@@ -232,7 +235,7 @@ public class HudGui extends GuiScreen {
@Override
public void onGuiClosed() {
HudCore.editing = false;
- Keyboard.enableRepeatEvents(wereKeypressesEnabled);
+ Keyboard.enableRepeatEvents(false);
}
@Override
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 ebc5459..723a09e 100644
--- a/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java
+++ b/src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java
@@ -12,6 +12,11 @@ public abstract class BasicHud {
public int paddingY = 5;
public boolean background = true;
public boolean rounded = false;
+ public BasicHud childLeft;
+ public BasicHud childRight;
+ public BasicHud childBottom;
+ public BasicHud childTop;
+ public BasicHud parent;
public abstract int getWidth(float scale);
@@ -28,13 +33,21 @@ public abstract class BasicHud {
}
public void drawAll(float x, float y, float scale) {
- drawBackground(x, y, scale);
+ if (parent == null) drawBackground(x, y, scale);
draw((int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale);
+ if (childLeft != null)
+ childLeft.drawAll((int) (x + paddingX * scale / 2f) - childRight.getWidth(scale), (int) (y + paddingY * scale / 2f), scale);
+ if (childRight != null)
+ childRight.drawAll((int) (x + paddingX * scale / 2f) + getWidth(scale), (int) (y + paddingY * scale / 2f), scale);
}
public void drawExampleAll(float x, float y, float scale) {
- drawBackground(x, y, scale);
+ if (parent == null) drawBackground(x, y, scale);
drawExample((int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale);
+ if (childLeft != null)
+ childLeft.drawExampleAll((int) (x + paddingX * scale / 2f) - childRight.getWidth(scale), (int) (y + paddingY * scale / 2f), scale);
+ if (childRight != null)
+ childRight.drawExampleAll((int) (x + paddingX * scale / 2f) + getWidth(scale), (int) (y + paddingY * scale / 2f), scale);
}
public void drawExample(int x, int y, float scale) {
@@ -43,7 +56,7 @@ public abstract class BasicHud {
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) (getTotalWidth(scale) + paddingX * scale), (int) (getTotalHeight(scale) + paddingY * scale),
(int) (2 * scale), new Color(0, 0, 0, 120).getRGB());
}
@@ -60,4 +73,18 @@ public abstract class BasicHud {
}
return (float) (screenHeight - (1d - yUnscaled) * screenHeight - (getHeight(scale) + paddingY * scale));
}
+
+ public int getTotalWidth(float scale) {
+ int width = getWidth(scale);
+ if (childLeft != null) width += childLeft.getWidth(scale);
+ if (childRight != null) width += childRight.getWidth(scale);
+ return width;
+ }
+
+ public int getTotalHeight(float scale) {
+ int height = getHeight(scale);
+ if (childBottom != null) height += childBottom.getHeight(scale);
+ if (childTop != null) height += childTop.getHeight(scale);
+ return height;
+ }
}