Search in sources :

Example 1 with ModuleConfig

use of org.terasology.engine.config.ModuleConfig in project Terasology by MovingBlocks.

the class NewGameScreen 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();
}
Also used : ModuleConfig(org.terasology.engine.config.ModuleConfig)

Example 2 with ModuleConfig

use of org.terasology.engine.config.ModuleConfig in project Terasology by MovingBlocks.

the class AdvancedGameSetupScreen method saveConfiguration.

private void saveConfiguration() {
    // moduleConfig passes the module collection to other screens
    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();
}
Also used : ModuleInstaller(org.terasology.engine.core.module.ModuleInstaller) WorldGeneratorManager(org.terasology.engine.world.generator.internal.WorldGeneratorManager) In(org.terasology.engine.registry.In) LoggerFactory(org.slf4j.LoggerFactory) WidgetUtil(org.terasology.nui.WidgetUtil) ModuleMetadata(org.terasology.gestalt.module.ModuleMetadata) ResolutionResult(org.terasology.gestalt.module.dependencyresolution.ResolutionResult) Future(java.util.concurrent.Future) Map(java.util.Map) AbstractItemRenderer(org.terasology.nui.itemRendering.AbstractItemRenderer) DependencyInfo(org.terasology.gestalt.module.dependencyresolution.DependencyInfo) Canvas(org.terasology.nui.Canvas) ResettableUIText(org.terasology.nui.widgets.ResettableUIText) StateLoading(org.terasology.engine.core.modes.StateLoading) ReadOnlyBinding(org.terasology.nui.databinding.ReadOnlyBinding) TranslationSystem(org.terasology.engine.i18n.TranslationSystem) Binding(org.terasology.nui.databinding.Binding) ImmutableSet(com.google.common.collect.ImmutableSet) StringUtils(org.codehaus.plexus.util.StringUtils) GameEngine(org.terasology.engine.core.GameEngine) CancellationException(java.util.concurrent.CancellationException) Module(org.terasology.gestalt.module.Module) Collection(java.util.Collection) UniverseWrapper(org.terasology.engine.rendering.nui.layers.mainMenu.UniverseWrapper) WaitPopup(org.terasology.engine.rendering.nui.layers.mainMenu.WaitPopup) Set(java.util.Set) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) SimpleUri(org.terasology.engine.core.SimpleUri) DependencyResolver(org.terasology.gestalt.module.dependencyresolution.DependencyResolver) Objects(java.util.Objects) UIText(org.terasology.nui.widgets.UIText) List(java.util.List) Vector2i(org.joml.Vector2i) UIList(org.terasology.nui.widgets.UIList) Name(org.terasology.gestalt.naming.Name) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) MenuAnimationSystems(org.terasology.engine.rendering.nui.animation.MenuAnimationSystems) TerasologyConstants(org.terasology.engine.core.TerasologyConstants) ModuleManager(org.terasology.engine.core.module.ModuleManager) ModuleDetailsScreen(org.terasology.engine.rendering.nui.layers.mainMenu.moduleDetailsScreen.ModuleDetailsScreen) NetworkMode(org.terasology.engine.network.NetworkMode) TargetLengthBasedClassNameAbbreviator(ch.qos.logback.classic.pattern.TargetLengthBasedClassNameAbbreviator) DependencyResolutionFailedException(org.terasology.engine.core.module.DependencyResolutionFailedException) FastRandom(org.terasology.engine.utilities.random.FastRandom) ArrayList(java.util.ArrayList) StandardModuleExtension(org.terasology.engine.core.module.StandardModuleExtension) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) GameManifest(org.terasology.engine.game.GameManifest) Lists(com.google.common.collect.Lists) ConfirmPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup) GameManifestProvider(org.terasology.engine.rendering.nui.layers.mainMenu.GameManifestProvider) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) ModuleConfig(org.terasology.engine.config.ModuleConfig) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) UILabel(org.terasology.nui.widgets.UILabel) SelectModulesConfig(org.terasology.engine.config.SelectModulesConfig) Maps(com.google.common.collect.Maps) CoreScreenLayer(org.terasology.engine.rendering.nui.CoreScreenLayer) UICheckbox(org.terasology.nui.widgets.UICheckbox) ExecutionException(java.util.concurrent.ExecutionException) Config(org.terasology.engine.config.Config) TextChangeEventListener(org.terasology.nui.widgets.TextChangeEventListener) UIButton(org.terasology.nui.widgets.UIButton) UniverseSetupScreen(org.terasology.engine.rendering.nui.layers.mainMenu.UniverseSetupScreen) Comparator(java.util.Comparator) SimpleUri(org.terasology.engine.core.SimpleUri) ModuleConfig(org.terasology.engine.config.ModuleConfig)

Aggregations

ModuleConfig (org.terasology.engine.config.ModuleConfig)2 TargetLengthBasedClassNameAbbreviator (ch.qos.logback.classic.pattern.TargetLengthBasedClassNameAbbreviator)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.codehaus.plexus.util.StringUtils)1