From e3d87c70c426be6e3c2b0a07140b84a66add48c7 Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Wed, 22 Dec 2021 05:37:59 +0000 Subject: [PATCH] Updated config to be smaller --- .../java/com/seibel/lod/common/Config.java | 30 ++++---- .../lod/common/wrappers/config/ConfigGui.java | 71 ++----------------- 2 files changed, 19 insertions(+), 82 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index ea7b66a19..533f7fd56 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -20,7 +20,6 @@ package com.seibel.lod.common; import com.seibel.lod.common.wrappers.config.ConfigGui; -import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.enums.config.*; import com.seibel.lod.core.enums.rendering.*; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*; @@ -30,9 +29,10 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.I /** * This handles any configuration the user has access to. * @author coolGi2007 - * @version 12-02-2021 + * @version 12-12-2021 */ public class Config extends ConfigGui +//public class Config extends TinyConfig { // CONFIG STRUCTURE // -> Client @@ -51,7 +51,7 @@ public class Config extends ConfigGui // Since the original config system uses forge stuff, that means we have to rewrite the whole config system - @ScreenEntry(to = "client") + @ScreenEntry public static Client client; @Entry @@ -60,30 +60,30 @@ public class Config extends ConfigGui public static class Client { @Category("client") - @ScreenEntry(to = "graphics") + @ScreenEntry public static Graphics graphics; @Category("client") - @ScreenEntry(to = "worldGenerator") + @ScreenEntry public static WorldGenerator worldGenerator; @Category("client") - @ScreenEntry(to = "advanced") + @ScreenEntry public static Advanced advanced; public static class Graphics { @Category("client.graphics") - @ScreenEntry(to = "quality") + @ScreenEntry public static Quality quality; @Category("client.graphics") - @ScreenEntry(to = "fogQuality") + @ScreenEntry public static FogQuality fogQuality; @Category("client.graphics") - @ScreenEntry(to = "advancedGraphics") + @ScreenEntry public static AdvancedGraphics advancedGraphics; @@ -121,10 +121,9 @@ public class Config extends ConfigGui @Entry public static FogDrawMode fogDrawMode = IFogQuality.FOG_DRAW_MODE_DEFAULT; - // FIXME: Currently worldFogColor gives black. @Category("client.graphics.fogQuality") @Entry - public static FogColorMode fogColorMode = FogColorMode.USE_SKY_COLOR; //IFogQuality.FOG_COLOR_MODE_DEFAULT; + public static FogColorMode fogColorMode = IFogQuality.FOG_COLOR_MODE_DEFAULT; @Category("client.graphics.fogQuality") @Entry @@ -134,6 +133,7 @@ public class Config extends ConfigGui public static class AdvancedGraphics { + @Category("client.graphics.advancedGraphics") @Entry public static boolean disableDirectionalCulling = IAdvancedGraphics.DISABLE_DIRECTIONAL_CULLING_DEFAULT; @@ -171,22 +171,20 @@ public class Config extends ConfigGui @Category("client.worldGenerator") @Entry public static BlocksToAvoid blocksToAvoid = IWorldGenerator.BLOCKS_TO_AVOID_DEFAULT; - -// public static boolean useExperimentalPreGenLoading = false; } public static class Advanced { @Category("client.advanced") - @ScreenEntry(to = "threading") + @ScreenEntry public static Threading threading; @Category("client.advanced") - @ScreenEntry(to = "debugging") + @ScreenEntry public static Debugging debugging; @Category("client.advanced") - @ScreenEntry(to = "buffers") + @ScreenEntry public static Buffers buffers; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java index 2deeea9d2..7e901ebb3 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java @@ -5,6 +5,7 @@ import com.moandjiezana.toml.Toml; // TomlWriter is threadsave while Writer is not import com.moandjiezana.toml.TomlWriter; import com.mojang.blaze3d.vertex.PoseStack; +import com.seibel.lod.core.ModInfo; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; @@ -51,67 +52,6 @@ import java.util.regex.Pattern; // This config should work for both Fabric and Forge as long as you use Mojang mappings @SuppressWarnings("unchecked") public abstract class ConfigGui { - /* - Small wiki on how to use this config - - Create a new class that extends this class - Every time you want to add a button put an @Entry before it and if you want it to be within a range then do @Entry(min = 0, max = 10) - MAKE SURE THE VARIABLE YOU ARE PUTTING IN IS A STATIC VARIABLE - - - - If you want to make a config asking if you want coolness then do this - - public class Config extends ConfigGui { - @Entry - public static bool coolness = false; - } - - - - If you want a comment then do this - @Comment public static Comment ThisIsACoolComment; - - - - For putting nested classes do @ScreenEntry for example - - public class Config extends ConfigGui { - @Entry - public static bool coolness = false; - - @ScreenEntry - public static NestedScreen nestedScreen = new NestedScreen(); - - public static void NestedScreen() { - @Category("nestedScreen") - @Entry(min = 0, max = 100) - public static int howMuchCoolness = 0; - } - } - - - All the text should be in your language file - There won't be a tutorial on how to make on since it is easy - - - FOR THE CONFIG TO SHOW - you need to have this somewhere in the main class - ConfigGui.init(ModInfo.ID, Config.class); - - For mod-menu integration look at the ModMenuIntegration class and put a reference to it in the fabric.mod.json - - To make a textured button to the options screen look in the mixins/MixinOptionsScreen class and TexturedButtonWidget class - Remember to add the MixinOptionsScreen to your ModID.mixins.json - */ - - /* - This is a small to do list for the config - - Make config save - Make wiki better - Add a way to add min and max from another variable - */ /* List of hacky things that are done that should be done properly @@ -152,7 +92,7 @@ public abstract class ConfigGui { } public static final Map> configClass = new HashMap<>(); - // public static List nestedClasses = new ArrayList<>(); +// public static List nestedClasses = new ArrayList<>(); private static Path path; public static void init(String modid, Class config) { @@ -194,7 +134,7 @@ public abstract class ConfigGui { String c = field.getAnnotation(Category.class) != null ? field.getAnnotation(Category.class).value() : ""; initClass(modid, field.getType(), (c != "" ? c + "." : "") - + field.getAnnotation(ScreenEntry.class).to()); + + field.getName()); } } } @@ -242,7 +182,7 @@ public abstract class ConfigGui { if (!s.name().equals("")) info.name = new TranslatableComponent(s.name()); info.button = true; - info.gotoScreen = (info.category != "" ? info.category + "." : "") + s.to(); + info.gotoScreen = (info.category != "" ? info.category + "." : "") + field.getName(); } entries.add(info); } @@ -515,17 +455,16 @@ public abstract class ConfigGui { @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Entry { + String name() default ""; int width() default 150; double min() default Double.MIN_NORMAL; double max() default Double.MAX_VALUE; - String name() default ""; } // Where the @ScreenEntry is defined @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface ScreenEntry { - String to(); String name() default ""; int width() default 100; }