aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-09-07 22:20:00 +0200
committerGitHub <noreply@github.com>2022-09-07 16:20:00 -0400
commit7c077e278b7266950a968a7e7f2f28b9a140ed96 (patch)
tree56b351874c48126f70e4ef6cbcf914ea832bdcd9
parent17cfe96255f1ec3ab5609aa153d4abed2075c435 (diff)
downloadOneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.tar.gz
OneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.tar.bz2
OneConfig-7c077e278b7266950a968a7e7f2f28b9a140ed96.zip
new: option descriptions (#127)
-rw-r--r--api/OneConfig.api55
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Switch.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java62
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java16
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java11
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java11
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java27
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java1
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java24
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java81
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java1
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java46
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/NVGAsset.java25
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java48
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java34
-rw-r--r--src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/IOUtilsDSL.kt12
-rw-r--r--src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/NetworkUtilsDSL.kt7
-rw-r--r--src/main/resources/assets/oneconfig/icons/InfoArrow.svg1
36 files changed, 383 insertions, 147 deletions
diff --git a/api/OneConfig.api b/api/OneConfig.api
index aafb10b..a922b10 100644
--- a/api/OneConfig.api
+++ b/api/OneConfig.api
@@ -28,6 +28,7 @@ public class cc/polyfrost/oneconfig/config/Config {
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Button : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun size ()I
public abstract fun subcategory ()Ljava/lang/String;
@@ -36,6 +37,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Checkbox : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun size ()I
public abstract fun subcategory ()Ljava/lang/String;
@@ -44,6 +46,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Color : java/lang/annotation/Annotation {
public abstract fun allowAlpha ()Z
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun size ()I
public abstract fun subcategory ()Ljava/lang/String;
@@ -55,6 +58,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Dropdown : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun options ()[Ljava/lang/String;
public abstract fun size ()I
@@ -63,6 +67,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/DualOption : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun left ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun right ()Ljava/lang/String;
@@ -96,6 +101,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/KeyBind : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun size ()I
public abstract fun subcategory ()Ljava/lang/String;
@@ -114,6 +120,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Slider : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun max ()F
public abstract fun min ()F
public abstract fun name ()Ljava/lang/String;
@@ -123,6 +130,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Switch : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun name ()Ljava/lang/String;
public abstract fun size ()I
public abstract fun subcategory ()Ljava/lang/String;
@@ -130,6 +138,7 @@ public abstract interface annotation class cc/polyfrost/oneconfig/config/annotat
public abstract interface annotation class cc/polyfrost/oneconfig/config/annotations/Text : java/lang/annotation/Annotation {
public abstract fun category ()Ljava/lang/String;
+ public abstract fun description ()Ljava/lang/String;
public abstract fun multiline ()Z
public abstract fun name ()Ljava/lang/String;
public abstract fun placeholder ()Ljava/lang/String;
@@ -281,16 +290,18 @@ public final class cc/polyfrost/oneconfig/config/data/PageLocation : java/lang/E
public abstract class cc/polyfrost/oneconfig/config/elements/BasicOption {
public final field category Ljava/lang/String;
+ public final field description Ljava/lang/String;
protected final field field Ljava/lang/reflect/Field;
public final field name Ljava/lang/String;
protected field parent Ljava/lang/Object;
public final field size I
public final field subcategory Ljava/lang/String;
- public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
+ public fun drawDescription (JIIILcc/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;
@@ -301,6 +312,7 @@ public abstract class cc/polyfrost/oneconfig/config/elements/BasicOption {
public fun keyTyped (CI)V
protected fun set (Ljava/lang/Object;)V
public fun setParent (Ljava/lang/Object;)V
+ protected fun shouldDrawDescription ()Z
}
public class cc/polyfrost/oneconfig/config/elements/OptionCategory {
@@ -702,9 +714,9 @@ public class cc/polyfrost/oneconfig/gui/elements/Slider : cc/polyfrost/oneconfig
}
public class cc/polyfrost/oneconfig/gui/elements/config/ConfigButton : cc/polyfrost/oneconfig/config/elements/BasicOption {
- public fun <init> (Ljava/lang/Runnable;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
- public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
- public fun <init> (Ljava/lang/reflect/Method;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
+ public fun <init> (Ljava/lang/Runnable;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V
+ public fun <init> (Ljava/lang/reflect/Method;Ljava/lang/Object;Ljava/lang/String;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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
@@ -712,14 +724,14 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigButton : cc/polyfr
}
public class cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox : cc/polyfrost/oneconfig/config/elements/BasicOption {
- public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (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 <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
public fun getHeight ()I
@@ -728,15 +740,16 @@ 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 <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I[Ljava/lang/String;)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
public fun drawLast (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
public fun getHeight ()I
+ protected fun shouldDrawDescription ()Z
}
public class cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption : cc/polyfrost/oneconfig/config/elements/BasicOption {
- public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
public fun getHeight ()I
@@ -757,7 +770,7 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo : cc/polyfros
}
public class cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind : cc/polyfrost/oneconfig/config/elements/BasicOption {
- public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
public fun getHeight ()I
@@ -774,7 +787,7 @@ public class cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton : cc/po
}
public class cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider : cc/polyfrost/oneconfig/config/elements/BasicOption {
- public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FFI)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
public fun getHeight ()I
@@ -782,18 +795,19 @@ 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 <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (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 <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;ZZ)V
+ public fun <init> (Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/String;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 (JIILcc/polyfrost/oneconfig/utils/InputHandler;)V
public fun getHeight ()I
public fun keyTyped (CI)V
+ protected fun shouldDrawDescription ()Z
}
public class cc/polyfrost/oneconfig/gui/elements/text/NumberInputField : cc/polyfrost/oneconfig/gui/elements/text/TextInputField {
@@ -1163,6 +1177,8 @@ public final class cc/polyfrost/oneconfig/renderer/AssetLoader {
public fun clearImages (J)V
public fun clearSVGs (J)V
public fun getImage (Ljava/lang/String;)I
+ public fun getNVGImage (Ljava/lang/String;)Lcc/polyfrost/oneconfig/renderer/NVGAsset;
+ public fun getNVGSVG (Ljava/lang/String;)Lcc/polyfrost/oneconfig/renderer/NVGAsset;
public fun getSVG (Ljava/lang/String;FF)I
public fun imageToIntBuffer (Ljava/lang/String;)Ljava/nio/IntBuffer;
public fun loadImage (JLcc/polyfrost/oneconfig/renderer/Image;)Z
@@ -1201,6 +1217,13 @@ public class cc/polyfrost/oneconfig/renderer/Image {
public fun <init> (Ljava/lang/String;I)V
}
+public class cc/polyfrost/oneconfig/renderer/NVGAsset {
+ protected fun <init> (III)V
+ public fun getHeight ()I
+ public fun getImage ()I
+ public fun getWidth ()I
+}
+
public final class cc/polyfrost/oneconfig/renderer/RenderManager {
public static fun color (JI)Lorg/lwjgl/nanovg/NVGColor;
public static fun drawBorderedText (Ljava/lang/String;FFII)I
@@ -1321,6 +1344,7 @@ public final class cc/polyfrost/oneconfig/utils/IOUtils {
public fun <init> ()V
public static fun copyImageToClipboard (Ljava/awt/Image;)V
public static fun copyStringToClipboard (Ljava/lang/String;)V
+ public static fun getFileChecksum (Ljava/io/File;)Ljava/lang/String;
public static fun getImageFromClipboard ()Ljava/awt/Image;
public static fun getStringFromClipboard ()Ljava/lang/String;
public static fun resourceToByteBuffer (Ljava/lang/String;)Ljava/nio/ByteBuffer;
@@ -1383,11 +1407,11 @@ public final class cc/polyfrost/oneconfig/utils/NetworkUtils {
public static fun browseLink (Ljava/lang/String;)V
public static fun downloadFile (Ljava/lang/String;Ljava/io/File;)Z
public static fun downloadFile (Ljava/lang/String;Ljava/io/File;Ljava/lang/String;IZ)Z
- public static fun getFileChecksum (Ljava/io/File;)Ljava/lang/String;
public static fun getJsonElement (Ljava/lang/String;)Lcom/google/gson/JsonElement;
public static fun getJsonElement (Ljava/lang/String;Ljava/lang/String;IZ)Lcom/google/gson/JsonElement;
public static fun getString (Ljava/lang/String;)Ljava/lang/String;
public static fun getString (Ljava/lang/String;Ljava/lang/String;IZ)Ljava/lang/String;
+ public static fun setupConnection (Ljava/lang/String;Ljava/lang/String;IZ)Ljava/io/InputStream;
}
public final class cc/polyfrost/oneconfig/utils/Notifications {
@@ -1555,6 +1579,10 @@ public final class cc/polyfrost/oneconfig/utils/dsl/ColorUtilsDSLKt {
public static final fun toColor (I)Lcc/polyfrost/oneconfig/config/core/OneColor;
}
+public final class cc/polyfrost/oneconfig/utils/dsl/IOUtilsDSLKt {
+ public static final fun checksum (Ljava/io/File;)Ljava/lang/String;
+}
+
public final class cc/polyfrost/oneconfig/utils/dsl/JsonUtilsDSLKt {
public static final fun asJsonElement (Ljava/lang/String;Z)Lcom/google/gson/JsonElement;
public static synthetic fun asJsonElement$default (Ljava/lang/String;ZILjava/lang/Object;)Lcom/google/gson/JsonElement;
@@ -1572,7 +1600,6 @@ public final class cc/polyfrost/oneconfig/utils/dsl/MultithreadingDSLKt {
public final class cc/polyfrost/oneconfig/utils/dsl/NetworkUtilsDSLKt {
public static final fun browseLink (Lcc/polyfrost/oneconfig/libs/universal/UDesktop;Ljava/lang/String;)V
- public static final fun checksum (Ljava/io/File;)Ljava/lang/String;
public static final fun download (Ljava/io/File;Ljava/lang/String;Ljava/lang/String;IZ)Z
public static synthetic fun download$default (Ljava/io/File;Ljava/lang/String;Ljava/lang/String;IZILjava/lang/Object;)Z
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java
index 783832e..0a6b66f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java
@@ -42,6 +42,8 @@ public @interface Button {
String text();
+ String description() default "";
+
int size() default 1;
String category() default "General";
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java
index daddfbd..825549d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java
@@ -40,6 +40,8 @@ import java.lang.annotation.Target;
public @interface Checkbox {
String name();
+ String description() default "";
+
int size() default 1;
String category() default "General";
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java
index 09dfa68..caa69f3 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java
@@ -40,6 +40,8 @@ import java.lang.annotation.Target;
public @interface Color {
String name();
+ String description() default "";
+
boolean allowAlpha() default true;
int size() default 1;
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java
index c3ebc6c..02f2ff2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java
@@ -42,6 +42,8 @@ public @interface Dropdown {
String[] options();
+ String description() default "";
+
int size() default 1;
String category() default "General";
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java
index 3bcef12..20b340b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java
@@ -44,6 +44,8 @@ public @interface DualOption {
String right();
+ String description() default "";
+
int size() default 1;
String category() default "General";
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java
index d59a316..cab3a2f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java
@@ -40,6 +40,8 @@ import java.lang.annotation.Target;
public @interface KeyBind {
String name();
+ String description() default "";
+
int size() default 1;
String category() default "General";
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java
index 8cdffc8..f01aaf6 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java
@@ -46,6 +46,8 @@ public @interface Slider {
int step() default 0;
+ String description() default "";
+
String category() default "General";
String subcategory() default "";
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Switch.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Switch.java
index ba8f5d7..253d08d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Switch.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Switch.java
@@ -40,6 +40,8 @@ import java.lang.annotation.Target;
public @interface Switch {
String name();
+ String description() default "";
+
int size() default 1;
String category() default "General";
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java
index a2ced12..e68c2a9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java
@@ -46,6 +46,8 @@ public @interface Text {
boolean multiline() default false;
+ String description() default "";
+
int size() default 1;
String category() default "General";
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 3394c52..a06002c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
@@ -26,8 +26,15 @@
package cc.polyfrost.oneconfig.config.elements;
-import cc.polyfrost.oneconfig.config.Config;
+import cc.polyfrost.oneconfig.gui.animations.Animation;
+import cc.polyfrost.oneconfig.gui.animations.DummyAnimation;
+import cc.polyfrost.oneconfig.gui.animations.EaseOutQuad;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
+import cc.polyfrost.oneconfig.renderer.RenderManager;
+import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.utils.InputHandler;
+import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -39,27 +46,36 @@ public abstract class BasicOption {
protected final Field field;
protected Object parent;
public final String name;
+ public final String description;
public final String category;
public final String subcategory;
private final ArrayList<Supplier<Boolean>> dependencies = new ArrayList<>();
private final ArrayList<Runnable> listeners = new ArrayList<>();
private final ArrayList<Supplier<Boolean>> hideConditions = new ArrayList<>();
+ private Animation descriptionAnimation = new DummyAnimation(0f);
+ private float mouseStillTime = 0f;
+ private float prevMouseX = 0f;
+ private float prevMouseY = 0f;
/**
* Initialize option
*
- * @param field variable attached to option (null for category)
- * @param parent the parent object of the field, used for getting and setting the variable
- * @param name name of option
- * @param size size of option, 0 for single column, 1 for double.
+ * @param field variable attached to option (null for category)
+ * @param parent the parent object of the field, used for getting and setting the variable
+ * @param name name of option
+ * @param description The description
+ * @param category The category
+ * @param subcategory The subcategory
+ * @param size size of option, 0 for single column, 1 for double.
*/
- public BasicOption(Field field, Object parent, String name, String category, String subcategory, int size) {
+ public BasicOption(Field field, Object parent, String name, String description, String category, String subcategory, int size) {
this.field = field;
this.parent = parent;
this.name = name;
- this.size = size;
+ this.description = description;
this.category = category;
this.subcategory = subcategory;
+ this.size = size;
if (field != null) field.setAccessible(true);
}
@@ -114,6 +130,38 @@ public abstract class BasicOption {
public void keyTyped(char key, int keyCode) {
}
+ public void drawDescription(long vg, int x, int y, int height, InputHandler inputHandler) {
+ if (description.trim().equals("")) return;
+ if (inputHandler.isAreaHovered(x - 16, y, size == 1 ? 512f : 1024f, height) && prevMouseX == inputHandler.mouseX() && prevMouseY == inputHandler.mouseY()) {
+ mouseStillTime += GuiUtils.getDeltaTime();
+ } else {
+ mouseStillTime = 0;
+ }
+ prevMouseX = inputHandler.mouseX();
+ prevMouseY = inputHandler.mouseY();
+ boolean shouldDrawDescription = shouldDrawDescription();
+ if (descriptionAnimation.getEnd() != 1f && shouldDrawDescription) {
+ descriptionAnimation = new EaseOutQuad(150, descriptionAnimation.get(0), 1f, false);
+ } else if (descriptionAnimation.getEnd() != 0f && !shouldDrawDescription) {
+ descriptionAnimation = new EaseOutQuad(150, descriptionAnimation.get(0), 0f, false);
+ }
+ if (!shouldDrawDescription && descriptionAnimation.isFinished()) return;
+ float textWidth = RenderManager.getTextWidth(vg, description, 16, Fonts.MEDIUM);
+ RenderManager.setAlpha(vg, descriptionAnimation.get());
+ RenderManager.drawRoundedRect(vg, x, y - 42f, textWidth + 68f, 44f, Colors.GRAY_700, 8f);
+ RenderManager.drawDropShadow(vg, x, y - 42f, textWidth + 68f, 44f, 32f, 0f, 8f);
+ RenderManager.drawSvg(vg, SVGs.INFO_ARROW, x + 16, y - 30f, 20f, 20f, Colors.WHITE_80);
+ RenderManager.drawText(vg, description, x + 52, y - 20, Colors.WHITE_80, 16, Fonts.MEDIUM);
+ RenderManager.setAlpha(vg, 1f);
+ }
+
+ /**
+ * @return If this option should draw its description
+ */
+ protected boolean shouldDrawDescription() {
+ return mouseStillTime > 350;
+ }
+
/**
* @return If the option is enabled, based on the dependencies
*/
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 08c59b8..628e973 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java
@@ -90,11 +90,15 @@ public class OptionSubcategory {
for (int i = 0; i < filteredOptions.size(); i++) {
BasicOption option = filteredOptions.get(i);
option.draw(vg, x, optionY, inputHandler);
+ int optionHeight = option.getHeight();
+ option.drawDescription(vg, x, optionY, optionHeight, 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, inputHandler);
- optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
+ nextOption.drawDescription(vg, x + 512, optionY, optionHeight, inputHandler);
+ int nextOptionHeight = nextOption.getHeight();
+ optionY += Math.max(optionHeight, nextOptionHeight) + 16;
i++;
continue;
}
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 fdd0c2f..681db60 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
@@ -42,20 +42,20 @@ import java.util.Arrays;
public class ConfigButton extends BasicOption {
private final BasicButton button;
- public ConfigButton(Runnable runnable, Object parent, String name, String category, String subcategory, int size, String text) {
- super(null, parent, name, category, subcategory, size);
+ public ConfigButton(Runnable runnable, Object parent, String name, String description, String category, String subcategory, int size, String text) {
+ super(null, parent, name, description, category, subcategory, size);
this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY);
this.button.setClickAction(runnable);
}
- public ConfigButton(Field field, Object parent, String name, String category, String subcategory, int size, String text) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigButton(Field field, Object parent, String name, String description, String category, String subcategory, int size, String text) {
+ super(field, parent, name, description, category, subcategory, size);
this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY);
this.button.setClickAction(getRunnableFromField(field, parent));
}
- public ConfigButton(Method method, Object parent, String name, String category, String subcategory, int size, String text) {
- super(null, parent, name, category, subcategory, size);
+ public ConfigButton(Method method, Object parent, String name, String description, String category, String subcategory, int size, String text) {
+ super(null, parent, name, description, category, subcategory, size);
this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY);
this.button.setClickAction(() -> {
try {
@@ -70,13 +70,13 @@ public class ConfigButton extends BasicOption {
public static ConfigButton create(Field field, Object parent) {
Button button = field.getAnnotation(Button.class);
- return new ConfigButton(field, parent, button.name(), button.category(), button.subcategory(), button.size(), button.text());
+ return new ConfigButton(field, parent, button.name(), button.description(), button.category(), button.subcategory(), button.size(), button.text());
}
public static ConfigButton create(Method method, Object parent) {
method.setAccessible(true);
Button button = method.getAnnotation(Button.class);
- return new ConfigButton(method, parent, button.name(), button.category(), button.subcategory(), button.size(), button.text());
+ return new ConfigButton(method, parent, button.name(), button.description(), button.category(), button.subcategory(), button.size(), button.text());
}
private static Runnable getRunnableFromField(Field field, Object parent) {
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 9cc60c9..6f3be32 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
@@ -48,13 +48,13 @@ public class ConfigCheckbox extends BasicOption {
private final ColorAnimation color = new ColorAnimation(ColorPalette.SECONDARY);
private Animation animation;
- public ConfigCheckbox(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigCheckbox(Field field, Object parent, String name, String description, String category, String subcategory, int size) {
+ super(field, parent, name, description, category, subcategory, size);
}
public static ConfigCheckbox create(Field field, Object parent) {
Checkbox checkbox = field.getAnnotation(Checkbox.class);
- return new ConfigCheckbox(field, parent, checkbox.name(), checkbox.category(), checkbox.subcategory(), checkbox.size());
+ return new ConfigCheckbox(field, parent, checkbox.name(), checkbox.description(), checkbox.category(), checkbox.subcategory(), checkbox.size());
}
@Override
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 39780a1..5e92ddc 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
@@ -48,8 +48,8 @@ public class ConfigColorElement extends BasicOption {
private boolean open = false;
private final boolean allowAlpha;
- public ConfigColorElement(Field field, Object parent, String name, String category, String subcategory, int size, boolean allowAlpha) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigColorElement(Field field, Object parent, String name, String description, String category, String subcategory, int size, boolean allowAlpha) {
+ super(field, parent, name, description, category, subcategory, size);
hexField.setCentered(true);
alphaField.setCentered(true);
alphaField.onlyAcceptNumbers(true);
@@ -58,7 +58,7 @@ public class ConfigColorElement extends BasicOption {
public static ConfigColorElement create(Field field, Object parent) {
Color color = field.getAnnotation(Color.class);
- return new ConfigColorElement(field, parent, color.name(), color.category(), color.subcategory(), color.size(), color.allowAlpha());
+ return new ConfigColorElement(field, parent, color.name(), color.description(), color.category(), color.subcategory(), color.size(), color.allowAlpha());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
index 2660266..6dd463f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
@@ -49,14 +49,14 @@ public class ConfigDropdown extends BasicOption {
private boolean opened = false;
private Scissor inputScissor = null;
- public ConfigDropdown(Field field, Object parent, String name, String category, String subcategory, int size, String[] options) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigDropdown(Field field, Object parent, String name, String description, String category, String subcategory, int size, String[] options) {
+ super(field, parent, name, description, category, subcategory, size);
this.options = options;
}
public static ConfigDropdown create(Field field, Object parent) {
Dropdown dropdown = field.getAnnotation(Dropdown.class);
- return new ConfigDropdown(field, parent, dropdown.name(), dropdown.category(), dropdown.subcategory(), dropdown.size(), dropdown.options());
+ return new ConfigDropdown(field, parent, dropdown.name(), dropdown.description(), dropdown.category(), dropdown.subcategory(), dropdown.size(), dropdown.options());
}
@Override
@@ -189,4 +189,9 @@ public class ConfigDropdown extends BasicOption {
public int getHeight() {
return 32;
}
+
+ @Override
+ protected boolean shouldDrawDescription() {
+ return super.shouldDrawDescription() && !opened;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
index c8582d1..eb1dece 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
@@ -42,15 +42,15 @@ public class ConfigDualOption extends BasicOption {
private final String left, right;
private Animation posAnimation;
- public ConfigDualOption(Field field, Object parent, String name, String category, String subcategory, int size, String left, String right) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigDualOption(Field field, Object parent, String name, String description, String category, String subcategory, int size, String left, String right) {
+ super(field, parent, name, description, category, subcategory, size);
this.left = left;
this.right = right;
}
public static ConfigDualOption create(Field field, Object parent) {
DualOption dualOption = field.getAnnotation(DualOption.class);
- return new ConfigDualOption(field, parent, dualOption.name(), dualOption.category(), dualOption.subcategory(), dualOption.size(), dualOption.left(), dualOption.right());
+ return new ConfigDualOption(field, parent, dualOption.name(), dualOption.description(), dualOption.category(), dualOption.subcategory(), dualOption.size(), dualOption.left(), dualOption.right());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
index 45865fe..5e9f27f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
@@ -40,7 +40,7 @@ import java.lang.reflect.Field;
public class ConfigHeader extends BasicOption {
public ConfigHeader(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ super(field, parent, name, "", category, subcategory, size);
}
public static ConfigHeader create(Field field, Object parent) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
index c44c50d..94afaec 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
@@ -42,7 +42,7 @@ public class ConfigInfo extends BasicOption {
private final InfoType type;
public ConfigInfo(Field field, Object parent, String name, String category, String subcategory, int size, InfoType type) {
- super(field, parent, name, category, subcategory, size);
+ super(field, parent, name, "", category, subcategory, size);
this.type = type;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
index daa034f..491a99c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
@@ -45,15 +45,15 @@ public class ConfigKeyBind extends BasicOption {
private final BasicButton button;
private boolean clicked = false;
- public ConfigKeyBind(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigKeyBind(Field field, Object parent, String name, String description, String category, String subcategory, int size) {
+ super(field, parent, name, description, category, subcategory, size);
button = new BasicButton(256, 32, "", SVGs.KEYSTROKE, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY);
button.setToggleable(true);
}
public static ConfigKeyBind create(Field field, Object parent) {
KeyBind keyBind = field.getAnnotation(KeyBind.class);
- return new ConfigKeyBind(field, parent, keyBind.name(), keyBind.category(), keyBind.subcategory(), keyBind.size());
+ return new ConfigKeyBind(field, parent, keyBind.name(), keyBind.description(), keyBind.category(), keyBind.subcategory(), keyBind.size());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
index de10600..2d8c4f2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
@@ -48,13 +48,13 @@ public class ConfigPageButton extends BasicOption {
private final ColorAnimation backgroundColor = new ColorAnimation(ColorPalette.SECONDARY);
public ConfigPageButton(Field field, Object parent, String name, String description, String category, String subcategory, OptionPage page) {
- super(field, parent, name, category, subcategory, 2);
+ super(field, parent, name, "", category, subcategory, 2);
this.description = description;
this.page = new ModConfigPage(page);
}
public ConfigPageButton(Field field, Object parent, String name, String description, String category, String subcategory, Page page) {
- super(field, parent, name, category, subcategory, 2);
+ super(field, parent, name, "", category, subcategory, 2);
this.description = description;
this.page = page;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
index 4e2dda5..a4088d9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
@@ -46,8 +46,8 @@ public class ConfigSlider extends BasicOption {
private boolean dragging = false;
private boolean mouseWasDown = false;
- public ConfigSlider(Field field, Object parent, String name, String category, String subcategory, float min, float max, int step) {
- super(field, parent, name,category, subcategory, 2);
+ public ConfigSlider(Field field, Object parent, String name, String description, String category, String subcategory, float min, float max, int step) {
+ super(field, parent, name, description, category, subcategory, 2);
this.min = min;
this.max = max;
this.step = step;
@@ -56,7 +56,7 @@ public class ConfigSlider extends BasicOption {
public static ConfigSlider create(Field field, Object parent) {
Slider slider = field.getAnnotation(Slider.class);
- return new ConfigSlider(field, parent, slider.name(), slider.category(), slider.subcategory(), slider.min(), slider.max(), slider.step());
+ return new ConfigSlider(field, parent, slider.name(), slider.description(), slider.category(), slider.subcategory(), slider.min(), slider.max(), slider.step());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
index 9d13e3e..4ecc42b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
@@ -45,13 +45,13 @@ public class ConfigSwitch extends BasicOption {
private ColorAnimation color;
private Animation animation;
- public ConfigSwitch(Field field, Object parent, String name, String category, String subcategory, int size) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigSwitch(Field field, Object parent, String name, String description, String category, String subcategory, int size) {
+ super(field, parent, name, description, category, subcategory, size);
}
public static ConfigSwitch create(Field field, Object parent) {
Switch options = field.getAnnotation(Switch.class);
- return new ConfigSwitch(field, parent, options.name(), options.category(), options.subcategory(), options.size());
+ return new ConfigSwitch(field, parent, options.name(), options.description(), options.category(), options.subcategory(), options.size());
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
index adb9131..4dc497b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
@@ -44,8 +44,8 @@ public class ConfigTextBox extends BasicOption {
private final boolean multiLine;
private final TextInputField textField;
- public ConfigTextBox(Field field, Object parent, String name, String category, String subcategory, int size, String placeholder, boolean secure, boolean multiLine) {
- super(field, parent, name, category, subcategory, size);
+ public ConfigTextBox(Field field, Object parent, String name, String description, String category, String subcategory, int size, String placeholder, boolean secure, boolean multiLine) {
+ super(field, parent, name, category, description, subcategory, size);
this.secure = secure;
this.multiLine = multiLine;
this.textField = new TextInputField(size == 1 ? 256 : 640, multiLine ? 64 : 32, placeholder, multiLine, secure);
@@ -53,7 +53,7 @@ public class ConfigTextBox extends BasicOption {
public static ConfigTextBox create(Field field, Object parent) {
Text text = field.getAnnotation(Text.class);
- return new ConfigTextBox(field, parent, text.name(), text.category(), text.subcategory(), text.secure() || text.multiline() ? 2 : text.size(), text.placeholder(), text.secure(), text.multiline());
+ return new ConfigTextBox(field, parent, text.name(), text.description(), text.category(), text.subcategory(), text.secure() || text.multiline() ? 2 : text.size(), text.placeholder(), text.secure(), text.multiline());
}
@Override
@@ -97,4 +97,9 @@ public class ConfigTextBox extends BasicOption {
public int getHeight() {
return multiLine ? textField.getHeight() : 32;
}
+
+ @Override
+ protected boolean shouldDrawDescription() {
+ return super.shouldDrawDescription() && !textField.isToggled();
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java
index caff4a6..ef8dd8d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java
@@ -32,13 +32,10 @@ import cc.polyfrost.oneconfig.config.core.ConfigUtils;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.config.elements.OptionPage;
import cc.polyfrost.oneconfig.gui.elements.config.*;
-import cc.polyfrost.oneconfig.hud.BasicHud;
-import cc.polyfrost.oneconfig.hud.Hud;
import cc.polyfrost.oneconfig.internal.hud.HudCore;
import java.lang.reflect.Field;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -73,27 +70,27 @@ public class HUDUtils {
HashMap<String, Field> fields = new HashMap<>();
for (Field f : fieldArrayList) fields.put(f.getName(), f);
options.add(new ConfigHeader(field, hud, hudAnnotation.name(), category, subcategory, 2));
- options.add(new ConfigSwitch(fields.get("enabled"), hud, "Enabled", category, subcategory, 2));
+ options.add(new ConfigSwitch(fields.get("enabled"), hud, "Enabled", "If the HUD is enabled", category, subcategory, 2));
options.addAll(ConfigUtils.getClassOptions(hud));
if (hud instanceof BasicHud) {
- options.add(new ConfigCheckbox(fields.get("background"), hud, "Background", category, subcategory, 1));
- options.add(new ConfigCheckbox(fields.get("rounded"), hud, "Rounded corners", category, subcategory, 1));
+ options.add(new ConfigCheckbox(fields.get("background"), hud, "Background", "If the background of the HUD is enabled.", category, subcategory, 1));
+ options.add(new ConfigCheckbox(fields.get("rounded"), hud, "Rounded corners", "If the background has rounded corners.", category, subcategory, 1));
options.get(options.size() - 1).addDependency(() -> ((BasicHud) hud).background || ((BasicHud) hud).border);
- options.add(new ConfigCheckbox(fields.get("border"), hud, "Outline/border", category, subcategory, 1));
- options.add(new ConfigColorElement(fields.get("bgColor"), hud, "Background color:", category, subcategory, 1, true));
+ options.add(new ConfigCheckbox(fields.get("border"), hud, "Outline/border", "If the hud has an outline.", category, subcategory, 1));
+ options.add(new ConfigColorElement(fields.get("bgColor"), hud, "Background color:", "The color of the background.", category, subcategory, 1, true));
options.get(options.size() - 1).addDependency(() -> ((BasicHud) hud).background);
- options.add(new ConfigColorElement(fields.get("borderColor"), hud, "Border color:", category, subcategory, 1, true));
+ options.add(new ConfigColorElement(fields.get("borderColor"), hud, "Border color:", "The color of the border.", category, subcategory, 1, true));
options.get(options.size() - 1).addDependency(() -> ((BasicHud) hud).border);
- options.add(new ConfigSlider(fields.get("cornerRadius"), hud, "Corner radius:", category, subcategory, 0, 10, 0));
+ options.add(new ConfigSlider(fields.get("cornerRadius"), hud, "Corner radius:", "The corner radius of the background.", category, subcategory, 0, 10, 0));
options.get(options.size() - 1).addDependency(() -> ((BasicHud) hud).rounded);
- options.add(new ConfigSlider(fields.get("borderSize"), hud, "Border thickness:", category, subcategory, 0, 10, 0));
+ options.add(new ConfigSlider(fields.get("borderSize"), hud, "Border thickness:", "The thickness of the outline.", category, subcategory, 0, 10, 0));
options.get(options.size() - 1).addDependency(() -> ((BasicHud) hud).border);
if (hud instanceof SingleTextHud) {
- options.add(new ConfigSlider(fields.get("paddingX"), hud, "Width", category, subcategory, 50, 72, 0));
- options.add(new ConfigSlider(fields.get("paddingY"), hud, "Height", category, subcategory, 10, 22, 0));
+ options.add(new ConfigSlider(fields.get("paddingX"), hud, "Width", "The width of the HUD.", category, subcategory, 50, 72, 0));
+ options.add(new ConfigSlider(fields.get("paddingY"), hud, "Height", "The height of the HUD.", category, subcategory, 10, 22, 0));
} else {
- options.add(new ConfigSlider(fields.get("paddingX"), hud, "X-Padding", category, subcategory, 0, 50, 0));
- options.add(new ConfigSlider(fields.get("paddingY"), hud, "Y-Padding", category, subcategory, 0, 50, 0));
+ options.add(new ConfigSlider(fields.get("paddingX"), hud, "X-Padding", "The horizontal padding of the HUD.", category, subcategory, 0, 50, 0));
+ options.add(new ConfigSlider(fields.get("paddingY"), hud, "Y-Padding", "The vertical padding of the HUD.", category, subcategory, 0, 50, 0));
}
options.get(options.size() - 2).addDependency(() -> ((BasicHud) hud).background || ((BasicHud) hud).border);
options.get(options.size() - 1).addDependency(() -> ((BasicHud) hud).background || ((BasicHud) hud).border);
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java b/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java
index cafedde..5ccf384 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java
@@ -51,6 +51,7 @@ public class SVGs {
public static final SVG X_CIRCLE_BOLD = new SVG("/assets/oneconfig/icons/XCircleBold.svg");
public static final SVG CARET_LEFT = new SVG("/assets/oneconfig/icons/CaretLeftBold.svg");
public static final SVG CARET_RIGHT = new SVG("/assets/oneconfig/icons/CaretRightBold.svg");
+ public static final SVG INFO_ARROW = new SVG("/assets/oneconfig/icons/InfoArrow.svg");
// OLD ICONS
public static final SVG BOX = new SVG("/assets/oneconfig/old-icons/Box.svg");
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java
index 66375cc..07c1e2a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig.java
@@ -85,35 +85,35 @@ public class VigilanceConfig extends Config {
ArrayList<BasicOption> options = ConfigUtils.getSubCategory(page, getCategory(attributes), getSubcategory(attributes)).options;
switch (attributes.getType()) {
case SWITCH:
- options.add(new ConfigSwitch(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2));
+ options.add(new ConfigSwitch(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2));
break;
case CHECKBOX:
- options.add(new ConfigCheckbox(getFieldOfProperty(option), option.getInstance(), getName(attributes),getCategory(attributes), getSubcategory(attributes), 2));
+ options.add(new ConfigCheckbox(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2));
break;
case PARAGRAPH:
case TEXT:
- options.add(new ConfigTextBox(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder(), attributes.getProtected(), attributes.getType() == PropertyType.PARAGRAPH));
+ options.add(new ConfigTextBox(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder(), attributes.getProtected(), attributes.getType() == PropertyType.PARAGRAPH));
break;
case SELECTOR:
- options.add(new ConfigDropdown(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2, attributes.getOptions().toArray(new String[0])));
+ options.add(new ConfigDropdown(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2, attributes.getOptions().toArray(new String[0])));
break;
case PERCENT_SLIDER:
- options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 0, 1, 0));
+ options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 0, 1, 0));
break;
case DECIMAL_SLIDER:
- options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), attributes.getMinF(), attributes.getMaxF(), 0));
+ options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), attributes.getMinF(), attributes.getMaxF(), 0));
break;
case NUMBER:
- options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 1));
+ options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 1));
break;
case SLIDER:
- options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 0));
+ options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), attributes.getMin(), attributes.getMax(), 0));
break;
case COLOR:
- options.add(new CompatConfigColorElement(getFieldOfProperty(option), option.getInstance(), getCategory(attributes), getSubcategory(attributes), getName(attributes), 2));
+ options.add(new CompatConfigColorElement(getFieldOfProperty(option), option.getInstance(), getCategory(attributes), attributes.getDescription(), getSubcategory(attributes), getName(attributes), 2));
break;
case BUTTON:
- options.add(new ConfigButton(() -> ((CallablePropertyValue) option.getValue()).invoke(option.getInstance()), option.getInstance(), getName(attributes), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder().isEmpty() ? "Activate" : attributes.getPlaceholder()));
+ options.add(new ConfigButton(() -> ((CallablePropertyValue) option.getValue()).invoke(option.getInstance()), option.getInstance(), getName(attributes), attributes.getDescription(), getCategory(attributes), getSubcategory(attributes), 2, attributes.getPlaceholder().isEmpty() ? "Activate" : attributes.getPlaceholder()));
break;
}
if (attributes.getType() == PropertyType.SWITCH || attributes.getType() == PropertyType.CHECKBOX) {
@@ -194,8 +194,8 @@ public class VigilanceConfig extends Config {
private Color prevColor = null;
private OneColor cachedColor = null;
- public CompatConfigColorElement(Field color, Vigilant parent, String name, String category, String subcategory, int size) {
- super(null, parent, name, category, subcategory, size, true);
+ public CompatConfigColorElement(Field color, Vigilant parent, String name, String description, String category, String subcategory, int size) {
+ super(null, parent, name, description, category, subcategory, size, true);
this.color = color;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java
index 6169896..ef5a25a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/gui/HudGui.java
@@ -30,14 +30,15 @@ import cc.polyfrost.oneconfig.gui.GuiPause;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.hud.Hud;
import cc.polyfrost.oneconfig.hud.Position;
-import cc.polyfrost.oneconfig.internal.hud.utils.GrabOffset;
-import cc.polyfrost.oneconfig.internal.hud.utils.SnappingLine;
import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.internal.hud.HudCore;
+import cc.polyfrost.oneconfig.internal.hud.utils.GrabOffset;
+import cc.polyfrost.oneconfig.internal.hud.utils.SnappingLine;
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.AssetLoader;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.utils.MathUtils;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
@@ -45,8 +46,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.lang.reflect.Field;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
public class HudGui extends UScreen implements GuiPause {
private static final int SNAPPING_DISTANCE = 10;
@@ -155,6 +158,7 @@ public class HudGui extends UScreen implements GuiPause {
} else if (keyCode == UKeyboard.KEY_RIGHT) {
setHudPositions(1f, 0f, false);
}
+ superSecretMethod(typedChar);
super.onKeyPressed(keyCode, typedChar, modifiers);
}
@@ -292,4 +296,73 @@ public class HudGui extends UScreen implements GuiPause {
}
return lines;
}
+
+ private String superSecretString = "";
+
+ private void superSecretMethod(char charTyped) {
+ superSecretString += charTyped;
+ superSecretString = superSecretString.toLowerCase();
+ if (!"blahaj".substring(0, superSecretString.length()).equals(superSecretString)
+ && !"blåhaj".substring(0, superSecretString.length()).equals(superSecretString)
+ && !"bigrat".substring(0, superSecretString.length()).equals(superSecretString)) {
+ superSecretString = "";
+ return;
+ } else if (!"blahaj".equals(superSecretString)
+ && !"blåhaj".equals(superSecretString)
+ && !"bigrat".equals(superSecretString)) {
+ return;
+ }
+ String url;
+ switch (superSecretString) {
+ case "blahaj":
+ case "blåhaj":
+ url = "https://blahaj.shop/api/random/image?" + UUID.randomUUID();
+ break;
+ case "bigrat":
+ url = "https://bigrat.monster/media/bigrat.png";
+ break;
+ default:
+ return;
+ }
+ superSecretString = "";
+ AtomicBoolean loaded = new AtomicBoolean();
+ RenderManager.setupAndDraw((vg) -> loaded.set(AssetLoader.INSTANCE.loadImage(vg, url)));
+ if (!loaded.get()) return;
+ int w = AssetLoader.INSTANCE.getNVGImage(url).getWidth();
+ int h = AssetLoader.INSTANCE.getNVGImage(url).getHeight();
+ float s = Math.min(300f / w, 300f / h);
+ float width = w * s;
+ float height = h * s;
+ HudCore.huds.put(new Map.Entry<Field, Object>() {
+ @Override
+ public Field getKey() {
+ return null;
+ }
+
+ @Override
+ public Object getValue() {
+ return null;
+ }
+
+ @Override
+ public Object setValue(Object o) {
+ return null;
+ }
+ }, new Hud(true) {
+ @Override
+ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolean example) {
+ RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawImage(vg, url, x, y, width * scale, height * scale));
+ }
+
+ @Override
+ protected float getWidth(float scale, boolean example) {
+ return width * scale;
+ }
+
+ @Override
+ protected float getHeight(float scale, boolean example) {
+ return height * scale;
+ }
+ });
+ }
} \ No newline at end of file
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
index f557c8d..05fb6e6 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/hud/HudCore.java
@@ -52,6 +52,7 @@ public class HudCore {
public static void reInitHuds() {
for (Map.Entry<Field, Object> field : huds.keySet()) {
+ if (field == null || field.getKey() == null || field.getValue() == null) continue;
try {
field.getKey().setAccessible(true);
Hud oldHud = huds.get(field);
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java b/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java
index 4fe8c0b..3e70ce1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java
@@ -59,8 +59,8 @@ public final class AssetLoader {
}
public static final int DEFAULT_FLAGS = NanoVG.NVG_IMAGE_REPEATX | NanoVG.NVG_IMAGE_REPEATY | NanoVG.NVG_IMAGE_GENERATE_MIPMAPS;
- private final HashMap<String, Integer> imageHashMap = new HashMap<>();
- private final HashMap<String, Integer> svgHashMap = new HashMap<>();
+ private final HashMap<String, NVGAsset> imageHashMap = new HashMap<>();
+ private final HashMap<String, NVGAsset> svgHashMap = new HashMap<>();
public static AssetLoader INSTANCE = new AssetLoader();
/**
@@ -87,7 +87,7 @@ public final class AssetLoader {
return false;
}
- imageHashMap.put(fileName, NanoVG.nvgCreateImageRGBA(vg, width[0], height[0], flags, buffer));
+ imageHashMap.put(fileName, new NVGAsset(NanoVG.nvgCreateImageRGBA(vg, width[0], height[0], flags, buffer), width[0], height[0]));
return true;
}
return true;
@@ -155,7 +155,7 @@ public final class AssetLoader {
NanoSVG.nsvgDeleteRasterizer(rasterizer);
NanoSVG.nsvgDelete(svg);
- svgHashMap.put(name, NanoVG.nvgCreateImageRGBA(vg, w, h, flags, image));
+ svgHashMap.put(name, new NVGAsset(NanoVG.nvgCreateImageRGBA(vg, w, h, flags, image), w, h));
return true;
} catch (Exception e) {
System.err.println("Failed to parse SVG file");
@@ -201,6 +201,18 @@ public final class AssetLoader {
* @see AssetLoader#loadImage(long, String)
*/
public int getImage(String fileName) {
+ return imageHashMap.get(fileName).getImage();
+ }
+
+ /**
+ * Get a loaded assets from the cache.
+ * <p><b>Requires the assets to have been loaded first.</b></p>
+ *
+ * @param fileName The name of the file to load.
+ * @return The image and its data
+ * @see AssetLoader#loadImage(long, String)
+ */
+ public NVGAsset getNVGImage(String fileName) {
return imageHashMap.get(fileName);
}
@@ -213,7 +225,7 @@ public final class AssetLoader {
* @see AssetLoader#loadImage(long, String)
*/
public void removeImage(long vg, String fileName) {
- NanoVG.nvgDeleteImage(vg, imageHashMap.get(fileName));
+ NanoVG.nvgDeleteImage(vg, imageHashMap.get(fileName).getImage());
imageHashMap.remove(fileName);
}
@@ -224,9 +236,9 @@ public final class AssetLoader {
* @param vg The NanoVG context.
*/
public void clearImages(long vg) {
- HashMap<String, Integer> temp = new HashMap<>(imageHashMap);
+ HashMap<String, NVGAsset> temp = new HashMap<>(imageHashMap);
for (String image : temp.keySet()) {
- NanoVG.nvgDeleteImage(vg, imageHashMap.get(image));
+ NanoVG.nvgDeleteImage(vg, imageHashMap.get(image).getImage());
imageHashMap.remove(image);
}
}
@@ -241,7 +253,19 @@ public final class AssetLoader {
*/
public int getSVG(String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
- return svgHashMap.get(name);
+ return svgHashMap.get(name).getImage();
+ }
+
+ /**
+ * Get a loaded assets from the cache.
+ * <p><b>Requires the assets to have been loaded first.</b></p>
+ *
+ * @param fileName The name of the file to load.
+ * @return The SVG and its data
+ * @see AssetLoader#loadImage(long, String)
+ */
+ public NVGAsset getNVGSVG(String fileName) {
+ return svgHashMap.get(fileName);
}
/**
@@ -254,7 +278,7 @@ public final class AssetLoader {
*/
public void removeSVG(long vg, String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
- NanoVG.nvgDeleteImage(vg, imageHashMap.get(name));
+ NanoVG.nvgDeleteImage(vg, imageHashMap.get(name).getImage());
svgHashMap.remove(name);
}
@@ -265,9 +289,9 @@ public final class AssetLoader {
* @param vg The NanoVG context.
*/
public void clearSVGs(long vg) {
- HashMap<String, Integer> temp = new HashMap<>(svgHashMap);
+ HashMap<String, NVGAsset> temp = new HashMap<>(svgHashMap);
for (String image : temp.keySet()) {
- NanoVG.nvgDeleteImage(vg, svgHashMap.get(image));
+ NanoVG.nvgDeleteImage(vg, svgHashMap.get(image).getImage());
svgHashMap.remove(image);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/NVGAsset.java b/src/main/java/cc/polyfrost/oneconfig/renderer/NVGAsset.java
new file mode 100644
index 0000000..b5253e6
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/NVGAsset.java
@@ -0,0 +1,25 @@
+package cc.polyfrost.oneconfig.renderer;
+
+public class NVGAsset {
+ private final int image;
+ private final int width;
+ private final int height;
+
+ protected NVGAsset(int image, int width, int height) {
+ this.image = image;
+ this.width = width;
+ this.height = height;
+ }
+
+ public int getImage() {
+ return image;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
index 1e66701..48498fd 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java
@@ -30,15 +30,13 @@ import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.awt.datatransfer.*;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.net.URL;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Files;
+import java.security.MessageDigest;
/**
* Utility class for I/O operations.
@@ -54,7 +52,9 @@ public final class IOUtils {
byte[] bytes;
path = path.trim();
if (path.startsWith("http")) {
- bytes = org.apache.commons.io.IOUtils.toByteArray(new URL(path));
+ try (InputStream in = NetworkUtils.setupConnection(path, "OneConfig", 5000, true)) {
+ bytes = org.apache.commons.io.IOUtils.toByteArray(in);
+ }
} else {
InputStream stream;
File file = new File(path);
@@ -84,6 +84,7 @@ public final class IOUtils {
/**
* Copy the specified String to the System Clipboard.
+ *
* @param s the string to copy
*/
public static void copyStringToClipboard(String s) {
@@ -93,6 +94,7 @@ public final class IOUtils {
/**
* Return the String on the system clipboard.
+ *
* @return the string on the system clipboard, or null if there is no string on the clipboard or another error occurred.
*/
public static String getStringFromClipboard() {
@@ -105,6 +107,7 @@ public final class IOUtils {
/**
* Copy the given image to the System Clipboard.
+ *
* @param image the image to copy
*/
public static void copyImageToClipboard(Image image) {
@@ -114,6 +117,7 @@ public final class IOUtils {
/**
* Return the image on the system clipboard.
+ *
* @return the image on the system clipboard, or null if there is no image on the clipboard or another error occurred.
*/
public static Image getImageFromClipboard() {
@@ -124,19 +128,49 @@ public final class IOUtils {
}
}
+ /**
+ * Gets the SHA-256 hash of a file.
+ *
+ * @param file The file to hash.
+ * @return The SHA-256 hash of the file.
+ */
+ public static String getFileChecksum(File file) {
+ try (FileInputStream inputStream = new FileInputStream(file)) {
+ MessageDigest digest = MessageDigest.getInstance("SHA-256");
+ byte[] bytesBuffer = new byte[1024];
+ int bytesRead;
+
+ while ((bytesRead = inputStream.read(bytesBuffer)) != -1) {
+ digest.update(bytesBuffer, 0, bytesRead);
+ }
+ return convertByteArrayToHexString(digest.digest());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+ private static String convertByteArrayToHexString(byte[] arrayBytes) {
+ StringBuilder stringBuffer = new StringBuilder();
+ for (byte arrayByte : arrayBytes) {
+ stringBuffer.append(Integer.toString((arrayByte & 0xff) + 0x100, 16)
+ .substring(1));
+ }
+ return stringBuffer.toString();
+ }
private static class ImageSelection implements Transferable {
private final Image image;
+
public ImageSelection(Image image) {
this.image = image;
}
@Override
public DataFlavor[] getTransferDataFlavors() {
- return new DataFlavor[] {DataFlavor.imageFlavor};
+ return new DataFlavor[]{DataFlavor.imageFlavor};
}
@Override
@@ -147,7 +181,7 @@ public final class IOUtils {
@NotNull
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
- if(!DataFlavor.imageFlavor.equals(flavor)) {
+ if (!DataFlavor.imageFlavor.equals(flavor)) {
throw new UnsupportedFlavorException(flavor);
}
return image;
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java
index 5919be8..f527175 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java
@@ -131,29 +131,6 @@ public final class NetworkUtils {
}
/**
- * Gets the SHA-256 hash of a file.
- *
- * @param file The file to hash.
- * @return The SHA-256 hash of the file.
- */
- public static String getFileChecksum(File file) {
- try (FileInputStream inputStream = new FileInputStream(file)) {
- MessageDigest digest = MessageDigest.getInstance("SHA-256");
- byte[] bytesBuffer = new byte[1024];
- int bytesRead;
-
- while ((bytesRead = inputStream.read(bytesBuffer)) != -1) {
- digest.update(bytesBuffer, 0, bytesRead);
- }
-
- return convertByteArrayToHexString(digest.digest());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "";
- }
-
- /**
* Launches a URL in the default browser.
*
* @param uri The URI to launch.
@@ -164,7 +141,7 @@ public final class NetworkUtils {
UDesktop.browse(URI.create(uri));
}
- private static InputStream setupConnection(String url, String userAgent, int timeout, boolean useCaches) throws IOException {
+ public static InputStream setupConnection(String url, String userAgent, int timeout, boolean useCaches) throws IOException {
HttpURLConnection connection = ((HttpURLConnection) new URL(url).openConnection());
connection.setRequestMethod("GET");
connection.setUseCaches(useCaches);
@@ -174,13 +151,4 @@ public final class NetworkUtils {
connection.setDoOutput(true);
return connection.getInputStream();
}
-
- private static String convertByteArrayToHexString(byte[] arrayBytes) {
- StringBuilder stringBuffer = new StringBuilder();
- for (byte arrayByte : arrayBytes) {
- stringBuffer.append(Integer.toString((arrayByte & 0xff) + 0x100, 16)
- .substring(1));
- }
- return stringBuffer.toString();
- }
}
diff --git a/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/IOUtilsDSL.kt b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/IOUtilsDSL.kt
new file mode 100644
index 0000000..6b89fe6
--- /dev/null
+++ b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/IOUtilsDSL.kt
@@ -0,0 +1,12 @@
+package cc.polyfrost.oneconfig.utils.dsl
+
+import cc.polyfrost.oneconfig.utils.IOUtils
+import cc.polyfrost.oneconfig.utils.NetworkUtils
+import java.io.File
+
+/**
+ * Returns the SHA-256 hash of the given [File].
+ *
+ * @see NetworkUtils.getFileChecksum
+ */
+fun File.checksum() = IOUtils.getFileChecksum(this) \ No newline at end of file
diff --git a/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/NetworkUtilsDSL.kt b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/NetworkUtilsDSL.kt
index 56fba21..a744a29 100644
--- a/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/NetworkUtilsDSL.kt
+++ b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/NetworkUtilsDSL.kt
@@ -31,13 +31,6 @@ import cc.polyfrost.oneconfig.libs.universal.UDesktop
import java.io.File
/**
- * Returns the SHA-256 hash of the given [File].
- *
- * @see NetworkUtils.getFileChecksum
- */
-fun File.checksum() = NetworkUtils.getFileChecksum(this)
-
-/**
* Downloads the given [url] to the given [File].
*
* @see NetworkUtils.downloadFile
diff --git a/src/main/resources/assets/oneconfig/icons/InfoArrow.svg b/src/main/resources/assets/oneconfig/icons/InfoArrow.svg
new file mode 100644
index 0000000..1685884
--- /dev/null
+++ b/src/main/resources/assets/oneconfig/icons/InfoArrow.svg
@@ -0,0 +1 @@
+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.25 16L8.85 15.55L8.25 16ZM7.73458 15.3871L8.21514 14.8113L7.73458 15.3871ZM7.04959 15.0446L7.2219 14.3146L7.04959 15.0446ZM2.6903 13.4567L1.99739 13.7437L2.6903 13.4567ZM4.04329 14.8097L3.75628 15.5026L4.04329 14.8097ZM12.9504 15.0446L12.7781 14.3146L12.9504 15.0446ZM11.75 16L11.15 15.55L11.75 16ZM12.2654 15.3871L11.7849 14.8113L12.2654 15.3871ZM10.151 18.0272L10.4229 18.7262L10.151 18.0272ZM9.46667 17.6222L8.86667 18.0722L9.46667 17.6222ZM9.84897 18.0272L9.57712 18.7262L9.84897 18.0272ZM17.3097 13.4567L18.0026 13.7437L17.3097 13.4567ZM15.9567 14.8097L16.2437 15.5026L15.9567 14.8097ZM16.135 2.77248L16.4755 2.10423L16.135 2.77248ZM17.2275 3.86502L17.8958 3.52453L17.2275 3.86502ZM3.86502 2.77248L3.52453 2.10423L3.86502 2.77248ZM2.77248 3.86502L2.10423 3.52453L2.77248 3.86502ZM9.25 11.6667C9.25 12.0809 9.58579 12.4167 10 12.4167C10.4142 12.4167 10.75 12.0809 10.75 11.6667H9.25ZM10.75 8.75C10.75 8.33579 10.4142 8 10 8C9.58579 8 9.25 8.33579 9.25 8.75H10.75ZM10 5.08333C9.58579 5.08333 9.25 5.41912 9.25 5.83333C9.25 6.24755 9.58579 6.58333 10 6.58333V5.08333ZM10.0083 6.58333C10.4225 6.58333 10.7583 6.24755 10.7583 5.83333C10.7583 5.41912 10.4225 5.08333 10.0083 5.08333V6.58333ZM6.5 3.25H13.5V1.75H6.5V3.25ZM16.75 6.5V11.25H18.25V6.5H16.75ZM11.15 15.55L9.93333 17.1722L11.1333 18.0722L12.35 16.45L11.15 15.55ZM3.25 11.25V6.5H1.75V11.25H3.25ZM10.0667 17.1722L8.85 15.55L7.65 16.45L8.86667 18.0722L10.0667 17.1722ZM8.85 15.55C8.6273 15.2531 8.44693 15.0047 8.21514 14.8113L7.25402 15.9629C7.3202 16.0181 7.38412 16.0955 7.65 16.45L8.85 15.55ZM6.25 15.75C6.69314 15.75 6.79337 15.7547 6.87727 15.7745L7.2219 14.3146C6.92807 14.2453 6.62116 14.25 6.25 14.25V15.75ZM8.21514 14.8113C7.9271 14.5709 7.58704 14.4008 7.2219 14.3146L6.87727 15.7745C7.01578 15.8072 7.14476 15.8717 7.25402 15.9629L8.21514 14.8113ZM1.75 11.25C1.75 11.8222 1.74959 12.2889 1.77553 12.6689C1.80192 13.0558 1.85808 13.4074 1.99739 13.7437L3.38321 13.1697C3.33222 13.0466 3.29323 12.8773 3.27205 12.5668C3.25041 12.2496 3.25 11.8427 3.25 11.25H1.75ZM6.25 14.25C5.65731 14.25 5.25036 14.2496 4.93316 14.228C4.62271 14.2068 4.4534 14.1678 4.3303 14.1168L3.75628 15.5026C4.09261 15.6419 4.44423 15.6981 4.83106 15.7245C5.21115 15.7504 5.67783 15.75 6.25 15.75V14.25ZM1.99739 13.7437C2.32725 14.5401 2.95994 15.1728 3.75628 15.5026L4.3303 14.1168C3.9015 13.9392 3.56083 13.5985 3.38321 13.1697L1.99739 13.7437ZM13.75 14.25C13.3788 14.25 13.0719 14.2453 12.7781 14.3146L13.1227 15.7745C13.2066 15.7547 13.3069 15.75 13.75 15.75V14.25ZM12.35 16.45C12.6159 16.0955 12.6798 16.0181 12.746 15.9629L11.7849 14.8113C11.5531 15.0047 11.3727 15.2531 11.15 15.55L12.35 16.45ZM12.7781 14.3146C12.413 14.4008 12.0729 14.5709 11.7849 14.8113L12.746 15.9629C12.8552 15.8717 12.9842 15.8072 13.1227 15.7745L12.7781 14.3146ZM9.93333 17.1722C9.88699 17.234 9.85152 17.2813 9.82055 17.3211C9.78945 17.3612 9.77033 17.3841 9.7583 17.3975C9.73002 17.4289 9.77399 17.3691 9.87918 17.3282L10.4229 18.7262C10.639 18.6422 10.7836 18.5005 10.8735 18.4006C10.9603 18.3041 11.0512 18.1817 11.1333 18.0722L9.93333 17.1722ZM8.86667 18.0722C8.94877 18.1817 9.03973 18.3041 9.12646 18.4006C9.21637 18.5005 9.36102 18.6422 9.57712 18.7262L10.1208 17.3282C10.226 17.3691 10.27 17.4289 10.2417 17.3975C10.2297 17.3841 10.2105 17.3612 10.1794 17.3211C10.1485 17.2813 10.113 17.234 10.0667 17.1722L8.86667 18.0722ZM9.87918 17.3282C9.95689 17.298 10.0431 17.298 10.1208 17.3282L9.57712 18.7262C9.84912 18.832 10.1509 18.832 10.4229 18.7262L9.87918 17.3282ZM16.75 11.25C16.75 11.8427 16.7496 12.2496 16.728 12.5668C16.7068 12.8773 16.6678 13.0466 16.6168 13.1697L18.0026 13.7437C18.1419 13.4074 18.1981 13.0558 18.2245 12.6689C18.2504 12.2889 18.25 11.8222 18.25 11.25H16.75ZM13.75 15.75C14.3222 15.75 14.7889 15.7504 15.1689 15.7245C15.5558 15.6981 15.9074 15.6419 16.2437 15.5026L15.6697 14.1168C15.5466 14.1678 15.3773 14.2068 15.0668 14.228C14.7496 14.2496 14.3427 14.25 13.75 14.25V15.75ZM16.6168 13.1697C16.4392 13.5985 16.0985 13.9392 15.6697 14.1168L16.2437 15.5026C17.0401 15.1728 17.6728 14.5401 18.0026 13.7437L16.6168 13.1697ZM13.5 3.25C14.2124 3.25 14.7017 3.25058 15.0809 3.28157C15.4514 3.31184 15.6504 3.36735 15.7945 3.44074L16.4755 2.10423C16.0847 1.90514 15.6663 1.8244 15.2031 1.78655C14.7486 1.74942 14.1877 1.75 13.5 1.75V3.25ZM18.25 6.5C18.25 5.81231 18.2506 5.25144 18.2134 4.79693C18.1756 4.33367 18.0949 3.91527 17.8958 3.52453L16.5593 4.20552C16.6327 4.34956 16.6882 4.54858 16.7184 4.91908C16.7494 5.29833 16.75 5.78756 16.75 6.5H18.25ZM15.7945 3.44074C16.1238 3.60852 16.3915 3.87623 16.5593 4.20552L17.8958 3.52453C17.5842 2.913 17.087 2.41582 16.4755 2.10423L15.7945 3.44074ZM6.5 1.75C5.81231 1.75 5.25144 1.74942 4.79693 1.78655C4.33367 1.8244 3.91527 1.90514 3.52453 2.10423L4.20552 3.44074C4.34956 3.36735 4.54858 3.31184 4.91908 3.28157C5.29833 3.25058 5.78756 3.25 6.5 3.25V1.75ZM3.25 6.5C3.25 5.78756 3.25058 5.29833 3.28157 4.91908C3.31184 4.54858 3.36735 4.34956 3.44074 4.20552L2.10423 3.52453C1.90514 3.91527 1.8244 4.33367 1.78655 4.79693C1.74942 5.25144 1.75 5.81231 1.75 6.5H3.25ZM3.52453 2.10423C2.913 2.41582 2.41582 2.913 2.10423 3.52453L3.44074 4.20552C3.60852 3.87623 3.87623 3.60852 4.20552 3.44074L3.52453 2.10423ZM10.75 11.6667V8.75H9.25V11.6667H10.75ZM10 6.58333H10.0083V5.08333H10V6.58333Z" fill="white"/></svg> \ No newline at end of file