Remove old config system

This commit is contained in:
modmuss50 2017-06-12 20:51:36 +01:00
parent fed253332b
commit 2df2a1d1ba
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA
4 changed files with 29 additions and 308 deletions

View file

@ -24,151 +24,40 @@
package techreborn.config;
import net.minecraftforge.common.config.Configuration;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import techreborn.lib.ModInfo;
import java.io.File;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class ConfigTechReborn {
public static String CATEGORY_WORLD = "world";
public static String CATEGORY_POWER = "power";
public static String CATEGORY_CRAFTING = "crafting";
public static String CATEGORY_UU = "uu";
public static String CATEGORY_EMC = "emc";
public static String CATEGORY_INTEGRATION = "Integration";
public static String CATEGORY_FEATURES = "Features";
@ConfigRegistry(config = "recipes", category = "railcraft", key = "disableRailcraftNugget", comment = "When true TechReborn will remove Railcrafts Iron Nugget to steel nuggert recipe.")
public static boolean disableRailcraftSteelNuggetRecipe = false;
// Charge
public static int IronDrillCharge;
public static int DiamondDrillCharge;
public static int AdvancedDrillCharge;
public static int IronChainsawCharge;
public static int DiamondChainsawCharge;
public static int AdvancedChainsawCharge;
public static int SteelJackhammerCharge;
public static int DiamondJackhammerCharge;
public static int AdvancedJackhammerCharge;
public static int LapotronPackCharge;
public static int LithiumBatpackCharge;
public static int LapotronicOrbMaxCharge;
public static int OmniToolCharge;
public static int RockCutterCharge;
public static int CloakingDeviceCharge;
public static int CentrifugeCharge;
public static int ThermalGeneratorCharge;
// Crafting
@ConfigRegistry(config = "recipes", category = "ic2", key = "deduplicate", comment = "Changes a lot of reipes and hides blocks to intrgrade TechReborn into IC2")
public static boolean REMOVE_DUPLICATES = false;
// Client
@ConfigRegistry(config = "client", category = "hud", key = "showChargeHud", comment = "Show the charge hud")
public static boolean ShowChargeHud = true;
@ConfigRegistry(config = "misc", category = "general", key = "enableGemTools", comment = "Enable Gem armor and tools")
public static boolean enableGemArmorAndTools = true;
public static Configuration config;
private static ConfigTechReborn instance = null;
//TODO give an annotation
public static int IronDrillCharge = 10000;
public static int DiamondDrillCharge = 100000;
public static int AdvancedDrillCharge = 1000000;
public static int IronChainsawCharge = 10000;
public static int DiamondChainsawCharge = 10000;
public static int AdvancedChainsawCharge = 1000000;
public static int SteelJackhammerCharge = 1000000;
public static int DiamondJackhammerCharge = 20000;
public static int AdvancedJackhammerCharge = 100000;
public static int LapotronPackCharge = 100000000;
public static int LithiumBatpackCharge = 4000000;
public static int LapotronicOrbMaxCharge = 20000;
public static int OmniToolCharge = 20000;
public static int RockCutterCharge = 10000;
public static int CloakingDeviceCharge = 10000000;
public static int CentrifugeCharge = 1000000;
public static int ThermalGeneratorCharge = 1000000;
private ConfigTechReborn(File configFile) {
config = new Configuration(configFile);
config.load();
ConfigTechReborn.Configs();
config.save();
}
public static ConfigTechReborn initialize(File configFile) {
if (instance == null)
instance = new ConfigTechReborn(configFile);
else
throw new IllegalStateException("Cannot initialize TechReborn Config twice");
return instance;
}
public static ConfigTechReborn instance() {
if (instance == null) {
throw new IllegalStateException("Instance of TechReborn Config requested before initialization");
}
return instance;
}
public static void Configs() {
// Charge
IronDrillCharge = config
.get(CATEGORY_POWER, "IronDrill MaxCharge", 10000, "Set the max charge for the iron drill").getInt();
DiamondDrillCharge = config
.get(CATEGORY_POWER, "DiamondDrill MaxCharge", 100000, "Set the max charge for the diamond drill")
.getInt();
AdvancedDrillCharge = config
.get(CATEGORY_POWER, "AdvancedDrill MaxCharge", 1000000, "Set the max charge for the advanced drill")
.getInt();
IronChainsawCharge = config
.get(CATEGORY_POWER, "IronChainsaw MaxCharge", 10000, "Set the max charge for the iron chainsaw")
.getInt();
DiamondChainsawCharge = config
.get(CATEGORY_POWER, "DiamondChainsaw MaxCharge", 100000, "Set the max charge for the diamond chainsaw")
.getInt();
AdvancedChainsawCharge = config.get(CATEGORY_POWER, "AdvancedChainsaw MaxCharge", 1000000,
"Set the max charge for the advanced chainsaw").getInt();
AdvancedJackhammerCharge = config
.get(CATEGORY_POWER, "AdvancedJackhammer MaxCharge", 100000, "Set the max charge for the advanced jackhammer")
.getInt();
SteelJackhammerCharge = config.get(CATEGORY_POWER, "SteelJackhammer MaxCharge", 10000,
"Set the max charge for the steel jackhammer").getInt();
DiamondJackhammerCharge = config.get(CATEGORY_POWER, "DiamondJackhammer MaxCharge", 20000,
"Set the max charge for the diamond jackhammer").getInt();
LapotronPackCharge = config
.get(CATEGORY_POWER, "LapotronPack MaxCharge", 100000000, "Set the max charge for the LapotronPack")
.getInt();
LapotronicOrbMaxCharge = config
.get(CATEGORY_POWER, "LapotronicOrb MaxCharge", 10000000, "Set the max charge for the LapotronicOrb")
.getInt();
LithiumBatpackCharge = config
.get(CATEGORY_POWER, "LithiumBatpack MaxCharge", 4000000, "Set the max charge for the LithiumBatpack")
.getInt();
OmniToolCharge = config.get(CATEGORY_POWER, "OmniTool MaxCharge", 20000, "Set the max charge for the OmniTool")
.getInt();
RockCutterCharge = config
.get(CATEGORY_POWER, "RockCutter MaxCharge", 10000, "Set the max charge for the RockCutter").getInt();
CloakingDeviceCharge = config
.get(CATEGORY_POWER, "CloakingDevice MaxCharge", 10000000, "Set the max charge for the CloakingDevice")
.getInt();
CentrifugeCharge = config
.get(CATEGORY_POWER, "Centrifuge MaxCharge", 1000000, "Set the max charge for the Centrifuge").getInt();
ThermalGeneratorCharge = config.get(CATEGORY_POWER, "ThermalGenerator MaxCharge", 1000000,
"Set the max charge for the ThermalGenerator").getInt();
if (config.hasChanged()) {
config.save();
}
}
}

