prep for Config UI refactoring
This commit is contained in:
@@ -131,6 +131,8 @@ public class Config
|
||||
// since they aren't part of "client" config class
|
||||
// TODO determine their destination programically instead of hard coding the value
|
||||
|
||||
public static ConfigUIComment advancedHeader = new ConfigUIComment.Builder().setParentConfigClass(Advanced.class).build();
|
||||
|
||||
public static ConfigCategory graphics = new ConfigCategory.Builder().set(Graphics.class).build();
|
||||
public static ConfigCategory worldGenerator = new ConfigCategory.Builder().set(Common.WorldGenerator.class).setDestination("common.worldGenerator").build();
|
||||
public static ConfigCategory multiplayer = new ConfigCategory.Builder().set(Multiplayer.class).build();
|
||||
@@ -146,23 +148,32 @@ public class Config
|
||||
|
||||
public static class Graphics
|
||||
{
|
||||
public static ConfigUIComment advancedGraphicsHeader = new ConfigUIComment.Builder().setParentConfigClass(Graphics.class).build();
|
||||
|
||||
public static ConfigCategory quality = new ConfigCategory.Builder().set(Quality.class).build();
|
||||
public static ConfigUISpacer qualitySpacer = new ConfigUISpacer.Builder().build();
|
||||
|
||||
public static ConfigUiLinkedEntry quickEnableSsao = new ConfigUiLinkedEntry(Ssao.enableSsao);
|
||||
public static ConfigCategory ssao = new ConfigCategory.Builder().set(Ssao.class).build();
|
||||
public static ConfigUISpacer ssaoSpacer = new ConfigUISpacer.Builder().build();
|
||||
|
||||
|
||||
public static ConfigUiLinkedEntry quickEnableGenericRendering = new ConfigUiLinkedEntry(GenericRendering.enableGenericRendering);
|
||||
public static ConfigCategory genericRendering = new ConfigCategory.Builder().set(GenericRendering.class).build();
|
||||
public static ConfigUISpacer genericRenderingSpacer = new ConfigUISpacer.Builder().build();
|
||||
|
||||
public static ConfigUiLinkedEntry quickEnableDhFog = new ConfigUiLinkedEntry(Fog.enableDhFog);
|
||||
public static ConfigUiLinkedEntry quickEnableMcFog = new ConfigUiLinkedEntry(Fog.enableVanillaFog);
|
||||
public static ConfigCategory fog = new ConfigCategory.Builder().set(Fog.class).build();
|
||||
public static ConfigUISpacer fogSpacer = new ConfigUISpacer.Builder().build();
|
||||
|
||||
public static ConfigUiLinkedEntry quickEnableNoiseTexture = new ConfigUiLinkedEntry(NoiseTexture.enableNoiseTexture);
|
||||
public static ConfigCategory noiseTexture = new ConfigCategory.Builder().set(NoiseTexture.class).build();
|
||||
public static ConfigUISpacer noiseTextureSpacer = new ConfigUISpacer.Builder().build();
|
||||
|
||||
public static ConfigUiLinkedEntry quickEnableCaveCulling = new ConfigUiLinkedEntry(Culling.enableCaveCulling);
|
||||
public static ConfigCategory culling = new ConfigCategory.Builder().set(Culling.class).build();
|
||||
public static ConfigUISpacer cullingSpacer = new ConfigUISpacer.Builder().build();
|
||||
|
||||
public static ConfigCategory experimental = new ConfigCategory.Builder().set(Experimental.class).build();
|
||||
|
||||
@@ -170,6 +181,8 @@ public class Config
|
||||
|
||||
public static class Quality
|
||||
{
|
||||
public static ConfigUIComment qualityHeader = new ConfigUIComment.Builder().setParentConfigClass(Quality.class).build();
|
||||
|
||||
public static ConfigEntry<Integer> lodChunkRenderDistanceRadius = new ConfigEntry.Builder<Integer>()
|
||||
.setMinDefaultMax(32, 256, 4096)
|
||||
.comment("" +
|
||||
@@ -351,6 +364,8 @@ public class Config
|
||||
|
||||
public static class Ssao
|
||||
{
|
||||
public static ConfigUIComment ssaoHeader = new ConfigUIComment.Builder().setParentConfigClass(Ssao.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableSsao = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment("Enable Screen Space Ambient Occlusion")
|
||||
@@ -413,6 +428,8 @@ public class Config
|
||||
|
||||
public static class GenericRendering
|
||||
{
|
||||
public static ConfigUIComment genericRendererHeader = new ConfigUIComment.Builder().setParentConfigClass(GenericRendering.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableGenericRendering = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment(""
|
||||
@@ -460,6 +477,8 @@ public class Config
|
||||
|
||||
|
||||
|
||||
public static ConfigUIComment fogHeader = new ConfigUIComment.Builder().setParentConfigClass(Fog.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableDhFog = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment(""
|
||||
@@ -561,6 +580,8 @@ public class Config
|
||||
|
||||
public static class HeightFog
|
||||
{
|
||||
public static ConfigUIComment heightFogHeader = new ConfigUIComment.Builder().setParentConfigClass(HeightFog.class).build();
|
||||
|
||||
public static ConfigEntry<EDhApiHeightFogMixMode> heightFogMixMode = new ConfigEntry.Builder<EDhApiHeightFogMixMode>()
|
||||
.set(EDhApiHeightFogMixMode.SPHERICAL)
|
||||
.comment(""
|
||||
@@ -656,6 +677,8 @@ public class Config
|
||||
|
||||
public static class NoiseTexture
|
||||
{
|
||||
public static ConfigUIComment noiseTextureHeader = new ConfigUIComment.Builder().setParentConfigClass(NoiseTexture.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableNoiseTexture = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment(""
|
||||
@@ -690,6 +713,8 @@ public class Config
|
||||
|
||||
public static class Culling
|
||||
{
|
||||
public static ConfigUIComment cullingHeader = new ConfigUIComment.Builder().setParentConfigClass(Culling.class).build();
|
||||
|
||||
public static ConfigEntry<Double> overdrawPrevention = new ConfigEntry.Builder<Double>()
|
||||
.setMinDefaultMax(0.0, 0.0, 1.0) // TODO change -1 to auto
|
||||
.comment(""
|
||||
@@ -814,6 +839,8 @@ public class Config
|
||||
|
||||
public static class Experimental
|
||||
{
|
||||
public static ConfigUIComment experimentalHeader = new ConfigUIComment.Builder().setParentConfigClass(Experimental.class).build();
|
||||
|
||||
public static ConfigEntry<Integer> earthCurveRatio = new ConfigEntry.Builder<Integer>()
|
||||
.setMinDefaultMax(0, 0, 5000)
|
||||
.comment(""
|
||||
@@ -836,6 +863,8 @@ public class Config
|
||||
|
||||
public static class AutoUpdater
|
||||
{
|
||||
public static ConfigUIComment autoUpdaterHeader = new ConfigUIComment.Builder().setParentConfigClass(AutoUpdater.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableAutoUpdater = new ConfigEntry.Builder<Boolean>()
|
||||
.set(!isRunningInDevEnvironment())
|
||||
.comment(""
|
||||
@@ -863,6 +892,8 @@ public class Config
|
||||
|
||||
public static class Multiplayer
|
||||
{
|
||||
public static ConfigUIComment multiplayerHeader = new ConfigUIComment.Builder().setParentConfigClass(Multiplayer.class).build();
|
||||
|
||||
public static ConfigEntry<EDhApiServerFolderNameMode> serverFolderNameMode = new ConfigEntry.Builder<EDhApiServerFolderNameMode>()
|
||||
.set(EDhApiServerFolderNameMode.NAME_ONLY)
|
||||
.comment(""
|
||||
@@ -879,6 +910,8 @@ public class Config
|
||||
|
||||
public static class Debugging
|
||||
{
|
||||
public static ConfigUIComment debuggingHeader = new ConfigUIComment.Builder().setParentConfigClass(Debugging.class).build();
|
||||
|
||||
public static ConfigEntry<EDhApiRendererMode> rendererMode = new ConfigEntry.Builder<EDhApiRendererMode>()
|
||||
.set(EDhApiRendererMode.DEFAULT)
|
||||
.comment(""
|
||||
@@ -967,6 +1000,8 @@ public class Config
|
||||
|
||||
public static class DebugWireframe
|
||||
{
|
||||
public static ConfigUIComment debugWireframeHeader = new ConfigUIComment.Builder().setParentConfigClass(DebugWireframe.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableRendering = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.comment(""
|
||||
@@ -1016,6 +1051,8 @@ public class Config
|
||||
|
||||
public static class OpenGl
|
||||
{
|
||||
public static ConfigUIComment openGlHeader = new ConfigUIComment.Builder().setParentConfigClass(OpenGl.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> overrideVanillaGLLogger = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment(""
|
||||
@@ -1063,6 +1100,8 @@ public class Config
|
||||
|
||||
public static class ColumnBuilderDebugging
|
||||
{
|
||||
public static ConfigUIComment columnBuilderDebuggingHeader = new ConfigUIComment.Builder().setParentConfigClass(ColumnBuilderDebugging.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> columnBuilderDebugEnable = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_GUI)
|
||||
@@ -1104,6 +1143,8 @@ public class Config
|
||||
|
||||
public static class F3Screen
|
||||
{
|
||||
public static ConfigUIComment f3ScreenHeader = new ConfigUIComment.Builder().setParentConfigClass(F3Screen.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> showPlayerPos = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment("Shows the player's LOD position.")
|
||||
@@ -1147,8 +1188,10 @@ public class Config
|
||||
// This will throw a warning when opened in the default ui to tell you about it not showing
|
||||
public static class ExampleConfigScreen
|
||||
{
|
||||
public static ConfigUIComment exampleConfigHeader = new ConfigUIComment.Builder().setParentConfigClass(ExampleConfigScreen.class).build();
|
||||
|
||||
// Defined in the lang, just a note about this screen
|
||||
public static ConfigUIComment debugConfigScreenNote = new ConfigUIComment();
|
||||
public static ConfigUIComment debugConfigScreenNote = new ConfigUIComment.Builder().setTextPosition(EConfigCommentTextPosition.CENTER_OF_SCREEN).build();
|
||||
|
||||
public static ConfigEntry<Boolean> boolTest = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
@@ -1156,6 +1199,7 @@ public class Config
|
||||
|
||||
public static ConfigEntry<Byte> byteTest = new ConfigEntry.Builder<Byte>()
|
||||
.set((byte) 8)
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) // no GUI renderer set up currently
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Integer> intTest = new ConfigEntry.Builder<Integer>()
|
||||
@@ -1168,14 +1212,17 @@ public class Config
|
||||
|
||||
public static ConfigEntry<Short> shortTest = new ConfigEntry.Builder<Short>()
|
||||
.set((short) 69)
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) // no GUI renderer set up currently
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Long> longTest = new ConfigEntry.Builder<Long>()
|
||||
.set(42069L)
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) // no GUI renderer set up currently
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Float> floatTest = new ConfigEntry.Builder<Float>()
|
||||
.set(0.42069f)
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) // no GUI renderer set up currently
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<String> stringTest = new ConfigEntry.Builder<String>()
|
||||
@@ -1184,10 +1231,12 @@ public class Config
|
||||
|
||||
public static ConfigEntry<List<String>> listTest = new ConfigEntry.Builder<List<String>>()
|
||||
.set(new ArrayList<String>(Arrays.asList("option 1", "option 2", "option 3")))
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) // no GUI renderer set up currently
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Map<String, String>> mapTest = new ConfigEntry.Builder<Map<String, String>>()
|
||||
.set(new HashMap<String, String>())
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_FILE) // no GUI renderer set up currently
|
||||
.build();
|
||||
|
||||
public static ConfigUIButton uiButtonTest = new ConfigUIButton(() ->
|
||||
@@ -1231,6 +1280,8 @@ public class Config
|
||||
{
|
||||
public static class WorldGenerator
|
||||
{
|
||||
public static ConfigUIComment worldGeneratorHeader = new ConfigUIComment.Builder().setParentConfigClass(WorldGenerator.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> enableDistantGeneration = new ConfigEntry.Builder<Boolean>()
|
||||
.setChatCommandName("generation.enable")
|
||||
.set(true)
|
||||
@@ -1324,6 +1375,8 @@ public class Config
|
||||
|
||||
public static class LodBuilding
|
||||
{
|
||||
public static ConfigUIComment lodBuildingHeader = new ConfigUIComment.Builder().setParentConfigClass(LodBuilding.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> disableUnchangedChunkCheck = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
// enabling this can be quite detrimental to performance,
|
||||
@@ -1445,6 +1498,8 @@ public class Config
|
||||
|
||||
public static class Experimental
|
||||
{
|
||||
public static ConfigUIComment experimentalHeader = new ConfigUIComment.Builder().setParentConfigClass(Experimental.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> upsampleLowerDetailLodsToFillHoles = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.comment(""
|
||||
@@ -1467,6 +1522,8 @@ public class Config
|
||||
|
||||
public static class MultiThreading
|
||||
{
|
||||
public static ConfigUIComment multiThreadingHeader = new ConfigUIComment.Builder().setParentConfigClass(MultiThreading.class).build();
|
||||
|
||||
public static final ConfigEntry<Integer> numberOfThreads = new ConfigEntry.Builder<Integer>()
|
||||
.setChatCommandName("threading.numberOfThreads")
|
||||
.setMinDefaultMax(1,
|
||||
@@ -1495,6 +1552,8 @@ public class Config
|
||||
|
||||
public static class Logging
|
||||
{
|
||||
public static ConfigUIComment loggingHeader = new ConfigUIComment.Builder().setParentConfigClass(Logging.class).build();
|
||||
|
||||
// TODO add change all option
|
||||
// TODO default to error chat and info file
|
||||
public static ConfigEntry<EDhApiLoggerMode> logWorldGenEvent = new ConfigEntry.Builder<EDhApiLoggerMode>()
|
||||
@@ -1549,6 +1608,7 @@ public class Config
|
||||
|
||||
public static class Warning
|
||||
{
|
||||
public static ConfigUIComment warningHeader = new ConfigUIComment.Builder().setParentConfigClass(Warning.class).build();
|
||||
|
||||
public static ConfigEntry<Boolean> showLowMemoryWarningOnStartup = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
|
||||
@@ -20,11 +20,9 @@
|
||||
package com.seibel.distanthorizons.core.config;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.file.ConfigFileHandling;
|
||||
import com.seibel.distanthorizons.core.config.types.*;
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.config.types.AbstractConfigType;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigCategory;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigUiLinkedEntry;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -41,7 +39,7 @@ import java.util.*;
|
||||
* @author Ran
|
||||
* @version 2023-8-26
|
||||
*/
|
||||
// Init the config after singletons have been blinded
|
||||
// Init the config after singletons have been bound
|
||||
public class ConfigBase
|
||||
{
|
||||
/** Our own config instance, don't modify unless you are the DH mod */
|
||||
@@ -198,11 +196,11 @@ public class ConfigBase
|
||||
* Used for checking that all the lang files for the config exist.
|
||||
* This is just to re-format the lang or check if there is something in the lang that is missing
|
||||
*
|
||||
* @param onlyShowNew If disabled then it would basically remake the config lang
|
||||
* @param onlyShowMissing If false then this will remake the entire config lang
|
||||
* @param checkEnums Checks if all the lang for the enum's exist
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String generateLang(boolean onlyShowNew, boolean checkEnums)
|
||||
public String generateLang(boolean onlyShowMissing, boolean checkEnums)
|
||||
{
|
||||
ILangWrapper langWrapper = SingletonInjector.INSTANCE.get(ILangWrapper.class);
|
||||
List<Class<? extends Enum<?>>> enumList = new ArrayList<>();
|
||||
@@ -213,42 +211,74 @@ public class ConfigBase
|
||||
String separator = "\":\n \"";
|
||||
String ending = "\",\n";
|
||||
|
||||
// config entries
|
||||
for (AbstractConfigType<?, ?> entry : this.entries)
|
||||
{
|
||||
String entryPrefix = "lod.config." + entry.getNameWCategory();
|
||||
String entryPrefix = "distanthorizons.config." + entry.getNameWCategory();
|
||||
|
||||
if (checkEnums && entry.getType().isEnum() && !enumList.contains(entry.getType()))
|
||||
{ // Put it in an enum list to work with at the end
|
||||
if (checkEnums
|
||||
&& entry.getType().isEnum()
|
||||
&& !enumList.contains(entry.getType()))
|
||||
{
|
||||
// Put it in an enum list to work with at the end
|
||||
enumList.add((Class<? extends Enum<?>>) entry.getType());
|
||||
}
|
||||
|
||||
if (!onlyShowNew || langWrapper.langExists(entryPrefix))
|
||||
|
||||
// config file items don't need lang entries
|
||||
if (!entry.getAppearance().showInGui)
|
||||
{
|
||||
if (!ConfigUiLinkedEntry.class.isAssignableFrom(entry.getClass()))
|
||||
{ // If it is a linked item, dont generate the base lang
|
||||
generatedLang += starter
|
||||
+ entryPrefix
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix)
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
|
||||
// Adds tooltips
|
||||
if (langWrapper.langExists(entryPrefix + ".@tooltip"))
|
||||
{
|
||||
generatedLang += starter
|
||||
+ entryPrefix + ".@tooltip"
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix + ".@tooltip")
|
||||
.replaceAll("\n", "\\\\n")
|
||||
.replaceAll("\"", "\\\\\"")
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// some entries don't need localization
|
||||
if (ConfigUiLinkedEntry.class.isAssignableFrom(entry.getClass())
|
||||
|| ConfigUISpacer.class.isAssignableFrom(entry.getClass()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ConfigUIComment.class.isAssignableFrom(entry.getClass())
|
||||
&& ((ConfigUIComment)entry).parentConfigPath != null)
|
||||
{
|
||||
// TODO this could potentially add the same item multiple times
|
||||
entryPrefix = "distanthorizons.config." + ((ConfigUIComment)entry).parentConfigPath;
|
||||
}
|
||||
|
||||
|
||||
if (langWrapper.langExists(entryPrefix)
|
||||
&& onlyShowMissing)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
generatedLang += starter
|
||||
+ entryPrefix
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix)
|
||||
+ ending
|
||||
;
|
||||
|
||||
// only add tooltips for entries that are also missing
|
||||
// their primary lang
|
||||
// this is done since not all menu items need a tooltip
|
||||
if (!langWrapper.langExists(entryPrefix + ".@tooltip")
|
||||
|| !onlyShowMissing)
|
||||
{
|
||||
generatedLang += starter
|
||||
+ entryPrefix + ".@tooltip"
|
||||
+ separator
|
||||
+ langWrapper.getLang(entryPrefix + ".@tooltip")
|
||||
.replaceAll("\n", "\\\\n")
|
||||
.replaceAll("\"", "\\\\\"")
|
||||
+ ending
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// enums
|
||||
if (!enumList.isEmpty())
|
||||
{
|
||||
generatedLang += "\n"; // Separate the main lang with the enum's
|
||||
@@ -257,9 +287,10 @@ public class ConfigBase
|
||||
{
|
||||
for (Object enumStr : new ArrayList<Object>(EnumSet.allOf(anEnum)))
|
||||
{
|
||||
String enumPrefix = "lod.config.enum." + anEnum.getSimpleName() + "." + enumStr.toString();
|
||||
String enumPrefix = "distanthorizons.config.enum." + anEnum.getSimpleName() + "." + enumStr.toString();
|
||||
|
||||
if (!onlyShowNew || langWrapper.langExists(enumPrefix))
|
||||
if (!langWrapper.langExists(enumPrefix)
|
||||
|| !onlyShowMissing)
|
||||
{
|
||||
generatedLang += starter
|
||||
+ enumPrefix
|
||||
@@ -272,11 +303,6 @@ public class ConfigBase
|
||||
}
|
||||
}
|
||||
|
||||
// trim to remove any newlines/spaces
|
||||
// that may be present when no lang entries need changing
|
||||
// then we can check length != 0 if any items are missing and need adding
|
||||
generatedLang = generatedLang.trim();
|
||||
|
||||
return generatedLang;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
|
||||
}
|
||||
@Override
|
||||
public T getApiValue() { return this.apiValue; }
|
||||
@Override
|
||||
public boolean apiValuePresent() { return this.apiValue != null; }
|
||||
@Override
|
||||
public boolean getAllowApiOverride() { return this.allowApiOverride; }
|
||||
|
||||
|
||||
+104
-8
@@ -19,7 +19,13 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.config.types;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition;
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Adds something like a ConfigEntry but without a button to change the input
|
||||
@@ -28,11 +34,25 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance
|
||||
*/
|
||||
public class ConfigUIComment extends AbstractConfigType<String, ConfigUIComment>
|
||||
{
|
||||
public ConfigUIComment()
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
|
||||
public String parentConfigPath = null;
|
||||
@Nullable
|
||||
public EConfigCommentTextPosition textPosition = null;
|
||||
|
||||
|
||||
|
||||
public ConfigUIComment() { this(null, null); }
|
||||
public ConfigUIComment(String parentConfigPath, EConfigCommentTextPosition textPosition)
|
||||
{
|
||||
super(EConfigEntryAppearance.ONLY_IN_GUI, "");
|
||||
this.parentConfigPath = parentConfigPath;
|
||||
this.textPosition = textPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Appearance shouldn't be changed */
|
||||
@Override
|
||||
public void setAppearance(EConfigEntryAppearance newAppearance) { }
|
||||
@@ -41,26 +61,102 @@ public class ConfigUIComment extends AbstractConfigType<String, ConfigUIComment>
|
||||
@Override
|
||||
public void set(String newValue) { }
|
||||
|
||||
|
||||
|
||||
public static class Builder extends AbstractConfigType.Builder<String, Builder>
|
||||
{
|
||||
public String tempParentConfigPath = null;
|
||||
public EConfigCommentTextPosition tempTextPosition = null;
|
||||
|
||||
|
||||
|
||||
/** Appearance shouldn't be changed */
|
||||
@Deprecated
|
||||
@Override
|
||||
public Builder setAppearance(EConfigEntryAppearance newAppearance)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public Builder setAppearance(EConfigEntryAppearance newAppearance) { return this; }
|
||||
|
||||
/** Pointless to set the value */
|
||||
@Deprecated
|
||||
@Override
|
||||
public Builder set(String newValue)
|
||||
{ return this; }
|
||||
|
||||
|
||||
public Builder setParentConfigClass(@NotNull Class<?> parentConfigClass)
|
||||
{
|
||||
// expected format: "Config.Client.Advanced"
|
||||
String packageName = parentConfigClass.getPackage().getName(); // com.seibel.distanthorizons.core.config
|
||||
String fullName = parentConfigClass.getName(); // com.seibel.distanthorizons.core.config.Config$Common$MultiThreading
|
||||
|
||||
try
|
||||
{
|
||||
String configPath = fullName.substring(
|
||||
packageName.length() + // "com.seibel.distanthorizons.core.config"
|
||||
1 + // "." before "Config"
|
||||
Config.class.getSimpleName().length() + // "Config"
|
||||
1); // "$" before the inner class name
|
||||
|
||||
// configPath after substring:
|
||||
// Config$Common$MultiThreading
|
||||
|
||||
this.tempParentConfigPath = convertPackageNameToLangPath(configPath); // client.advanced.graphics.Quality
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.tempParentConfigPath = parentConfigClass.getSimpleName();
|
||||
LOGGER.warn("Failed to parse config class: ["+fullName+"], error: ["+e.getMessage()+"], defaulting to: ["+this.tempParentConfigPath+"].", e);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* example:
|
||||
* input: "Client$Advanced$multiThreading"
|
||||
* output: "client.advanced.multiThreading"
|
||||
*/
|
||||
public static String convertPackageNameToLangPath(String input)
|
||||
{
|
||||
StringBuilder result = new StringBuilder(input.length());
|
||||
|
||||
for (int i = 0; i < input.length(); i++)
|
||||
{
|
||||
char ch = input.charAt(i);
|
||||
if (i == 0)
|
||||
{
|
||||
result.append(Character.toLowerCase(ch));
|
||||
continue;
|
||||
}
|
||||
|
||||
// replace '$' -> '.' to match lang path naming
|
||||
if (ch == '$')
|
||||
{
|
||||
result.append('.');
|
||||
continue;
|
||||
}
|
||||
|
||||
char lastCh = input.charAt(i-1);
|
||||
if (lastCh == '$')
|
||||
{
|
||||
result.append(Character.toLowerCase(ch));
|
||||
continue;
|
||||
}
|
||||
|
||||
result.append(ch);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
public Builder setTextPosition(EConfigCommentTextPosition textPosition)
|
||||
{
|
||||
this.tempTextPosition = textPosition;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ConfigUIComment build()
|
||||
{
|
||||
return new ConfigUIComment();
|
||||
}
|
||||
{ return new ConfigUIComment(this.tempParentConfigPath, this.tempTextPosition); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.core.config.types;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance;
|
||||
|
||||
/**
|
||||
* Adds empty space the height of a button.
|
||||
* Useful for separating different categories.
|
||||
*/
|
||||
public class ConfigUISpacer extends AbstractConfigType<String, ConfigUISpacer>
|
||||
{
|
||||
public ConfigUISpacer()
|
||||
{ super(EConfigEntryAppearance.ONLY_IN_GUI, ""); }
|
||||
|
||||
|
||||
|
||||
/** Appearance shouldn't be changed */
|
||||
@Override
|
||||
public void setAppearance(EConfigEntryAppearance newAppearance) { }
|
||||
|
||||
/** Pointless to set the value */
|
||||
@Override
|
||||
public void set(String newValue) { }
|
||||
|
||||
|
||||
|
||||
public static class Builder extends AbstractConfigType.Builder<String, Builder>
|
||||
{
|
||||
/** Appearance shouldn't be changed */
|
||||
@Override
|
||||
public Builder setAppearance(EConfigEntryAppearance newAppearance) { return this; }
|
||||
|
||||
/** Pointless to set the value */
|
||||
@Override
|
||||
public Builder set(String newValue) { return this; }
|
||||
|
||||
public ConfigUISpacer build() { return new ConfigUISpacer(); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -27,7 +27,6 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
@Deprecated // FIXME doesn't work with localization
|
||||
public class ConfigUiLinkedEntry extends AbstractConfigType<AbstractConfigType<?, ?>, ConfigUiLinkedEntry>
|
||||
{
|
||||
public ConfigUiLinkedEntry(AbstractConfigType<?, ?> value)
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.core.config.types.enums;
|
||||
|
||||
/**
|
||||
* RIGHT_OVER_BUTTONS <br/>
|
||||
* CENTER_OF_SCREEN <br/>
|
||||
* CENTERED_OVER_BUTTONS <br/>
|
||||
*/
|
||||
public enum EConfigCommentTextPosition
|
||||
{
|
||||
RIGHT_JUSTIFIED,
|
||||
CENTER_OF_SCREEN,
|
||||
CENTERED_OVER_BUTTONS,
|
||||
}
|
||||
@@ -22,6 +22,12 @@
|
||||
"Cancel",
|
||||
"distanthorizons.general.reset":
|
||||
"Reset",
|
||||
"distanthorizons.general.spacer":
|
||||
"",
|
||||
"distanthorizons.general.apiOverride":
|
||||
"API LOCK",
|
||||
"distanthorizons.general.disabledByApi.@tooltip":
|
||||
"This option is controlled by another mod via DH's API \nso it cannot be changed via the UI or config file.",
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user