aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r--src/main/java/makamys/neodymium/Config.java3
-rw-r--r--src/main/java/makamys/neodymium/config/HumanReadableConfigElement.java39
2 files changed, 41 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/Config.java b/src/main/java/makamys/neodymium/Config.java
index 54a7017..33539d0 100644
--- a/src/main/java/makamys/neodymium/Config.java
+++ b/src/main/java/makamys/neodymium/Config.java
@@ -27,6 +27,7 @@ import java.util.List;
import org.lwjgl.input.Keyboard;
import cpw.mods.fml.client.config.IConfigElement;
+import makamys.neodymium.config.HumanReadableConfigElement;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
@@ -195,7 +196,7 @@ public class Config {
public static List<IConfigElement> getElements() {
List<IConfigElement> list = new ArrayList<IConfigElement>();
for(Property prop : config.getCategory("render").values()) {
- list.add(new ConfigElement(prop));
+ list.add(new HumanReadableConfigElement(prop));
}
return list;
}
diff --git a/src/main/java/makamys/neodymium/config/HumanReadableConfigElement.java b/src/main/java/makamys/neodymium/config/HumanReadableConfigElement.java
new file mode 100644
index 0000000..761f114
--- /dev/null
+++ b/src/main/java/makamys/neodymium/config/HumanReadableConfigElement.java
@@ -0,0 +1,39 @@
+package makamys.neodymium.config;
+
+import net.minecraftforge.common.config.ConfigElement;
+import net.minecraftforge.common.config.Property;
+
+public class HumanReadableConfigElement extends ConfigElement {
+
+ public HumanReadableConfigElement(Property prop) {
+ super(prop);
+ }
+
+ @Override
+ public String getName() {
+ return decamelize(super.getName());
+ }
+
+ private static String decamelize(String s) {
+ boolean[] spaceField = new boolean[s.length()];
+
+ for(int i = 0; i < s.length(); i++) {
+ if(i > 0 && i < s.length() && !Character.isUpperCase(s.charAt(i - 1)) && Character.isUpperCase(s.charAt(i))) {
+ spaceField[i] = true;
+ } else if(i > 2 && Character.isUpperCase(s.charAt(i - 2)) && Character.isUpperCase(s.charAt(i - 1)) && !Character.isUpperCase(s.charAt(i))) {
+ spaceField[i - 1] = true;
+ }
+ }
+
+ String out = "";
+ for(int i = 0; i < s.length(); i++) {
+ if(spaceField[i]) {
+ out += " ";
+ }
+ out += i == 0 ? Character.toUpperCase(s.charAt(i)) : s.charAt(i);
+ }
+
+ return out;
+ }
+
+}