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 --- api/OneConfig.api | 249 +++++++++++------- build.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- lwjgl/1.16.2-fabric/api/1.16.2-fabric.api | 0 lwjgl/build.gradle.kts | 24 +- lwjgl/root.gradle.kts | 4 +- settings.gradle.kts | 3 +- .../java/cc/polyfrost/oneconfig/config/Config.java | 5 +- .../oneconfig/config/core/OneKeyBind.java | 1 - .../java/cc/polyfrost/oneconfig/gui/GuiPause.java | 1 + .../java/cc/polyfrost/oneconfig/gui/HudGui.java | 292 --------------------- .../cc/polyfrost/oneconfig/gui/OneConfigGui.java | 14 +- .../java/cc/polyfrost/oneconfig/gui/SideBar.java | 3 +- .../oneconfig/gui/elements/BasicButton.java | 6 +- .../oneconfig/gui/elements/BasicElement.java | 6 +- .../oneconfig/gui/elements/ColorSelector.java | 46 ++-- .../polyfrost/oneconfig/gui/elements/ModCard.java | 2 +- .../polyfrost/oneconfig/gui/elements/Slider.java | 8 +- .../gui/elements/text/NumberInputField.java | 2 +- .../gui/elements/text/TextInputField.java | 14 +- .../cc/polyfrost/oneconfig/gui/pages/Page.java | 2 +- .../java/cc/polyfrost/oneconfig/hud/BasicHud.java | 116 ++++++++ .../java/cc/polyfrost/oneconfig/hud/HUDUtils.java | 48 ++-- src/main/java/cc/polyfrost/oneconfig/hud/Hud.java | 208 +++++---------- .../java/cc/polyfrost/oneconfig/hud/Position.java | 279 ++++++++++++++++++++ .../cc/polyfrost/oneconfig/hud/SingleTextHud.java | 49 +--- .../java/cc/polyfrost/oneconfig/hud/TextHud.java | 71 ++--- .../oneconfig/internal/assets/Colors.java | 5 - .../internal/command/OneConfigCommand.java | 4 +- .../oneconfig/internal/config/Preferences.java | 7 +- .../compatibility/vigilance/VigilanceConfig.java | 11 +- .../polyfrost/oneconfig/internal/gui/HudGui.java | 269 +++++++++++++++++++ .../polyfrost/oneconfig/internal/hud/HudCore.java | 2 +- .../oneconfig/internal/hud/utils/GrabOffset.java | 27 ++ .../oneconfig/internal/hud/utils/SnappingLine.java | 49 ++++ .../oneconfig/internal/init/OneConfigInit.java | 5 + .../oneconfig/platform/NanoVGPlatform.java | 42 +++ .../cc/polyfrost/oneconfig/platform/Platform.java | 13 + .../oneconfig/renderer/RenderManager.java | 28 +- .../polyfrost/oneconfig/renderer/TextRenderer.java | 4 +- .../oneconfig/renderer/scissor/Scissor.java | 2 +- .../cc/polyfrost/oneconfig/utils/InputUtils.java | 32 +-- .../oneconfig/utils/commands/CommandManager.java | 10 +- .../utils/commands/PlatformCommandManager.java | 31 ++- .../utils/commands/annotations/Command.java | 8 + .../utils/commands/annotations/SubCommand.java | 9 + .../cc/polyfrost/oneconfig/utils/gui/GuiUtils.java | 1 - .../polyfrost/oneconfig/utils/gui/OneUIScreen.java | 39 +-- .../oneconfig/textures/entity/pig/technocrown.png | Bin 252 -> 0 bytes versions/1.12.2-1.16.2.txt | 4 +- versions/1.12.2-forge/api/1.12.2-forge.api | 20 ++ .../oneconfig/internal/mixin/MinecraftMixin.java | 5 - versions/1.16.2-fabric/api/1.16.2-fabric.api | 122 +++++++++ .../oneconfig/internal/hook/FramebufferHook.java | 6 + .../oneconfig/internal/mixin/FramebufferMixin.java | 62 +++++ .../internal/mixin/GameRendererAccessor.java | 12 + .../internal/mixin/GuiIngameForgeMixin.java | 19 ++ .../oneconfig/internal/mixin/KeyboardMixin.java | 20 ++ .../oneconfig/internal/mixin/MinecraftMixin.java | 60 +++++ .../oneconfig/internal/mixin/MouseAccessor.java | 17 ++ .../oneconfig/internal/mixin/MouseMixin.java | 20 ++ .../internal/mixin/NetHandlerPlayClientMixin.java | 25 ++ .../internal/mixin/NetworkManagerMixin.java | 42 +++ .../internal/mixin/TickTimeTrackerMixin.java | 24 ++ .../oneconfig/internal/mixin/WorldClientMixin.java | 24 ++ .../internal/plugin/OneConfigPreLaunch.java | 11 + .../utils/commands/PlatformCommandManagerImpl.java | 122 +++++++++ versions/1.16.2-forge/api/1.16.2-forge.api | 20 ++ .../internal/mixin/ClientModLoaderMixin.java | 5 +- .../internal/mixin/KeyboardListenerMixin.java | 17 -- .../oneconfig/internal/mixin/KeyboardMixin.java | 17 ++ .../oneconfig/internal/mixin/MouseAccessor.java | 11 + .../internal/mixin/MouseHelperAccessor.java | 11 - .../oneconfig/internal/mixin/MouseHelperMixin.java | 17 -- .../oneconfig/internal/mixin/MouseMixin.java | 17 ++ .../internal/mixin/TickTimeTrackerMixin.java | 22 ++ .../oneconfig/internal/mixin/TimeTrackerMixin.java | 22 -- versions/1.8.9-forge/api/1.8.9-forge.api | 20 ++ versions/build.gradle.kts | 158 ++++++++--- versions/root.gradle.kts | 4 +- .../cc/polyfrost/oneconfig/internal/OneConfig.java | 23 +- .../internal/eggs/TechnobladeCrownRenderer.java | 39 --- .../internal/gui/impl/BlurHandlerImpl.java | 7 + .../oneconfig/internal/mixin/MinecraftMixin.java | 5 - .../oneconfig/internal/mixin/RenderPigMixin.java | 25 -- .../internal/plugin/OneConfigMixinPlugin.java | 15 +- .../oneconfig/platform/impl/GLPlatformImpl.java | 10 +- .../oneconfig/platform/impl/GuiPlatformImpl.java | 1 - .../oneconfig/platform/impl/I18nPlatformImpl.java | 1 - .../platform/impl/LoaderPlatformImpl.java | 29 +- .../oneconfig/platform/impl/MousePlatformImpl.java | 17 +- .../platform/impl/NanoVGPlatformImpl.java | 88 +++++++ .../oneconfig/platform/impl/PlatformImpl.java | 10 +- .../platform/impl/ServerPlatformImpl.java | 1 - .../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 ++- .../cc.polyfrost.oneconfig.platform.NanoVGPlatform | 1 + versions/src/main/resources/fabric.mod.json | 35 +++ versions/src/main/resources/mixins.oneconfig.json | 1 - 103 files changed, 2402 insertions(+), 1026 deletions(-) create mode 100644 lwjgl/1.16.2-fabric/api/1.16.2-fabric.api delete mode 100644 src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java create mode 100644 src/main/java/cc/polyfrost/oneconfig/hud/BasicHud.java create mode 100644 src/main/java/cc/polyfrost/oneconfig/hud/Position.java create mode 100644 src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java create mode 100644 src/main/java/cc/polyfrost/oneconfig/internal/hud/utils/GrabOffset.java create mode 100644 src/main/java/cc/polyfrost/oneconfig/internal/hud/utils/SnappingLine.java create mode 100644 src/main/java/cc/polyfrost/oneconfig/platform/NanoVGPlatform.java delete mode 100644 src/main/resources/assets/oneconfig/textures/entity/pig/technocrown.png create mode 100644 versions/1.16.2-fabric/api/1.16.2-fabric.api create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/hook/FramebufferHook.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/FramebufferMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GameRendererAccessor.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseAccessor.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TickTimeTrackerMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigPreLaunch.java create mode 100644 versions/1.16.2-fabric/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java delete mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardListenerMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseAccessor.java delete mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperAccessor.java delete mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TickTimeTrackerMixin.java delete mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TimeTrackerMixin.java delete mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/internal/eggs/TechnobladeCrownRenderer.java delete mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/RenderPigMixin.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/NanoVGPlatformImpl.java 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 create mode 100644 versions/src/main/resources/META-INF/services/cc.polyfrost.oneconfig.platform.NanoVGPlatform create mode 100644 versions/src/main/resources/fabric.mod.json diff --git a/api/OneConfig.api b/api/OneConfig.api index 24a9286..da10ec7 100644 --- a/api/OneConfig.api +++ b/api/OneConfig.api @@ -466,17 +466,6 @@ public abstract interface class cc/polyfrost/oneconfig/gui/GuiPause { public abstract fun doesGuiPauseGame ()Z } -public class cc/polyfrost/oneconfig/gui/HudGui : cc/polyfrost/oneconfig/libs/universal/UScreen, cc/polyfrost/oneconfig/gui/GuiPause { - public fun (Z)V - public fun doesGuiPauseGame ()Z - public fun initScreen (II)V - public fun onDrawScreen (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V - public fun onKeyPressed (ICLcc/polyfrost/oneconfig/libs/universal/UKeyboard$Modifiers;)V - public fun onMouseClicked (DDI)V - public fun onMouseReleased (DDI)V - public fun onScreenClose ()V -} - public class cc/polyfrost/oneconfig/gui/OneConfigGui : cc/polyfrost/oneconfig/libs/universal/UScreen, cc/polyfrost/oneconfig/gui/GuiPause { public static field INSTANCE Lcc/polyfrost/oneconfig/gui/OneConfigGui; public field allowClose Z @@ -565,12 +554,12 @@ public class cc/polyfrost/oneconfig/gui/elements/BasicButton : cc/polyfrost/onec protected field icon1 Lcc/polyfrost/oneconfig/internal/assets/SVGs; protected field icon2 Lcc/polyfrost/oneconfig/internal/assets/SVGs; protected field text Ljava/lang/String; - public field x I - public field y I + public field x F + public field y F public fun (IILcc/polyfrost/oneconfig/internal/assets/SVGs;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/internal/assets/SVGs;Lcc/polyfrost/oneconfig/internal/assets/SVGs;ILcc/polyfrost/oneconfig/utils/color/ColorPalette;)V - public fun draw (JII)V + public fun draw (JFF)V public fun getPage ()Lcc/polyfrost/oneconfig/gui/pages/Page; public fun getText ()Ljava/lang/String; public fun hasClickAction ()Z @@ -603,7 +592,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 (JII)V + public fun draw (JFF)V public fun getHeight ()I public fun getWidth ()I public fun ignoreBlockedTouches (Z)V @@ -618,12 +607,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 (II)V + public fun update (FF)V } public class cc/polyfrost/oneconfig/gui/elements/ColorSelector { - public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;II)V - public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;IIZ)V + public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;FF)V + public fun (Lcc/polyfrost/oneconfig/config/core/OneColor;FFZ)V public fun draw (J)V public fun getColor ()Lcc/polyfrost/oneconfig/config/core/OneColor; public fun isAlphaAllowed ()Z @@ -634,7 +623,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 (JII)V + public fun draw (JFF)V public fun getModData ()Lcc/polyfrost/oneconfig/config/data/Mod; public fun isActive ()Z public fun isDisabled ()Z @@ -648,11 +637,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 (JII)V + public fun draw (JFF)V public fun getValue ()F public fun isDragging ()Z public fun setValue (F)V - public fun update (II)V + public fun update (FF)V } public class cc/polyfrost/oneconfig/gui/elements/config/ConfigButton : cc/polyfrost/oneconfig/config/elements/BasicOption { @@ -750,7 +739,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 (JII)V + public fun draw (JFF)V public fun getCurrentValue ()F public fun onClose ()V public fun setCurrentValue (F)V @@ -778,12 +767,12 @@ public class cc/polyfrost/oneconfig/gui/elements/text/TextInputField : cc/polyfr protected field startLine I protected field vg J protected field wrappedText Ljava/util/ArrayList; - protected field x I - protected field y I + protected field x F + protected field y F public fun (IILjava/lang/String;ZZ)V public fun (IILjava/lang/String;ZZLcc/polyfrost/oneconfig/internal/assets/SVGs;)V public fun (IIZLjava/lang/String;)V - public fun draw (JII)V + public fun draw (JFF)V public fun getInput ()Ljava/lang/String; public fun getLines ()I public fun getPassword ()Z @@ -849,76 +838,121 @@ public abstract class cc/polyfrost/oneconfig/gui/pages/Page { public fun scrollWithDraw (JII)V } +public abstract class cc/polyfrost/oneconfig/hud/BasicHud : cc/polyfrost/oneconfig/hud/Hud { + protected field bgColor Lcc/polyfrost/oneconfig/config/core/OneColor; + protected field border Z + protected field borderColor Lcc/polyfrost/oneconfig/config/core/OneColor; + protected field borderSize F + protected field cornerRadius F + protected field paddingX F + protected field paddingY F + protected field rounded Z + public fun ()V + public fun (Z)V + public fun (ZFF)V + public fun (ZFFF)V + public fun (ZFFFZFFFLcc/polyfrost/oneconfig/config/core/OneColor;ZFLcc/polyfrost/oneconfig/config/core/OneColor;)V + public fun drawAll (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Z)V + protected fun drawBackground (FFFFF)V + public fun setScale (FZ)V + protected fun shouldDrawBackground ()Z +} + public class cc/polyfrost/oneconfig/hud/HUDUtils { public fun ()V public static fun addHudOptions (Lcc/polyfrost/oneconfig/config/elements/OptionPage;Ljava/lang/reflect/Field;Ljava/lang/Object;Lcc/polyfrost/oneconfig/config/Config;)V } public abstract class cc/polyfrost/oneconfig/hud/Hud { - public field bgColor Lcc/polyfrost/oneconfig/config/core/OneColor; - public field border Z - public field borderColor Lcc/polyfrost/oneconfig/config/core/OneColor; - public field borderSize F - public field cornerRadius F - public field enabled Z - public field paddingX F - public field paddingY F - public field rounded Z - public field scale F + protected field enabled Z + public final field position Lcc/polyfrost/oneconfig/hud/Position; + protected field scale F public field showInChat Z public field showInDebug Z public field showInGuis Z - public field xUnscaled D - public field yUnscaled D + public fun ()V public fun (Z)V - public fun (ZII)V - public fun (ZIIFZIIILcc/polyfrost/oneconfig/config/core/OneColor;ZFLcc/polyfrost/oneconfig/config/core/OneColor;)V - public fun (ZIII)V - public abstract fun draw (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V - public fun drawAll (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;FFFZ)V - public fun drawBackground ()Z - public fun drawExample (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V - public fun drawExampleAll (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;FFFZ)V - public fun getExampleHeight (F)I - public fun getExampleWidth (F)I - public abstract fun getHeight (F)I - public abstract fun getWidth (F)I - public fun getXScaled (I)F - public fun getYScaled (I)F + public fun (ZFF)V + public fun (ZFFF)V + protected abstract fun draw (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;FFFZ)V + public fun drawAll (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Z)V + protected abstract fun getHeight (FZ)F + public fun getScale ()F + protected abstract fun getWidth (FZ)F public fun isEnabled ()Z + protected fun preRender (Z)V public fun setConfig (Lcc/polyfrost/oneconfig/config/Config;)V + public fun setScale (FZ)V + protected fun shouldShow ()Z +} + +public class cc/polyfrost/oneconfig/hud/Position { + public fun (FFFF)V + public fun (FFFFFF)V + public fun getBottomY ()F + public fun getBottomY (F)F + public fun getCenterX ()F + public fun getCenterX (F)F + public fun getCenterY ()F + public fun getCenterY (F)F + public fun getHeight ()F + public fun getRightX ()F + public fun getRightX (F)F + public fun getWidth ()F + public fun getX ()F + public fun getX (F)F + public fun getY ()F + public fun getY (F)F + public fun setPosition (FF)V + public fun setPosition (FFFF)V + public fun setSize (FF)V + public fun updateSizePosition (FF)V +} + +public final class cc/polyfrost/oneconfig/hud/Position$AnchorPosition : java/lang/Enum { + public static final field BOTTOM_CENTER Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field BOTTOM_LEFT Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field BOTTOM_RIGHT Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field MIDDLE_CENTER Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field MIDDLE_LEFT Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field MIDDLE_RIGHT Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field TOP_CENTER Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field TOP_LEFT Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static final field TOP_RIGHT Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public final field x F + public final field y F + public static fun valueOf (Ljava/lang/String;)Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; + public static fun values ()[Lcc/polyfrost/oneconfig/hud/Position$AnchorPosition; } public abstract class cc/polyfrost/oneconfig/hud/SingleTextHud : cc/polyfrost/oneconfig/hud/TextHud { - public field brackets Z - public field title Ljava/lang/String; - public field titleLocation I + protected field brackets Z + protected field title Ljava/lang/String; + protected field titleLocation I public fun (Ljava/lang/String;Z)V public fun (Ljava/lang/String;ZII)V protected final fun getCompleteText (Ljava/lang/String;)Ljava/lang/String; - protected fun getExampleLines (Ljava/util/List;)V - protected fun getExampleLinesFrequent (Ljava/util/List;)V - protected fun getExampleText ()Ljava/lang/String; - protected fun getExampleTextFrequent ()Ljava/lang/String; - protected fun getLines (Ljava/util/List;)V - protected fun getLinesFrequent (Ljava/util/List;)V - protected abstract fun getText ()Ljava/lang/String; - protected fun getTextFrequent ()Ljava/lang/String; -} - -public abstract class cc/polyfrost/oneconfig/hud/TextHud : cc/polyfrost/oneconfig/hud/Hud { - public field color Lcc/polyfrost/oneconfig/config/core/OneColor; + protected fun getLines (Ljava/util/List;Z)V + protected fun getLinesFrequent (Ljava/util/List;Z)V + protected abstract fun getText (Z)Ljava/lang/String; + protected fun getTextFrequent (Z)Ljava/lang/String; +} + +public abstract class cc/polyfrost/oneconfig/hud/TextHud : cc/polyfrost/oneconfig/hud/BasicHud { + protected field color Lcc/polyfrost/oneconfig/config/core/OneColor; protected field lines Ljava/util/List; - public field textType I + protected field textType I public fun (Z)V public fun (ZII)V - public fun draw (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V - protected fun getExampleLines (Ljava/util/List;)V - protected fun getExampleLinesFrequent (Ljava/util/List;)V - public fun getHeight (F)I - protected abstract fun getLines (Ljava/util/List;)V - protected fun getLinesFrequent (Ljava/util/List;)V - public fun getWidth (F)I + public fun draw (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;FFFZ)V + protected fun drawLine (Ljava/lang/String;FFF)V + protected fun getHeight (FZ)F + protected fun getLineWidth (Ljava/lang/String;F)F + protected abstract fun getLines (Ljava/util/List;Z)V + protected fun getLinesFrequent (Ljava/util/List;Z)V + protected fun getWidth (FZ)F + protected fun preRender (Z)V + public fun shouldDrawBackground ()Z } public class cc/polyfrost/oneconfig/images/Image { @@ -1003,18 +1037,49 @@ public abstract interface class cc/polyfrost/oneconfig/platform/MousePlatform { public abstract fun isButtonDown (I)Z } +public abstract interface class cc/polyfrost/oneconfig/platform/NanoVGPlatform { + public static final field NVG_ANTIALIAS I + public static final field NVG_DEBUG I + public static final field NVG_IMAGE_NODELETE I + public static final field NVG_STENCIL_STROKES I + public abstract fun nnvgCreate (I)J + public abstract fun nnvgDelete (J)V + public abstract fun nnvglCreateImageFromHandle (JIIII)I + public abstract fun nnvglImageHandle (JI)I + public abstract fun nnvgluBindFramebuffer (JJ)V + public abstract fun nnvgluCreateFramebuffer (JIII)J + public abstract fun nnvgluDeleteFramebuffer (JJ)V + public abstract fun nvgCreate (I)J + public abstract fun nvgDelete (J)V + public abstract fun nvglCreateImageFromHandle (JIIII)I + public abstract fun nvglImageHandle (JI)I + public abstract fun nvgluBindFramebuffer (JLorg/lwjgl/nanovg/NVGLUFramebuffer;)V + public abstract fun nvgluCreateFramebuffer (JIII)Lorg/lwjgl/nanovg/NVGLUFramebuffer; + public abstract fun nvgluDeleteFramebuffer (JLorg/lwjgl/nanovg/NVGLUFramebuffer;)V + public abstract fun triggerStaticInitialization ()V +} + public abstract interface class cc/polyfrost/oneconfig/platform/Platform { public static fun getGLPlatform ()Lcc/polyfrost/oneconfig/platform/GLPlatform; public static fun getGuiPlatform ()Lcc/polyfrost/oneconfig/platform/GuiPlatform; public static fun getI18nPlatform ()Lcc/polyfrost/oneconfig/platform/I18nPlatform; public static fun getInstance ()Lcc/polyfrost/oneconfig/platform/Platform; + public abstract fun getLoader ()Lcc/polyfrost/oneconfig/platform/Platform$Loader; public static fun getLoaderPlatform ()Lcc/polyfrost/oneconfig/platform/LoaderPlatform; public abstract fun getMinecraftVersion ()I public static fun getMousePlatform ()Lcc/polyfrost/oneconfig/platform/MousePlatform; + public static fun getNanoVGPlatform ()Lcc/polyfrost/oneconfig/platform/NanoVGPlatform; public static fun getServerPlatform ()Lcc/polyfrost/oneconfig/platform/ServerPlatform; public abstract fun isCallingFromMinecraftThread ()Z } +public final class cc/polyfrost/oneconfig/platform/Platform$Loader : java/lang/Enum { + public static final field FABRIC Lcc/polyfrost/oneconfig/platform/Platform$Loader; + public static final field FORGE Lcc/polyfrost/oneconfig/platform/Platform$Loader; + public static fun valueOf (Ljava/lang/String;)Lcc/polyfrost/oneconfig/platform/Platform$Loader; + public static fun values ()[Lcc/polyfrost/oneconfig/platform/Platform$Loader; +} + public class cc/polyfrost/oneconfig/platform/Platform$PlatformHolder { } @@ -1053,7 +1118,6 @@ public final class cc/polyfrost/oneconfig/renderer/RenderManager { public static fun drawInfo (JLcc/polyfrost/oneconfig/config/data/InfoType;FFF)V public static fun drawLine (JFFFFFI)V public static fun drawRect (JFFFFI)V - public static fun drawRectangle (JFFFFI)V public static fun drawRoundImage (JLcc/polyfrost/oneconfig/internal/assets/Images;FFFFF)V public static fun drawRoundImage (JLjava/lang/String;FFFFF)V public static fun drawRoundedRect (JFFFFIF)V @@ -1129,7 +1193,7 @@ public class cc/polyfrost/oneconfig/renderer/scissor/Scissor { public field y F public fun (FFFF)V public fun (Lcc/polyfrost/oneconfig/renderer/scissor/Scissor;)V - public fun isInScissor (II)Z + public fun isInScissor (FF)Z } public class cc/polyfrost/oneconfig/renderer/scissor/ScissorManager { @@ -1152,16 +1216,16 @@ public final class cc/polyfrost/oneconfig/utils/IOUtils { public final class cc/polyfrost/oneconfig/utils/InputUtils { public fun ()V public static fun blockAllInput ()Lcc/polyfrost/oneconfig/renderer/scissor/Scissor; - public static fun blockInputArea (IIII)Lcc/polyfrost/oneconfig/renderer/scissor/Scissor; - public static fun isAreaClicked (IIII)Z - public static fun isAreaClicked (IIIIZ)Z - public static fun isAreaHovered (IIII)Z - public static fun isAreaHovered (IIIIZ)Z + 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 ()I - public static fun mouseY ()I + 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 } @@ -1263,6 +1327,7 @@ public abstract class cc/polyfrost/oneconfig/utils/commands/PlatformCommandManag public abstract interface annotation class cc/polyfrost/oneconfig/utils/commands/annotations/Command : java/lang/annotation/Annotation { public abstract fun aliases ()[Ljava/lang/String; + public abstract fun color ()Lcc/polyfrost/oneconfig/libs/universal/ChatColor; public abstract fun description ()Ljava/lang/String; public abstract fun helpCommand ()Z public abstract fun value ()Ljava/lang/String; @@ -1282,6 +1347,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/utils/commands public abstract interface annotation class cc/polyfrost/oneconfig/utils/commands/annotations/SubCommand : java/lang/annotation/Annotation { public abstract fun aliases ()[Ljava/lang/String; + public abstract fun color ()Lcc/polyfrost/oneconfig/libs/universal/ChatColor; public abstract fun description ()Ljava/lang/String; public abstract fun value ()Ljava/lang/String; } @@ -1467,19 +1533,16 @@ public final class cc/polyfrost/oneconfig/utils/gui/GuiUtils { 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 doesGuiPauseGame ()Z public abstract fun draw (JF)V - public fun getMouseX ()I - public fun getMouseY ()I + protected fun getMouseX ()F + protected fun getMouseY ()F public fun ignoreMinecraftScale ()Z - public fun initScreen (II)V public fun isBlockingClicks ()Z - public fun isClicked ()Z - public fun isClicked (Z)Z - public fun isMouseDown ()Z - public fun onDrawScreen (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V - public fun onMouseClicked (DDI)V - public abstract fun onScreenClose ()V - public abstract fun onScreenOpen ()V + protected fun isClicked ()Z + protected fun isClicked (Z)Z + protected fun isMouseDown ()Z + public final fun onDrawScreen (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V public fun shouldBlockClicks (Z)V } diff --git a/build.gradle.kts b/build.gradle.kts index 056d1d1..89d44d9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -114,7 +114,7 @@ dependencies { shade("org.spongepowered:mixin:0.7.11-SNAPSHOT") { isTransitive = false } - shade("cc.polyfrost:lwjgl-1.8.9-forge:1.0.0-alpha5") + shade("cc.polyfrost:lwjgl-1.8.9-forge:1.0.0-alpha8") shadeNoPom(prebundle(shadeRelocated)) configurations.named(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME) { extendsFrom(shadeNoPom) } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92f06b5..2ec77e5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/lwjgl/1.16.2-fabric/api/1.16.2-fabric.api b/lwjgl/1.16.2-fabric/api/1.16.2-fabric.api new file mode 100644 index 0000000..e69de29 diff --git a/lwjgl/build.gradle.kts b/lwjgl/build.gradle.kts index fcc5511..925fb4d 100644 --- a/lwjgl/build.gradle.kts +++ b/lwjgl/build.gradle.kts @@ -16,7 +16,7 @@ val mod_name: String by project val mod_version: String by project val mod_id: String by project -version = "1.0.0-alpha5" +version = "1.0.0-alpha8" repositories { maven("https://repo.polyfrost.cc/releases") @@ -50,19 +50,27 @@ dependencies { shadeRuntimeOnly("org.lwjgl:lwjgl:$lwjgl:natives-macos") shadeRuntimeOnly("org.lwjgl:lwjgl-stb:$lwjgl:natives-macos") shadeRuntimeOnly("org.lwjgl:lwjgl-tinyfd:$lwjgl:natives-macos") + shadeRuntimeOnly("org.lwjgl:lwjgl:$lwjgl:natives-macos-arm64") + shadeRuntimeOnly("org.lwjgl:lwjgl-stb:$lwjgl:natives-macos-arm64") + shadeRuntimeOnly("org.lwjgl:lwjgl-tinyfd:$lwjgl:natives-macos-arm64") } shadeCompileOnly("org.lwjgl:lwjgl-nanovg:$lwjgl") { - isTransitive = platform.isLegacyForge + isTransitive = false } shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:$lwjgl:natives-windows") { - isTransitive = platform.isLegacyForge + isTransitive = false } shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:$lwjgl:natives-linux") { - isTransitive = platform.isLegacyForge + isTransitive = false } shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:$lwjgl:natives-macos") { - isTransitive = platform.isLegacyForge + isTransitive = false + } + // force 3.3.1 for this, because + // if the user is actually running M1+, LWJGL must be 3.3.0+ + shadeRuntimeOnly("org.lwjgl:lwjgl-nanovg:3.3.1:natives-macos-arm64") { + isTransitive = false } } @@ -70,10 +78,10 @@ tasks { named("shadowJar") { archiveClassifier.set("") configurations = listOf(shadeCompileOnly, shadeRuntimeOnly) - exclude("META-INF/versions/**") - exclude("**/module-info.class") - exclude("**/package-info.class") if (platform.isLegacyForge) { + exclude("META-INF/versions/**") + exclude("**/module-info.class") + exclude("**/package-info.class") relocate("org.lwjgl", "org.lwjgl3") { include("org.lwjgl.PointerBuffer") include("org.lwjgl.BufferUtils") diff --git a/lwjgl/root.gradle.kts b/lwjgl/root.gradle.kts index d2dc0c7..2c4ada8 100644 --- a/lwjgl/root.gradle.kts +++ b/lwjgl/root.gradle.kts @@ -10,7 +10,9 @@ plugins { preprocess { "1.8.9-forge"(10809, "srg") { "1.12.2-forge"(11202, "srg") { - "1.16.2-forge"(11602, "srg") + "1.16.2-forge"(11602, "srg") { + "1.16.2-fabric"(11602, "yarn") + } } } } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 1ac4f26..e5fe21b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -40,7 +40,8 @@ project(":platform").apply { listOf( "1.8.9-forge", "1.12.2-forge", - "1.16.2-forge" + "1.16.2-forge", + "1.16.2-fabric" ).forEach { version -> include(":platform:$version") include(":lwjgl:$version") diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java index 8a5608e..1b5c5e6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java @@ -24,7 +24,10 @@ import cc.polyfrost.oneconfig.utils.JsonUtils; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; import com.google.gson.*; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java index 791bc4a..7e844f0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java @@ -14,7 +14,6 @@ public class OneKeyBind { keyBinds.add(key); } } - public boolean isActive() { if (keyBinds.size() == 0) return false; for (int keyBind : keyBinds) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java index 44b2b5c..344f7bb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/GuiPause.java @@ -5,5 +5,6 @@ package cc.polyfrost.oneconfig.gui; * Minecraft itself. */ public interface GuiPause { + @SuppressWarnings("unused") boolean doesGuiPauseGame(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java deleted file mode 100644 index fc90c01..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java +++ /dev/null @@ -1,292 +0,0 @@ -package cc.polyfrost.oneconfig.gui; - -import cc.polyfrost.oneconfig.hud.Hud; -import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; -import cc.polyfrost.oneconfig.internal.hud.HudCore; -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.renderer.RenderManager; -import cc.polyfrost.oneconfig.utils.gui.GuiUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.util.ArrayList; - -public class HudGui extends UScreen implements GuiPause { - private Hud editingHud; - private boolean isDragging; - private boolean isScaling; - private final boolean openOneConfigOnClose; - private int xOffset; - private int yOffset; - - public HudGui(boolean openOneConfigOnClose) { - super(); - this.openOneConfigOnClose = openOneConfigOnClose; - } - - @Override - public void initScreen(int width, int height) { - HudCore.editing = true; - UKeyboard.allowRepeatEvents(true); - super.initScreen(width, height); - } - - @Override - public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - RenderManager.drawGlRect(0, 0, UResolution.getScaledWidth(), UResolution.getScaledHeight(), new Color(80, 80, 80, 50).getRGB()); - - if (isDragging) { - setPosition(mouseX - xOffset, mouseY - yOffset, true); - } - - for (Hud hud : HudCore.huds) { - if (hud.isEnabled()) processHud(matrixStack, hud, mouseX); - } - } - - private void processHud(UMatrixStack matrixStack, Hud hud, int mouseX) { - if (hud == editingHud && isScaling) { - float xFloat = hud.getXScaled(UResolution.getScaledWidth()); - float yFloat = hud.getYScaled(UResolution.getScaledHeight()); - float pos = getXSnapping(mouseX, true); - float newWidth = pos - xFloat; - float newScale = newWidth / ((hud.getWidth(hud.scale) + hud.paddingX * hud.scale) / hud.scale); - if (newScale > 20) - newScale = 20; - else if (newScale < 0.3) - newScale = 0.3f; - hud.scale = newScale; - - if (xFloat / UResolution.getScaledWidth() > 0.5) - editingHud.xUnscaled = (xFloat + (hud.getWidth(hud.scale) + hud.paddingX * hud.scale)) / (double) UResolution.getScaledWidth(); - if (yFloat / UResolution.getScaledHeight() > 0.5) - editingHud.yUnscaled = (yFloat + (hud.getHeight(hud.scale) + hud.paddingY * hud.scale)) / (double) UResolution.getScaledHeight(); - } - - int width = (int) (hud.getExampleWidth(hud.scale) + hud.paddingX * hud.scale); - int height = (int) (hud.getExampleHeight(hud.scale) + hud.paddingY * hud.scale); - int x = (int) hud.getXScaled(UResolution.getScaledWidth()); - int y = (int) hud.getYScaled(UResolution.getScaledHeight()); - - hud.drawExampleAll(matrixStack, x, y, hud.scale, true); - int color = new Color(215, 224, 235).getRGB(); - if (editingHud == hud) { - color = new Color(43, 159, 235).getRGB(); - if (isDragging) - RenderManager.drawGlRect(x, y, width, height, new Color(108, 176, 255, 60).getRGB()); - } - int finalColor = color; - RenderManager.setupAndDraw(true, (vg) -> { - RenderManager.drawLine(vg, x - 2 / 4f, y, x + width + 2 / 4f, y, 1, finalColor); - RenderManager.drawLine(vg, x, y, x, y + height, 1, finalColor); - RenderManager.drawLine(vg, x + width, y, x + width, y + height, 1, finalColor); - RenderManager.drawLine(vg, x - 2 / 4f, y + height, x + width + 2 / 4f, y + height, 1, finalColor); - }); - - if (hud == editingHud && !isDragging) { - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawCircle(vg, x + width, y + height, 3, new Color(43, 159, 235).getRGB())); - } - } - - private void setPosition(float newX, float newY, boolean snap) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - - if (newX < 0) - newX = 0; - else if (newX + width > UResolution.getScaledWidth()) - newX = UResolution.getScaledWidth() - width; - if (newY < 0) - newY = 0; - else if (newY + height > UResolution.getScaledHeight()) - newY = UResolution.getScaledHeight() - height; - - if (snap) { - float snapX = getXSnapping(newX, false); - float snapY = getYSnapping(newY); - if (snapX != newX || snapY != newY) { - newX = snapX; - newY = snapY; - } - } - - if (newX / UResolution.getScaledWidth() <= 0.5) - editingHud.xUnscaled = newX / (double) UResolution.getScaledWidth(); - else - editingHud.xUnscaled = (newX + width) / (double) UResolution.getScaledWidth(); - if (newY / UResolution.getScaledHeight() <= 0.5) - editingHud.yUnscaled = newY / (double) UResolution.getScaledHeight(); - else - editingHud.yUnscaled = (newY + height) / (double) UResolution.getScaledHeight(); - } - - private float getXSnapping(float pos, boolean rightOnly) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - ArrayList verticalLines = new ArrayList<>(); - for (Hud hud : HudCore.huds) { - if (!hud.isEnabled()) continue; - verticalLines.addAll(getXSnappingHud(hud)); - } - getSpaceSnapping(verticalLines); - verticalLines.add(UResolution.getScaledWidth() / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineX : verticalLines) { - for (float offset = 0; offset <= (rightOnly ? 0 : width); offset += width / 2f) { - if (Math.abs(lineX - pos - offset) < 5 && (Math.abs(lineX - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineX - pos); - smallestLine = lineX; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - float finalSmallestLine = smallestLine; - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, finalSmallestLine, 0, finalSmallestLine, UResolution.getScaledHeight(), 1, new Color(255, 255, 255).getRGB())); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList getXSnappingHud(Hud hud) { - ArrayList verticalLines = new ArrayList<>(); - if (hud == editingHud) return verticalLines; - int hudWidth = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int hudX = (int) hud.getXScaled(UResolution.getScaledWidth()); - verticalLines.add((float) hudX); - verticalLines.add((float) (hudX + hudWidth)); - return verticalLines; - } - - private float getYSnapping(float pos) { - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - ArrayList horizontalLines = new ArrayList<>(); - for (Hud hud : HudCore.huds) { - if (!hud.isEnabled()) continue; - horizontalLines.addAll(getYSnappingHud(hud)); - } - getSpaceSnapping(horizontalLines); - horizontalLines.add(UResolution.getScaledHeight() / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineY : horizontalLines) { - for (float offset = 0; offset <= height; offset += height / 2f) { - if (Math.abs(lineY - pos - offset) < 5 && (Math.abs(lineY - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineY - pos); - smallestLine = lineY; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - float finalSmallestLine = smallestLine; - RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawLine(vg, 0, finalSmallestLine, UResolution.getScaledWidth(), finalSmallestLine, 1, new Color(255, 255, 255).getRGB())); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList getYSnappingHud(Hud hud) { - ArrayList horizontalLines = new ArrayList<>(); - if (hud == editingHud) return horizontalLines; - int hudHeight = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int hudY = (int) hud.getYScaled(UResolution.getScaledHeight()); - horizontalLines.add((float) hudY); - horizontalLines.add((float) (hudY + hudHeight)); - return horizontalLines; - } - - private void getSpaceSnapping(ArrayList lines) { - ArrayList newLines = new ArrayList<>(); - for (int i = 0; i < lines.size(); i++) { - for (int l = i + 1; l < lines.size(); l++) { - newLines.add(Math.max(lines.get(i), lines.get(l)) + Math.abs(lines.get(i) - lines.get(l))); - newLines.add(Math.min(lines.get(i), lines.get(l)) - Math.abs(lines.get(i) - lines.get(l))); - } - } - lines.addAll(newLines); - } - - @Override - public void onMouseClicked(double mouseX, double mouseY, int mouseButton) { - super.onMouseClicked(mouseX, mouseY, mouseButton); - if (mouseButton == 0) { - if (editingHud != null) { - int width = (int) (editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale); - int height = (int) (editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale); - float x = editingHud.getXScaled(UResolution.getScaledWidth()); - float y = editingHud.getYScaled(UResolution.getScaledHeight()); - if (mouseX >= x + width - 3 && mouseX <= x + width + 3 && mouseY >= y + height - 3 && mouseY <= y + height + 3) { - isScaling = true; - return; - } - } - editingHud = null; - for (Hud hud : HudCore.huds) { - if (!hud.isEnabled()) continue; - if (mouseClickedHud(hud, (int) mouseX, (int) mouseY)) - break; - } - } - } - - private boolean mouseClickedHud(Hud hud, int mouseX, int mouseY) { - int width = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int height = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - float x = hud.getXScaled(UResolution.getScaledWidth()); - float y = hud.getYScaled(UResolution.getScaledHeight()); - if (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height) { - editingHud = hud; - xOffset = (int) (mouseX - x); - yOffset = (int) (mouseY - y); - isDragging = true; - return true; - } - return false; - } - - @Override - public void onMouseReleased(double mouseX, double mouseY, int state) { - super.onMouseReleased(mouseX, mouseY, state); - isDragging = false; - isScaling = false; - } - - @Override - public void onKeyPressed(int keyCode, char typedChar, @Nullable UKeyboard.Modifiers modifiers) { - if (editingHud != null) { - float x = editingHud.getXScaled(UResolution.getScaledWidth()); - float y = editingHud.getYScaled(UResolution.getScaledHeight()); - if (keyCode == UKeyboard.KEY_UP) { - setPosition(x, y - 1, false); - } else if (keyCode == UKeyboard.KEY_DOWN) { - setPosition(x, y + 1, false); - } else if (keyCode == UKeyboard.KEY_LEFT) { - setPosition(x - 1, y, false); - } else if (keyCode == UKeyboard.KEY_RIGHT) { - setPosition(x + 1, y, false); - } - } - super.onKeyPressed(keyCode, typedChar, modifiers); - } - - @Override - public void onScreenClose() { - super.onScreenClose(); - HudCore.editing = false; - UKeyboard.allowRepeatEvents(false); - ConfigCore.saveAll(); - if(openOneConfigOnClose) GuiUtils.displayScreen(OneConfigGui.create()); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 41d0b4f..1d40d0a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -85,13 +85,13 @@ 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); - if (Colors.ROUNDED_CORNERS) { - RenderManager.drawDropShadow(vg, x, y, 1280, 800, 32, 0, 20); - RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, Colors.GRAY_800, Colors.CORNER_RADIUS_WIN); - RenderManager.drawRoundedRect(vg, x, y, 244, 800, Colors.GRAY_800_95, Colors.CORNER_RADIUS_WIN); - RenderManager.drawRect(vg, x + 224, y, 20, 800, Colors.GRAY_800); - RenderManager.drawHollowRoundRect(vg, x - 1, y - 1, 1282, 802, 0x4DCCCCCC, 20, scale < 1 ? 1 / scale : 1); - } + + RenderManager.drawDropShadow(vg, x, y, 1280, 800, 32, 0, 20); + RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, Colors.GRAY_800, 20f); + RenderManager.drawRoundedRect(vg, x, y, 244, 800, Colors.GRAY_800_95, 20f); + RenderManager.drawRect(vg, x + 224, y, 20, 800, Colors.GRAY_800); + RenderManager.drawHollowRoundRect(vg, x - 1, y - 1, 1282, 802, 0x4DCCCCCC, 20, scale < 1 ? 1 / scale : 1); + RenderManager.drawLine(vg, x + 224, y + 72, x + 1280, y + 72, 1, Colors.GRAY_700); RenderManager.drawLine(vg, x + 224, y, x + 222, y + 800, 1, Colors.GRAY_700); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index d1b5532..ebfc8cb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -10,6 +10,7 @@ import cc.polyfrost.oneconfig.gui.pages.ModsPage; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.internal.assets.SVGs; 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.color.ColorPalette; @@ -43,7 +44,7 @@ public class SideBar { buttons.get(0).setClickAction(new CreditsPage()); buttons.get(2).setClickAction(new ModsPage()); buttons.get(8).setClickAction(new ModConfigPage(Preferences.getInstance().mod.defaultPage, true)); - HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui(true))); + HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui())); CloseButton.setClickAction(GuiUtils::closeScreen); for (BasicButton button : buttons) { if (button.hasClickAction()) continue; 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 7869114..1691eca 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -16,9 +16,9 @@ public class BasicButton extends BasicElement { protected SVGs icon1, icon2; private final int alignment; private final float fontSize, cornerRadius; - private final int xSpacing, xPadding; + private final float xSpacing, xPadding; private final int iconSize; - public int x, y; + public float x, y; public static final int ALIGNMENT_LEFT = 0; public static final int ALIGNMENT_CENTER = 2; public static final int ALIGNMENT_JUSTIFIED = 3; @@ -57,7 +57,7 @@ public class BasicButton extends BasicElement { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { this.x = x; this.y = y; this.update(x, y); 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 6f203c4..ef98120 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -72,13 +72,13 @@ public class BasicElement { /** * Draw script for the element. - *
Make sure to call {@link #update(int x, int y)} to update the elements states! + *
Make sure to call {@link #update(float, float)} 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, int x, int y) { + public void draw(long vg, float x, float y) { this.update(x, y); RenderManager.drawRoundedRect(vg, x, y, width, height, currentColor, radius); } @@ -86,7 +86,7 @@ public class BasicElement { /** * Update this element's clicked, hovered, toggled, and pressed states, invoke any necessary methods, and update the color animation. */ - public void update(int x, int y) { + public void update(float x, float y) { if (disabled) { hovered = false; pressed = false; 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 1fed640..568567d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -45,21 +45,21 @@ public class ColorSelector { private final ColorSlider topSlider = new ColorSlider(384, 0, 360, 127); private final ColorSlider bottomSlider = new ColorSlider(384, 0, 255, 100); private final Slider speedSlider = new Slider(296, 1, 32, 0); - private int x; - private int y; + private float x; + private float y; private Animation barMoveAnimation = new DummyAnimation(18); private Animation moveAnimation = new DummyAnimation(1); - private int mouseX, mouseY; + private float mouseX, mouseY; private int mode = 0; private boolean dragging, mouseWasDown; private final boolean hasAlpha; private Scissor inputScissor = null; - public ColorSelector(OneColor color, int mouseX, int mouseY) { + public ColorSelector(OneColor color, float mouseX, float mouseY) { this(color, mouseX, mouseY, true); } - public ColorSelector(OneColor color, int mouseX, int mouseY, boolean hasAlpha) { + public ColorSelector(OneColor color, float mouseX, float mouseY, boolean hasAlpha) { this.color = color; this.hasAlpha = hasAlpha; buttons.add(new BasicButton(124, 28, "HSB Box", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY)); @@ -82,12 +82,12 @@ public class ColorSelector { this.y = Math.max(0, mouseY - 776); if (color.getDataBit() != -1) mode = 2; if (mode == 0 || mode == 2) { - this.mouseX = (int) (color.getSaturation() / 100f * 384 + x + 16); - this.mouseY = (int) (Math.abs(color.getBrightness() / 100f - 1f) * 288 + y + 120); + this.mouseX = (color.getSaturation() / 100f * 384 + x + 16); + this.mouseY = (Math.abs(color.getBrightness() / 100f - 1f) * 288 + y + 120); } else { topSlider.setValue(color.getBrightness() / 100f * 360f); - this.mouseX = (int) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); - this.mouseY = (int) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); + this.mouseX = (float) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); + this.mouseY = (float) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); } //for(OneColor color1 : OneConfigConfig.recentColors) { // recentColors.add(new ColorBox(color1)); @@ -178,7 +178,7 @@ public class ColorSelector { setColorFromXY(); if (mode != 2) color.setChromaSpeed(-1); - drawColorSelector(vg, mode, (int) (x * percentMoveMain), y); + drawColorSelector(vg, mode, (x * percentMoveMain), y); if (dragging && InputUtils.isClicked(true)) { dragging = false; } @@ -209,7 +209,7 @@ public class ColorSelector { } } - private void drawColorSelector(long vg, int mode, int x, int y) { + private void drawColorSelector(long vg, int mode, float x, float y) { switch (mode) { default: case 0: @@ -242,8 +242,8 @@ public class ColorSelector { private void doDrag() { if (InputUtils.isAreaHovered(x, y, 368, 64) && Platform.getMousePlatform().isButtonDown(0) && !dragging) { - int dx = (int) (Platform.getMousePlatform().getMouseDX() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); - int dy = (int) (Platform.getMousePlatform().getMouseDY() / (OneConfigGui.INSTANCE == null ? 1 : OneConfigGui.INSTANCE.getScaleFactor())); + 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; mouseX += dx; y -= dy; @@ -279,8 +279,8 @@ public class ColorSelector { } break; case 1: - int circleCenterX = x + 208; - int circleCenterY = y + 264; + float circleCenterX = x + 208; + float circleCenterY = y + 264; double squareDist = Math.pow((circleCenterX - InputUtils.mouseX()), 2) + Math.pow((circleCenterY - InputUtils.mouseY()), 2); hovered = squareDist < 144 * 144 && Platform.getMousePlatform().isButtonDown(0); isMouseDown = Platform.getMousePlatform().isButtonDown(0); @@ -293,8 +293,8 @@ public class ColorSelector { if (angle < 0) angle += 360; if ((squareDist / (144 * 144) > 1f)) { saturation = 100; - mouseX = (int) (Math.sin(Math.toRadians(-angle) + 1.5708) * 144 + x + 208); - mouseY = (int) (Math.cos(Math.toRadians(-angle) + 1.5708) * 144 + y + 264); + mouseX = (float) (Math.sin(Math.toRadians(-angle) + 1.5708) * 144 + x + 208); + mouseY = (float) (Math.cos(Math.toRadians(-angle) + 1.5708) * 144 + y + 264); } else { saturation = (int) (squareDist / (144 * 144) * 100); mouseX = InputUtils.mouseX(); @@ -309,14 +309,14 @@ public class ColorSelector { private void setXYFromColor() { bottomSlider.setValue(color.getAlpha()); if (mode == 1) { - mouseX = (int) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); - mouseY = (int) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); + mouseX = (float) (Math.sin(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + x + 208); + mouseY = (float) (Math.cos(Math.toRadians(-color.getHue()) + 1.5708) * (saturationInput.getCurrentValue() / 100 * 144) + y + 264); topSlider.setValue(color.getBrightness() / 100f * 360f); } if (mode == 0 || mode == 2) { topSlider.setValue(color.getHue()); - mouseX = (int) (saturationInput.getCurrentValue() / 100f * 384 + x + 16); - mouseY = (int) (Math.abs(brightnessInput.getCurrentValue() / 100f - 1f) * 288 + y + 120); + mouseX = (saturationInput.getCurrentValue() / 100f * 384 + x + 16); + mouseY = (Math.abs(brightnessInput.getCurrentValue() / 100f - 1f) * 288 + y + 120); } } @@ -429,7 +429,7 @@ public class ColorSelector { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { if (!disabled) update(x, y); else RenderManager.setAlpha(vg, 0.5f); super.dragPointerSize = 15f; @@ -469,7 +469,7 @@ public class ColorSelector { } @Override - public void draw(long vg, int x, int y) { + public void draw(long vg, float x, float y) { RenderManager.drawRoundedRect(vg, x, y, 32, 32, toggl