From aad5111d45a66d943f0bcbe885ccb28249441d11 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Tue, 26 Apr 2022 20:35:35 +0200 Subject: config system rewrite --- .../java/io/polyfrost/oneconfig/OneConfig.java | 17 ++-- .../oneconfig/config/OneConfigConfig.java | 4 +- .../oneconfig/config/annotations/Button.java | 18 ---- .../oneconfig/config/annotations/Category.java | 16 ---- .../oneconfig/config/annotations/ColorPicker.java | 18 ---- .../oneconfig/config/annotations/HudComponent.java | 16 ---- .../oneconfig/config/annotations/Option.java | 42 +++++++++ .../oneconfig/config/annotations/Selector.java | 20 ---- .../oneconfig/config/annotations/Slider.java | 22 ----- .../oneconfig/config/annotations/Switch.java | 16 ---- .../oneconfig/config/annotations/TextField.java | 20 ---- .../oneconfig/config/core/ConfigCore.java | 14 ++- .../io/polyfrost/oneconfig/config/data/Mod.java | 25 +++++ .../polyfrost/oneconfig/config/data/ModData.java | 24 ----- .../oneconfig/config/data/OptionPage.java | 20 ++++ .../oneconfig/config/data/OptionType.java | 6 ++ .../oneconfig/config/interfaces/BasicOption.java | 78 ++++++++++++++++ .../oneconfig/config/interfaces/Config.java | 101 +++++++++------------ .../oneconfig/config/interfaces/Option.java | 78 ---------------- .../polyfrost/oneconfig/gui/elements/ModCard.java | 10 +- .../oneconfig/gui/elements/config/ConfigPage.java | 26 ++++++ .../gui/elements/config/ConfigSwitch.java | 23 +++++ .../gui/elements/config/OConfigButton.java | 36 -------- .../gui/elements/config/OConfigCategory.java | 24 ----- .../gui/elements/config/OConfigColor.java | 24 ----- .../oneconfig/gui/elements/config/OConfigHud.java | 22 ----- .../gui/elements/config/OConfigSelector.java | 26 ------ .../gui/elements/config/OConfigSlider.java | 28 ------ .../gui/elements/config/OConfigSwitch.java | 22 ----- .../oneconfig/gui/elements/config/OConfigText.java | 26 ------ .../oneconfig/gui/pages/ModConfigPage.java | 32 ++----- .../io/polyfrost/oneconfig/gui/pages/ModsPage.java | 4 +- .../oneconfig/gui/pages/PerformanceModsPage.java | 4 +- .../io/polyfrost/oneconfig/test/TestConfig.java | 36 ++++---- .../java/io/polyfrost/oneconfig/test/TestPage.java | 14 +++ 35 files changed, 328 insertions(+), 584 deletions(-) delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java create mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java create mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/Mod.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/ModData.java create mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java create mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java create mode 100644 src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java create mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPage.java create mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigHud.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java create mode 100644 src/main/java/io/polyfrost/oneconfig/test/TestPage.java (limited to 'src/main/java/io/polyfrost/oneconfig') diff --git a/src/main/java/io/polyfrost/oneconfig/OneConfig.java b/src/main/java/io/polyfrost/oneconfig/OneConfig.java index f3668d8..658536a 100644 --- a/src/main/java/io/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/OneConfig.java @@ -3,7 +3,7 @@ package io.polyfrost.oneconfig; import io.polyfrost.oneconfig.command.OneConfigCommand; import io.polyfrost.oneconfig.config.OneConfigConfig; import io.polyfrost.oneconfig.config.core.ConfigCore; -import io.polyfrost.oneconfig.config.data.ModData; +import io.polyfrost.oneconfig.config.data.Mod; import io.polyfrost.oneconfig.config.data.ModType; import io.polyfrost.oneconfig.hud.HudCore; import io.polyfrost.oneconfig.test.TestConfig; @@ -11,7 +11,6 @@ import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -23,7 +22,7 @@ import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; -@Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") +@net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") public class OneConfig { private static final Minecraft mc = Minecraft.getMinecraft(); public static File jarFile; @@ -31,10 +30,10 @@ public class OneConfig { public static File themesDir = new File(oneConfigDir, "themes/"); public static OneConfigConfig config; public static TestConfig testConfig; - public static List loadedMods = new ArrayList<>(); + public static List loadedMods = new ArrayList<>(); public static List loadedOtherMods = new ArrayList<>(); - @Mod.EventHandler + @net.minecraftforge.fml.common.Mod.EventHandler public void onPreFMLInit(FMLPreInitializationEvent event) { jarFile = event.getSourceFile(); oneConfigDir.mkdirs(); @@ -42,7 +41,7 @@ public class OneConfig { config = new OneConfigConfig(); } - @Mod.EventHandler + @net.minecraftforge.fml.common.Mod.EventHandler public void onFMLInitialization(FMLInitializationEvent event) { testConfig = new TestConfig(); ClientCommandHandler.instance.registerCommand(new OneConfigCommand()); @@ -50,19 +49,19 @@ public class OneConfig { MinecraftForge.EVENT_BUS.register(new HudCore()); } - @Mod.EventHandler + @net.minecraftforge.fml.common.Mod.EventHandler public void onPostFMLInit(FMLPostInitializationEvent event) { reloadModsList(); } public static void reloadModsList() { loadedMods.addAll(ConfigCore.settings.keySet()); - LinkedHashSet modData = new LinkedHashSet<>(ConfigCore.settings.keySet()); + LinkedHashSet modData = new LinkedHashSet<>(ConfigCore.settings.keySet()); for (ModContainer mod : Loader.instance().getActiveModList()) { ModMetadata metadata = mod.getMetadata(); loadedOtherMods.add(metadata); String author = metadata.authorList.size() > 0 ? metadata.authorList.get(0) : ""; - ModData newMod = new ModData(metadata.name, ModType.OTHER, author, metadata.version); + Mod newMod = new Mod(metadata.name, ModType.OTHER, author, metadata.version); if (newMod.name.equals("Minecraft Coder Pack") || newMod.name.equals("Forge Mod Loader") || newMod.name.equals("Minecraft Forge")) { // TODO add oneconfig continue; } diff --git a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java index bfb123a..f10111c 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java @@ -1,7 +1,7 @@ package io.polyfrost.oneconfig.config; import com.google.gson.JsonParser; -import io.polyfrost.oneconfig.config.data.ModData; +import io.polyfrost.oneconfig.config.data.Mod; import io.polyfrost.oneconfig.config.interfaces.Config; import java.awt.*; @@ -48,7 +48,7 @@ public class OneConfigConfig extends Config { } @Override - public void init(ModData modData) { + public void init(Mod mod) { if (new File("OneConfig/" + configFile).exists()) load(); else save(); } diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java deleted file mode 100644 index 3ba1078..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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 Button { - String name(); - - String description() default ""; - - String text() default "Button"; - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java deleted file mode 100644 index 83b7af4..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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.TYPE) -public @interface Category { - String name(); - - String description() default ""; - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java deleted file mode 100644 index 6854bc2..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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 ColorPicker { - String name(); - - String description() default ""; - - boolean allowAlpha() default true; - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java deleted file mode 100644 index 00a2e74..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/HudComponent.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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 HudComponent { - String name(); - - String description() default ""; - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java new file mode 100644 index 0000000..8abb303 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java @@ -0,0 +1,42 @@ +package io.polyfrost.oneconfig.config.annotations; + +import io.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 page that will be displayed to the user + */ + String name(); + + /** + * The description of the page that will be displayed to the user + */ + String description() default ""; + + /** + * 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(); + + /** + * The width of the option (1 = half width, 2 = full width) + */ + int size() default 1; +} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java deleted file mode 100644 index 00d88d8..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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 Selector { - String name(); - - String description() default ""; - - String[] options(); - - int defaultSelection() default 0; - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java deleted file mode 100644 index ea19da5..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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 Slider { - String name(); - - String description() default ""; - - float min(); - - float max(); - - float precision(); - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java deleted file mode 100644 index 8ff2f11..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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 Switch { - String name(); - - String description() default ""; - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java deleted file mode 100644 index 0df1426..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -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 TextField { - String name(); - - String description() default ""; - - String placeholder() default ""; - - boolean hideText() default false; - - int size() default 1; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java index 9bb2e85..9be25e9 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java +++ b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java @@ -1,26 +1,24 @@ package io.polyfrost.oneconfig.config.core; -import io.polyfrost.oneconfig.config.data.ModData; -import io.polyfrost.oneconfig.config.interfaces.Option; +import io.polyfrost.oneconfig.config.data.Mod; import io.polyfrost.oneconfig.hud.HudCore; import java.util.ArrayList; -import java.util.HashMap; public class ConfigCore { - public static HashMap> settings = new HashMap<>(); + public static ArrayList OneConfigMods = new ArrayList<>(); public static void saveAll() { - for (ModData modData : settings.keySet()) { + for (Mod modData : OneConfigMods) { modData.config.save(); } } public static void reInitAll() { - ArrayList data = new ArrayList<>(settings.keySet()); - settings.clear(); + ArrayList data = new ArrayList<>(OneConfigMods); + OneConfigMods.clear(); HudCore.huds.clear(); - for (ModData modData : data) { + for (Mod modData : data) { modData.config.init(modData); } } diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java b/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java new file mode 100644 index 0000000..435fb32 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java @@ -0,0 +1,25 @@ +package io.polyfrost.oneconfig.config.data; + +import io.polyfrost.oneconfig.config.interfaces.Config; + +public class Mod { + public final String name; + public final ModType modType; + public final String creator; + public final String version; + public Config config; + public OptionPage defaultPage = new OptionPage(""); + + /** + * @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 Mod(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/config/data/ModData.java b/src/main/java/io/polyfrost/oneconfig/config/data/ModData.java deleted file mode 100644 index c5e6633..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/ModData.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -import io.polyfrost.oneconfig.config.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/config/data/OptionPage.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java new file mode 100644 index 0000000..021786d --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java @@ -0,0 +1,20 @@ +package io.polyfrost.oneconfig.config.data; + +import io.polyfrost.oneconfig.config.interfaces.BasicOption; + +import java.util.ArrayList; +import java.util.HashMap; + +public class OptionPage { + public final String name; + /** + * Depth 1 = categories + * Depth 2 = subcategories + * Depth 3 = list of options + */ + public final HashMap>> categories = new HashMap<>(); + + public OptionPage(String name) { + this.name = name; + } +} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java new file mode 100644 index 0000000..22c92c0 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java @@ -0,0 +1,6 @@ +package io.polyfrost.oneconfig.config.data; + +public enum OptionType { + PAGE, + SWITCH +} diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java new file mode 100644 index 0000000..42c826e --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java @@ -0,0 +1,78 @@ +package io.polyfrost.oneconfig.config.interfaces; + +import java.lang.reflect.Field; + +@SuppressWarnings({"unused"}) +public abstract class BasicOption { + protected final Field field; + protected final String name; + protected final String description; + public final int size; + + /** + * Initialize option + * + * @param field variable attached to option (null for category) + * @param name name of option + * @param description description of option + * @param size size of option, 0 for single column, 1 for double. + */ + public BasicOption(Field field, String name, String description, int size) { + this.field = field; + this.name = name; + this.description = description; + this.size = size; + if (field != null) field.setAccessible(true); + } + + /** + * @param object Java object to set the variable to + */ + protected void set(Object object) throws IllegalAccessException { + if (field == null) return; + field.set(null, object); + } + + /** + * @return value of variable as Java object + */ + protected Object get() throws IllegalAccessException { + if (field == null) return null; + return field.get(null); + } + + /** + * @return height of option to align other options accordingly + */ + public abstract int getHeight(); + + /** + * Function that gets called when drawing option + * + * @param vg NanoVG context + * @param x x position + * @param y y position + * @param mouseX x position of mouse + * @param mouseY y position of mouse + */ + public abstract void draw(long vg, int x, int y, int mouseX, int mouseY); + + /** + * Function that gets called when mouse is clicked + * + * @param mouseX x position of mouse + * @param mouseY y position of mouse + * @param mouseButton button that got pressed + */ + protected void onMouseClicked(int mouseX, int mouseY, int mouseButton) { + } + + /** + * Function that gets called when a key is typed + * + * @param typedChar char that has been typed + * @param keyCode code of key + */ + protected void keyTyped(char typedChar, int keyCode) { + } +} diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java index f0efcb0..c68162e 100644 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java @@ -1,23 +1,20 @@ package io.polyfrost.oneconfig.config.interfaces; import com.google.gson.*; -import io.polyfrost.oneconfig.config.annotations.*; -import io.polyfrost.oneconfig.config.core.ConfigCore; -import io.polyfrost.oneconfig.config.data.ModData; +import io.polyfrost.oneconfig.config.annotations.Option; +import io.polyfrost.oneconfig.config.data.Mod; +import io.polyfrost.oneconfig.config.data.OptionPage; import io.polyfrost.oneconfig.config.profiles.Profiles; -import io.polyfrost.oneconfig.gui.elements.config.*; -import io.polyfrost.oneconfig.hud.HudCore; -import io.polyfrost.oneconfig.hud.interfaces.BasicHud; +import io.polyfrost.oneconfig.gui.elements.config.ConfigPage; +import io.polyfrost.oneconfig.gui.elements.config.ConfigSwitch; +import io.polyfrost.oneconfig.test.TestConfig; import java.io.*; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Map; -import java.util.Optional; +import java.util.*; public class Config { protected final String configFile; @@ -27,16 +24,16 @@ public class Config { * @param modData information about the mod * @param configFile file where config is stored */ - public Config(ModData modData, String configFile) { + public Config(Mod modData, String configFile) { this.configFile = configFile; init(modData); } - public void init(ModData modData) { + public void init(Mod mod) { if (Profiles.getProfileFile(configFile).exists()) load(); else save(); - modData.config = this; - ConfigCore.settings.put(modData, generateOptionList(this.getClass())); + mod.config = this; + generateOptionList(this.getClass(), mod.defaultPage); } /** @@ -62,63 +59,51 @@ public class Config { } /** - * Generate the option list for internal use only + * Generate the option list, for internal use only * * @param clazz target class - * @return list of options + * @param page page to add options too */ - protected ArrayList