aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-06 18:20:23 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-06 18:20:23 +0200
commit21d31344a151dfe94c79a20b503af55120c63b63 (patch)
tree6bae89e3532b2ed976a493ff8d6b5b7bfed94221 /src/main/java/cc/polyfrost/oneconfig
parent462d5976f3654f40229ff61391e7e55d0819d82d (diff)
downloadOneConfig-21d31344a151dfe94c79a20b503af55120c63b63.tar.gz
OneConfig-21d31344a151dfe94c79a20b503af55120c63b63.tar.bz2
OneConfig-21d31344a151dfe94c79a20b503af55120c63b63.zip
rewrite config system
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/Config.java101
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java24
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java24
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java26
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Header.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Info.java25
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java85
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java26
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Switch.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java28
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceName.java (renamed from src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java81
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java35
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/migration/Migrator.java (renamed from src/main/java/cc/polyfrost/oneconfig/config/migration/vigilance/Migrator.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/migration/VigilanceMigrator.java (renamed from src/main/java/cc/polyfrost/oneconfig/config/migration/vigilance/VigilanceMigrator.java)4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java2
-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.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java13
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java11
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java17
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java23
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/assets/Colors.java (renamed from src/main/java/cc/polyfrost/oneconfig/gui/Colors.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/assets/Images.java (renamed from src/main/java/cc/polyfrost/oneconfig/renderer/image/Images.java)6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java (renamed from src/main/java/cc/polyfrost/oneconfig/renderer/image/SVGs.java)6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/annotations/Option.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java (renamed from src/main/java/cc/polyfrost/oneconfig/internal/config/ConfigCore.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java (renamed from src/main/java/cc/polyfrost/oneconfig/renderer/image/ImageLoader.java)34
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java27
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java297
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestHud.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestPage.java40
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java4
60 files changed, 621 insertions, 648 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
index 2c51387..de6c575 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
@@ -1,24 +1,19 @@
package cc.polyfrost.oneconfig.config;
-import cc.polyfrost.oneconfig.config.annotations.ConfigPage;
-import cc.polyfrost.oneconfig.config.annotations.Option;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
import cc.polyfrost.oneconfig.config.core.ConfigUtils;
-import cc.polyfrost.oneconfig.internal.config.ConfigCore;
+import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.data.*;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
-import cc.polyfrost.oneconfig.config.elements.OptionCategory;
import cc.polyfrost.oneconfig.config.elements.OptionPage;
-import cc.polyfrost.oneconfig.config.elements.OptionSubcategory;
import cc.polyfrost.oneconfig.config.profiles.Profiles;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
-import cc.polyfrost.oneconfig.gui.elements.config.*;
import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
-import cc.polyfrost.oneconfig.hud.BasicHud;
-import cc.polyfrost.oneconfig.internal.hud.HudCore;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import com.google.gson.*;
import java.io.*;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.charset.StandardCharsets;
@@ -87,89 +82,11 @@ public class Config {
* @param migrate whether the migrator should be run
*/
protected void generateOptionList(Object instance, OptionPage page, Mod mod, boolean migrate) {
- Class<?> clazz = instance.getClass();
- for (Field field : clazz.getDeclaredFields()) {
- String pagePrefix = page.equals(mod.defaultPage) ? "" : page.name + ".";
- if (!field.isAnnotationPresent(Option.class) && !field.isAnnotationPresent(ConfigPage.class)) {
- processCustomOption(field, page);
- continue;
- } else if (field.isAnnotationPresent(ConfigPage.class)) {
- ConfigPage option = field.getAnnotation(ConfigPage.class);
- if (!page.categories.containsKey(option.category()))
- page.categories.put(option.category(), new OptionCategory());
- OptionCategory category = page.categories.get(option.category());
- if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(option.subcategory()))
- category.subcategories.add(new OptionSubcategory(option.subcategory()));
- OptionSubcategory subcategory = category.subcategories.get(category.subcategories.size() - 1);
- OptionPage newPage = new OptionPage(option.name(), mod);
- try {
- field.setAccessible(true);
- Object object = field.get(clazz);
- generateOptionList(object, newPage, mod, migrate);
- ConfigPageButton configPageButton = new ConfigPageButton(field, instance, option.name(), option.description(), newPage);
- switch (option.location()) {
- case TOP:
- subcategory.topButtons.add(configPageButton);
- break;
- case BOTTOM:
- subcategory.bottomButtons.add(configPageButton);
- break;
- }
- optionNames.put(pagePrefix + field.getName(), configPageButton);
- } catch (IllegalAccessException ignored) {
- }
- continue;
- }
- Option option = field.getAnnotation(Option.class);
- if (!page.categories.containsKey(option.category()))
- page.categories.put(option.category(), new OptionCategory());
- OptionCategory category = page.categories.get(option.category());
- if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(option.subcategory()))
- category.subcategories.add(new OptionSubcategory(option.subcategory()));
- if (migrate) {
- try {
- Object value = mod.migrator.getValue(field, option.name(), option.category(), option.subcategory());
- if (value != null) {
- field.setAccessible(true);
- field.set(instance, value);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- ArrayList<BasicOption> options = category.subcategories.get(category.subcategories.size() - 1).options;
- if (option.type() == OptionType.HUD) {
- try {
- field.setAccessible(true);
- BasicHud hud = (BasicHud) field.get(instance);
- HudCore.huds.add(hud);
- options.add(new ConfigHeader(field, hud, option.name(), 1));
- options.add(new ConfigSwitch(hud.getClass().getField("enabled"), hud, "Enabled", 1));
- options.addAll(ConfigUtils.getClassOptions(hud));
- options.add(new ConfigCheckbox(hud.getClass().getField("rounded"), hud, "Rounded corners", 1));
- options.get(options.size() - 1).setDependency(() -> hud.enabled);
- options.add(new ConfigCheckbox(hud.getClass().getField("border"), hud, "Outline/border", 1));
- options.get(options.size() - 1).setDependency(() -> hud.enabled);
- options.add(new ConfigColorElement(hud.getClass().getField("bgColor"), hud, "Background color:", 1));
- options.get(options.size() - 1).setDependency(() -> hud.enabled);
- options.add(new ConfigColorElement(hud.getClass().getField("borderColor"), hud, "Border color:", 1));
- options.get(options.size() - 1).setDependency(() -> hud.enabled && hud.border);
- options.add(new ConfigSlider(hud.getClass().getField("cornerRadius"), hud, "Corner radius:", 2, 0, 10, 0));
- options.get(options.size() - 1).setDependency(() -> hud.enabled && hud.rounded);
- options.add(new ConfigSlider(hud.getClass().getField("borderSize"), hud, "Border thickness:", 2, 0, 10, 0));
- options.get(options.size() - 1).setDependency(() -> hud.enabled && hud.border);
- options.add(new ConfigSlider(hud.getClass().getField("paddingX"), hud, "X-Padding", 2, 0, 50, 0));
- options.get(options.size() - 1).setDependency(() -> hud.enabled);
- options.add(new ConfigSlider(hud.getClass().getField("paddingY"), hud, "Y-Padding", 2, 0, 50, 0));
- options.get(options.size() - 1).setDependency(() -> hud.enabled);
- } catch (IllegalAccessException | NoSuchFieldException e) {
- e.printStackTrace();
- }
- } else {
- options.add(ConfigUtils.getOption(option, field, instance));
- }
- if (!option.type().equals(OptionType.HUD))
- optionNames.put(pagePrefix + field.getName(), options.get(options.size() - 1));
+ for (Field field : instance.getClass().getDeclaredFields()) {
+ Option option = ConfigUtils.findAnnotation(field, Option.class);
+ if (option != null)
+ ConfigUtils.addOptionToPage(page, option, field, instance, migrate ? mod.migrator : null);
+ // TODO: Make dependencies work, pages, hud
}
}
@@ -227,6 +144,6 @@ public class Config {
*/
protected void addDependency(String option, Supplier<Boolean> condition) {
if (!optionNames.containsKey(option)) return;
- optionNames.get(option).setDependency(condition);
+ optionNames.get(option).addDependency(condition);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java
new file mode 100644
index 0000000..300651f
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Button.java
@@ -0,0 +1,24 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.BUTTON)
+public @interface Button {
+ String name();
+
+ String text();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java
new file mode 100644
index 0000000..eae35e4
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Checkbox.java
@@ -0,0 +1,22 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.CHECKBOX)
+public @interface Checkbox {
+ String name();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java
new file mode 100644
index 0000000..98cc5ec
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Color.java
@@ -0,0 +1,22 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.COLOR)
+public @interface Color {
+ String name();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java
new file mode 100644
index 0000000..1fbf162
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Dropdown.java
@@ -0,0 +1,24 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.DROPDOWN)
+public @interface Dropdown {
+ String name();
+
+ String[] options();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java
new file mode 100644
index 0000000..f01d074
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/DualOption.java
@@ -0,0 +1,26 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.DUAL_OPTION)
+public @interface DualOption {
+ String name();
+
+ String left();
+
+ String right();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Header.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Header.java
new file mode 100644
index 0000000..3821a01
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Header.java
@@ -0,0 +1,22 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.HEADER)
+public @interface Header {
+ String text();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Info.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Info.java
new file mode 100644
index 0000000..3f058ed
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Info.java
@@ -0,0 +1,25 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.InfoType;
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.INFO)
+public @interface Info {
+ String text();
+
+ InfoType type();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java
new file mode 100644
index 0000000..7d6cfdc
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/KeyBind.java
@@ -0,0 +1,22 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.KEYBIND)
+public @interface KeyBind {
+ String name();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java
deleted file mode 100644
index f30f01e..0000000
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Option.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package cc.polyfrost.oneconfig.config.annotations;
-
-import cc.polyfrost.oneconfig.config.data.InfoType;
-import cc.polyfrost.oneconfig.config.data.OptionType;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface Option {
- /**
- * The name of the option that will be displayed to the user
- */
- String name();
-
- /**
- * The type of the option
- */
- OptionType type();
-
- /**
- * The category of the component
- */
- String category() default "General";
-
- /**
- * The subcategory of the component (displayed as header)
- */
- String subcategory() default "";
-
- /**
- * The width of the option (1 = half width, 2 = full width)
- */
- int size() default 1;
-
- /**
- * A String array of all the possible values for the UniSelector, dropdownList, and ComboBox.
- * Also used in the DualOption slider, index 0 is the left, index 1 is the right; for example:
- * {"Option 1", "Option 2"}
- */
- String[] options() default {};
-
- /**
- * The placeholder in the text field
- */
- String placeholder() default "";
-
- /**
- * If the text field is secure or not
- */
- boolean secure() default false;
-
- /**
- * If the text field is multi line or not
- */
- boolean multiLine() default false;
-
- /**
- * Minimum value of slider
- */
- float min() default 0;
-
- /**
- * The maximum value of the slider
- */
- float max() default 0;
-
- /**
- * Steps of slider (0 for no steps)
- */
- int step() default 0;
-
- /**
- * Option for info option type
- */
- InfoType infoType() default InfoType.INFO;
-
- /**
- * Text displayed inside button
- */
- String buttonText() default "Activate";
-}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java
new file mode 100644
index 0000000..144d329
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Slider.java
@@ -0,0 +1,26 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.SLIDER)
+public @interface Slider {
+ String name();
+
+ float min();
+
+ float max();
+
+ int step() default 0;
+
+ 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
new file mode 100644
index 0000000..d3b8e80
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Switch.java
@@ -0,0 +1,22 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.SWITCH)
+public @interface Switch {
+ String name();
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java
new file mode 100644
index 0000000..90e5779
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/Text.java
@@ -0,0 +1,28 @@
+package cc.polyfrost.oneconfig.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+@Option(type = OptionType.TEXT)
+public @interface Text {
+ String name();
+
+ String placeholder() default "";
+
+ boolean secure() default false;
+
+ boolean multiline() default false;
+
+ int size() default 1;
+
+ String category() default "General";
+
+ String subcategory() default "";
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java
index 3b0fcd6..a34b792 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.config.compatibility.vigilance;
-import cc.polyfrost.oneconfig.internal.config.ConfigCore;
+import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.elements.OptionCategory;
@@ -55,7 +55,7 @@ public class VigilanceConfig extends Config {
}
private void generateOptionsList(OptionPage page) {
- for (PropertyData option : ((VigilantAccessor) vigilant).getPropertyCollector().getProperties()) {
+ /*for (PropertyData option : ((VigilantAccessor) vigilant).getPropertyCollector().getProperties()) {
PropertyAttributesExt attributes = option.getAttributesExt();
if (attributes.getHidden()) continue;
if (!page.categories.containsKey(getCategory(attributes)))
@@ -66,7 +66,7 @@ public class VigilanceConfig extends Config {
ArrayList<BasicOption> options = category.subcategories.get(category.subcategories.size() - 1).options;
switch (attributes.getType()) {
case SWITCH:
- options.add(new ConfigSwitch(getFieldOfProperty(option), option.getInstance(), getName(attributes), 2));
+ options.add(new ConfigSwitch(getFieldOfProperty(option), option.getInstance(), getName(attributes), "", "", 2));
break;
case CHECKBOX:
options.add(new ConfigCheckbox(getFieldOfProperty(option), option.getInstance(), getName(attributes), 2));
@@ -97,7 +97,7 @@ public class VigilanceConfig extends Config {
if (attributes.getType() == PropertyType.SWITCH || attributes.getType() == PropertyType.CHECKBOX) {
optionNames.put(PropertyKt.fullPropertyPath(option.getAttributesExt()), options.get(options.size() - 1));
}
- }
+ }*/
}
private Field getFieldOfProperty(PropertyData data) {
@@ -163,11 +163,11 @@ public class VigilanceConfig extends Config {
public void addDependency(PropertyData property, PropertyData dependency) {
BasicOption option = optionNames.get(PropertyKt.fullPropertyPath(property.getAttributesExt()));
if (option != null) {
- option.setDependency(() -> Objects.equals(dependency.getValue().getValue(vigilant), true));
+ option.addDependency(() -> Objects.equals(dependency.getValue().getValue(vigilant), true));
}
}
- private static class CompatConfigColorElement extends ConfigColorElement {
+ /*private static class CompatConfigColorElement extends ConfigColorElement {
private final Field color;
private Color prevColor = null;
private OneColor cachedColor = null;
@@ -198,5 +198,5 @@ public class VigilanceConfig extends Config {
}
}
}
- }
+ }*/
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceName.java
index e4b042a..8417ad8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceName.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.config.annotations;
+package cc.polyfrost.oneconfig.config.compatibility.vigilance;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java b/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java
index d44488d..2002b01 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/core/ConfigUtils.java
@@ -1,9 +1,15 @@
package cc.polyfrost.oneconfig.config.core;
-import cc.polyfrost.oneconfig.config.annotations.Option;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
+import cc.polyfrost.oneconfig.config.elements.OptionCategory;
+import cc.polyfrost.oneconfig.config.elements.OptionPage;
+import cc.polyfrost.oneconfig.config.elements.OptionSubcategory;
+import cc.polyfrost.oneconfig.config.migration.Migrator;
import cc.polyfrost.oneconfig.gui.elements.config.*;
+import cc.polyfrost.oneconfig.internal.config.annotations.Option;
+import org.jetbrains.annotations.Nullable;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -11,38 +17,69 @@ public class ConfigUtils {
public static BasicOption getOption(Option option, Field field, Object instance) {
switch (option.type()) {
case SWITCH:
- return new ConfigSwitch(field, instance, option.name(), option.size());
+ return ConfigSwitch.create(field, instance);
case CHECKBOX:
- return new ConfigCheckbox(field, instance, option.name(), option.size());
- case TEXT:
- return new ConfigTextBox(field, instance, option.name(), option.size(), option.placeholder(), option.secure(), option.multiLine());
- case DUAL_OPTION:
- return new ConfigDualOption(field, instance, option.name(), option.size(), option.options());
- case DROPDOWN:
- return new ConfigDropdown(field, instance, option.name(), option.size(), option.options());
- case SLIDER:
- return new ConfigSlider(field, instance, option.name(), option.size(), option.min(), option.max(), option.step());
+ return ConfigCheckbox.create(field, instance);
case INFO:
- return new ConfigInfo(field, instance, option.name(), option.size(), option.infoType());
- case COLOR:
- return new ConfigColorElement(field, instance, option.name(), option.size());
+ return ConfigInfo.create(field, instance);
case HEADER:
- return new ConfigHeader(field, instance, option.name(), option.size());
+ return ConfigHeader.create(field, instance);
+ case COLOR:
+ return ConfigColorElement.create(field, instance);
+ case DROPDOWN:
+ return ConfigDropdown.create(field, instance);
+ case TEXT:
+ return ConfigTextBox.create(field, instance);
case BUTTON:
- return new ConfigButton(field, instance, option.name(), option.size(), option.buttonText());
+ return ConfigButton.create(field, instance);
+ case SLIDER:
+ return ConfigSlider.create(field, instance);
case KEYBIND:
- return new ConfigKeyBind(field, instance, option.name(), option.size());
+ return ConfigKeyBind.create(field, instance);
+ case DUAL_OPTION:
+ return ConfigDualOption.create(field, instance);
}
return null;
}
- public static ArrayList<BasicOption> getClassOptions(Object hud) {
+ public static ArrayList<BasicOption> getClassOptions(Object object) {
ArrayList<BasicOption> options = new ArrayList<>();
- for (Field field : hud.getClass().getDeclaredFields()) {
- if (!field.isAnnotationPresent(Option.class)) continue;
- Option option = field.getAnnotation(Option.class);
- options.add(getOption(option, field, hud));
+ for (Field field : object.getClass().getDeclaredFields()) {
+ Option option = findAnnotation(field, Option.class);
+ if (option == null) continue;
+ options.add(getOption(option, field, object));
}
return options;
}
+
+ public static void addOptionToPage(OptionPage page, Option option, Field field, Object instance, @Nullable Migrator migrator) {
+ BasicOption configOption = getOption(option, field, instance);
+ if (configOption == null) return;
+ if (migrator != null) {
+ Object value = migrator.getValue(field, configOption.name, configOption.category, configOption.subcategory);
+ if (value != null) {
+ try {
+ field.set(instance, value);
+ } catch (IllegalAccessException ignored) {
+ }
+ }
+ }
+ getOptions(page, configOption.category, configOption.subcategory).add(configOption);
+ }
+
+ public static ArrayList<BasicOption> getOptions(OptionPage page, String categoryName, String subcategoryName) {
+ if (!page.categories.containsKey(categoryName)) page.categories.put(categoryName, new OptionCategory());
+ OptionCategory category = page.categories.get(categoryName);
+ if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(subcategoryName))
+ category.subcategories.add(new OptionSubcategory(subcategoryName));
+ return category.subcategories.get(category.subcategories.size() - 1).options;
+ }
+
+ public static <T extends Annotation> T findAnnotation(Field field, Class<T> annotationType) {
+ for (Annotation ann : field.getDeclaredAnnotations()) {
+ if (ann.annotationType().isAnnotationPresent(annotationType))
+ return ann.annotationType().getAnnotation(annotationType);
+ }
+ return null;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java b/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java
index 090d1f8..ca931b7 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java
@@ -2,7 +2,7 @@ package cc.polyfrost.oneconfig.config.data;
import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.elements.OptionPage;
-import cc.polyfrost.oneconfig.config.migration.vigilance.Migrator;
+import cc.polyfrost.oneconfig.config.migration.Migrator;
import org.jetbrains.annotations.Nullable;
public class Mod {
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 d4efeaa..947156a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/BasicOption.java
@@ -1,15 +1,18 @@
package cc.polyfrost.oneconfig.config.elements;
import java.lang.reflect.Field;
+import java.util.ArrayList;
import java.util.function.Supplier;
@SuppressWarnings({"unused"})
public abstract class BasicOption {
public final int size;
protected final Field field;
- protected final String name;
protected final Object parent;
- private Supplier<Boolean> dependency;
+ public final String name;
+ public final String category;
+ public final String subcategory;
+ private final ArrayList<Supplier<Boolean>> dependencies = new ArrayList<>();
/**
* Initialize option
@@ -19,11 +22,13 @@ public abstract class BasicOption {
* @param name name of option
* @param size size of option, 0 for single column, 1 for double.
*/
- public BasicOption(Field field, Object parent, String name, int size) {
+ public BasicOption(Field field, Object parent, String name, String category, String subcategory, int size) {
this.field = field;
this.parent = parent;
this.name = name;
this.size = size;
+ this.category = category;
+ this.subcategory = subcategory;
if (field != null) field.setAccessible(true);
}
@@ -78,21 +83,21 @@ public abstract class BasicOption {
}
/**
- * @return If the component has an option to render at half size
+ * Add a condition to this option
+ *
+ * @param supplier The dependency
*/
- public boolean hasHalfSize() {
- return true;
- }
-
- public String getName() {
- return name;
- }
-
- public void setDependency(Supplier<Boolean> supplier) {
- this.dependency = supplier;
+ public void addDependency(Supplier<Boolean> supplier) {
+ this.dependencies.add(supplier);
}
+ /**
+ * @return If the option is enabled, based on the dependencies
+ */
protected boolean isEnabled() {
- return dependency == null || dependency.get();
+ for (Supplier<Boolean> dependency : dependencies) {
+ if (!dependency.get()) return false;
+ }
+ return true;
}
}
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 ff1d770..66714a4 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java
@@ -1,7 +1,6 @@
package cc.polyfrost.oneconfig.config.elements;
-import cc.polyfrost.oneconfig.gui.Colors;
-import cc.polyfrost.oneconfig.config.elements.BasicOption;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.config.ConfigPageButton;
import cc.polyfrost.oneconfig.renderer.RenderManager;
@@ -31,14 +30,14 @@ public class OptionSubcategory {
filteredTop.clear();
filteredBottom.clear();
for (BasicOption option : options) {
- if (option.getName().toLowerCase().contains(filter)) filteredOptions.add(option);
+ if (option.name.toLowerCase().contains(filter)) filteredOptions.add(option);
}
for (ConfigPageButton page : topButtons) {
- if (page.getName().toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
+ if (page.name.toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
filteredTop.add(page);
}
for (ConfigPageButton page : bottomButtons) {
- if (page.getName().toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
+ if (page.name.toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
filteredBottom.add(page);
}
}
@@ -60,7 +59,7 @@ public class OptionSubcategory {
BasicOption option = filteredOptions.get(i);
if (i + 1 < filteredOptions.size()) {
BasicOption nextOption = filteredOptions.get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
+ if (option.size == 1 && nextOption.size == 1) {
backgroundSize += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
i++;
continue;
@@ -79,7 +78,7 @@ public class OptionSubcategory {
option.draw(vg, x, optionY);
if (i + 1 < filteredOptions.size()) {
BasicOption nextOption = filteredOptions.get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
+ if (option.size == 1 && nextOption.size == 1) {
nextOption.draw(vg, x + 512, optionY);
optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
i++;
@@ -105,7 +104,7 @@ public class OptionSubcategory {
option.drawLast(vg, x, drawLastY);
if (i + 1 < filteredOptions.size()) {
BasicOption nextOption = filteredOptions.get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
+ if (option.size == 1 && nextOption.size == 1) {
nextOption.drawLast(vg, x + 512, drawLastY);
drawLastY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
i++;
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/migration/vigilance/Migrator.java b/src/main/java/cc/polyfrost/oneconfig/config/migration/Migrator.java
index f3f60b7..abfb2a0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/migration/vigilance/Migrator.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/migration/Migrator.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.config.migration.vigilance;
+package cc.polyfrost.oneconfig.config.migration;
import java.lang.reflect.Field;
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/migration/vigilance/VigilanceMigrator.java b/src/main/java/cc/polyfrost/oneconfig/config/migration/VigilanceMigrator.java
index 2870e03..4a9cd3b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/migration/vigilance/VigilanceMigrator.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/migration/VigilanceMigrator.java
@@ -1,6 +1,6 @@
-package cc.polyfrost.oneconfig.config.migration.vigilance;
+package cc.polyfrost.oneconfig.config.migration;
-import cc.polyfrost.oneconfig.config.annotations.VigilanceName;
+import cc.polyfrost.oneconfig.config.compatibility.vigilance.VigilanceName;
import java.io.BufferedReader;
import java.io.FileReader;
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
index 2b0a97e..07ce53e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
@@ -1,7 +1,7 @@
package cc.polyfrost.oneconfig.config.profiles;
import cc.polyfrost.oneconfig.internal.OneConfig;
-import cc.polyfrost.oneconfig.internal.config.ConfigCore;
+import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.internal.config.OneConfigConfig;
import org.apache.commons.io.FileUtils;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
index 7f3bf15..13174ab 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.gui;
-import cc.polyfrost.oneconfig.internal.config.ConfigCore;
+import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.hud.BasicHud;
import cc.polyfrost.oneconfig.internal.hud.HudCore;
import cc.polyfrost.oneconfig.renderer.RenderManager;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 81fe9c0..0ddf469 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -8,9 +8,10 @@ import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.gui.pages.ModsPage;
import cc.polyfrost.oneconfig.gui.pages.Page;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index b6f1160..5678189 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -6,9 +6,10 @@ import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuart;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.gui.pages.CreditsPage;
import cc.polyfrost.oneconfig.gui.pages.ModsPage;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.test.ButtonTestPage;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
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 f3168dd..7869114 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -1,11 +1,11 @@
package cc.polyfrost.oneconfig.gui.elements;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.pages.Page;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import cc.polyfrost.oneconfig.utils.color.ColorUtils;
import org.jetbrains.annotations.NotNull;
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 d42d465..4729684 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.gui.elements;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.animations.Animation;
@@ -12,8 +12,8 @@ import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.internal.config.OneConfigConfig;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.Images;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.Images;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.renderer.scissor.Scissor;
import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager;
import cc.polyfrost.oneconfig.utils.InputUtils;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
index f48e1af..893d628 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -1,14 +1,14 @@
package cc.polyfrost.oneconfig.gui.elements;
import cc.polyfrost.oneconfig.internal.OneConfig;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.animations.ColorAnimation;
import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.renderer.scissor.Scissor;
import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager;
import cc.polyfrost.oneconfig.utils.InputUtils;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java
index 5705ba8..73853a1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/Slider.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.gui.elements;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.utils.InputUtils;
import org.lwjgl.input.Mouse;
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 a488fea..9879ac2 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
@@ -1,8 +1,9 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Button;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
@@ -12,18 +13,23 @@ import java.lang.reflect.Field;
public class ConfigButton extends BasicOption {
private final BasicButton button;
- public ConfigButton(Runnable runnable, Object parent, String name, int size, String text) {
- super(null, parent, name, size);
+ public ConfigButton(Runnable runnable, Object parent, String name, String category, String subcategory, int size, String text) {
+ super(null, parent, name, 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, int size, String text) {
- super(field, parent, name, size);
+ public ConfigButton(Field field, Object parent, String name, String category, String subcategory, int size, String text) {
+ super(field, parent, name, 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 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());
+ }
+
private static Runnable getRunnableFromField(Field field, Object parent) {
Runnable runnable = () -> {
};
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 b21c7dc..0ff7d8f 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
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Checkbox;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.animations.Animation;
import cc.polyfrost.oneconfig.gui.animations.ColorAnimation;
@@ -8,7 +9,7 @@ import cc.polyfrost.oneconfig.gui.animations.DummyAnimation;
import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import cc.polyfrost.oneconfig.utils.color.ColorUtils;
@@ -21,8 +22,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, int size) {
- super(field, parent, name, size);
+ public ConfigCheckbox(Field field, Object parent, String name, String category, String subcategory, int size) {
+ super(field, parent, name, 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());
}
@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 0e13f07..5cd9c83 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
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Color;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
@@ -9,7 +10,7 @@ import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.Images;
+import cc.polyfrost.oneconfig.internal.assets.Images;
import cc.polyfrost.oneconfig.utils.InputUtils;
import java.lang.reflect.Field;
@@ -20,13 +21,18 @@ public class ConfigColorElement extends BasicOption {
private final BasicElement element = new BasicElement(64, 32, false);
private boolean open = false;
- public ConfigColorElement(Field field, Object parent, String name, int size) {
- super(field, parent, name, size);
+ public ConfigColorElement(Field field, Object parent, String name, String category, String subcategory, int size) {
+ super(field, parent, name, category, subcategory, size);
hexField.setCentered(true);
alphaField.setCentered(true);
alphaField.onlyAcceptNumbers(true);
}
+ 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());
+ }
+
@Override
public void draw(long vg, int x, int y) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
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 1d64420..657cf99 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
@@ -1,11 +1,12 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Dropdown;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.animations.ColorAnimation;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import org.lwjgl.input.Mouse;
@@ -20,11 +21,16 @@ public class ConfigDropdown extends BasicOption {
private final ColorAnimation atomColor = new ColorAnimation(new ColorPalette(Colors.PRIMARY_600, Colors.PRIMARY_500, Colors.PRIMARY_500));
private boolean opened = false;
- public ConfigDropdown(Field field, Object parent, String name, int size, String[] options) {
- super(field, parent, name, size);
+ public ConfigDropdown(Field field, Object parent, String name, String category, String subcategory, int size, String[] options) {
+ super(field, parent, name, 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());
+ }
+
@Override
public void draw(long vg, int x, int y) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
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 5bf28c0..1eceac8 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
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.DualOption;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.animations.Animation;
import cc.polyfrost.oneconfig.gui.animations.DummyAnimation;
@@ -15,11 +16,15 @@ public class ConfigDualOption extends BasicOption {
private final String left, right;
private Animation posAnimation;
- public ConfigDualOption(Field field, Object parent, String name, int size, String[] options) {
- super(field, parent, name, size);
- this.left = options[0];
- this.right = options[1];
+ 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);
+ 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());
}
@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 bfdb8ca..b930450 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
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Header;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
@@ -11,8 +12,13 @@ import java.lang.reflect.Field;
public class ConfigHeader extends BasicOption {
- public ConfigHeader(Field field, Object parent, String name, int size) {
- super(field, parent, name, size);
+ public ConfigHeader(Field field, Object parent, String name, String category, String subcategory, int size) {
+ super(field, parent, name, category, subcategory, size);
+ }
+
+ public static ConfigHeader create(Field field, Object parent) {
+ Header header = field.getAnnotation(Header.class);
+ return new ConfigHeader(field, parent, header.text(), header.category(), header.subcategory(), header.size());
}
@Override
@@ -22,7 +28,6 @@ public class ConfigHeader extends BasicOption {
ScissorManager.resetScissor(vg, scissor);
}
-
@Override
public int getHeight() {
return 32;
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 c0e041f..11a5cf8 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
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Info;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.data.InfoType;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.renderer.RenderManager;
@@ -13,11 +14,16 @@ import java.lang.reflect.Field;
public class ConfigInfo extends BasicOption {
private final InfoType type;
- public ConfigInfo(Field field, Object parent, String name, int size, InfoType type) {
- super(field, parent, name, size);
+ public ConfigInfo(Field field, Object parent, String name, String category, String subcategory, int size, InfoType type) {
+ super(field, parent, name, category, subcategory, size);
this.type = type;
}
+ public static ConfigInfo create(Field field, Object parent) {
+ Info info = field.getAnnotation(Info.class);
+ return new ConfigInfo(field, parent, info.text(), info.category(), info.subcategory(), info.size(), info.type());
+ }
+
@Override
public void draw(long vg, int x, int y) {
Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 448 : 960, 32);
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 986bb98..5c239c0 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
@@ -1,13 +1,14 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.KeyBind;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import gg.essential.universal.UKeyboard;
@@ -17,12 +18,17 @@ public class ConfigKeyBind extends BasicOption {
private final BasicButton button;
private boolean clicked = false;
- public ConfigKeyBind(Field field, Object parent, String name, int size) {
- super(field, parent, name, size);
+ public ConfigKeyBind(Field field, Object parent, String name, String category, String subcategory, int size) {
+ super(field, parent, name, 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());
+ }
+
@Override
public void draw(long vg, int x, int y) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
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 e4fcc77..5c7c2c4 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
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.OptionPage;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
@@ -8,7 +8,7 @@ import cc.polyfrost.oneconfig.gui.animations.ColorAnimation;
import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import org.lwjgl.input.Mouse;
@@ -21,7 +21,7 @@ public class ConfigPageButton extends BasicOption {
private final ColorAnimation backgroundColor = new ColorAnimation(ColorPalette.SECONDARY);
public ConfigPageButton(Field field, Object parent, String name, String description, OptionPage page) {
- super(field, parent, name, 2);
+ super(field, parent, name, "", "", 2);
this.description = description;
this.page = page;
}
@@ -48,9 +48,4 @@ public class ConfigPageButton extends BasicOption {
public int getHeight() {
return description.equals("") ? 64 : 96;
}
-
- @Override
- public boolean hasHalfSize() {
- return false;
- }
}
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 2bda274..a254729 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
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Slider;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.elements.text.NumberInputField;
import cc.polyfrost.oneconfig.renderer.RenderManager;
@@ -19,14 +20,19 @@ public class ConfigSlider extends BasicOption {
private boolean dragging = false;
private boolean mouseWasDown = false;
- public ConfigSlider(Field field, Object parent, String name, int size, float min, float max, int step) {
- super(field, parent, name, size);
+ public ConfigSlider(Field field, Object parent, String name, String category, String subcategory, int size, float min, float max, int step) {
+ super(field, parent, name,category, subcategory, size);
this.min = min;
this.max = max;
this.step = step;
inputField = new NumberInputField(84, 32, 0, min, max, step == 0 ? 1 : step);
}
+ 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(), 2, slider.min(), slider.max(), slider.step());
+ }
+
@Override
public void draw(long vg, int x, int y) {
int xCoordinate = 0;
@@ -107,9 +113,4 @@ public class ConfigSlider extends BasicOption {
public int getHeight() {
return 32;
}
-
- @Override
- public boolean hasHalfSize() {
- return false;
- }
}
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 2aedf4e..68e5be3 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
@@ -1,6 +1,7 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Switch;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.animations.Animation;
import cc.polyfrost.oneconfig.gui.animations.ColorAnimation;
@@ -18,8 +19,13 @@ public class ConfigSwitch extends BasicOption {
private ColorAnimation color;
private Animation animation;
- public ConfigSwitch(Field field, Object parent, String name, int size) {
- super(field, parent, name, size);
+ public ConfigSwitch(Field field, Object parent, String name, String category, String subcategory, int size) {
+ super(field, parent, name, 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());
}
@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 225232b..81de9ba 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
@@ -1,11 +1,12 @@
package cc.polyfrost.oneconfig.gui.elements.config;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.config.annotations.Text;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.InputUtils;
import org.lwjgl.input.Mouse;
@@ -16,11 +17,16 @@ public class ConfigTextBox extends BasicOption {
private final boolean multiLine;
private final TextInputField textField;
- public ConfigTextBox(Field field, Object parent, String name, int size, String placeholder, boolean secure, boolean multiLine) {
- super(field, parent, name, size);
+ 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);
this.secure = secure;
this.multiLine = multiLine;
- this.textField = new TextInputField(size == 1 && hasHalfSize() ? 256 : 640, multiLine ? 64 : 32, placeholder, multiLine, secure);
+ this.textField = new TextInputField(size == 1 ? 256 : 640, multiLine ? 64 : 32, placeholder, multiLine, secure);
+ }
+
+ 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());
}
@Override
@@ -37,7 +43,7 @@ public class ConfigTextBox extends BasicOption {
if (multiLine && textField.getLines() > 2) textField.setHeight(64 + 24 * (textField.getLines() - 2));
else if (multiLine) textField.setHeight(64);
- textField.draw(vg, x + (size == 1 && hasHalfSize() ? 224 : 352), y);
+ textField.draw(vg, x + (size == 1 ? 224 : 352), y);
if (secure) {
SVGs icon = textField.getPassword() ? SVGs.EYE_OFF : SVGs.EYE;
@@ -64,9 +70,4 @@ public class ConfigTextBox extends BasicOption {
public int getHeight() {
return multiLine ? textField.getHeight() : 32;
}
-
- @Override
- public boolean hasHalfSize() {
- return !secure && !multiLine;
- }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java
index a76c242..e6cf5d9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java
@@ -1,10 +1,10 @@
package cc.polyfrost.oneconfig.gui.elements.text;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.gui.animations.ColorAnimation;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.renderer.RenderManager;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
public class NumberInputField extends TextInputField {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
index 3fde012..559b2b2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
@@ -1,10 +1,10 @@
package cc.polyfrost.oneconfig.gui.elements.text;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.renderer.scissor.Scissor;
import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager;
import cc.polyfrost.oneconfig.utils.InputUtils;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
index ddc144c..455a538 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
@@ -2,7 +2,7 @@ package cc.polyfrost.oneconfig.gui.pages;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
public class CreditsPage extends Page {
public CreditsPage() {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
index 4c24058..53394a1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -1,9 +1,9 @@
package cc.polyfrost.oneconfig.gui.pages;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
public class HomePage extends Page {
/*private final BasicButton socialsBtn = new BasicButton(184, 36, "Socials", SVGs.SHARE, SVGs.POP_OUT, BasicButton.ALIGNMENT_CENTER, ColorUtils.PRIMARY);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
index c192255..797512f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -1,7 +1,7 @@
package cc.polyfrost.oneconfig.gui.pages;
import cc.polyfrost.oneconfig.internal.OneConfig;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
index 7f0882a..51e3a6f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.internal;
-import cc.polyfrost.oneconfig.internal.config.ConfigCore;
+import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
import cc.polyfrost.oneconfig.events.EventManager;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/Colors.java b/src/main/java/cc/polyfrost/oneconfig/internal/assets/Colors.java
index 6cb9567..a8d1e72 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/Colors.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/assets/Colors.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.gui;
+package cc.polyfrost.oneconfig.internal.assets;
import java.awt.*;
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/image/Images.java b/src/main/java/cc/polyfrost/oneconfig/internal/assets/Images.java
index ad1941e..b7dc9cc 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/image/Images.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/assets/Images.java
@@ -1,10 +1,12 @@
-package cc.polyfrost.oneconfig.renderer.image;
+package cc.polyfrost.oneconfig.internal.assets;
+
+import cc.polyfrost.oneconfig.renderer.AssetLoader;
/**
* An enum of images used in OneConfig.
*
* @see cc.polyfrost.oneconfig.renderer.RenderManager#drawImage(long, String, float, float, float, float, int)
- * @see ImageLoader
+ * @see AssetLoader
*/
public enum Images {
HUE_GRADIENT("/assets/oneconfig/options/HueGradient.png"),
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/image/SVGs.java b/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java
index 5ba3fcd..eaad4ba 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/image/SVGs.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/assets/SVGs.java
@@ -1,10 +1,12 @@
-package cc.polyfrost.oneconfig.renderer.image;
+package cc.polyfrost.oneconfig.internal.assets;
+
+import cc.polyfrost.oneconfig.renderer.AssetLoader;
/**
* An enum of SVGs used in OneConfig.
*
* @see cc.polyfrost.oneconfig.renderer.RenderManager#drawSvg(long, String, float, float, float, float, int)
- * @see ImageLoader
+ * @see AssetLoader
*/
public enum SVGs {
ONECONFIG("/assets/oneconfig/icons/OneConfig.svg"),
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/annotations/Option.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/annotations/Option.java
new file mode 100644
index 0000000..02e6d8e
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/annotations/Option.java
@@ -0,0 +1,14 @@
+package cc.polyfrost.oneconfig.internal.config.annotations;
+
+import cc.polyfrost.oneconfig.config.data.OptionType;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface Option {
+ OptionType type();
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/ConfigCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
index f41b74e..02ac8f8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/ConfigCore.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.internal.config;
+package cc.polyfrost.oneconfig.internal.config.core;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.internal.hud.HudCore;
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java
index 09f40e7..58e3575 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java
@@ -1,7 +1,7 @@
package cc.polyfrost.oneconfig.internal.plugin.asm.tweakers;
import cc.polyfrost.oneconfig.config.compatibility.vigilance.VigilanceConfig;
-import cc.polyfrost.oneconfig.internal.config.ConfigCore;
+import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
import cc.polyfrost.oneconfig.internal.plugin.asm.ITransformer;
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/image/ImageLoader.java b/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java
index e8861eb..ee6c326 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/image/ImageLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/AssetLoader.java
@@ -1,5 +1,7 @@
-package cc.polyfrost.oneconfig.renderer.image;
+package cc.polyfrost.oneconfig.renderer;
+import cc.polyfrost.oneconfig.internal.assets.Images;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.IOUtils;
import org.lwjgl.nanovg.NSVGImage;
import org.lwjgl.nanovg.NanoSVG;
@@ -20,21 +22,21 @@ import java.util.HashMap;
* @see Images
* @see SVGs
*/
-public final class ImageLoader {
- private ImageLoader() {
+public final class AssetLoader {
+ private AssetLoader() {
}
private final HashMap<String, Integer> imageHashMap = new HashMap<>();
private final HashMap<String, Integer> svgHashMap = new HashMap<>();
- public static ImageLoader INSTANCE = new ImageLoader();
+ public static AssetLoader INSTANCE = new AssetLoader();
/**
- * Loads an image from resources.
+ * Loads an assets from resources.
*
* @param vg The NanoVG context.
* @param fileName The name of the file to load.
- * @return Whether the image was loaded successfully.
+ * @return Whether the assets was loaded successfully.
*/
public boolean loadImage(long vg, String fileName) {
if (!imageHashMap.containsKey(fileName)) {
@@ -109,24 +111,24 @@ public final class ImageLoader {
}
/**
- * Get a loaded image from the cache.
- * <p><b>Requires the image to have been loaded first.</b></p>
+ * 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
- * @see ImageLoader#loadImage(long, String)
+ * @return The assets
+ * @see AssetLoader#loadImage(long, String)
*/
public int getImage(String fileName) {
return imageHashMap.get(fileName);
}
/**
- * Remove an image from the cache, allowing the image to be garbage collected.
- * Should be used when the GUI rendering the image is closed.
+ * Remove an assets from the cache, allowing the assets to be garbage collected.
+ * Should be used when the GUI rendering the assets is closed.
*
* @param vg The NanoVG context.
* @param fileName The name of the file to remove.
- * @see ImageLoader#loadImage(long, String)
+ * @see AssetLoader#loadImage(long, String)
*/
public void removeImage(long vg, String fileName) {
NanoVG.nvgDeleteImage(vg, imageHashMap.get(fileName));
@@ -153,7 +155,7 @@ public final class ImageLoader {
*
* @param fileName The name of the file to load.
* @return The SVG
- * @see ImageLoader#loadSVG(long, String, float, float)
+ * @see AssetLoader#loadSVG(long, String, float, float)
*/
public int getSVG(String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
@@ -161,12 +163,12 @@ public final class ImageLoader {
}
/**
- * Remove a SVG from the cache, allowing the SVG to be garbage collected.
+ * Remove an SVG from the cache, allowing the SVG to be garbage collected.
* Should be used when the GUI rendering the SVG is closed.
*
* @param vg The NanoVG context.
* @param fileName The name of the file to remove.
- * @see ImageLoader#loadSVG(long, String, float, float)
+ * @see AssetLoader#loadSVG(long, String, float, float)
*/
public void removeSVG(long vg, String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
index 20fc8f6..7ab39e0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java
@@ -1,14 +1,13 @@
package cc.polyfrost.oneconfig.renderer;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.data.InfoType;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.renderer.font.Font;
import cc.polyfrost.oneconfig.renderer.font.FontManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.renderer.image.ImageLoader;
-import cc.polyfrost.oneconfig.renderer.image.Images;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.Images;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.NetworkUtils;
import gg.essential.universal.UGraphics;
@@ -405,9 +404,9 @@ public final class RenderManager {
* @see RenderManager#drawImage(long, String, float, float, float, float, int)
*/
public static void drawImage(long vg, String filePath, float x, float y, float width, float height) {
- if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
+ if (AssetLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getImage(filePath);
+ int image = AssetLoader.INSTANCE.getImage(filePath);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRect(vg, x, y, width, height);
@@ -429,9 +428,9 @@ public final class RenderManager {
* @param color The color.
*/
public static void drawImage(long vg, String filePath, float x, float y, float width, float height, int color) {
- if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
+ if (AssetLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getImage(filePath);
+ int image = AssetLoader.INSTANCE.getImage(filePath);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), imagePaint.innerColor());
@@ -472,9 +471,9 @@ public final class RenderManager {
* @param radius The radius.
*/
public static void drawRoundImage(long vg, String filePath, float x, float y, float width, float height, float radius) {
- if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
+ if (AssetLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getImage(filePath);
+ int image = AssetLoader.INSTANCE.getImage(filePath);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRoundedRect(vg, x, y, width, height, radius);
@@ -636,9 +635,9 @@ public final class RenderManager {
w *= OneConfigGui.INSTANCE.getScaleFactor();
h *= OneConfigGui.INSTANCE.getScaleFactor();
}
- if (ImageLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
+ if (AssetLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getSVG(filePath, w, h);
+ int image = AssetLoader.INSTANCE.getSVG(filePath, w, h);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRect(vg, x, y, width, height);
@@ -666,9 +665,9 @@ public final class RenderManager {
w *= OneConfigGui.INSTANCE.getScaleFactor();
h *= OneConfigGui.INSTANCE.getScaleFactor();
}
- if (ImageLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
+ if (AssetLoader.INSTANCE.loadSVG(vg, filePath, w, h)) {
NVGPaint imagePaint = NVGPaint.calloc();
- int image = ImageLoader.INSTANCE.getSVG(filePath, w, h);
+ int image = AssetLoader.INSTANCE.getSVG(filePath, w, h);
nvgBeginPath(vg);
nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint);
nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), imagePaint.innerColor());
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java b/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java
index 3dd74dc..d7575ce 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java
@@ -2,7 +2,7 @@ package cc.polyfrost.oneconfig.test;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.gui.pages.Page;
-import cc.polyfrost.oneconfig.renderer.image.SVGs;
+import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.util.ArrayList;
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
index 2d76a0e..8d14fb0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java
@@ -1,289 +1,106 @@
package cc.polyfrost.oneconfig.test;
-import cc.polyfrost.oneconfig.config.annotations.ConfigPage;
-import cc.polyfrost.oneconfig.config.annotations.Option;
+import cc.polyfrost.oneconfig.config.annotations.*;
import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.config.data.*;
import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.data.ModType;
-import cc.polyfrost.oneconfig.config.migration.vigilance.VigilanceMigrator;
+import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator;
+import gg.essential.universal.UKeyboard;
import net.minecraftforge.fml.common.FMLCommonHandler;
public class TestConfig extends Config {
- @Option(
- name = "Very cool HUD",
- subcategory = "Test",
- type = OptionType.HUD,
+ @Switch(
+ name = "Test Switch",
size = 2
)
- public static TestHud TestHud = new TestHud(true, 500, 500);
+ boolean testSwitch = false;
- @Option(
- name = "This is all still in beta",
- subcategory = "Test",
- type = OptionType.INFO,
- infoType = InfoType.INFO,
+ @Checkbox(
+ name = "Check box",
size = 2
)
- public static boolean ignored;
+ boolean testCheckBox = true;
- @Option(
- name = "Keybind (1x)",
- subcategory = "Test",
- type = OptionType.KEYBIND
- )
- public static OneKeyBind oneKeyBind = new OneKeyBind(18, 80);
-
- @Option(
- name = "Keybind (2x)",
- subcategory = "Test",
- type = OptionType.KEYBIND,
+ @Info(
+ text = "Test Info",
+ type = InfoType.ERROR,
size = 2
)
- public static OneKeyBind oneKeyBind2 = new OneKeyBind(27, 80);
-
- @Option(
- name = "Crash game",
- subcategory = "Test",
- type = OptionType.BUTTON,
- buttonText = "Crash!"
- )
- public static Runnable runnable = () -> FMLCommonHandler.instance().exitJava(69, false);
+ boolean ignored;
- @Option(
- name = "Crash game",
- subcategory = "Test",
- type = OptionType.BUTTON,
- size = 2,
- buttonText = "Crash!"
- )
- public static Runnable runnable2 = () -> FMLCommonHandler.instance().exitJava(69, false);
-
- @Option(
- name = "Test color selector",
- subcategory = "Test",
- type = OptionType.COLOR,
+ @Header(
+ text = "Test Header",
size = 2
)
- public static OneColor colorTest = new OneColor(126, 137, 42);
-
- @Option(
- name = "Test dual thing",
- subcategory = "Test",
- min = 3f, max = 127f,
- type = OptionType.SLIDER
- )
- public static float sliderText;
-
- @Option(
- name = "Test string",
- subcategory = "Test",
- options = {"NO", "YES"},
- type = OptionType.DUAL_OPTION
- )
- public static boolean switchTest1;
+ boolean ignored1;
- @Option(
- name = "Test dual option",
- subcategory = "Test",
- options = {"HI", "BYE"},
- type = OptionType.DUAL_OPTION
- )
- public static boolean switchTest2;
-
- @ConfigPage(
- name = "Test Page",
- location = PageLocation.TOP
+ @Dropdown(
+ name = "Test Dropdown",
+ options = {"option1", "option2", "option3"},
+ size = 2
)
- public static TestPage testPage = new TestPage();
+ int testDropdown = 0;
- @ConfigPage(
- name = "Test Page width description",
- description = "Wow, an epic description",
- location = PageLocation.BOTTOM
+ @Color(
+ name = "Test Color",
+ size = 2
)
- public static TestPage testPage2 = new TestPage();
+ OneColor testColor = new OneColor(0, 255, 255);
- @Option(
- name = "Test switch",
- subcategory = "Other subcategory",
- type = OptionType.SWITCH
+ @Text(
+ name = "Test Text",
+ size = 2
)
- public static boolean switchTest4;
+ String testText = "Epic Text";
- @Option(
- name = "Test checkbox",
- subcategory = "Other subcategory",
- type = OptionType.CHECKBOX
+ @Button(
+ name = "Test Button",
+ text = "Crash game"
)
- public static boolean switchTest5;
+ Runnable runnable = () -> FMLCommonHandler.instance().exitJava(69, false);
- @Option(
- name = "Favorite food",
- subcategory = "Dropdowns",
- type = OptionType.DROPDOWN,
- category = "Dropdowns",
- options = {"Taco", "Pizza", "Hamburger", "Paimon"}
+ @Slider(
+ name = "Test Slider",
+ min = 25,
+ max = 50
)
- public static int dropdown1;
+ float testSlider = 50;
- @Option(
- name = "Favorite food",
- subcategory = "Dropdowns",
- type = OptionType.DROPDOWN,
- category = "Dropdowns",
- options = {"Taco", "Pizza", "Hamburger", "Paimon"}
+ @KeyBind(
+ name = "Test KeyBind",
+ size = 2
)
- public static int dropdown2;
+ OneKeyBind testKeyBind = new OneKeyBind(UKeyboard.KEY_LSHIFT, UKeyboard.KEY_S);
- @Option(
- name = "Favorite food",
- subcategory = "Dropdowns",
- type = OptionType.DROPDOWN,
- category = "Dropdowns",
- size = 2,
- options = {"Taco", "Pizza", "Hamburger", "Paimon"}
+ @DualOption(
+ name = "Test Dual Option",
+ left = "YES",
+ right = "NO",
+ size = 2
)
- public static int dropdown3;
+ boolean testDualOption = false;
- @Option(
- name = "Slider",
- subcategory = "Sliders",
- type = OptionType.SLIDER,
- category = "Sliders",
+ @Switch(
+ name = "Test Switch",
size = 2,
- min = 0,
- max = 25
+ category = "Category 2"
)
- public static int slider1;
+ boolean testSwitch1 = false;
- @Option(
- name = "Stepped Slider",
- subcategory = "Sliders",
- type = OptionType.SLIDER,
- category = "Sliders",
+ @Switch(
+ name = "Test Switch",
size = 2,
- min = 0,
- max = 30,
- step = 2
- )
- public static float slider2;
-
- @Option(
- name = "Slider",
- type = OptionType.SLIDER,
- category = "subcategory test",
- min = 5,
- max = 3287
- )
- public static float slider = 26;
-
- @Option(
- name = "Slider",
- type = OptionType.SLIDER,
- category = "subcategory test",
- min = 5,
- max = 3287
+ category = "Category 2",
+ subcategory = "Test Subcategory"
)
- public static float slider10 = 26;
+ boolean testSwitch2 = false;
- @Option(
- name = "Slider",
- type = OptionType.SLIDER,
- category = "subcategory test",
- min = 5,
- max = 3287,
- subcategory = "Second subcategory"
- )
- public static float slider11 = 26;
-
- @Option(
- name = "Header Test",
- type = OptionType.HEADER,
- category = "subcategory test",
- subcategory = "Second subcategory",
- size = 2
- )
- public static boolean somethingHere;
-
-
- @Option(
- name = "Slider",
- type = OptionType.SLIDER,
- category = "subcategory test",
- min = 5,
- max = 3287,
- subcategory = "Second subcategory"
- )
- public static float slider12 = 26;
-
- @ConfigPage(
- name = "Test page",
- location = PageLocation.TOP,
- category = "subcategory test",
- subcategory = "Second subcategory"
- )
- public static TestPage testPage23 = new TestPage();
-
- @ConfigPage(
- name = "Test page",
- location = PageLocation.BOTTOM,
- category = "subcategory test",
- subcategory = "Second subcategory"
- )
- public static TestPage testPage24 = new TestPage();
-
- @Option(
- name = "Slider",
- type = OptionType.SLIDER,
- category = "subcategory test",
- min = 5,
- max = 3287
- )
- public static float slider13 = 26;
-
- @Option(
- name = "Int test",
- type = OptionType.SLIDER,
- category = "Migrator",
- subcategory = "Test",
- min = 5,
- max = 3287
- )
- public static int testInt = 5;
-
- @Option(
- name = "Float test",
- type = OptionType.SLIDER,
- category = "Migrator",
- subcategory = "Test",
- min = 5,
- max = 3287
- )
- public static float floatTest = 5f;
-
- @Option(
- name = "Boolean test",
- type = OptionType.SWITCH,
- category = "Migrator",
- subcategory = "Test"
- )
- public static boolean booleanTest = false;
-
- @Option(
- name = "String test",
- type = OptionType.TEXT,
- category = "Migrator",
- subcategory = "Test"
- )
- public static String stringTest123 = "text";
public TestConfig() {
super(new Mod("Test Mod", ModType.UTIL_QOL, new VigilanceMigrator("./config/testConfig.toml")), "hacksConfig.json");
- addDependency("switchTest5", () -> switchTest4);
- addDependency("Test page.testDescription", () -> false);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java
index 930d827..0a59c23 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java
@@ -1,7 +1,5 @@
package cc.polyfrost.oneconfig.test;
-import cc.polyfrost.oneconfig.config.annotations.Option;
-import cc.polyfrost.oneconfig.config.data.OptionType;
import cc.polyfrost.oneconfig.hud.TextHud;
import net.minecraft.client.Minecraft;
@@ -21,15 +19,7 @@ public class TestHud extends TextHud {
return lines;
}
- @Option(
- name = "Enable Second Line",
- type = OptionType.SWITCH
- )
public boolean hasSecondLine = false;
- @Option(
- name = "Second Line Text",
- type = OptionType.TEXT
- )
public String secondLine = "Epic text";
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestPage.java b/src/main/java/cc/polyfrost/oneconfig/test/TestPage.java
index c70610a..abb4cc7 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestPage.java
@@ -1,44 +1,4 @@
package cc.polyfrost.oneconfig.test;
-import cc.polyfrost.oneconfig.config.annotations.Option;
-import cc.polyfrost.oneconfig.config.data.OptionType;
-
public class TestPage {
- @Option(
- name = "Text field 1x",
- subcategory = "Test",
- type = OptionType.TEXT
- )
- public static String testDescription;
-
- @Option(
- name = "Text field 1x",
- subcategory = "Test",
- type = OptionType.TEXT
- )
- public static String testDescription2;
-
- @Option(
- name = "Text field 2x",
- subcategory = "Test",
- type = OptionType.TEXT,
- size = 2
- )
- public static String testDescription3;
-
- @Option(
- name = "Secure text field",
- subcategory = "Test",
- type = OptionType.TEXT,
- secure = true
- )
- public static String testDescription4;
-
- @Option(
- name = "Text box",
- subcategory = "Test",
- type = OptionType.TEXT,
- multiLine = true
- )
- public static String testDescription5;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java
index dc15e92..823e0aa 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java
@@ -1,12 +1,12 @@
package cc.polyfrost.oneconfig.utils.color;
-import cc.polyfrost.oneconfig.gui.Colors;
+import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.config.core.OneColor;
import java.awt.*;
-import static cc.polyfrost.oneconfig.gui.Colors.*;
+import static cc.polyfrost.oneconfig.internal.assets.Colors.*;
public class ColorPalette {
/**