Skip to content

Commit

Permalink
Rename config option + add tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Sep 3, 2023
1 parent 48e7280 commit d821163
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@

@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal"})
@Config(name = MEGACells.MODID)
public class MEGAConfig implements ConfigData {
public final class MEGAConfig implements ConfigData {
@ConfigEntry.Gui.Excluded
public static MEGAConfig INSTANCE;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 2, max = 12)
private int CompressionChainLength = 3;
private int CompressionChainLimit = 3;

public int getCompressionChainLength() {
return CompressionChainLength;
public int getCompressionChainLimit() {
return CompressionChainLimit;
}

public static void load() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public enum MEGATranslations implements LocalizationEnum {
AcceleratorThreads("Provides 4 co-processing threads per block.", Type.TOOLTIP),
ALot("A lot.", Type.TOOLTIP),
Compression("Compression: %s", Type.TOOLTIP),
CompressionChainLength("Bulk Compression chain length", Type.CONFIG),
Contains("Contains: %s", Type.TOOLTIP),
Disabled("Disabled", Type.TOOLTIP),
Empty("Empty", Type.TOOLTIP),
Expand All @@ -19,14 +18,26 @@ public enum MEGATranslations implements LocalizationEnum {
PartitionedFor("Partitioned for: %s", Type.TOOLTIP),
ProcessingOnly("Supports processing patterns only.", Type.TOOLTIP),
Quantity("Quantity: %s", Type.TOOLTIP),
NotPartitioned("Not Partitioned", Type.TOOLTIP);
NotPartitioned("Not Partitioned", Type.TOOLTIP),

CompressionChainLimit("Bulk Compression chain limit", Type.CONFIG_OPTION),
CompressionChainLimitTooltip(
"The maximum number of variants that a compression-enabled Bulk Cell may report as being stored.",
Type.CONFIG_TOOLTIP,
CompressionChainLimit);

private final String englishText;
private final Type type;
private final MEGATranslations associated;

MEGATranslations(String englishText, Type type) {
this(englishText, type, null);
}

MEGATranslations(String englishText, Type type, MEGATranslations associated) {
this.englishText = englishText;
this.type = type;
this.associated = associated;
}

@Override
Expand All @@ -36,15 +47,18 @@ public String getEnglishText() {

@Override
public String getTranslationKey() {
return type == Type.CONFIG
? type.root.formatted(MEGACells.MODID) + "." + name()
: String.format("%s.%s.%s", type.root, MEGACells.MODID, name());
return switch (type) {
case CONFIG_OPTION -> type.root.formatted(MEGACells.MODID) + "." + name();
case CONFIG_TOOLTIP -> type.root.formatted(MEGACells.MODID) + "." + associated.name() + ".@Tooltip";
default -> String.format("%s.%s.%s", type.root, MEGACells.MODID, name());
};
}

private enum Type {
GUI("gui"),
TOOLTIP("gui.tooltips"),
CONFIG("text.autoconfig.%s.option");
CONFIG_OPTION("text.autoconfig.%s.option"),
CONFIG_TOOLTIP("text.autoconfig.%s.option");

private final String root;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public CompressionChain lastMultiplierSwapped() {
}

public CompressionChain limited() {
var chainLength = MEGAConfig.INSTANCE.getCompressionChainLength();
var chainLength = MEGAConfig.INSTANCE.getCompressionChainLimit();

if (size <= chainLength) {
return this;
Expand Down

0 comments on commit d821163

Please sign in to comment.