diff options
author | makamys <makamys@outlook.com> | 2022-06-30 16:01:58 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-30 16:58:14 +0200 |
commit | e599b420e4ac09a68c19c2e083facdd44ca9b3ae (patch) | |
tree | 5c2a507caa38bd589a90e028702e636737766d68 /src/main/java/makamys/neodymium/Config.java | |
parent | f7de909c592785b3ce984472f06f3b7f6c2ca713 (diff) | |
download | Neodymium-e599b420e4ac09a68c19c2e083facdd44ca9b3ae.tar.gz Neodymium-e599b420e4ac09a68c19c2e083facdd44ca9b3ae.tar.bz2 Neodymium-e599b420e4ac09a68c19c2e083facdd44ca9b3ae.zip |
Add simple config GUI
Diffstat (limited to 'src/main/java/makamys/neodymium/Config.java')
-rw-r--r-- | src/main/java/makamys/neodymium/Config.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/Config.java b/src/main/java/makamys/neodymium/Config.java index 86aade3..54a7017 100644 --- a/src/main/java/makamys/neodymium/Config.java +++ b/src/main/java/makamys/neodymium/Config.java @@ -21,11 +21,16 @@ import java.nio.file.Files; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; import java.nio.file.WatchService; +import java.util.ArrayList; +import java.util.List; import org.lwjgl.input.Keyboard; +import cpw.mods.fml.client.config.IConfigElement; import net.minecraft.launchwrapper.Launch; +import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; public class Config { @@ -69,6 +74,7 @@ public class Config { @ConfigBoolean(cat="debug", def=false) public static boolean wireframe; + private static Configuration config; private static File configFile = new File(Launch.minecraftHome, "config/" + MODID + ".cfg"); private static WatchService watcher; @@ -83,7 +89,7 @@ public class Config { e.printStackTrace(); } - Configuration config = new Configuration(configFile, Neodymium.VERSION); + config = new Configuration(configFile, Neodymium.VERSION); config.load(); @@ -186,6 +192,20 @@ public class Config { configFile.toPath().getParent().register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY); } + public static List<IConfigElement> getElements() { + List<IConfigElement> list = new ArrayList<IConfigElement>(); + for(Property prop : config.getCategory("render").values()) { + list.add(new ConfigElement(prop)); + } + return list; + } + + public static void flush() { + if(config.hasChanged()) { + config.save(); + } + } + @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public static @interface NeedsReload { |