-
Posts
4 -
Joined
-
Last visited
Posts posted by Phylogeny
-
-
1 minute ago, diesieben07 said:
Make a pull request to Forge.
I see. Then in the mean time, my next questions is: How stable is the solution I posted? Is this a "that's just not the intended usage" objection, or a "that can cause actual problems" objection?
-
An enum is what tells Forge to generate a cycling button config element. Do you have a constructive suggestions as to how to tell Forge to create one with formatted text (with or without an enum)? It helps to give input on what should be done, as well a what shouldn't.
-
Here's a more stable way, that requires only the EnumHelper:
static { for (RarityGlowTypeNames value : RarityGlowTypeNames.values()) { String name = ""; for (String word : value.name().split("_")) name += word.substring(0, 1) + word.substring(1).toLowerCase() + " "; EnumHelper.addEnum(RarityGlowType.class, name.substring(0, name.length() - 1), new Class<?>[0]); } } // This is inside the root class for the config file public static class Inventory { @Config.Name("Rarity Type") public RarityGlowType rarityGlowType = RarityGlowType.values()[0]; } public enum RarityGlowType {} public enum RarityGlowTypeNames { SOLID_COLOR, GRADIENT_COLOR; }
Or here's a variant of that without dynamic name generation:
static { for (RarityGlowTypeNames name : RarityGlowTypeNames.values()) EnumHelper.addEnum(RarityGlowType.class, name.toString(), new Class<?>[0]); } // This is inside the root class for the config file public static class Inventory { @Config.Name("Rarity Type") public RarityGlowType rarityGlowType = RarityGlowType.values()[0]; } public enum RarityGlowType {} public enum RarityGlowTypeNames { SOLID_COLOR("Solid Color"), GRADIENT_COLOR("Gradient Color"); private String name; private RarityGlowTypeNames(String name) { this.name = name; } @Override public String toString() { return name; } }
An example of checking the value could be:
ConfigMod.inventory.rarityGlowType.ordinal() == RarityGlowTypeNames.GRADIENT_COLOR.ordinal()
[Solved] Config enum value text
in Modder Support
Posted
Well, that's unfortunate. I haven't looked much at the backend of the config annotations system, but perhaps calling Enum#toString rather than Enum#name will work without breaking anything else.