use of org.terasology.config.ModuleConfig in project Terasology by MovingBlocks.
the class CreateGameScreen method setSelectedGameplayModule.
private void setSelectedGameplayModule(Module module) {
ModuleConfig moduleConfig = config.getDefaultModSelection();
if (moduleConfig.getDefaultGameplayModuleName().equals(module.getId().toString())) {
// same as before -> we're done
return;
}
moduleConfig.setDefaultGameplayModuleName(module.getId().toString());
moduleConfig.clear();
moduleConfig.addModule(module.getId());
// Set the default generator of the selected gameplay module
setDefaultGeneratorOfGameplayModule(module);
config.save();
}
use of org.terasology.config.ModuleConfig in project Terasology by MovingBlocks.
the class SelectModulesScreen method onClosed.
@Override
public void onClosed() {
// moduleConfig passes the module collection to the Create Game Screen.
ModuleConfig moduleConfig = config.getDefaultModSelection();
moduleConfig.clear();
// Fetch all the selected/activated modules using allSortedModules
// instead of fetching only selected/activated modules from filtered collection of modules using sortedModules
allSortedModules.stream().filter(info -> info.isSelected() && info.isExplicitSelection()).forEach(info -> moduleConfig.addModule(info.getMetadata().getId()));
SimpleUri defaultGenerator = config.getWorldGeneration().getDefaultGenerator();
ModuleSelectionInfo info = modulesLookup.get(defaultGenerator.getModuleName());
if (info != null && !info.isSelected()) {
config.getWorldGeneration().setDefaultGenerator(new SimpleUri());
}
worldGenManager.refresh();
config.save();
}
use of org.terasology.config.ModuleConfig in project Terasology by MovingBlocks.
the class CreateGameScreen method setDefaultGeneratorOfGameplayModule.
// Sets the default generator of the passed in gameplay module. Make sure it's already selected.
private void setDefaultGeneratorOfGameplayModule(Module module) {
ModuleConfig moduleConfig = config.getDefaultModSelection();
// Set the default generator of the selected gameplay module
SimpleUri defaultWorldGenerator = StandardModuleExtension.getDefaultWorldGenerator(module);
if (defaultWorldGenerator != null) {
for (WorldGeneratorInfo worldGenInfo : worldGeneratorManager.getWorldGenerators()) {
if (worldGenInfo.getUri().equals(defaultWorldGenerator)) {
config.getWorldGeneration().setDefaultGenerator(worldGenInfo.getUri());
}
}
}
config.save();
}
Aggregations