From 78274eb2b66b27052fe32960916fa4419202dc76 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Sat, 12 Feb 2022 19:44:15 +0100 Subject: finish config backend --- .../polyfrost/oneconfig/annotations/Category.java | 1 + .../io/polyfrost/oneconfig/annotations/Slider.java | 5 +- .../io/polyfrost/oneconfig/core/ConfigCore.java | 11 +++ .../java/io/polyfrost/oneconfig/data/ModData.java | 24 +++++++ .../java/io/polyfrost/oneconfig/data/ModType.java | 10 +++ .../gui/elements/config/OConfigButton.java | 22 +++++- .../gui/elements/config/OConfigCategory.java | 24 +++++++ .../gui/elements/config/OConfigColor.java | 22 +++++- .../gui/elements/config/OConfigSelector.java | 24 ++++++- .../gui/elements/config/OConfigSlider.java | 26 ++++++- .../gui/elements/config/OConfigSwitch.java | 20 +++++- .../oneconfig/gui/elements/config/OConfigText.java | 24 ++++++- .../io/polyfrost/oneconfig/interfaces/Config.java | 81 +++++++++++++++++++--- .../oneconfig/interfaces/OneConfigTypeAdapter.java | 4 +- .../io/polyfrost/oneconfig/interfaces/Option.java | 76 ++++++++++++++++++++ .../io/polyfrost/oneconfig/test/TestConfig.java | 6 +- 16 files changed, 358 insertions(+), 22 deletions(-) create mode 100644 src/main/java/io/polyfrost/oneconfig/core/ConfigCore.java create mode 100644 src/main/java/io/polyfrost/oneconfig/data/ModData.java create mode 100644 src/main/java/io/polyfrost/oneconfig/data/ModType.java create mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java create mode 100644 src/main/java/io/polyfrost/oneconfig/interfaces/Option.java (limited to 'src') diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/Category.java b/src/main/java/io/polyfrost/oneconfig/annotations/Category.java index 05449dc..21c5533 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/Category.java +++ b/src/main/java/io/polyfrost/oneconfig/annotations/Category.java @@ -9,4 +9,5 @@ import java.lang.annotation.Target; @Target(ElementType.TYPE) public @interface Category { String name(); + String description() default ""; } diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/Slider.java b/src/main/java/io/polyfrost/oneconfig/annotations/Slider.java index 990c70b..fa855bf 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/Slider.java +++ b/src/main/java/io/polyfrost/oneconfig/annotations/Slider.java @@ -10,6 +10,7 @@ import java.lang.annotation.Target; public @interface Slider { String name(); String description() default ""; - int min(); - int max(); + float min(); + float max(); + float precision(); } diff --git a/src/main/java/io/polyfrost/oneconfig/core/ConfigCore.java b/src/main/java/io/polyfrost/oneconfig/core/ConfigCore.java new file mode 100644 index 0000000..8fe7c81 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/core/ConfigCore.java @@ -0,0 +1,11 @@ +package io.polyfrost.oneconfig.core; + +import io.polyfrost.oneconfig.data.ModData; +import io.polyfrost.oneconfig.interfaces.Option; + +import java.util.ArrayList; +import java.util.HashMap; + +public class ConfigCore { + public static HashMap> settings = new HashMap<>(); +} diff --git a/src/main/java/io/polyfrost/oneconfig/data/ModData.java b/src/main/java/io/polyfrost/oneconfig/data/ModData.java new file mode 100644 index 0000000..24ed1e5 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/data/ModData.java @@ -0,0 +1,24 @@ +package io.polyfrost.oneconfig.data; + +import io.polyfrost.oneconfig.interfaces.Config; + +public class ModData { + public final String name; + public final ModType modType; + public final String creator; + public final String version; + public Config config; + + /** + * @param name Friendly name of the mod + * @param modType Type of the mod (for example ModType.QOL) + * @param creator Creator of the mod + * @param version Version of the mod + */ + public ModData(String name, ModType modType, String creator, String version) { + this.name = name; + this.modType = modType; + this.creator = creator; + this.version = version; + } +} diff --git a/src/main/java/io/polyfrost/oneconfig/data/ModType.java b/src/main/java/io/polyfrost/oneconfig/data/ModType.java new file mode 100644 index 0000000..18cf638 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/data/ModType.java @@ -0,0 +1,10 @@ +package io.polyfrost.oneconfig.data; + +public enum ModType { + PVP, + PERFORMANCE, + HUD, + QOL, + HYPIXEL, + OTHER +} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java index de21d9d..a6951a6 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java @@ -1,4 +1,24 @@ package io.polyfrost.oneconfig.gui.elements.config; -public class OConfigButton { +import io.polyfrost.oneconfig.interfaces.Option; + +import java.lang.reflect.Field; + +public class OConfigButton extends Option { + private final String text; + + public OConfigButton(Field field, String name, String description, String text) { + super(field, name, description); + this.text = text; + } + + @Override + public int getHeight() { + return 0; + } + + @Override + public void draw(int x, int y, int width, int mouseX, int mouseY) { + + } } diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java new file mode 100644 index 0000000..0eae75a --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java @@ -0,0 +1,24 @@ +package io.polyfrost.oneconfig.gui.elements.config; + +import io.polyfrost.oneconfig.interfaces.Option; + +import java.util.List; + +public class OConfigCategory extends Option { + public final List