diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-08-17 17:43:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-17 17:43:23 +0200 |
commit | 97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f (patch) | |
tree | 2bccc96007025fbccf1758ac66d4665a97d6c315 /versions | |
parent | e18629af6aee276b0be6cec473e4099cca9100f1 (diff) | |
download | OneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.tar.gz OneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.tar.bz2 OneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.zip |
Input revamp (#93)
* hud fix
* api
* things
* stuff
Diffstat (limited to 'versions')
8 files changed, 24 insertions, 6 deletions
diff --git a/versions/1.12.2-forge/api/1.12.2-forge.api b/versions/1.12.2-forge/api/1.12.2-forge.api index a948ea0..cba3f3b 100644 --- a/versions/1.12.2-forge/api/1.12.2-forge.api +++ b/versions/1.12.2-forge/api/1.12.2-forge.api @@ -129,5 +129,6 @@ public final class cc/polyfrost/oneconfig/utils/gui/GuiUtils { public static fun displayScreen (Lnet/minecraft/client/gui/GuiScreen;I)V public static fun getDeltaTime ()F public static fun getScreenQueue ()Ljava/util/Deque; + public static fun wasMouseDown ()Z } diff --git a/versions/1.16.2-fabric/api/1.16.2-fabric.api b/versions/1.16.2-fabric/api/1.16.2-fabric.api index 51e5d73..295d7c7 100644 --- a/versions/1.16.2-fabric/api/1.16.2-fabric.api +++ b/versions/1.16.2-fabric/api/1.16.2-fabric.api @@ -118,5 +118,6 @@ public final class cc/polyfrost/oneconfig/utils/gui/GuiUtils { public static fun displayScreen (Lnet/minecraft/client/gui/screen/Screen;I)V public static fun getDeltaTime ()F public static fun getScreenQueue ()Ljava/util/Deque; + public static fun wasMouseDown ()Z } diff --git a/versions/1.16.2-forge/api/1.16.2-forge.api b/versions/1.16.2-forge/api/1.16.2-forge.api index cbd559e..0a584e1 100644 --- a/versions/1.16.2-forge/api/1.16.2-forge.api +++ b/versions/1.16.2-forge/api/1.16.2-forge.api @@ -118,5 +118,6 @@ public final class cc/polyfrost/oneconfig/utils/gui/GuiUtils { public static fun displayScreen (Lnet/minecraft/client/gui/screen/Screen;I)V public static fun getDeltaTime ()F public static fun getScreenQueue ()Ljava/util/Deque; + public static fun wasMouseDown ()Z } diff --git a/versions/1.8.9-forge/api/1.8.9-forge.api b/versions/1.8.9-forge/api/1.8.9-forge.api index 44cd883..dddfb40 100644 --- a/versions/1.8.9-forge/api/1.8.9-forge.api +++ b/versions/1.8.9-forge/api/1.8.9-forge.api @@ -129,5 +129,6 @@ public final class cc/polyfrost/oneconfig/utils/gui/GuiUtils { public static fun displayScreen (Lnet/minecraft/client/gui/GuiScreen;I)V public static fun getDeltaTime ()F public static fun getScreenQueue ()Ljava/util/Deque; + public static fun wasMouseDown ()Z } diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java index ce5ab00..4d04f61 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java @@ -29,6 +29,7 @@ package cc.polyfrost.oneconfig.test; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.gui.pages.Page; import cc.polyfrost.oneconfig.internal.assets.SVGs; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import java.util.ArrayList; @@ -76,20 +77,20 @@ public class ButtonTestPage_Test extends Page { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, int x, int y, InputHandler inputHandler) { int buttonY = y + 16; for (BasicButton button : row1) { - button.draw(vg, x + 16, buttonY); + button.draw(vg, x + 16, buttonY, inputHandler); buttonY += 64; } buttonY = y + 16; for (BasicButton button : row2) { - button.draw(vg, x + 286, buttonY); + button.draw(vg, x + 286, buttonY, inputHandler); buttonY += 64; } buttonY = y + 16; for (BasicButton button : row3) { - button.draw(vg, x + 556, buttonY); + button.draw(vg, x + 556, buttonY, inputHandler); buttonY += 64; } } 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 index 8caa7d8..1af2f9e 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestKotlinNanoVGGui_Test.kt @@ -27,6 +27,7 @@ package cc.polyfrost.oneconfig.test import cc.polyfrost.oneconfig.renderer.font.Fonts +import cc.polyfrost.oneconfig.utils.InputHandler import cc.polyfrost.oneconfig.utils.dsl.* import cc.polyfrost.oneconfig.utils.gui.OneUIScreen import java.awt.Color @@ -41,7 +42,7 @@ import kotlin.system.measureTimeMillis */ class TestKotlinNanoVGGui_Test : OneUIScreen() { - override fun draw(vg: Long, partialTicks: Float) { + override fun draw(vg: Long, partialTicks: Float, inputHandler: InputHandler) { nanoVG(vg) { val millis = measureTimeMillis { drawRect(0f, 0f, 100f, 100f, Color.BLUE.rgb) 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 b62c166..315eed5 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 @@ -28,6 +28,7 @@ package cc.polyfrost.oneconfig.test; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.gui.OneUIScreen; import java.awt.*; @@ -42,7 +43,7 @@ import java.awt.*; public class TestNanoVGGui_Test extends OneUIScreen { @Override - public void draw(long vg, float partialTicks) { + public void draw(long vg, float partialTicks, InputHandler inputHandler) { long startTime = System.nanoTime(); RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java b/versions/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java index bda5b2f..96b5866 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java @@ -33,6 +33,7 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import cc.polyfrost.oneconfig.libs.universal.UScreen; +import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.utils.TickDelay; import net.minecraft.client.gui.GuiScreen; @@ -46,6 +47,7 @@ import java.util.concurrent.ConcurrentLinkedDeque; public final class GuiUtils { private static long time = -1L; private static long deltaTime = 17L; + private static boolean wasMouseDown = false; private static final Deque<Optional<GuiScreen>> screenQueue = new ConcurrentLinkedDeque<>(); static { @@ -112,6 +114,13 @@ public final class GuiUtils { return deltaTime; } + /** + * @return If the mouse was down last frame + */ + public static boolean wasMouseDown() { + return wasMouseDown; + } + @Subscribe private void onRenderEvent(RenderEvent event) { if (event.stage == Stage.START) { @@ -121,6 +130,8 @@ public final class GuiUtils { deltaTime = currentTime - time; time = currentTime; } + } else if (event.stage == Stage.END) { + wasMouseDown = Platform.getMousePlatform().isButtonDown(0); } } } |