aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-02 07:38:22 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-02 07:38:22 +0700
commita81bc67e90df2fddb8e2b8ad5ac6e13cf7c81032 (patch)
tree939ef5ca9e1911d3fa9186d3c7b8f2f9472952a5 /src/main/java
parent511269ba2d250893481cb55f84ae22cba9ba0dc6 (diff)
downloadOneConfig-a81bc67e90df2fddb8e2b8ad5ac6e13cf7c81032.tar.gz
OneConfig-a81bc67e90df2fddb8e2b8ad5ac6e13cf7c81032.tar.bz2
OneConfig-a81bc67e90df2fddb8e2b8ad5ac6e13cf7c81032.zip
pass a UMatrixStack in HUD API
From 1.17+, most matrix transformations can only be done with a MatrixStack instance, thus to prepare for a OneConfig 1.17+ port this has been done.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/events/event/HudRenderEvent.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/Hud.java17
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java2
5 files changed, 20 insertions, 15 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/events/event/HudRenderEvent.java b/src/main/java/cc/polyfrost/oneconfig/events/event/HudRenderEvent.java
index 465a2f6..41011aa 100644
--- a/src/main/java/cc/polyfrost/oneconfig/events/event/HudRenderEvent.java
+++ b/src/main/java/cc/polyfrost/oneconfig/events/event/HudRenderEvent.java
@@ -1,5 +1,7 @@
package cc.polyfrost.oneconfig.events.event;
+import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
+
/**
* Called when external HUDs can be rendered.
*/
@@ -8,8 +10,10 @@ public class HudRenderEvent {
* How much time has elapsed since the last tick, in ticks. Used for animations.
*/
public final float deltaTicks;
+ public final UMatrixStack matrices;
- public HudRenderEvent(float deltaTicks) {
+ public HudRenderEvent(UMatrixStack matrices, float deltaTicks) {
+ this.matrices = matrices;
this.deltaTicks = deltaTicks;
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
index 2c3e681..b45a1d8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
@@ -37,11 +37,11 @@ public class HudGui extends UScreen implements GuiPause {
}
for (Hud hud : HudCore.huds) {
- if (hud.enabled) processHud(hud, mouseX);
+ if (hud.enabled) processHud(matrixStack, hud, mouseX);
}
}
- private void processHud(Hud hud, int mouseX) {
+ private void processHud(UMatrixStack matrixStack, Hud hud, int mouseX) {
if (hud == editingHud && isScaling) {
float xFloat = hud.getXScaled(UResolution.getScaledWidth());
float yFloat = hud.getYScaled(UResolution.getScaledHeight());
@@ -65,7 +65,7 @@ public class HudGui extends UScreen implements GuiPause {
int x = (int) hud.getXScaled(UResolution.getScaledWidth());
int y = (int) hud.getYScaled(UResolution.getScaledHeight());
- hud.drawExampleAll(x, y, hud.scale, true);
+ hud.drawExampleAll(matrixStack, x, y, hud.scale, true);
int color = new Color(215, 224, 235).getRGB();
if (editingHud == hud) {
color = new Color(43, 159, 235).getRGB();
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/Hud.java b/src/main/java/cc/polyfrost/oneconfig/hud/Hud.java
index 9c9a005..982bee9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/hud/Hud.java
+++ b/src/main/java/cc/polyfrost/oneconfig/hud/Hud.java
@@ -4,6 +4,7 @@ import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.annotations.Switch;
import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
+import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
@@ -14,7 +15,7 @@ import cc.polyfrost.oneconfig.renderer.RenderManager;
* If you simply want to display text, extend {@link TextHud} or {@link SingleTextHud},
* whichever applies to the use case. Then, override the required methods.
* <p>
- * If you want to display something else, extend this class and override {@link Hud#getWidth(float)}, {@link Hud#getHeight(float)}, and {@link Hud#draw(int, int, float)} with the width, height, and the drawing code respectively.
+ * If you want to display something else, extend this class and override {@link Hud#getWidth(float)}, {@link Hud#getHeight(float)}, and {@link Hud#draw(UMatrixStack, int, int, float)} with the width, height, and the drawing code respectively.
* </p>
* <p>
* It should also be noted that additional options to the HUD can be added simply by declaring them.
@@ -115,7 +116,7 @@ public abstract class Hud {
* @param y Top left y-coordinate of the hud
* @param scale Scale of the hud
*/
- public abstract void draw(int x, int y, float scale);
+ public abstract void draw(UMatrixStack matrices, int x, int y, float scale);
/**
* Function called when drawing the example version of the hud.
@@ -125,8 +126,8 @@ public abstract class Hud {
* @param y Top left y-coordinate of the hud
* @param scale Scale of the hud
*/
- public void drawExample(int x, int y, float scale) {
- draw(x, y, scale);
+ public void drawExample(UMatrixStack matrices, int x, int y, float scale) {
+ draw(matrices, x, y, scale);
}
/**
@@ -172,12 +173,12 @@ public abstract class Hud {
* @param scale Scale of the hud
* @param background If background should be drawn or not
*/
- public void drawAll(float x, float y, float scale, boolean background) {
+ public void drawAll(UMatrixStack matrices, float x, float y, float scale, boolean background) {
if (!showInGuis && Platform.getGuiPlatform().getCurrentScreen() != null && !(Platform.getGuiPlatform().getCurrentScreen() instanceof OneConfigGui)) return;
if (!showInChat && Platform.getGuiPlatform().isInChat()) return;
if (!showInDebug && Platform.getGuiPlatform().isInDebug()) return;
if (background && drawBackground()) drawBackground(x, y, getWidth(scale), getHeight(scale), scale);
- draw((int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale);
+ draw(matrices, (int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale);
}
/**
@@ -188,9 +189,9 @@ public abstract class Hud {
* @param scale Scale of the hud
* @param background If background should be drawn or not
*/
- public void drawExampleAll(float x, float y, float scale, boolean background) {
+ public void drawExampleAll(UMatrixStack matrices, float x, float y, float scale, boolean background) {
if (background) drawBackground(x, y, getWidth(scale), getHeight(scale), scale);
- drawExample((int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale);
+ drawExample(matrices, (int) (x + paddingX * scale / 2f), (int) (y + paddingY * scale / 2f), scale);
}
/**
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java
index 3b74c4c..381e0a8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java
+++ b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java
@@ -8,7 +8,7 @@ import cc.polyfrost.oneconfig.events.event.Stage;
import cc.polyfrost.oneconfig.events.event.TickEvent;
import cc.polyfrost.oneconfig.internal.hud.HudCore;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
-import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
+import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
@@ -75,7 +75,7 @@ public abstract class TextHud extends Hud {
}
@Override
- public void draw(int x, int y, float scale) {
+ public void draw(UMatrixStack matrices, int x, int y, float scale) {
if (!HudCore.editing) getLinesFrequent(lines);
else getExampleLinesFrequent(lines);
if (lines == null) return;
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
index 7912ec5..2bbd3b7 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
@@ -16,7 +16,7 @@ public class HudCore {
if (editing) return;
for (Hud hud : huds) {
if (hud.enabled)
- hud.drawAll(hud.getXScaled(UResolution.getScaledWidth()), hud.getYScaled(UResolution.getScaledHeight()), hud.scale, true);
+ hud.drawAll(event.matrices, hud.getXScaled(UResolution.getScaledWidth()), hud.getYScaled(UResolution.getScaledHeight()), hud.scale, true);
}
}
}