From f06946c01b2c8f210b398a16610c260eca093a8b Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Thu, 21 Jul 2022 04:04:48 +0900 Subject: HUD Improvements, 1.16 port, fix NanoVG with ARM (#52) * egg 1 * separate Hud from background stuff * 1984 This reverts commit 9ae517d57bbd495d30d35cb1cbfe81a03556e6bd. * hitboxes woo!!!!! * Revert "hitboxes woo!!!!!" This reverts commit 405d32d17df3c83f2e79eddf0de853f7279767a6. * padding * allow position to go slightly off the screen * stop using ints for ABSOLUTELY EVERYTHING, DIAMOND ... fix vigilance compat not setting color * start on new pos system * some stuff * finish new position system * api momento * 1.16.2 fabric port * start on hud gui * temp remove 1.16.2 fabric since it doesn't compile * fix fabric build * hud gui stuff * apiDump * fix fabric build 2 * so true * selecting stuff * scaling + other small things * More protecting * fix nanovg not working with macOS ARM move OneConfig.preLaunch to OneConfigInit * clean up OneUIScreen make kotlin version of TestNanoVGGui * make keybinds have runnable by default * rollback keybind things * merge master into hud-improvements (#55) * Release workflow (#53) * release workflow * update normal version to hash * fix * fix naming * fix some stuff * fix version thing * switch to number from hash * Release workflow (#54) * release workflow * update normal version to hash * fix * fix naming * fix some stuff * fix version thing * switch to number from hash * Maybe epic fixo * gotta love those Java principles * Revert "gotta love those Java principles", wrong branch This reverts commit 333d8b2ad8941790c13c4bfe0777fbd203d463e5. * start on snapping * Finish snapping * stop including mixin by default on legacy versions this breaks builds if the mod itself does not use mixin * merge draw and drawExample * fix gradle publish * Some fixes * Api DUmpidy * Help subcommand impovments (#59) * Made the overall look of the "help" subcommand better + added the ability to change the colour for the command overall + each individual SubCommand * Made the alliases show batter + added support for to show subcommand aliasses * mr deliverer didnt reply but whatever, added a space between command/subcommand and alliasses Co-authored-by: pinkulu * fix file not overwriting toJavaColor * Fix full shadow not scaling correctly Co-authored-by: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Co-authored-by: nxtdaydelivery <12willettsh@gmail.com> Co-authored-by: pinkulu <56201697+pinkulu@users.noreply.github.com> Co-authored-by: pinkulu --- .../oneconfig/renderer/RenderManager.java | 28 ++++------------------ .../polyfrost/oneconfig/renderer/TextRenderer.java | 4 ++-- .../oneconfig/renderer/scissor/Scissor.java | 2 +- 3 files changed, 8 insertions(+), 26 deletions(-) (limited to 'src/main/java/cc/polyfrost/oneconfig/renderer') diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java index 93c3c94..5f8ea11 100644 --- a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java @@ -7,6 +7,7 @@ import cc.polyfrost.oneconfig.internal.assets.Images; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.libs.universal.UGraphics; import cc.polyfrost.oneconfig.libs.universal.UResolution; +import cc.polyfrost.oneconfig.platform.NanoVGPlatform; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.font.Font; import cc.polyfrost.oneconfig.renderer.font.FontManager; @@ -14,7 +15,6 @@ import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.NetworkUtils; import org.lwjgl.nanovg.NVGColor; import org.lwjgl.nanovg.NVGPaint; -import org.lwjgl.nanovg.NanoVGGL2; import org.lwjgl.opengl.GL11; import java.util.function.LongConsumer; @@ -52,7 +52,7 @@ public final class RenderManager { */ public static void setupAndDraw(boolean mcScaling, LongConsumer consumer) { if (vg == -1) { - vg = NanoVGGL2.nvgCreate(NanoVGGL2.NVG_ANTIALIAS); + vg = Platform.getNanoVGPlatform().nvgCreate(NanoVGPlatform.NVG_ANTIALIAS); if (vg == -1) { throw new RuntimeException("Failed to create nvg context"); } @@ -76,24 +76,6 @@ public final class RenderManager { GL11.glPopAttrib(); } - /** - * Draws a rectangle with the given parameters. - * - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. - * @param color The color. - */ - public static void drawRectangle(long vg, float x, float y, float width, float height, int color) { // TODO make everything use this one day - if (Colors.ROUNDED_CORNERS) { - drawRoundedRect(vg, x, y, width, height, color, Colors.CORNER_RADIUS); - } else { - drawRect(vg, x, y, width, height, color); - } - } - /** * Draws a rectangle with the given parameters. * @@ -330,12 +312,12 @@ public final class RenderManager { *

This does NOT scale to Minecraft's GUI scale!

* * @see RenderManager#drawText(long, String, float, float, int, float, Font) - * @see InputUtils#isAreaClicked(int, int, int, int) + * @see InputUtils#isAreaClicked(float, float, float, float) */ public static void drawURL(long vg, String url, float x, float y, float size, Font font) { drawText(vg, url, x, y, Colors.PRIMARY_500, size, font); float length = getTextWidth(vg, url, size, font); - drawRectangle(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500); + drawRect(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500); if (InputUtils.isAreaClicked((int) (x - 2), (int) (y - 1), (int) (length + 4), (int) (size / 2 + 3))) { NetworkUtils.browseLink(url); } @@ -723,7 +705,7 @@ public final class RenderManager { Platform.getGLPlatform().drawText(text, x * (1 / scale), y * (1 / scale), color, true); break; case FULL: - drawBorderedText(text, x, y, color, 100); + drawBorderedText(text, x * (1 / scale), y * (1 / scale), color, 100); break; } UGraphics.GL.popMatrix(); diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java b/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java index 95071d1..ed77942 100644 --- a/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java +++ b/src/main/java/cc/polyfrost/oneconfig/renderer/TextRenderer.java @@ -122,12 +122,12 @@ public class TextRenderer { *

This does NOT scale to Minecraft's GUI scale!

* * @see RenderManager#drawText(long, String, float, float, int, float, Font) - * @see InputUtils#isAreaClicked(int, int, int, int) + * @see InputUtils#isAreaClicked(float, float, float, float) */ public static void drawURL(long vg, String url, float x, float y, float size, Font font) { drawText(vg, url, x, y, Colors.PRIMARY_500, size, font); float length = getTextWidth(vg, url, size, font); - RenderManager.drawRectangle(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500); + RenderManager.drawRect(vg, x, y + size / 2, length, 1, Colors.PRIMARY_500); if (InputUtils.isAreaClicked((int) (x - 2), (int) (y - 1), (int) (length + 4), (int) (size / 2 + 3))) { NetworkUtils.browseLink(url); } diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java b/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java index 62854ef..7ced323 100644 --- a/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java +++ b/src/main/java/cc/polyfrost/oneconfig/renderer/scissor/Scissor.java @@ -25,7 +25,7 @@ public class Scissor { this.height = scissor.height; } - public boolean isInScissor(int x, int y) { + public boolean isInScissor(float x, float y) { return x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height; } } -- cgit