From 4908d5967c3dfeff5616c65144e701859b9e30a2 Mon Sep 17 00:00:00 2001 From: boubou19 Date: Tue, 27 Aug 2024 20:50:30 +0200 Subject: Config/gregtech.cfg (#2939) * first pass on config migration * second pass on config migration * removing bad configs * rename config classes and register them * move debug options to its own debug category * migrate pollution * finish migrating general config * removing useless config * finish GregTech.cfg port to GTNHLib * don't accidentally force panic mode in dev env * typo * defaults are now handled by the confg handler * remove dead config * force config save after defaults are being written * stop messing with the GregTech.cfg externally * removing comments * new underground fluid builder and porting default underground fluids to code * move config handlers of gregtech.cfg in their own package * process MachineStats.cfg * yeeted MaterialProperties.cfg * remove unused compat in GTNH * process OverpoweredStuff.cfg * process Other.cfg * ungregify some config variables * remove unused variables * fix Ids.cfg not being populated * delete duplicate printing of MTE IDs in GT5U clients * bump hodgepodge version to get mod phase timers * process Client.cfg * fix bad category naming * registering all the config handlers in gui * bump GTNHLib version * actually only registering client configs * use proper double arrays now * move GT ore mixes to patternbuilders * dead code * fix multifiles config not being handled properly * import class from NHCore * removing reflection * use enums for registration * yeet config for Asteroid dimensions * remove unused since 2015 enum entry * todo * rework oremix enums * imported dimension data in enums * convert old dirty predicate into proper one * hook gagreg onto the OreMixes enum * finally nuke worldgen.ore.mix config category! * hook gagreg small ores onto the SmallOres enum * imported dim values in enum * fix dirty work around in vm predicate * yeet unused classes * hook GT stones to GTStones enum * yeet all the remaining booleans in the worldgen category * port endasteroids category * port general category * deprecated * yeet unused bw compat * finish worldgen config migration * hardcode config into code * remove not generated config entry * remove Unification.cfg * fix build * migrate oreveins away from config * migrate small ores away from config * delete config parser * forgotten * fix EoH recipe crash in dev * fix GT NEI Ore Plugin config and csv paths * shade opencsv * rewrite csv generator * spotless apply --- .../java/gregtech/client/GT_GUI_ClientConfig.java | 66 ++++++---------------- src/main/java/gregtech/client/GT_GuiFactory.java | 20 +------ 2 files changed, 18 insertions(+), 68 deletions(-) (limited to 'src/main/java/gregtech/client') diff --git a/src/main/java/gregtech/client/GT_GUI_ClientConfig.java b/src/main/java/gregtech/client/GT_GUI_ClientConfig.java index 1e9841369b..dfb4b2800c 100644 --- a/src/main/java/gregtech/client/GT_GUI_ClientConfig.java +++ b/src/main/java/gregtech/client/GT_GUI_ClientConfig.java @@ -2,62 +2,28 @@ package gregtech.client; import static gregtech.api.enums.Mods.GregTech; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; -import cpw.mods.fml.client.config.GuiConfig; -import cpw.mods.fml.client.config.IConfigElement; -import gregtech.api.GregTech_API; +import com.gtnewhorizon.gtnhlib.config.ConfigException; +import com.gtnewhorizon.gtnhlib.config.SimpleGuiConfig; + +import gregtech.common.config.client.ConfigColorModulation; +import gregtech.common.config.client.ConfigInterface; +import gregtech.common.config.client.ConfigPreference; +import gregtech.common.config.client.ConfigRender; +import gregtech.common.config.client.ConfigWaila; -public class GT_GUI_ClientConfig extends GuiConfig { +public class GT_GUI_ClientConfig extends SimpleGuiConfig { - public GT_GUI_ClientConfig(GuiScreen parentScreen) { + public GT_GUI_ClientConfig(GuiScreen parentScreen) throws ConfigException { super( parentScreen, - getConfigElements(), GregTech.ID, - "client", - false, - false, - getAbridgedConfigPath(GregTech_API.sClientDataFile.mConfig.toString())); - } - - @SuppressWarnings("rawtypes") - private static List getConfigElements() { - final Configuration config = GregTech_API.sClientDataFile.mConfig; - setLanguageKeys(config); - return config.getCategoryNames() - .stream() - .filter(name -> name.indexOf('.') == -1) - .map(name -> new ConfigElement(config.getCategory(name))) - .collect(Collectors.toList()); - } - - private static void setLanguageKeys(Configuration config) { - for (String categoryName : config.getCategoryNames()) { - ConfigCategory category = config.getCategory(categoryName); - category.setLanguageKey("GT5U.config." + categoryName); - for (Map.Entry entry : category.entrySet()) { - // drop the default value in name - String name = entry.getKey(); - int defaultStart = name.lastIndexOf('_'); - String realName = defaultStart >= 0 ? name.substring(0, defaultStart) : name; - if (categoryName.equals("nei.recipe_categories")) { - // reuse existing translation for RecipeCategory - entry.getValue() - .setLanguageKey(name); - } else { - entry.getValue() - .setLanguageKey(String.format("%s.%s", category.getLanguagekey(), realName)); - } - } - } + "GregTech", + ConfigColorModulation.class, + ConfigInterface.class, + ConfigPreference.class, + ConfigRender.class, + ConfigWaila.class); } } diff --git a/src/main/java/gregtech/client/GT_GuiFactory.java b/src/main/java/gregtech/client/GT_GuiFactory.java index 3c8e5cd52c..ecf317a6fa 100644 --- a/src/main/java/gregtech/client/GT_GuiFactory.java +++ b/src/main/java/gregtech/client/GT_GuiFactory.java @@ -1,29 +1,13 @@ package gregtech.client; -import java.util.Set; - -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import cpw.mods.fml.client.IModGuiFactory; - -public class GT_GuiFactory implements IModGuiFactory { +import com.gtnewhorizon.gtnhlib.config.SimpleGuiFactory; - @Override - public void initialize(Minecraft minecraftInstance) {} +public class GT_GuiFactory implements SimpleGuiFactory { @Override public Class mainConfigGuiClass() { return GT_GUI_ClientConfig.class; } - - @Override - public Set runtimeGuiCategories() { - return null; - } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { - return null; - } } -- cgit