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 --- api/OneConfig.api | 124 ++++++------ .../oneconfig/config/elements/BasicOption.java | 5 +- .../config/elements/OptionSubcategory.java | 17 +- .../cc/polyfrost/oneconfig/gui/OneConfigGui.java | 37 ++-- .../java/cc/polyfrost/oneconfig/gui/SideBar.java | 25 +-- .../oneconfig/gui/elements/BasicButton.java | 5 +- .../oneconfig/gui/elements/BasicElement.java | 16 +- .../oneconfig/gui/elements/ColorSelector.java | 80 ++++---- .../polyfrost/oneconfig/gui/elements/ModCard.java | 12 +- .../polyfrost/oneconfig/gui/elements/Slider.java | 18 +- .../gui/elements/config/ConfigButton.java | 5 +- .../gui/elements/config/ConfigCheckbox.java | 8 +- .../gui/elements/config/ConfigColorElement.java | 12 +- .../gui/elements/config/ConfigDropdown.java | 36 ++-- .../gui/elements/config/ConfigDualOption.java | 10 +- .../gui/elements/config/ConfigHeader.java | 3 +- .../oneconfig/gui/elements/config/ConfigInfo.java | 3 +- .../gui/elements/config/ConfigKeyBind.java | 5 +- .../gui/elements/config/ConfigPageButton.java | 8 +- .../gui/elements/config/ConfigSlider.java | 12 +- .../gui/elements/config/ConfigSwitch.java | 8 +- .../gui/elements/config/ConfigTextBox.java | 10 +- .../gui/elements/text/NumberInputField.java | 15 +- .../gui/elements/text/TextInputField.java | 26 +-- .../polyfrost/oneconfig/gui/pages/CreditsPage.java | 3 +- .../cc/polyfrost/oneconfig/gui/pages/HomePage.java | 5 +- .../oneconfig/gui/pages/ModConfigPage.java | 12 +- .../cc/polyfrost/oneconfig/gui/pages/ModsPage.java | 9 +- .../cc/polyfrost/oneconfig/gui/pages/Page.java | 28 +-- .../internal/command/OneConfigCommand.java | 4 +- .../oneconfig/renderer/RenderManager.java | 8 +- .../polyfrost/oneconfig/renderer/TextRenderer.java | 8 +- .../cc/polyfrost/oneconfig/utils/InputHandler.java | 215 +++++++++++++++++++++ .../cc/polyfrost/oneconfig/utils/InputUtils.java | 195 ------------------- .../cc/polyfrost/oneconfig/utils/gui/GuiUtils.java | 10 + .../polyfrost/oneconfig/utils/gui/OneUIScreen.java | 97 +++------- .../oneconfig/utils/dsl/RenderManagerDSL.kt | 8 +- versions/1.12.2-forge/api/1.12.2-forge.api | 1 + versions/1.16.2-fabric/api/1.16.2-fabric.api | 1 + versions/1.16.2-forge/api/1.16.2-forge.api | 1 + versions/1.8.9-forge/api/1.8.9-forge.api | 1 + .../oneconfig/test/ButtonTestPage_Test.java | 9 +- .../oneconfig/test/TestKotlinNanoVGGui_Test.kt | 3 +- .../oneconfig/test/TestNanoVGGui_Test.java | 3 +- .../cc/polyfrost/oneconfig/utils/gui/GuiUtils.java | 11 ++ 45 files changed, 571 insertions(+), 561 deletions(-) create mode 100644 src/main/java/cc/polyfrost/oneconfig/utils/InputHandler.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java diff --git a/api/OneConfig.api b/api/OneConfig.api index 751ba76..c59b18e 100644 --- a/api/OneConfig.api +++ b/api/OneConfig.api @@ -292,8 +292,8 @@ public abstract class cc/polyfrost/oneconfig/config/elements/BasicOption { public fun addDependency (Ljava/util/function/Supplier;)V public fun addHideCondition (Ljava/util/function/Supplier;)V public fun addListener (Ljava/lang/Runnable;)V - public abstract fun draw (JII)V - public fun drawLast (JII)V + public abstract fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V + public fun drawLast (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun get ()Ljava/lang/Object; public fun getField ()Ljava/lang/reflect/Field; public abstract fun getHeight ()I @@ -325,8 +325,8 @@ public class cc/polyfrost/oneconfig/config/elements/OptionSubcategory { public field options Ljava/util/ArrayList; public field topButtons Ljava/util/ArrayList; public fun (Ljava/lang/String;)V - public fun draw (JII)I - public fun drawLast (JI)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)I + public fun drawLast (JILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getName ()Ljava/lang/String; public fun reset (Lcc/polyfrost/oneconfig/config/Config;)V } @@ -522,7 +522,7 @@ public class cc/polyfrost/oneconfig/gui/OneConfigGui : cc/polyfrost/oneconfig/li public class cc/polyfrost/oneconfig/gui/SideBar { public fun ()V - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun pageOpened (Ljava/lang/String;)V } @@ -598,7 +598,7 @@ public class cc/polyfrost/oneconfig/gui/elements/BasicButton : cc/polyfrost/onec public fun (IILcc/polyfrost/oneconfig/renderer/SVG;ILcc/polyfrost/oneconfig/utils/color/ColorPalette;)V public fun (IILjava/lang/String;ILcc/polyfrost/oneconfig/utils/color/ColorPalette;)V public fun (IILjava/lang/String;Lcc/polyfrost/oneconfig/renderer/SVG;Lcc/polyfrost/oneconfig/renderer/SVG;ILcc/polyfrost/oneconfig/utils/color/ColorPalette;)V - public fun draw (JFF)V + public fun draw (JFFLcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getPage ()Lcc/polyfrost/oneconfig/gui/pages/Page; public fun getText ()Ljava/lang/String; public fun hasClickAction ()Z @@ -631,7 +631,7 @@ public class cc/polyfrost/oneconfig/gui/elements/BasicElement { public fun (IILcc/polyfrost/oneconfig/utils/color/ColorPalette;ZF)V public fun (IIZ)V public fun disable (Z)V - public fun draw (JFF)V + public fun draw (JFFLcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I public fun getWidth ()I public fun ignoreBlockedTouches (Z)V @@ -646,12 +646,12 @@ public class cc/polyfrost/oneconfig/gui/elements/BasicElement { public fun setHeight (I)V public fun setToggled (Z)V public fun setWidth (I)V - public fun update (FF)V + public fun update (FFLcc/polyfrost/oneconfig/utils/InputHandler;)V } public class cc/polyfrost/oneconfig/gui/elements/ColorSelector { - public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;FF)V - public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;FFZ)V + public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;FFLcc/polyfrost/oneconfig/utils/InputHandler;)V + public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;FFZLcc/polyfrost/oneconfig/utils/InputHandler;)V public fun draw (J)V public fun getColor ()Lcc/polyfrost/oneconfig/config/core/OneColor; public fun isAlphaAllowed ()Z @@ -662,7 +662,7 @@ public class cc/polyfrost/oneconfig/gui/elements/ColorSelector { public class cc/polyfrost/oneconfig/gui/elements/ModCard : cc/polyfrost/oneconfig/gui/elements/BasicElement { public fun (Lcc/polyfrost/oneconfig/config/data/Mod;ZZZLcc/polyfrost/oneconfig/gui/pages/ModsPage;)V - public fun draw (JFF)V + public fun draw (JFFLcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getModData ()Lcc/polyfrost/oneconfig/config/data/Mod; public fun isActive ()Z public fun isDisabled ()Z @@ -676,11 +676,11 @@ public class cc/polyfrost/oneconfig/gui/elements/Slider : cc/polyfrost/oneconfig protected field dragPointerSize F protected field value F public fun (IFFF)V - public fun draw (JFF)V + public fun draw (JFFLcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getValue ()F public fun isDragging ()Z public fun setValue (F)V - public fun update (FF)V + public fun update (FFLcc/polyfrost/oneconfig/utils/InputHandler;)V } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigButton : cc/polyfrost/oneconfig/config/elements/BasicOption { @@ -689,21 +689,21 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigButton : cc/polyfr public fun (Ljava/lang/reflect/Method;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigButton; public static fun create (Ljava/lang/reflect/Method;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigButton; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I public fun keyTyped (CI)V protected fun setColor (Lcc/polyfrost/oneconfig/config/core/OneColor;)V @@ -712,36 +712,36 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement : cc/ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I[Ljava/lang/String;)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown; - public fun draw (JII)V - public fun drawLast (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V + public fun drawLast (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigHeader; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILcc/polyfrost/oneconfig/config/data/InfoType;)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigInfo; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I public fun keyTyped (CI)V } @@ -751,14 +751,14 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton : cc/po public final field page Lcc/polyfrost/oneconfig/gui/pages/Page; public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcc/polyfrost/oneconfig/config/elements/OptionPage;)V public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcc/polyfrost/oneconfig/gui/pages/Page;)V - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFI)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigSlider; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I public fun keyTyped (CI)V } @@ -766,14 +766,14 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider : cc/polyfr public class cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox : cc/polyfrost/oneconfig/config/elements/BasicOption { public fun (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;ZZ)V public static fun create (Ljava/lang/reflect/Field;Ljava/lang/Object;)Lcc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox; - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getHeight ()I public fun keyTyped (CI)V } @@ -781,7 +781,7 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox : cc/polyf public class cc/polyfrost/oneconfig/gui/elements/text/NumberInputField : cc/polyfrost/oneconfig/gui/elements/text/TextInputField { public fun (IIFFFF)V public fun arrowsClicked ()Z - public fun draw (JFF)V + public fun draw (JFFLcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getCurrentValue ()F public fun onClose ()V public fun setCurrentValue (F)V @@ -814,7 +814,7 @@ public class cc/polyfrost/oneconfig/gui/elements/text/TextInputField : cc/polyfr public fun (IILjava/lang/String;ZZ)V public fun (IILjava/lang/String;ZZLcc/polyfrost/oneconfig/renderer/SVG;)V public fun (IIZLjava/lang/String;)V - public fun draw (JFF)V + public fun draw (JFFLcc/polyfrost/oneconfig/utils/InputHandler;)V public fun getInput ()Ljava/lang/String; public fun getLines ()I public fun getPassword ()Z @@ -832,21 +832,21 @@ public class cc/polyfrost/oneconfig/gui/elements/text/TextInputField : cc/polyfr public class cc/polyfrost/oneconfig/gui/pages/CreditsPage : cc/polyfrost/oneconfig/gui/pages/Page { public fun ()V - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun isBase ()Z } public class cc/polyfrost/oneconfig/gui/pages/HomePage : cc/polyfrost/oneconfig/gui/pages/Page { public fun ()V - public fun draw (JII)V + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V public fun isBase ()Z } public class cc/polyfrost/oneconfig/gui/pages/ModConfigPage : cc/polyfrost/oneconfig/gui/pages/Page { public fun (Lcc/polyfrost/oneconfig/config/elements/OptionPage;)V public fun (Lcc/polyfrost/oneconfig/config/elements/OptionPage;Z)V - public fun draw (JII)V - public fun drawStatic (JII)I + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V + public fun drawStatic (JIILcc/polyfrost/oneconfig/utils/InputHandler;)I public fun finishUpAndClose ()V public fun getMaxScrollHeight ()I public fun isBase ()Z @@ -856,8 +856,8 @@ public class cc/polyfrost/oneconfig/gui/pages/ModConfigPage : cc/polyfrost/oneco public class cc/polyfrost/oneconfig/gui/pages/ModsPage : cc/polyfrost/oneconfig/gui/pages/Page { public fun ()V - public fun draw (JII)V - public fun drawStatic (JII)I + public fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V + public fun drawStatic (JIILcc/polyfrost/oneconfig/utils/InputHandler;)I public fun getMaxScrollHeight ()I public fun isBase ()Z public fun reloadMods ()V @@ -870,14 +870,14 @@ public abstract class cc/polyfrost/oneconfig/gui/pages/Page { protected field scrollTarget F protected final field title Ljava/lang/String; public fun (Ljava/lang/String;)V - public abstract fun draw (JII)V - public fun drawStatic (JII)I + public abstract fun draw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V + public fun drawStatic (JIILcc/polyfrost/oneconfig/utils/InputHandler;)I public fun finishUpAndClose ()V public fun getMaxScrollHeight ()I public fun getTitle ()Ljava/lang/String; public fun isBase ()Z public fun keyTyped (CI)V - public fun scrollWithDraw (JII)V + public fun scrollWithDraw (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V } public abstract class cc/polyfrost/oneconfig/hud/BasicHud : cc/polyfrost/oneconfig/hud/Hud { @@ -1176,7 +1176,7 @@ public final class cc/polyfrost/oneconfig/renderer/RenderManager { public static fun drawSvg (JLjava/lang/String;FFFF)V public static fun drawSvg (JLjava/lang/String;FFFFI)V public static fun drawText (JLjava/lang/String;FFIFLcc/polyfrost/oneconfig/renderer/font/Font;)V - public static fun drawURL (JLjava/lang/String;FFFLcc/polyfrost/oneconfig/renderer/font/Font;)V + public static fun drawURL (JLjava/lang/String;FFFLcc/polyfrost/oneconfig/renderer/font/Font;Lcc/polyfrost/oneconfig/utils/InputHandler;)V public static fun drawWrappedString (JLjava/lang/String;FFFIFLcc/polyfrost/oneconfig/renderer/font/Font;)V public static fun fillNVGColorWithRGBA (FFFFLorg/lwjgl/nanovg/NVGColor;)V public static fun getTextWidth (JLjava/lang/String;FLcc/polyfrost/oneconfig/renderer/font/Font;)F @@ -1206,7 +1206,7 @@ public class cc/polyfrost/oneconfig/renderer/TextRenderer { public static fun drawText (JLjava/lang/String;FFIFLcc/polyfrost/oneconfig/renderer/font/Font;F)V public static fun drawText (JLjava/util/ArrayList;FFIFLcc/polyfrost/oneconfig/renderer/font/Font;F)V public static fun drawText (JLjava/util/ArrayList;FFIFLcc/polyfrost/oneconfig/renderer/font/Font;FF)V - public static fun drawURL (JLjava/lang/String;FFFLcc/polyfrost/oneconfig/renderer/font/Font;)V + public static fun drawURL (JLjava/lang/String;FFFLcc/polyfrost/oneconfig/renderer/font/Font;Lcc/polyfrost/oneconfig/utils/InputHandler;)V public static fun drawWrappedString (JLjava/lang/String;FFFIFLcc/polyfrost/oneconfig/renderer/font/Font;)V public static fun getTextWidth (JLjava/lang/String;FLcc/polyfrost/oneconfig/renderer/font/Font;)F public static fun getTextWidth (JLjava/lang/String;FLcc/polyfrost/oneconfig/renderer/font/Font;F)F @@ -1266,21 +1266,23 @@ public final class cc/polyfrost/oneconfig/utils/IOUtils { public static fun resourceToByteBufferNullable (Ljava/lang/String;)Ljava/nio/ByteBuffer; } -public final class cc/polyfrost/oneconfig/utils/InputUtils { +public class cc/polyfrost/oneconfig/utils/InputHandler { public fun ()V - public static fun blockAllInput ()Lcc/polyfrost/oneconfig/renderer/scissor/Scissor; - public static fun blockInputArea (FFFF)Lcc/polyfrost/oneconfig/renderer/scissor/Scissor; - public static fun isAreaClicked (FFFF)Z - public static fun isAreaClicked (FFFFZ)Z - public static fun isAreaHovered (FFFF)Z - public static fun isAreaHovered (FFFFZ)Z - public static fun isBlockingInput ()Z - public static fun isClicked ()Z - public static fun isClicked (Z)Z - public static fun mouseX ()F - public static fun mouseY ()F - public static fun stopBlock (Lcc/polyfrost/oneconfig/renderer/scissor/Scissor;)V - public static fun stopBlockingInput ()V + public fun blockAllInput ()Lcc/polyfrost/oneconfig/renderer/scissor/Scissor; + public fun blockInputArea (FFFF)Lcc/polyfrost/oneconfig/renderer/scissor/Scissor; + public fun isAreaClicked (FFFF)Z + public fun isAreaClicked (FFFFZ)Z + public fun isAreaHovered (FFFF)Z + public fun isAreaHovered (FFFFZ)Z + public fun isBlockingInput ()Z + public fun isClicked ()Z + public fun isClicked (Z)Z + public fun mouseX ()F + public fun mouseY ()F + public fun resetScale ()V + public fun scale (DD)V + public fun stopBlock (Lcc/polyfrost/oneconfig/renderer/scissor/Scissor;)V + public fun stopBlockingInput ()V } public final class cc/polyfrost/oneconfig/utils/JsonUtils { @@ -1532,8 +1534,8 @@ public final class cc/polyfrost/oneconfig/utils/dsl/RenderManagerDSLKt { public static final fun drawSVG (Lcc/polyfrost/oneconfig/utils/dsl/VG;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;I)V public static final fun drawText (JLjava/lang/String;Ljava/lang/Number;Ljava/lang/Number;ILjava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;)V public static final fun drawText (Lcc/polyfrost/oneconfig/utils/dsl/VG;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Number;ILjava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;)V - public static final fun drawURL (JLjava/lang/String;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;)V - public static final fun drawURL (Lcc/polyfrost/oneconfig/utils/dsl/VG;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;)V + public static final fun drawURL (JLjava/lang/String;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;Lcc/polyfrost/oneconfig/utils/InputHandler;)V + public static final fun drawURL (Lcc/polyfrost/oneconfig/utils/dsl/VG;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;Lcc/polyfrost/oneconfig/utils/InputHandler;)V public static final fun drawWrappedString (JLjava/lang/String;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;ILjava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;)V public static final fun drawWrappedString (Lcc/polyfrost/oneconfig/utils/dsl/VG;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Number;Ljava/lang/Number;ILjava/lang/Number;Lcc/polyfrost/oneconfig/renderer/font/Font;)V public static final fun fill (Lorg/lwjgl/nanovg/NVGColor;FFFF)V @@ -1581,22 +1583,16 @@ public final class cc/polyfrost/oneconfig/utils/gui/GuiUtils { public static fun displayScreen (Ljava/lang/Object;)V public static fun displayScreen (Ljava/lang/Object;I)V public static fun getDeltaTime ()F + public static fun wasMouseDown ()Z } public abstract class cc/polyfrost/oneconfig/utils/gui/OneUIScreen : cc/polyfrost/oneconfig/libs/universal/UScreen, cc/polyfrost/oneconfig/gui/GuiPause { public fun ()V public fun (Z)V + public fun (ZZ)V public fun doesGuiPauseGame ()Z - public abstract fun draw (JF)V - protected fun getMouseX ()F - protected fun getMouseY ()F - public fun ignoreMinecraftScale ()Z - public fun isBlockingClicks ()Z - protected fun isClicked ()Z - protected fun isClicked (Z)Z - protected fun isMouseDown ()Z + public abstract fun draw (JFLcc/polyfrost/oneconfig/utils/InputHandler;)V public final fun onDrawScreen (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V - public fun shouldBlockClicks (Z)V } public class cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils { diff --git a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java index 64c31cf..82d8b31 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java @@ -27,6 +27,7 @@ package cc.polyfrost.oneconfig.config.elements; import cc.polyfrost.oneconfig.config.Config; +import cc.polyfrost.oneconfig.utils.InputHandler; import java.lang.reflect.Field; import java.util.ArrayList; @@ -91,7 +92,7 @@ public abstract class BasicOption { * @param x x position * @param y y position */ - public abstract void draw(long vg, int x, int y); + public abstract void draw(long vg, int x, int y, InputHandler inputHandler); /** * Function that gets called last drawing option, @@ -101,7 +102,7 @@ public abstract class BasicOption { * @param x x position * @param y y position */ - public void drawLast(long vg, int x, int y) { + public void drawLast(long vg, int x, int y , InputHandler inputHandler) { } /** diff --git a/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java b/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java index 80e8964..282f30f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java @@ -32,6 +32,7 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.elements.config.ConfigPageButton; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; +import cc.polyfrost.oneconfig.utils.InputHandler; import java.util.ArrayList; import java.util.List; @@ -49,7 +50,7 @@ public class OptionSubcategory { this.name = name; } - public int draw(long vg, int x, int y) { + public int draw(long vg, int x, int y, InputHandler inputHandler) { String filter = OneConfigGui.INSTANCE == null ? "" : OneConfigGui.INSTANCE.getSearchValue().toLowerCase().trim(); filteredOptions = options.stream().filter(option -> !option.isHidden() && (filter.equals("") || name.toLowerCase().contains(filter) || option.name.toLowerCase().contains(filter))).collect(Collectors.toList()); List filteredTop = topButtons.stream().filter(page -> !page.isHidden() && (filter.equals("") || name.toLowerCase().contains(filter) || page.name.toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))).collect(Collectors.toList()); @@ -62,7 +63,7 @@ public class OptionSubcategory { } for (ConfigPageButton page : filteredTop) { - page.draw(vg, x, optionY); + page.draw(vg, x, optionY, inputHandler); optionY += page.getHeight() + 16; } @@ -88,11 +89,11 @@ public class OptionSubcategory { if (filteredOptions.size() > 0) { for (int i = 0; i < filteredOptions.size(); i++) { BasicOption option = filteredOptions.get(i); - option.draw(vg, x, optionY); + option.draw(vg, x, optionY, inputHandler); if (i + 1 < filteredOptions.size()) { BasicOption nextOption = filteredOptions.get(i + 1); if (option.size == 1 && nextOption.size == 1) { - nextOption.draw(vg, x + 512, optionY); + nextOption.draw(vg, x + 512, optionY, inputHandler); optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16; i++; continue; @@ -104,21 +105,21 @@ public class OptionSubcategory { } for (ConfigPageButton page : filteredBottom) { - page.draw(vg, x, optionY); + page.draw(vg, x, optionY, inputHandler); optionY += page.getHeight() + 16; } return optionY - y; } - public void drawLast(long vg, int x) { + public void drawLast(long vg, int x, InputHandler inputHandler) { for (int i = 0; i < filteredOptions.size(); i++) { BasicOption option = filteredOptions.get(i); - option.drawLast(vg, x, drawLastY); + option.drawLast(vg, x, drawLastY, inputHandler); if (i + 1 < filteredOptions.size()) { BasicOption nextOption = filteredOptions.get(i + 1); if (option.size == 1 && nextOption.size == 1) { - nextOption.drawLast(vg, x + 512, drawLastY); + nextOption.drawLast(vg, x + 512, drawLastY, inputHandler); drawLastY += Math.max(option.getHeight(), nextOption.getHeight()) + 16; i++; continue; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index ba04aff..c0c4c96 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -38,16 +38,13 @@ import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; import cc.polyfrost.oneconfig.internal.config.Preferences; -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.libs.universal.*; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; import org.jetbrains.annotations.NotNull; @@ -58,6 +55,7 @@ import java.util.ArrayList; public class OneConfigGui extends UScreen implements GuiPause { public static OneConfigGui INSTANCE; + private InputHandler inputHandler = new InputHandler(); private final SideBar sideBar = new SideBar(); private final TextInputField textInputField = new TextInputField(248, 40, "Search...", false, false, SVGs.MAGNIFYING_GLASS_BOLD); private final ArrayList previousPages = new ArrayList<>(); @@ -105,6 +103,7 @@ public class OneConfigGui extends UScreen implements GuiPause { int x = (int) ((UResolution.getWindowWidth() - 1280 * scale) / 2f / scale); int y = (int) ((UResolution.getWindowHeight() - 800 * scale) / 2f / scale); RenderManager.scale(vg, scale, scale); + inputHandler.scale(scale, scale); RenderManager.drawDropShadow(vg, x, y, 1280, 800, 32, 0, 20); RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, Colors.GRAY_800, 20f); @@ -119,10 +118,10 @@ public class OneConfigGui extends UScreen implements GuiPause { RenderManager.drawText(vg, "OneConfig", x + 69, y + 32, -1, 18f, Fonts.BOLD); // added half line height to center text RenderManager.drawText(vg, "By Polyfrost", x + 69, y + 51, -1, 12f, Fonts.REGULAR); - textInputField.draw(vg, x + 1020, y + 16); - sideBar.draw(vg, x, y); - backArrow.draw(vg, x + 240, y + 16); - forwardArrow.draw(vg, x + 288, y + 16); + textInputField.draw(vg, x + 1020, y + 16, inputHandler); + sideBar.draw(vg, x, y, inputHandler); + backArrow.draw(vg, x + 240, y + 16, inputHandler); + forwardArrow.draw(vg, x + 288, y + 16, inputHandler); if (previousPages.size() == 0) { backArrow.disable(true); @@ -162,37 +161,37 @@ public class OneConfigGui extends UScreen implements GuiPause { } ScissorManager.scissor(vg, x + 224, y + 72, 1056, 728); - Scissor blockedClicks = InputUtils.blockInputArea(x + 224, y, 1056, 72); + Scissor blockedClicks = inputHandler.blockInputArea(x + 224, y, 1056, 72); if (prevPage != null && animation != null) { float pageProgress = animation.get(GuiUtils.getDeltaTime()); if (!animation.isReversed()) { - prevPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72); - currentPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72); + prevPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72, inputHandler); + currentPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72, inputHandler); } else { - prevPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72); - currentPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72); + prevPage.scrollWithDraw(vg, (int) (x - 1904 + pageProgress), y + 72, inputHandler); + currentPage.scrollWithDraw(vg, (int) (x + pageProgress), y + 72, inputHandler); } if (animation.isFinished()) { prevPage = null; } } else { - currentPage.scrollWithDraw(vg, x + 224, y + 72); + currentPage.scrollWithDraw(vg, x + 224, y + 72, inputHandler); } ScissorManager.clearScissors(vg); - InputUtils.stopBlock(blockedClicks); + inputHandler.stopBlock(blockedClicks); float breadcrumbX = x + 352; for (int i = 0; i < currentPage.parents.size(); i++) { String title = currentPage.parents.get(i).getTitle(); float width = RenderManager.getTextWidth(vg, title, 24f, Fonts.SEMIBOLD); - boolean hovered = InputUtils.isAreaHovered((int) breadcrumbX, y + 24, (int) width, 36); + boolean hovered = inputHandler.isAreaHovered((int) breadcrumbX, y + 24, (int) width, 36); int color = Colors.WHITE_60; if (i == currentPage.parents.size() - 1) color = Colors.WHITE; else if (hovered && !Platform.getMousePlatform().isButtonDown(0)) color = Colors.WHITE_80; RenderManager.drawText(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.SEMIBOLD); if (i != 0) RenderManager.drawSvg(vg, SVGs.CARET_RIGHT, breadcrumbX - 28, y + 25, 24, 24, color); - if (hovered && InputUtils.isClicked()) openPage(currentPage.parents.get(i)); + if (hovered && inputHandler.isClicked()) openPage(currentPage.parents.get(i)); breadcrumbX += width + 32; } @@ -264,7 +263,7 @@ public class OneConfigGui extends UScreen implements GuiPause { /** * initialize a new ColorSelector and add it to the draw script. This method is used to make sure it is always rendered on top. *

- * Correct usage: OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY())); + * Correct usage: OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, inputUtils.mouseX(), inputUtils.mouseY())); */ public void initColorSelector(ColorSelector colorSelector) { if (currentColorSelector != null) closeColorSelector(); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index cad5a07..bd0503c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -39,6 +39,7 @@ import cc.polyfrost.oneconfig.internal.config.Preferences; import cc.polyfrost.oneconfig.internal.gui.HudGui; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; @@ -78,7 +79,7 @@ public class SideBar { } } - public void draw(long vg, int x, int y) { + public void draw(long vg, int x, int y, InputHandler inputHandler) { this.y = y; for (BasicButton button : buttons) { if (!button.isClicked()) continue; @@ -94,19 +95,19 @@ public class SideBar { } } - buttons.get(0).draw(vg, x + 16, y + 80); - buttons.get(1).draw(vg, x + 16, y + 116); + buttons.get(0).draw(vg, x + 16, y + 80, inputHandler); + buttons.get(1).draw(vg, x + 16, y + 116, inputHandler); RenderManager.drawText(vg, "MOD CONFIG", x + 16, y + 178, Colors.WHITE, 12, Fonts.SEMIBOLD); - buttons.get(2).draw(vg, x + 16, y + 192); - buttons.get(3).draw(vg, x + 16, y + 228); - buttons.get(4).draw(vg, x + 16, y + 264); - buttons.get(5).draw(vg, x + 16, y + 300); + buttons.get(2).draw(vg, x + 16, y + 192, inputHandler); + buttons.get(3).draw(vg, x + 16, y + 228, inputHandler); + buttons.get(4).draw(vg, x + 16, y + 264, inputHandler); + buttons.get(5).draw(vg, x + 16, y + 300, inputHandler); RenderManager.drawText(vg, "PERSONALIZATION", x + 16, y + 362, Colors.WHITE, 12, Fonts.SEMIBOLD); - buttons.get(6).draw(vg, x + 16, y + 376); - buttons.get(7).draw(vg, x + 16, y + 412); - buttons.get(8).draw(vg, x + 16, y + 448); - HUDButton.draw(vg, x + 16, y + 704); - CloseButton.draw(vg, x + 16, y + 748); + buttons.get(6).draw(vg, x + 16, y + 376, inputHandler); + buttons.get(7).draw(vg, x + 16, y + 412, inputHandler); + buttons.get(8).draw(vg, x + 16, y + 448, inputHandler); + HUDButton.draw(vg, x + 16, y + 704, inputHandler); + CloseButton.draw(vg, x + 16, y + 748, inputHandler); } public void pageOpened(String page) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java index e1f7789..948ec11 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -32,6 +32,7 @@ import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.SVG; import cc.polyfrost.oneconfig.renderer.font.Fonts; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.color.ColorUtils; import org.jetbrains.annotations.NotNull; @@ -83,10 +84,10 @@ public class BasicButton extends BasicElement { } @Override - public void draw(long vg, float x, float y) { + public void draw(long vg, float x, float y, InputHandler inputHandler) { this.x = x; this.y = y; - this.update(x, y); + this.update(x, y, inputHandler); if (disabled) RenderManager.setAlpha(vg, 0.5f); float contentWidth = 0f; int color; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java index 807b8aa..e390880 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -29,7 +29,7 @@ package cc.polyfrost.oneconfig.gui.elements; import cc.polyfrost.oneconfig.gui.animations.ColorAnimation; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import org.jetbrains.annotations.NotNull; @@ -70,7 +70,7 @@ public class BasicElement { public int currentColor; protected final float radius; /** - * Boolean to determine if this element is allowed to be clicked when {@link InputUtils#isBlockingInput()} is true. + * Boolean to determine if this element is allowed to be clicked when {@link InputHandler#isBlockingInput()} is true. */ private boolean block = false; /** @@ -98,29 +98,29 @@ public class BasicElement { /** * Draw script for the element. - *
Make sure to call {@link #update(float, float)} to update the elements states! + *
Make sure to call {@link #update(float, float, InputHandler)} to update the elements states! * * @param vg NanoVG context (see {@link RenderManager}) * @param x x position of the element * @param y y position of the element */ - public void draw(long vg, float x, float y) { - this.update(x, y); + public void draw(long vg, float x, float y, InputHandler inputHandler) { + this.update(x, y, inputHandler); RenderManager.drawRoundedRect(vg, x, y, width, height, currentColor, radius); } /** * Update this element's clicked, hovered, toggled, and pressed states, invoke any necessary methods, and update the color animation. */ - public void update(float x, float y) { + public void update(float x, float y, InputHandler inputHandler) { if (disabled) { hovered = false; pressed = false; clicked = false; } else { - hovered = InputUtils.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY); + hovered = inputHandler.isAreaHovered(x - hitBoxX, y - hitBoxY, width + hitBoxX, height + hitBoxY); pressed = hovered && Platform.getMousePlatform().isButtonDown(0); - clicked = InputUtils.isClicked(block) && hovered; + clicked = inputHandler.isClicked(block) && hovered; if (clicked) { toggled = !toggled; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java index b03f868..0fa5514 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -44,7 +44,7 @@ import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager; import cc.polyfrost.oneconfig.utils.IOUtils; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.NetworkUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; @@ -80,12 +80,14 @@ public class ColorSelector { private boolean dragging, mouseWasDown; private final boolean hasAlpha; private Scissor inputScissor = null; + private final InputHandler inputHandler; - public ColorSelector(OneColor color, float mouseX, float mouseY) { - this(color, mouseX, mouseY, true); + public ColorSelector(OneColor color, float mouseX, float mouseY, InputHandler inputHandler) { + this(color, mouseX, mouseY, true, inputHandler); } - public ColorSelector(OneColor color, float mouseX, float mouseY, boolean hasAlpha) { + public ColorSelector(OneColor color, float mouseX, float mouseY, boolean hasAlpha, InputHandler inputHandler) { + this.inputHandler = inputHandler; this.color = color; this.hasAlpha = hasAlpha; buttons.add(new BasicButton(124, 28, "HSB Box", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY)); @@ -132,7 +134,7 @@ public class ColorSelector { } public void draw(long vg) { - if (inputScissor != null) InputUtils.stopBlock(inputScissor); + if (inputScissor != null) inputHandler.stopBlock(inputScissor); doDrag(); int width = 416; int height = 768; @@ -141,7 +143,7 @@ public class ColorSelector { RenderManager.drawRoundedRect(vg, x, y, width, height, Colors.GRAY_800, 20f); RenderManager.drawText(vg, "Color Selector", x + 16, y + 32, Colors.WHITE_90, 18f, Fonts.SEMIBOLD); if (!closeBtn.isHovered()) RenderManager.setAlpha(vg, 0.8f); - closeBtn.draw(vg, x + 368, y + 16); + closeBtn.draw(vg, x + 368, y + 16, inputHandler); RenderManager.drawSvg(vg, SVGs.X_CIRCLE_BOLD, x + 368, y + 16, 32, 32, closeBtn.isHovered() ? Colors.ERROR_600 : -1); RenderManager.setAlpha(vg, 1f); @@ -151,13 +153,13 @@ public class ColorSelector { } // TODO favorite stuff - faveBtn.draw(vg, x + 16, y + 672); - recentBtn.draw(vg, x + 16, y + 720); + faveBtn.draw(vg, x + 16, y + 672, inputHandler); + recentBtn.draw(vg, x + 16, y + 720, inputHandler); for (int i = 0; i < 7; i++) { - favoriteColors.get(i).draw(vg, x + 104 + i * 44, y + 672); + favoriteColors.get(i).draw(vg, x + 104 + i * 44, y + 672, inputHandler); } for (int i = 0; i < 7; i++) { - recentColors.get(i).draw(vg, x + 104 + i * 44, y + 720); + recentColors.get(i).draw(vg, x + 104 + i * 44, y + 720, inputHandler); } RenderManager.drawRoundedRect(vg, x + 16, y + 64, 384, 32, Colors.GRAY_500, 12f); @@ -167,7 +169,7 @@ public class ColorSelector { int i = 18; for (BasicElement button : buttons) { - button.draw(vg, x + i, y + 66); + button.draw(vg, x + i, y + 66, inputHandler); if (button.isClicked()) { int prevMode = mode; mode = buttons.indexOf(button); @@ -181,36 +183,36 @@ public class ColorSelector { float percentMoveMain = moveAnimation.get(); RenderManager.drawText(vg, "Saturation", x + 224, y + 560, Colors.WHITE_80, 12f, Fonts.MEDIUM); - saturationInput.draw(vg, x + 312, y + 544); + saturationInput.draw(vg, x + 312, y + 544, inputHandler); RenderManager.drawText(vg, "Brightness", x + 16, y + 599, Colors.WHITE_80, 12f, Fonts.MEDIUM); - brightnessInput.draw(vg, x + 104, y + 584); + brightnessInput.draw(vg, x + 104, y + 584, inputHandler); RenderManager.drawText(vg, "Alpha (%)", x + 224, y + 599, Colors.WHITE_80, 12f, Fonts.MEDIUM); - alphaInput.draw(vg, x + 312, y + 584); + alphaInput.draw(vg, x + 312, y + 584, inputHandler); RenderManager.drawText(vg, color.getDataBit() == -1 ? "Hex (RGB):" : "Color Code:", x + 16, y + 641, Colors.WHITE_80, 12f, Fonts.MEDIUM); - hexInput.draw(vg, x + 104, y + 624); + hexInput.draw(vg, x + 104, y + 624, inputHandler); - copyBtn.draw(vg, x + 204, y + 624); - pasteBtn.draw(vg, x + 244, y + 624); + copyBtn.draw(vg, x + 204, y + 624, inputHandler); + pasteBtn.draw(vg, x + 244, y + 624, inputHandler); if (mode != 2) { RenderManager.drawText(vg, "Hue", x + 16, y + 560, Colors.WHITE_80, 12f, Fonts.MEDIUM); - hueInput.draw(vg, x + 104, y + 544); + hueInput.draw(vg, x + 104, y + 544, inputHandler); } else { RenderManager.drawText(vg, "Speed (s)", x + 16, y + 560, Colors.WHITE_80, 12f, Fonts.MEDIUM); - speedInput.draw(vg, x + 104, y + 544); + speedInput.draw(vg, x + 104, y + 544, inputHandler); } - guideBtn.draw(vg, x + 288, y + 624); + guideBtn.draw(vg, x + 288, y + 624, inputHandler); setColorFromXY(); if (mode != 2) color.setChromaSpeed(-1); drawColorSelector(vg, mode, (x * percentMoveMain), y); - if (dragging && InputUtils.isClicked(true)) { + if (dragging && inputHandler.isClicked(true)) { dragging = false; } bottomSlider.setGradient(Colors.TRANSPARENT, color.getRGBNoAlpha()); RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x + 16, y + 456, 384, 16, 8f); - bottomSlider.draw(vg, x + 16, y + 456); + bottomSlider.draw(vg, x + 16, y + 456, inputHandler); if (percentMoveMain > 0.96f) { RenderManager.drawRoundedRect(vg, mouseX - 7, mouseY - 7, 14, 14, Colors.WHITE, 14f); @@ -227,7 +229,7 @@ public class ColorSelector { RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x + 20, y + 492, 376, 32, 8f); RenderManager.drawRoundedRect(vg, x + 20, y + 492, 376, 32, color.getRGB(), 8f); - inputScissor = InputUtils.blockInputArea(x - 3, y - 3, width + 6, height + 6); + inputScissor = inputHandler.blockInputArea(x - 3, y - 3, width + 6, height + 6); ScissorManager.resetScissor(vg, scissor); mouseWasDown = Platform.getMousePlatform().isButtonDown(0); if (closeBtn.isClicked()) { @@ -246,10 +248,10 @@ public class ColorSelector { if (mode == 0) { topSlider.setColor(color.getRGBMax(true)); - topSlider.draw(vg, x + 16, y + 424); + topSlider.draw(vg, x + 16, y + 424, inputHandler); } if (mode == 2) { - speedSlider.draw(vg, x + 60, y + 424); + speedSlider.draw(vg, x + 60, y + 424, inputHandler); RenderManager.drawText(vg, "SLOW", x + 16, y + 429, Colors.WHITE_80, 12f, Fonts.REGULAR); RenderManager.drawText(vg, "FAST", x + 370, y + 429, Colors.WHITE_80, 12f, Fonts.REGULAR); } @@ -261,13 +263,13 @@ public class ColorSelector { topSlider.setGradient(Colors.BLACK, color.getRGBMax(true)); topSlider.setImage(null); - topSlider.draw(vg, x + 16, y + 424); + topSlider.draw(vg, x + 16, y + 424, inputHandler); break; } } private void doDrag() { - if (InputUtils.isAreaHovered(x, y, 368, 64) && Platform.getMousePlatform().isButtonDown(0) && !dragging) { + if (inputHandler.isAreaHovered(x, y, 368, 64) && Platform.getMousePlatform().isButtonDown(0) && !dragging) { float dx = (float) (Platform.getMousePlatform().getMouseDX() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); float dy = (float) (Platform.getMousePlatform().getMouseDY() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); x += dx; @@ -279,14 +281,14 @@ public class ColorSelector { private void setColorFromXY() { boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0); - boolean hovered = Platform.getMousePlatform().isButtonDown(0) && InputUtils.isAreaHovered(x + 16, y + 120, 384, 288); + boolean hovered = Platform.getMousePlatform().isButtonDown(0) && inputHandler.isAreaHovered(x + 16, y + 120, 384, 288); if (hovered && isMouseDown && !mouseWasDown) dragging = true; switch (mode) { case 0: case 2: if (dragging) { - mouseX = InputUtils.mouseX(); - mouseY = InputUtils.mouseY(); + mouseX = inputHandler.mouseX(); + mouseY = inputHandler.mouseY(); } if (mouseX < x + 16) mouseX = x + 16; if (mouseY < y + 120) mouseY = y + 120; @@ -307,7 +309,7 @@ public class ColorSelector { case 1: float circleCenterX = x + 208; float circleCenterY = y + 264; - double squareDist = Math.pow((circleCenterX - InputUtils.mouseX()), 2) + Math.pow((circleCenterY - InputUtils.mouseY()), 2); + double squareDist = Math.pow((circleCenterX - inputHandler.mouseX()), 2) + Math.pow((circleCenterY - inputHandler.mouseY()), 2); hovered = squareDist < 144 * 144 && Platform.getMousePlatform().isButtonDown(0); isMouseDown = Platform.getMousePlatform().isButtonDown(0); if (hovered && isMouseDown && !mouseWasDown) dragging = true; @@ -315,7 +317,7 @@ public class ColorSelector { int angle = 0; int saturation = color.getSaturation(); if (dragging) { - angle = (int) Math.toDegrees(Math.atan2(InputUtils.mouseY() - circleCenterY, InputUtils.mouseX() - circleCenterX)); + angle = (int) Math.toDegrees(Math.atan2(inputHandler.mouseY() - circleCenterY, inputHandler.mouseX() - circleCenterX)); if (angle < 0) angle += 360; if ((squareDist / (144 * 144) > 1f)) { saturation = 100; @@ -323,8 +325,8 @@ public class ColorSelector { mouseY = (float) (Math.cos(Math.toRadians(-angle) + 1.5708) * 144 + y + 264); } else { saturation = (int) (squareDist / (144 * 144) * 100); - mouseX = InputUtils.mouseX(); - mouseY = InputUtils.mouseY(); + mouseX = inputHandler.mouseX(); + mouseY = inputHandler.mouseY(); } } color.setHSBA(dragging ? angle : color.getHue(), saturation, (int) (topSlider.getValue() / 360 * 100), (int) bottomSlider.getValue()); @@ -419,7 +421,7 @@ public class ColorSelector { } public void onClose() { - if (inputScissor != null) InputUtils.stopBlock(inputScissor); + if (inputScissor != null) inputHandler.stopBlock(inputScissor); /*for (int i = 0; i < OneConfigConfig.recentColors.size(); i++) { OneColor color1 = OneConfigConfig.recentColors.get(i); if (color1.getRGB() == color.getRGB()) { @@ -455,8 +457,8 @@ public class ColorSelector { } @Override - public void draw(long vg, float x, float y) { - if (!disabled) update(x, y); + public void draw(long vg, float x, float y, InputHandler inputHandler) { + if (!disabled) update(x, y, inputHandler); else RenderManager.setAlpha(vg, 0.5f); super.dragPointerSize = 15f; if (image != null) { @@ -495,11 +497,11 @@ public class ColorSelector { } @Override - public void draw(long vg, float x, float y) { + public void draw(long vg, float x, float y, InputHandler inputHandler) { RenderManager.drawRoundedRect(vg, x, y, 32, 32, toggled ? Colors.PRIMARY_600 : Colors.GRAY_300, 12f); RenderManager.drawRoundedRect(vg, x + 2, y + 2, 28, 28, Colors.GRAY_800, 10f); RenderManager.drawRoundedRect(vg, x + 4, y + 4, 24, 24, color.getRGB(), 8f); - update(x, y); + update(x, y, inputHandler); } public OneColor getColor() { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java index 5b30b59..afeaccd 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -42,7 +42,7 @@ import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.color.ColorUtils; import org.jetbrains.annotations.NotNull; @@ -70,13 +70,13 @@ public class ModCard extends BasicElement { } @Override - public void draw(long vg, float x, float y) { - super.update(x, y); + public void draw(long vg, float x, float y, InputHandler inputHandler) { + super.update(x, y, inputHandler); String cleanName = modData.name.replaceAll("ยง.", ""); Scissor scissor = ScissorManager.scissor(vg, x, y, width, height); - isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87); - boolean isHoveredSecondary = InputUtils.isAreaHovered(x, y + 87, width - 32, 32) && !disabled; + isHoveredMain = inputHandler.isAreaHovered(x, y, width, 87); + boolean isHoveredSecondary = inputHandler.isAreaHovered(x, y + 87, width - 32, 32) && !disabled; if (disabled) RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRectVaried(vg, x, y, width, 87, colorFrame.getColor(isHoveredMain, isHoveredMain && Platform.getMousePlatform().isButtonDown(0)), 12f, 12f, 0f, 0f); RenderManager.drawRoundedRectVaried(vg, x, y + 87, width, 32, colorToggle.getColor(isHoveredSecondary, isHoveredSecondary && Platform.getMousePlatform().isButtonDown(0)), 0f, 0f, 12f, 12f); @@ -88,7 +88,7 @@ public class ModCard extends BasicElement { } else { RenderManager.drawText(vg, cleanName, x + Math.max(0, (244 - RenderManager.getTextWidth(vg, cleanName, 16, Fonts.MINECRAFT_BOLD))) / 2f, y + 44, ColorUtils.setAlpha(Colors.WHITE, (int) (colorFrame.getAlpha() * 255)), 16, Fonts.MINECRAFT_BOLD); } - favoriteButton.draw(vg, x + 212, y + 87); + favoriteButton.draw(vg, x + 212, y + 87, inputHandler); favorite = favoriteButton.isToggled(); if (favoriteButton.isClicked()) { if (favorite) OneConfigConfig.favoriteMods.add(modData.name); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java index a43103b..ffb4470 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java @@ -29,7 +29,7 @@ package cc.polyfrost.oneconfig.gui.elements; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; public class Slider extends BasicElement { private final float min, max; @@ -47,8 +47,8 @@ public class Slider extends BasicElement { } @Override - public void draw(long vg, float x, float y) { - if(!disabled) update(x, y); + public void draw(long vg, float x, float y, InputHandler inputHandler) { + if(!disabled) update(x, y, inputHandler); else RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x, y + 2, width, height - 4, Colors.GRAY_300, 3f); RenderManager.drawRoundedRect(vg, x, y + 2, width * value, height - 4, Colors.PRIMARY_500, 3f); @@ -58,18 +58,18 @@ public class Slider extends BasicElement { } - public void update(float x, float y) { - super.update(x, y); + public void update(float x, float y, InputHandler inputHandler) { + super.update(x, y, inputHandler); boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0); - boolean hovered = InputUtils.isAreaHovered(x - 6, y - 3, width + 12, height + 6); + boolean hovered = inputHandler.isAreaHovered(x - 6, y - 3, width + 12, height + 6); if (hovered && isMouseDown && !mouseWasDown) dragging = true; mouseWasDown = isMouseDown; if (dragging) { - value = (InputUtils.mouseX() - x) / width; + value = (inputHandler.mouseX() - x) / width; } - if (dragging && InputUtils.isClicked(true)) { + if (dragging && inputHandler.isClicked(true)) { dragging = false; - value = (InputUtils.mouseX() - x) / width; + value = (inputHandler.mouseX() - x) / width; } if (value < 0) value = 0; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java index d7c4103..fdd0c2f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java @@ -32,6 +32,7 @@ import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import java.lang.reflect.Field; @@ -90,11 +91,11 @@ public class ConfigButton extends BasicOption { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, int x, int y, InputHandler inputHandler) { button.disable(!isEnabled()); if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); RenderManager.drawText(vg, name, x, y + 17, Colors.WHITE, 14f, Fonts.MEDIUM); - button.draw(vg, x + (size == 1 ? 352 : 736), y); + button.draw(vg, x + (size == 1 ? 352 : 736), y, inputHandler); RenderManager.setAlpha(vg, 1f); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java index 491eaf4..9cc60c9 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java @@ -37,7 +37,7 @@ import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.internal.assets.SVGs; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.color.ColorUtils; @@ -58,7 +58,7 @@ public class ConfigCheckbox extends BasicOption { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, int x, int y, InputHandler inputHandler) { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); boolean toggled = false; try { @@ -66,9 +66,9 @@ public class ConfigCheckbox extends BasicOption { if (animation == null) animation = new DummyAnimation(toggled ? 1 : 0); } catch (IllegalAccessException ignored) { } - boolean hover = InputUtils.isAreaHovered(x, y + 4, 24, 24); + boolean hover = inputHandler.isAreaHovered(x, y + 4, 24, 24); - boolean clicked = InputUtils.isClicked() && hover; + boolean clicked = inputHandler.isClicked() && hover; if (clicked && isEnabled()) { toggled = !toggled; animation = new EaseInOutQuad(100, 0, 1, !toggled); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java index 39b88a6..39780a1 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java @@ -37,7 +37,7 @@ import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.internal.assets.Images; -import cc.polyfrost.oneconfig.utils.InputUtils; +import cc.polyfrost.oneconfig.utils.InputHandler; import java.lang.reflect.Field; @@ -62,7 +62,7 @@ public class ConfigColorElement extends BasicOption { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, int x, int y, InputHandler inputHandler) { if(OneConfigGui.INSTANCE == null) return; if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); hexField.disable(!isEnabled()); @@ -86,7 +86,7 @@ public class ConfigColorElement e