View file

@ -25,170 +25,23 @@
package techreborn.config;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.config.DummyConfigElement;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.GuiConfigEntries;
import net.minecraftforge.fml.client.config.GuiConfigEntries.CategoryEntry;
import net.minecraftforge.fml.client.config.IConfigElement;
import techreborn.lib.ModInfo;
import java.util.ArrayList;
import java.util.List;
//TODO load from config annoations
public class TechRebornConfigGui extends GuiConfig {
public TechRebornConfigGui(GuiScreen top) {
super(top, getConfigCategories(), "TechReborn", false, false,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
super(top, getConfigCategories(), ModInfo.MOD_ID, false, true,
ModInfo.MOD_NAME);
}
private static List<IConfigElement> getConfigCategories() {
List<IConfigElement> list = new ArrayList<>();
list.add(
new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.general"),
"tr.configgui.category.trGeneral", TRGeneral.class));
list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.world"),
"tr.configgui.category.trWorld", TRWORLD.class));
list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.power"),
"tr.configgui.category.trPower", TRPOWER.class));
list.add(new DummyConfigElement.DummyCategoryElement(
I18n.translateToLocal("config.techreborn.category.crafting"), "tr.configgui.category.trCrafting",
TRCRAFTING.class));
list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.uu"),
"tr.configgui.category.truu", TRUU.class));
list.add(new DummyConfigElement.DummyCategoryElement(I18n.translateToLocal("config.techreborn.category.emc"),
"tr.configgui.category.tremc", TREMC.class));
list.add(new DummyConfigElement.DummyCategoryElement(
I18n.translateToLocal("config.techreborn.category.integration"), "tr.configgui.category.treinter",
TRINT.class));
return list;
}
public static class TRGeneral extends CategoryEntry {
public TRGeneral(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config.getCategory(Configuration.CATEGORY_GENERAL)))
.getChildElements(),
this.owningScreen.modID, Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
}
// World
public static class TRWORLD extends CategoryEntry {
public TRWORLD(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_WORLD)))
.getChildElements(),
this.owningScreen.modID, Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
}
// Power
public static class TRPOWER extends CategoryEntry {
public TRPOWER(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_POWER)))
.getChildElements(),
this.owningScreen.modID, Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
}
// Crafting
public static class TRCRAFTING extends CategoryEntry {
public TRCRAFTING(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_CRAFTING)))
.getChildElements(),
this.owningScreen.modID, Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
}
// Crafting
public static class TRUU extends CategoryEntry {
public TRUU(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_UU)))
.getChildElements(),
this.owningScreen.modID, Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
}
// Emc
public static class TREMC extends CategoryEntry {
public TREMC(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_EMC)))
.getChildElements(),
this.owningScreen.modID, Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
}
// Mod Integration
public static class TRINT extends CategoryEntry {
public TRINT(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config.getCategory(ConfigTechReborn.CATEGORY_INTEGRATION)))
.getChildElements(),
this.owningScreen.modID, Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
}
}