diff --git a/src/main/java/com/seibel/lod/core/ModInfo.java b/src/main/java/com/seibel/lod/core/ModInfo.java index 00f026c86..b63e65336 100644 --- a/src/main/java/com/seibel/lod/core/ModInfo.java +++ b/src/main/java/com/seibel/lod/core/ModInfo.java @@ -35,7 +35,7 @@ public final class ModInfo public static final String ID = "lod"; /** The internal mod name */ public static final String NAME = "DistantHorizons"; - /** Human readable version of NAME */ + /** Human-readable version of NAME */ public static final String READABLE_NAME = "Distant Horizons"; public static final String API = "LodAPI"; public static final String VERSION = "1.6.2a"; diff --git a/src/main/java/com/seibel/lod/core/config/ConfigAnnotations.java b/src/main/java/com/seibel/lod/core/config/ConfigAnnotations.java index 6c173e2d0..ed320f9f9 100644 --- a/src/main/java/com/seibel/lod/core/config/ConfigAnnotations.java +++ b/src/main/java/com/seibel/lod/core/config/ConfigAnnotations.java @@ -13,24 +13,6 @@ import java.lang.annotation.Target; * @version 02-07-2022 */ public class ConfigAnnotations { - /** A textField, button, etc. that can be interacted with */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - public @interface Entry - { - String name() default ""; - - @Deprecated - int width() default 150; - - @Deprecated - double minValue() default Double.MIN_NORMAL; - - @Deprecated - double maxValue() default Double.MAX_VALUE; - - } - /** For making categories */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @@ -39,7 +21,7 @@ public class ConfigAnnotations { } - /** Makes text (looks like @Entry but dosnt save and has no button */ + /** Makes text (looks like @Entry but doesn't save and has no button) */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Comment @@ -57,15 +39,4 @@ public class ConfigAnnotations { { } - - /** DONT USE AS IT WILL BE REMOVED IN THE REWORK OF THE CONFIG */ - @Deprecated - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - public @interface ScreenEntry - { - String name() default ""; - - int width() default 100; - } } diff --git a/src/main/java/com/seibel/lod/core/config/ConfigBase.java b/src/main/java/com/seibel/lod/core/config/ConfigBase.java index e140bbbf6..b028531c0 100644 --- a/src/main/java/com/seibel/lod/core/config/ConfigBase.java +++ b/src/main/java/com/seibel/lod/core/config/ConfigBase.java @@ -5,25 +5,40 @@ import com.seibel.lod.core.util.SingletonHandler; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; import java.io.File; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; /** - * Config class should extend this + * Indexes and sets everything up for the file handling and gui * * @author coolGi2007 */ -public abstract class ConfigBase { - public static final File ConfigPath = SingletonHandler.get(IMinecraftWrapper.class).getGameDirectory().toPath().resolve("config").resolve(ModInfo.NAME+".toml").toFile(); +public class ConfigBase { public static final List entries = new ArrayList<>(); + public static final List categories = new ArrayList<>(); public static void init(Class config) { - initNestedClass(config); + categories.add(""); // Add root category to category list + initNestedClass(config, ""); // Init root category // File handling (load from file) } - private static void initNestedClass(Class config) { + private static void initNestedClass(Class config, String category) { // Put all the entries in entries + + for (Field field : config.getFields()) + { + if (ConfigEntry.class.isAssignableFrom(field.getType())) { // If item is type ConfigEntry +// entries.add(field); + } + + if (field.isAnnotationPresent(ConfigAnnotations.Category.class)) { // If it's a category then init the stuff inside it and put it in the category list + String NCategory = (category.isEmpty() ? "" : category + ".") + field.getName(); + categories.add(NCategory); + initNestedClass(field.getType(), NCategory); + } + } } } diff --git a/src/main/java/com/seibel/lod/core/config/ConfigEntry.java b/src/main/java/com/seibel/lod/core/config/ConfigEntry.java index 3758ed1f6..1ef209bc6 100644 --- a/src/main/java/com/seibel/lod/core/config/ConfigEntry.java +++ b/src/main/java/com/seibel/lod/core/config/ConfigEntry.java @@ -70,6 +70,20 @@ public class ConfigEntry { } + /** Should not be needed for anything other than the gui/file handling */ + public String getCategory() { + return this.category; + } + /** Should not be needed for anything other than the gui/file handling */ + public String getName() { + return this.name; + } + /** Should not be needed for anything other than the gui/file handling */ + public String getNameWCategory() { + return (this.category.isEmpty() ? "" : this.category + ".") + this.name; + } + + /** * Checks if the option is valid * diff --git a/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java b/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java index eff9813e8..efb023f74 100644 --- a/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java +++ b/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java @@ -1,9 +1,24 @@ package com.seibel.lod.core.config.file; +import com.seibel.lod.core.ModInfo; +import com.seibel.lod.core.util.SingletonHandler; +import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper; + +import java.io.File; + /** * Handles all stuff to do with the files * * @author coolGi2007 */ public class ConfigFileHandling { + public static final File ConfigPath = SingletonHandler.get(IMinecraftWrapper.class).getGameDirectory().toPath().resolve("config").resolve(ModInfo.NAME+".toml").toFile(); + + public static void saveToFile() { + + } + + public static void loadFromFile() { + + } }