diff --git a/src/main/java/com/seibel/lod/core/Config.java b/src/main/java/com/seibel/lod/core/Config.java new file mode 100644 index 000000000..a3697304e --- /dev/null +++ b/src/main/java/com/seibel/lod/core/Config.java @@ -0,0 +1,270 @@ +package com.seibel.lod.core; + +import com.seibel.lod.core.config.*; +import com.seibel.lod.core.enums.config.*; +import com.seibel.lod.core.enums.rendering.*; +import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; + +/** + * This handles any configuration the user has access to. + * @author coolGi2007 + * @version 02-07-2022 + */ +public class Config extends ConfigBase +{ + // CONFIG STRUCTURE + // -> Client + // | + // |-> Graphics + // | |-> Quality + // | |-> FogQuality + // | |-> AdvancedGraphics + // | + // |-> World Generation + // | + // |-> Advanced + // |-> Threads + // |-> Buffers + // |-> Debugging + + @ConfigAnnotations.Category + public static Client client; + + public static class Client + { + @ConfigAnnotations.Category + public static Graphics graphics; + + @ConfigAnnotations.Category + public static WorldGenerator worldGenerator; + + @ConfigAnnotations.Category + public static Advanced advanced; + + + @ConfigAnnotations.Entry + public static ConfigEntry optionsButton = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.OPTIONS_BUTTON_DESC) + .set(ILodConfigWrapperSingleton.IClient.OPTIONS_BUTTON_DEFAULT) + .build(); + + + public static class Graphics + { + @ConfigAnnotations.Category + public static Quality quality; + + @ConfigAnnotations.Category + public static FogQuality fogQuality; + + @ConfigAnnotations.Category + public static AdvancedGraphics advancedGraphics; + + + public static class Quality + { + @ConfigAnnotations.Entry + public static ConfigEntry drawResolution = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.DRAW_RESOLUTION_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.DRAW_RESOLUTION_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry lodChunkRenderDistance = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.LOD_CHUNK_RENDER_DISTANCE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX.defaultValue) + .setMinMax(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX.minValue, ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.LOD_CHUNK_RENDER_DISTANCE_MIN_DEFAULT_MAX.maxValue) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry verticalQuality = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.VERTICAL_QUALITY_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.VERTICAL_QUALITY_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry horizontalScale = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.HORIZONTAL_SCALE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.defaultValue) + .setMinMax(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.minValue, ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.maxValue) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry horizontalQuality = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.HORIZONTAL_SCALE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.HORIZONTAL_QUALITY_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry dropoffQuality = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.DROPOFF_QUALITY_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IQuality.DROPOFF_QUALITY_DEFAULT) + .build(); + } + + + public static class FogQuality + { + @ConfigAnnotations.Entry + public static ConfigEntry fogDistance = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.FOG_DISTANCE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.FOG_DISTANCE_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry fogDrawMode = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.FOG_DRAW_MODE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.FOG_DRAW_MODE_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry fogColorMode = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.FOG_COLOR_MODE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.FOG_COLOR_MODE_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry disableVanillaFog = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.DISABLE_VANILLA_FOG_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IFogQuality.DISABLE_VANILLA_FOG_DEFAULT) + .build(); + } + + + public static class AdvancedGraphics + { + @ConfigAnnotations.Entry + public static ConfigEntry disableDirectionalCulling = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry vanillaOverdraw = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IAdvancedGraphics.VANILLA_OVERDRAW_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IAdvancedGraphics.VANILLA_OVERDRAW_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry useExtendedNearClipPlane = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IGraphics.IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IGraphics.IAdvancedGraphics.USE_EXTENDED_NEAR_CLIP_PLANE_DEFAULT) + .build(); + + /* + @ConfigAnnotations.Entry(minValue = 0, maxValue = 512) + public static int backsideCullingRange = IAdvancedGraphics.VANILLA_CULLING_RANGE_MIN_DEFAULT_MAX.defaultValue; + */ + } + } + + + public static class WorldGenerator + { + @ConfigAnnotations.Entry + public static ConfigEntry enableDistantGeneration = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IWorldGenerator.ENABLE_DISTANT_GENERATION_DESC) + .set(ILodConfigWrapperSingleton.IClient.IWorldGenerator.ENABLE_DISTANT_GENERATION_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry distanceGenerationMode = new ConfigEntry.Builder() + //.comment(ILodConfigWrapperSingleton.IClient.IWorldGenerator.getDistanceGenerationModeDesc()) + .set(ILodConfigWrapperSingleton.IClient.IWorldGenerator.DISTANCE_GENERATION_MODE_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry lightGenerationMode = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IWorldGenerator.LIGHT_GENERATION_MODE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IWorldGenerator.LIGHT_GENERATION_MODE_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry generationPriority = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IWorldGenerator.GENERATION_PRIORITY_DESC) + .set(ILodConfigWrapperSingleton.IClient.IWorldGenerator.GENERATION_PRIORITY_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry blocksToAvoid = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IWorldGenerator.BLOCKS_TO_AVOID_DESC) + .set(ILodConfigWrapperSingleton.IClient.IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT) + .build(); + } + + public static class Advanced + { + @ConfigAnnotations.Category + public static Threading threading; + + @ConfigAnnotations.Category + public static Debugging debugging; + + @ConfigAnnotations.Category + public static Buffers buffers; + + + public static class Threading + { + @ConfigAnnotations.Entry + public static ConfigEntry numberOfWorldGenerationThreads = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.defaultValue) + .setMinMax(ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.minValue, ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_WORLD_GENERATION_THREADS_DEFAULT.maxValue) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry numberOfBufferBuilderThreads = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX.defaultValue) + .setMinMax(ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX.minValue, ILodConfigWrapperSingleton.IClient.IAdvanced.IThreading.NUMBER_OF_BUFFER_BUILDER_THREADS_MIN_DEFAULT_MAX.maxValue) + .build(); + } + + + public static class Debugging + { + @ConfigAnnotations.Entry + public static ConfigEntry drawLods = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.DRAW_LODS_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.DRAW_LODS_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry debugMode = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.DEBUG_MODE_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.DEBUG_MODE_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry enableDebugKeybindings = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.DEBUG_KEYBINDINGS_ENABLED_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IDebugging.DEBUG_KEYBINDINGS_ENABLED_DEFAULT) + .build(); + } + + + public static class Buffers + { + @ConfigAnnotations.Entry + public static ConfigEntry gpuUploadMethod = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.GPU_UPLOAD_METHOD_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.GPU_UPLOAD_METHOD_DEFAULT) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry gpuUploadPerMegabyteInMilliseconds = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DEFAULT.defaultValue) + .setMinMax(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DEFAULT.minValue, ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.GPU_UPLOAD_PER_MEGABYTE_IN_MILLISECONDS_DEFAULT.maxValue) + .build(); + + @ConfigAnnotations.Entry + public static ConfigEntry rebuildTimes = new ConfigEntry.Builder() + .comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.REBUILD_TIMES_DESC) + .set(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.REBUILD_TIMES_DEFAULT) + .build(); + } + } + } +} 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 6998dc333..858528feb 100644 --- a/src/main/java/com/seibel/lod/core/config/ConfigAnnotations.java +++ b/src/main/java/com/seibel/lod/core/config/ConfigAnnotations.java @@ -10,27 +10,15 @@ import java.lang.annotation.Target; * If there is no annotation then the config will not touch it * * @author coolGi2007 - * @version 12-28-2021 + * @version 02-07-2022 */ public class ConfigAnnotations { - // Everything with @Deprecated will be removed after 1.6 - - /** 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 */ @@ -53,22 +41,10 @@ public class ConfigAnnotations { * Adds a comment to the file, * This should only be used in special cases where comments from an entry cant reach */ - @Deprecated @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface FileComment { } - - /** 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 new file mode 100644 index 000000000..e140bbbf6 --- /dev/null +++ b/src/main/java/com/seibel/lod/core/config/ConfigBase.java @@ -0,0 +1,29 @@ +package com.seibel.lod.core.config; + +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; +import java.util.ArrayList; +import java.util.List; + +/** + * Config class should extend this + * + * @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 static final List entries = new ArrayList<>(); + + public static void init(Class config) { + initNestedClass(config); + + // File handling (load from file) + } + + private static void initNestedClass(Class config) { + // Put all the entries in entries + } +} diff --git a/src/main/java/com/seibel/lod/core/config/ConfigEntry.java b/src/main/java/com/seibel/lod/core/config/ConfigEntry.java new file mode 100644 index 000000000..3758ed1f6 --- /dev/null +++ b/src/main/java/com/seibel/lod/core/config/ConfigEntry.java @@ -0,0 +1,150 @@ +package com.seibel.lod.core.config; + +/** + * Use for making the config variables + * + * @author coolGi2007 + * @version 02-06-2022 + */ +public class ConfigEntry { + public String category = ""; // This should only be set once in the init + public String name; // This should only be set once in the init + + private T value; + private String comment; + private T min; + private T max; + private boolean show; // Show the option + + /** Creates the entry */ + private ConfigEntry(T value, String comment, T min, T max, boolean show) { + this.value = value; + this.comment = comment; + this.min = min; + this.max = max; + this.show = show; + } + + /** Gets the value */ + public T get() { + return this.value; + } + /** Sets the value */ + public void set(T new_value) { + this.value = new_value; + save(); + } + + /** Gets the min value */ + public T getMin() { + return this.min; + } + /** Sets the min value */ + public void setMin(T newMin) { + this.min = newMin; + } + /** Gets the max value */ + public T getMax() { + return this.max; + } + /** Sets the max value */ + public void setMax(T newMax) { + this.max = newMax; + } + /** Checks weather it should be shown */ + public boolean getShow() { + return this.show; + } + /** Says to show the option */ + public void setShow(boolean newShow) { + this.show = newShow; + } + + /** Gets the comment */ + public String getComment() { + return this.comment; + } + /** Sets the comment */ + public void setComment(String newComment) { + this.comment = newComment; + } + + + /** + * Checks if the option is valid + * + * 0 == valid + * 1 == number too high + * -1 == number too low + */ + public byte isValid() { + if (Number.class.isAssignableFrom(this.value.getClass())) { // Only check min max if it is a number + if (this.max != null && (Double) this.value > (Double) this.max) + return 1; + if (this.min != null && (Double) this.value < (Double) this.min) + return -1; + + return 0; + } + return 0; + } + + /** This should normally not be called since set() automatically calls this */ + public void save() { + // Call to something to save option + } + /** This should normally not be called except for special circumstances */ + public void load() { + // Call something to load option + } + + /** Is the value of this equal to another */ + public boolean equals(ConfigEntry obj) { + if (this.value.getClass() != obj.value.getClass()) + return false; + if (Number.class.isAssignableFrom(this.value.getClass())) { + if (this.value == obj.value) + return true; + else return false; + } else { + if (this.value.equals(obj.value)) + return true; + else return false; + } + } + + // Use this so it dost do file handling stuff + public static class Builder { + private T tmpValue; + private String tmpComment; + private T tmpMin; + private T tmpMax; + private boolean tmpShow = true; + + public Builder set(T newValue) { + this.tmpValue = newValue; + return this; + } + + public Builder comment(String newComment) { + this.tmpComment = newComment; + return this; + } + + public Builder setMinMax(T newMin, T newMax) { + this.tmpMin = newMin; + this.tmpMax = newMax; + return this; + } + + public Builder showOption(boolean newShow) { + this.tmpShow = newShow; + return this; + } + + + public ConfigEntry build() { + return new ConfigEntry(tmpValue, tmpComment, tmpMin, tmpMax, tmpShow); + } + } +} 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 new file mode 100644 index 000000000..eff9813e8 --- /dev/null +++ b/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java @@ -0,0 +1,9 @@ +package com.seibel.lod.core.config.file; + +/** + * Handles all stuff to do with the files + * + * @author coolGi2007 + */ +public class ConfigFileHandling { +}