Search in sources :

Example 1 with ModuleConfig

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

Example 2 with ModuleConfig

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();
}
Also used : SelectModulesConfig(org.terasology.config.SelectModulesConfig) CoreScreenLayer(org.terasology.rendering.nui.CoreScreenLayer) DependencyResolver(org.terasology.module.DependencyResolver) LoggerFactory(org.slf4j.LoggerFactory) Config(org.terasology.config.Config) Future(java.util.concurrent.Future) ModuleMetadata(org.terasology.module.ModuleMetadata) Map(java.util.Map) SimpleUri(org.terasology.engine.SimpleUri) TerasologyConstants(org.terasology.engine.TerasologyConstants) MessagePopup(org.terasology.rendering.nui.layers.mainMenu.MessagePopup) ImmutableSet(com.google.common.collect.ImmutableSet) WidgetUtil(org.terasology.rendering.nui.WidgetUtil) CancellationException(java.util.concurrent.CancellationException) DependencyInfo(org.terasology.module.DependencyInfo) Set(java.util.Set) ConfirmPopup(org.terasology.rendering.nui.layers.mainMenu.ConfirmPopup) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) List(java.util.List) ResourceUrn(org.terasology.assets.ResourceUrn) In(org.terasology.registry.In) ReadOnlyBinding(org.terasology.rendering.nui.databinding.ReadOnlyBinding) MenuAnimationSystems(org.terasology.rendering.nui.animation.MenuAnimationSystems) AbstractItemRenderer(org.terasology.rendering.nui.itemRendering.AbstractItemRenderer) ArrayList(java.util.ArrayList) DependencyResolutionFailedException(org.terasology.engine.module.DependencyResolutionFailedException) Lists(com.google.common.collect.Lists) ResolutionResult(org.terasology.module.ResolutionResult) TranslationSystem(org.terasology.i18n.TranslationSystem) TextChangeEventListener(org.terasology.rendering.nui.widgets.TextChangeEventListener) UIList(org.terasology.rendering.nui.widgets.UIList) Name(org.terasology.naming.Name) ModuleManager(org.terasology.engine.module.ModuleManager) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Vector2i(org.terasology.math.geom.Vector2i) Maps(com.google.common.collect.Maps) UILabel(org.terasology.rendering.nui.widgets.UILabel) WorldGeneratorManager(org.terasology.world.generator.internal.WorldGeneratorManager) ExecutionException(java.util.concurrent.ExecutionException) UICheckbox(org.terasology.rendering.nui.widgets.UICheckbox) Binding(org.terasology.rendering.nui.databinding.Binding) Canvas(org.terasology.rendering.nui.Canvas) UIButton(org.terasology.rendering.nui.widgets.UIButton) ModuleInstaller(org.terasology.engine.module.ModuleInstaller) ModuleConfig(org.terasology.config.ModuleConfig) WaitPopup(org.terasology.rendering.nui.layers.mainMenu.WaitPopup) ResettableUIText(org.terasology.rendering.nui.widgets.ResettableUIText) Comparator(java.util.Comparator) Collections(java.util.Collections) Module(org.terasology.module.Module) SimpleUri(org.terasology.engine.SimpleUri) ModuleConfig(org.terasology.config.ModuleConfig)

Example 3 with ModuleConfig

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();
}
Also used : SimpleUri(org.terasology.engine.SimpleUri) ModuleConfig(org.terasology.config.ModuleConfig) WorldGeneratorInfo(org.terasology.world.generator.internal.WorldGeneratorInfo)

Aggregations

ModuleConfig (org.terasology.config.ModuleConfig)3 SimpleUri (org.terasology.engine.SimpleUri)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)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 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 ResourceUrn (org.terasology.assets.ResourceUrn)1