Added some stuff for new config (not redy yet so dont use)

This commit is contained in:
coolGi2007
2022-02-12 09:24:52 +00:00
parent 50819c30da
commit 87ff857b59
5 changed files with 459 additions and 25 deletions
@@ -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<Boolean>()
.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<HorizontalResolution>()
.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<Integer>()
.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<VerticalQuality>()
.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<Integer>()
.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<HorizontalQuality>()
.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<DropoffQuality>()
.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<FogDistance>()
.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<FogDrawMode>()
.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<FogColorMode>()
.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<Boolean>()
.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<Boolean>()
.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<VanillaOverdraw>()
.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<Boolean>()
.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<Boolean>()
.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<DistanceGenerationMode>()
//.comment(ILodConfigWrapperSingleton.IClient.IWorldGenerator.getDistanceGenerationModeDesc())
.set(ILodConfigWrapperSingleton.IClient.IWorldGenerator.DISTANCE_GENERATION_MODE_DEFAULT)
.build();
@ConfigAnnotations.Entry
public static ConfigEntry lightGenerationMode = new ConfigEntry.Builder<LightGenerationMode>()
.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<GenerationPriority>()
.comment(ILodConfigWrapperSingleton.IClient.IWorldGenerator.GENERATION_PRIORITY_DESC)
.set(ILodConfigWrapperSingleton.IClient.IWorldGenerator.GENERATION_PRIORITY_DEFAULT)
.build();
@ConfigAnnotations.Entry
public static ConfigEntry blocksToAvoid = new ConfigEntry.Builder<BlocksToAvoid>()
.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<Integer>()
.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<Integer>()
.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<Boolean>()
.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<DebugMode>()
.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<Boolean>()
.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<GpuUploadMethod>()
.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<Integer>()
.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<BufferRebuildTimes>()
.comment(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.REBUILD_TIMES_DESC)
.set(ILodConfigWrapperSingleton.IClient.IAdvanced.IBuffers.REBUILD_TIMES_DEFAULT)
.build();
}
}
}
}
@@ -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;
}
}
@@ -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<ConfigEntry> 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
}
}
@@ -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<T> {
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<T> {
private T tmpValue;
private String tmpComment;
private T tmpMin;
private T tmpMax;
private boolean tmpShow = true;
public Builder<T> set(T newValue) {
this.tmpValue = newValue;
return this;
}
public Builder<T> comment(String newComment) {
this.tmpComment = newComment;
return this;
}
public Builder<T> setMinMax(T newMin, T newMax) {
this.tmpMin = newMin;
this.tmpMax = newMax;
return this;
}
public Builder<T> showOption(boolean newShow) {
this.tmpShow = newShow;
return this;
}
public ConfigEntry<T> build() {
return new ConfigEntry<T>(tmpValue, tmpComment, tmpMin, tmpMax, tmpShow);
}
}
}
@@ -0,0 +1,9 @@
package com.seibel.lod.core.config.file;
/**
* Handles all stuff to do with the files
*
* @author coolGi2007
*/
public class ConfigFileHandling {
}