diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal/gui')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java | 81 |
1 files changed, 77 insertions, 4 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java index 6169896..ef5a25a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java @@ -30,14 +30,15 @@ import cc.polyfrost.oneconfig.gui.GuiPause; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.hud.Hud; import cc.polyfrost.oneconfig.hud.Position; -import cc.polyfrost.oneconfig.internal.hud.utils.GrabOffset; -import cc.polyfrost.oneconfig.internal.hud.utils.SnappingLine; import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; import cc.polyfrost.oneconfig.internal.hud.HudCore; +import cc.polyfrost.oneconfig.internal.hud.utils.GrabOffset; +import cc.polyfrost.oneconfig.internal.hud.utils.SnappingLine; import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; import cc.polyfrost.oneconfig.libs.universal.UResolution; import cc.polyfrost.oneconfig.libs.universal.UScreen; +import cc.polyfrost.oneconfig.renderer.AssetLoader; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.utils.MathUtils; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; @@ -45,8 +46,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; +import java.lang.reflect.Field; +import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; public class HudGui extends UScreen implements GuiPause { private static final int SNAPPING_DISTANCE = 10; @@ -155,6 +158,7 @@ public class HudGui extends UScreen implements GuiPause { } else if (keyCode == UKeyboard.KEY_RIGHT) { setHudPositions(1f, 0f, false); } + superSecretMethod(typedChar); super.onKeyPressed(keyCode, typedChar, modifiers); } @@ -292,4 +296,73 @@ public class HudGui extends UScreen implements GuiPause { } return lines; } + + private String superSecretString = ""; + + private void superSecretMethod(char charTyped) { + superSecretString += charTyped; + superSecretString = superSecretString.toLowerCase(); + if (!"blahaj".substring(0, superSecretString.length()).equals(superSecretString) + && !"blåhaj".substring(0, superSecretString.length()).equals(superSecretString) + && !"bigrat".substring(0, superSecretString.length()).equals(superSecretString)) { + superSecretString = ""; + return; + } else if (!"blahaj".equals(superSecretString) + && !"blåhaj".equals(superSecretString) + && !"bigrat".equals(superSecretString)) { + return; + } + String url; + switch (superSecretString) { + case "blahaj": + case "blåhaj": + url = "https://blahaj.shop/api/random/image?" + UUID.randomUUID(); + break; + case "bigrat": + url = "https://bigrat.monster/media/bigrat.png"; + break; + default: + return; + } + superSecretString = ""; + AtomicBoolean loaded = new AtomicBoolean(); + RenderManager.setupAndDraw((vg) -> loaded.set(AssetLoader.INSTANCE.loadImage(vg, url))); + if (!loaded.get()) return; + int w = AssetLoader.INSTANCE.getNVGImage(url).getWidth(); + int h = AssetLoader.INSTANCE.getNVGImage(url).getHeight(); + float s = Math.min(300f / w, 300f / h); + float width = w * s; + float height = h * s; + HudCore.huds.put(new Map.Entry<Field, Object>() { + @Override + public Field getKey() { + return null; + } + + @Override + public Object getValue() { + return null; + } + + @Override + public Object setValue(Object o) { + return null; + } + }, new Hud(true) { + @Override + protected void draw(UMatrixStack matrices, float x, float y, float scale, boolean example) { + RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawImage(vg, url, x, y, width * scale, height * scale)); + } + + @Override + protected float getWidth(float scale, boolean example) { + return width * scale; + } + + @Override + protected float getHeight(float scale, boolean example) { + return height * scale; + } + }); + } }
\ No newline at end of file |