From 97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Wed, 17 Aug 2022 17:43:23 +0200 Subject: Input revamp (#93) * hud fix * api * things * stuff --- .../main/java/cc/polyfrost/oneconfig/utils/gui/GuiUtils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'versions/src/main/java/cc/polyfrost/oneconfig/utils/gui') 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> 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); } } } -- cgit