Added runnable and performance impact to the config

This commit is contained in:
coolGi
2022-07-18 15:16:22 +09:30
parent c01fc2ed86
commit adc51bab9a
3 changed files with 65 additions and 22 deletions
@@ -173,10 +173,8 @@ public class Config
{
public static ConfigEntry<EFogDistance> fogDistance = new ConfigEntry.Builder<EFogDistance>()
.set(EFogDistance.FAR)
.comment(""
+ "At what distance should Fog be drawn on the fake chunks? \n"
+ "\n"
+ "This setting shouldn't affect performance.")
.comment("At what distance should Fog be drawn on the fake chunks?")
.setPerformance(ConfigEntryPerformance.NONE)
.build();
public static ConfigEntry<EFogDrawMode> fogDrawMode = new ConfigEntry.Builder<EFogDrawMode>()
@@ -396,9 +394,8 @@ public class Config
+ " LODs will render on top of distant vanilla chunks to hide delayed loading. \n"
+ " Will dynamically decide the border offset based on vanilla render distance. \n"
+ EVanillaOverdraw.ALWAYS + ": \n"
+ " LODs will render on all vanilla chunks preventing all holes in the world. \n"
+ "\n"
+ "This setting shouldn't affect performance.")
+ " LODs will render on all vanilla chunks preventing all holes in the world.")
.setPerformance(ConfigEntryPerformance.NONE)
.build();
public static ConfigEntry<Integer> overdrawOffset = new ConfigEntry.Builder<Integer>()
@@ -417,9 +414,8 @@ public class Config
.set(true)
.comment(""
+ "Will prevent some overdraw issues, but may cause nearby fake chunks to render incorrectly \n"
+ " especially when in/near an ocean. \n"
+ "\n"
+ "This setting shouldn't affect performance.")
+ " especially when in/near an ocean.")
.setPerformance(ConfigEntryPerformance.NONE)
.build();
public static ConfigEntry<Double> brightnessMultiplier = new ConfigEntry.Builder<Double>() // TODO: Make this a float (the ClassicConfigGUI dosnt support floats)
@@ -589,9 +585,8 @@ public class Config
+ "\n"
+ EGenerationPriority.AUTO + " \n"
+ "Uses " + EGenerationPriority.BALANCED + " when on a single player world \n"
+ " and " + EGenerationPriority.NEAR_FIRST + " when connected to a server. \n"
+ "\n"
+ "This shouldn't affect performance.")
+ " and " + EGenerationPriority.NEAR_FIRST + " when connected to a server.")
.setPerformance(ConfigEntryPerformance.NONE)
.build();
public static ConfigEntry<EBlocksToAvoid> blocksToAvoid = new ConfigEntry.Builder<EBlocksToAvoid>()
@@ -605,9 +600,8 @@ public class Config
+ EBlocksToAvoid.NONE + ": Use all blocks when generating fake chunks \n"
+ EBlocksToAvoid.NON_FULL + ": Only use full blocks when generating fake chunks (ignores slabs, lanterns, torches, tall grass, etc.) \n"
+ EBlocksToAvoid.NO_COLLISION + ": Only use solid blocks when generating fake chunks (ignores tall grass, torches, etc.) \n"
+ EBlocksToAvoid.BOTH + ": Only use full solid blocks when generating fake chunks \n"
+ "\n"
+ "This wont't affect performance.")
+ EBlocksToAvoid.BOTH + ": Only use full solid blocks when generating fake chunks")
.setPerformance(ConfigEntryPerformance.NONE)
.build();
public static ConfigEntry<Boolean> tintWithAvoidedBlocks = new ConfigEntry.Builder<Boolean>()
@@ -15,7 +15,7 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
private String comment;
private T min;
private T max;
// API control //
/**
* If true this config can be controlled by the API <br>
@@ -23,17 +23,21 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
*/
public final boolean allowApiOverride;
private T apiValue;
private Runnable runnable; // What to run when the value gets changed
private ConfigEntryPerformance performance;
/** Creates the entry */
private ConfigEntry(ConfigEntryAppearance appearance, T value, String comment, T min, T max, boolean allowApiOverride) {
private ConfigEntry(ConfigEntryAppearance appearance, T value, String comment, T min, T max, boolean allowApiOverride, Runnable runnable, ConfigEntryPerformance performance) {
super(appearance, value);
this.defaultValue = value;
this.comment = comment;
this.min = min;
this.max = max;
this.allowApiOverride = allowApiOverride;
this.runnable = runnable;
this.performance = performance;
}
@@ -99,6 +103,10 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
this.comment = newComment;
}
/** Gets the performance impact of an option */
public ConfigEntryPerformance getPerformance() {
return this.performance;
}
/**
* Checks if the option is valid
@@ -151,11 +159,24 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
}
}
public Runnable getRunnable() {
return this.runnable;
}
public void setRunnable(Runnable runnable) {
this.runnable = runnable;
}
public void runRunnable() {
if (runnable != null)
runnable.run();
}
public static class Builder<T> extends AbstractConfigType.Builder<T, Builder<T>> {
private String tmpComment = null;
private T tmpMin;
private T tmpMax;
private boolean tmpUseApiOverwrite;
private Runnable runnable;
private ConfigEntryPerformance performance = ConfigEntryPerformance.DONT_SHOW;
public Builder<T> comment(String newComment) {
this.tmpComment = newComment;
@@ -188,9 +209,20 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>>
return this;
}
public Builder<T> setRunnable(Runnable runnable) {
this.runnable = runnable;
return this;
}
public Builder<T> setPerformance(ConfigEntryPerformance performance) {
this.performance = performance;
return this;
}
public ConfigEntry<T> build() {
return new ConfigEntry<T>(tmpAppearance, tmpValue, tmpComment, tmpMin, tmpMax, tmpUseApiOverwrite);
return new ConfigEntry<T>(tmpAppearance, tmpValue, tmpComment, tmpMin, tmpMax, tmpUseApiOverwrite, runnable, performance);
}
}
}
@@ -0,0 +1,17 @@
package com.seibel.lod.core.config.types;
/**
* What is the performance impact of an entry
*
* @author coolGi
*/
public enum ConfigEntryPerformance {
NONE,
VERY_LOW,
LOW,
MEDIUM,
HIGH,
VERY_HIGH,
DONT_SHOW
}