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/test/TestBasicHud_Test.java | 23 +++++++++++ .../polyfrost/oneconfig/test/TestConfig_Test.java | 6 +++ .../cc/polyfrost/oneconfig/test/TestHud_Test.java | 2 +- .../oneconfig/test/TestKotlinNanoVGGui_Test.kt | 45 ++++++++++++++++++++++ .../oneconfig/test/TestMultilineHud_Test.java | 3 +- .../oneconfig/test/TestNanoVGGui_Test.java | 30 ++++++++------- 6 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestBasicHud_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt (limited to 'versions/src/main/java/cc/polyfrost/oneconfig/test') diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestBasicHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestBasicHud_Test.java new file mode 100644 index 0000000..805937f --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestBasicHud_Test.java @@ -0,0 +1,23 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.hud.BasicHud; +import cc.polyfrost.oneconfig.internal.assets.Images; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import cc.polyfrost.oneconfig.renderer.RenderManager; + +public class TestBasicHud_Test extends BasicHud { + @Override + protected void draw(UMatrixStack matrices, float x, float y, float scale, boolean example) { + RenderManager.setupAndDraw(true, vg -> RenderManager.drawImage(vg, Images.HUE_GRADIENT, x, y, 50 * scale, 50f * scale)); + } + + @Override + protected float getWidth(float scale, boolean example) { + return 50 * scale; + } + + @Override + protected float getHeight(float scale, boolean example) { + return 50 * scale; + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java index 772bba7..09b3fe5 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java @@ -126,6 +126,12 @@ public class TestConfig_Test extends Config { ) public TestMultilineHud_Test multilineHud = new TestMultilineHud_Test(); + @HUD( + name = "Test Basic HUD", + category = "HUD" + ) + public TestBasicHud_Test basicHud = new TestBasicHud_Test(); + public TestConfig_Test() { super(new Mod("Test Mod", ModType.UTIL_QOL, new VigilanceMigrator("./config/testConfig.toml")), "hacksConfig.json"); initialize(); diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java index ae557c7..4b380ca 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java @@ -15,7 +15,7 @@ public class TestHud_Test extends SingleTextHud { } @Override - public String getText() { + public String getText(boolean example) { times++; return String.valueOf(times); } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt new file mode 100644 index 0000000..fd6df6b --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt @@ -0,0 +1,45 @@ +package cc.polyfrost.oneconfig.test + +import cc.polyfrost.oneconfig.renderer.font.Fonts +import cc.polyfrost.oneconfig.utils.dsl.* +import cc.polyfrost.oneconfig.utils.gui.OneUIScreen +import java.awt.Color +import kotlin.system.measureTimeMillis + +/** + * A kotlinified version of [TestNanoVGGui_Test]. + * Uses OneConfig's Kotlin DSL to render instead of RenderManager + * + * @see nanoVG + * @see TestNanoVGGui_Test + */ +class TestKotlinNanoVGGui_Test : OneUIScreen() { + + override fun draw(vg: Long, partialTicks: Float) { + nanoVG(vg) { + val millis = measureTimeMillis { + drawRect(0f, 0f, 100f, 100f, Color.BLUE.rgb) + drawRoundedRect( + 305f, 305f, 100f, 100f, 8f, Color.YELLOW.rgb + ) + drawText( + "Hello!", 100f, 100f, Color.WHITE.rgb, 50f, Fonts.BOLD + ) + drawLine( + 0f, 0f, 100f, 100f, 7f, Color.PINK.rgb + ) + drawCircle( + 200f, 200f, 50f, Color.WHITE.rgb + ) + } + drawText( + millis.toString() + "ms", + 500f, + 500f, + Color.WHITE.rgb, + 100f, + Fonts.BOLD + ) + } + } +} \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java index 1665062..f71b01d 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java @@ -10,7 +10,8 @@ public class TestMultilineHud_Test extends TextHud { } @Override - protected void getLines(List lines) { + protected void getLines(List lines, boolean example) { lines.add(String.valueOf(System.currentTimeMillis())); + lines.add("HEY!"); } } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java index e8b6b91..4182bb6 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java @@ -2,25 +2,27 @@ package cc.polyfrost.oneconfig.test; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; -import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; -import cc.polyfrost.oneconfig.libs.universal.UScreen; -import org.jetbrains.annotations.NotNull; +import cc.polyfrost.oneconfig.utils.gui.OneUIScreen; import java.awt.*; -public class TestNanoVGGui_Test extends UScreen { +/** + * A GUI that uses RenderManager, NanoVG, and OneUIScreen to render a simple GUI. + * + * @see OneUIScreen + * @see TestKotlinNanoVGGui_Test + * @see RenderManager + */ +public class TestNanoVGGui_Test extends OneUIScreen { @Override - public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks); + public void draw(long vg, float partialTicks) { long startTime = System.nanoTime(); - RenderManager.setupAndDraw((vg) -> { - RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); - RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); - RenderManager.drawText(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); - RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB()); - RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB()); - RenderManager.drawText(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); - }); + RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); + RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); + RenderManager.drawText(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); + RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB()); + RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB()); + RenderManager.drawText(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); } } -- cgit