public static void preInit() {
stage = Stage.PRE_INIT;
Locale locale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
Configuration config = new Configuration(new File(Railcraft.getMod().getConfigFolder(), MODULE_CONFIG_FILE_NAME));
config.load();
config.addCustomCategoryComment(CATEGORY_MODULES, "Disabling these modules can greatly change how the mod functions.\n"
+ "For example, disabling the Train Module will prevent you from linking carts.\n"
+ "Disabling the World Module will disable all world gen.\n"
+ "Disabling the Energy Module will remove the energy requirement from machines, "
+ "but will only do so if Forestry or Buildcraft are not installed.");
Set<Module> toLoad = EnumSet.allOf(Module.class);
Iterator<Module> it = toLoad.iterator();
while (it.hasNext()) {
Module m = it.next();
if (m == Module.CORE)
continue;
if (!isEnabled(config, m)) {
it.remove();
Game.log(Level.INFO, "Module disabled: {0}", m);
continue;
}
RailcraftModule inst = m.instance;
if (inst == null) {
it.remove();
Game.log(Level.INFO, "Module not found: {0}", m);
continue;
}
if (!inst.canModuleLoad()) {
it.remove();
inst.printLoadError();
continue;
}
}
boolean changed;
do {
changed = false;
it = toLoad.iterator();
while (it.hasNext()) {
Module m = it.next();
if (m.instance == null)
continue;
Set<Module> deps = m.instance.getDependencies();
if (!toLoad.containsAll(deps)) {
it.remove();
changed = true;
Game.log(Level.WARN, "Module {0} is missing dependancies: {1}", m, deps);
continue;
}
}
} while (changed);
unloadedModules.removeAll(toLoad);
loadedModules.addAll(toLoad);
if (config.hasChanged())
config.save();
Locale.setDefault(locale);
for (Module m : loadedModules) {
preInit(m);