Search in sources :

Example 16 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class ModuleDetailsScreen method setUpDependencies.

private void setUpDependencies() {
    dependencies.setList(Collections.emptyList());
    dependencies.setItemRenderer(new AbstractItemRenderer<DependencyInfo>() {

        private String getString(DependencyInfo value) {
            if (value != null) {
                return value.getId().toString();
            }
            return "";
        }

        @Override
        public void draw(DependencyInfo value, Canvas canvas) {
            Module module = moduleManager.getRegistry().getLatestModuleVersion(value.getId());
            if (module == null || !(value.versionPredicate().test(module.getVersion()))) {
                canvas.setMode("invalid");
            } else {
                canvas.setMode("available");
            }
            canvas.drawText(getString(value), canvas.getRegion());
        }

        @Override
        public Vector2i getPreferredSize(DependencyInfo value, Canvas canvas) {
            String text = getString(value);
            canvas.getCurrentStyle().setTextColor(Color.RED);
            return new Vector2i(canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight());
        }
    });
    dependencies.subscribe(((widget, item) -> {
        if (item != null) {
            modules.getList().stream().filter(m -> item.getId().equals(m.getId())).findFirst().ifPresent(m -> modules.setSelection(m));
        }
    }));
}
Also used : ModuleInstaller(org.terasology.engine.core.module.ModuleInstaller) Arrays(java.util.Arrays) In(org.terasology.engine.registry.In) Color(org.terasology.nui.Color) LoggerFactory(org.slf4j.LoggerFactory) ModuleMetadata(org.terasology.gestalt.module.ModuleMetadata) AbstractItemRenderer(org.terasology.nui.itemRendering.AbstractItemRenderer) DependencyInfo(org.terasology.gestalt.module.dependencyresolution.DependencyInfo) Canvas(org.terasology.nui.Canvas) ReadOnlyBinding(org.terasology.nui.databinding.ReadOnlyBinding) DateFormat(java.text.DateFormat) TranslationSystem(org.terasology.engine.i18n.TranslationSystem) StringTextRenderer(org.terasology.nui.itemRendering.StringTextRenderer) Binding(org.terasology.nui.databinding.Binding) StringUtils(org.codehaus.plexus.util.StringUtils) Module(org.terasology.gestalt.module.Module) Collection(java.util.Collection) WaitPopup(org.terasology.engine.rendering.nui.layers.mainMenu.WaitPopup) Set(java.util.Set) Version(org.terasology.gestalt.naming.Version) Collectors(java.util.stream.Collectors) DependencyResolver(org.terasology.gestalt.module.dependencyresolution.DependencyResolver) Objects(java.util.Objects) UIText(org.terasology.nui.widgets.UIText) List(java.util.List) Context(org.terasology.engine.context.Context) Stream(java.util.stream.Stream) Vector2i(org.joml.Vector2i) ExtraDataModuleExtension(org.terasology.engine.core.module.ExtraDataModuleExtension) UIList(org.terasology.nui.widgets.UIList) Name(org.terasology.gestalt.naming.Name) MenuAnimationSystems(org.terasology.engine.rendering.nui.animation.MenuAnimationSystems) ModuleManager(org.terasology.engine.core.module.ModuleManager) UIButtonWebBrowser(org.terasology.engine.rendering.nui.widgets.UIButtonWebBrowser) SimpleDateFormat(java.text.SimpleDateFormat) DownloadPopupProgressListener(org.terasology.engine.rendering.nui.layers.mainMenu.advancedGameSetupScreen.DownloadPopupProgressListener) DependencyResolutionFailedException(org.terasology.engine.core.module.DependencyResolutionFailedException) HashSet(java.util.HashSet) StandardModuleExtension(org.terasology.engine.core.module.StandardModuleExtension) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ConfirmPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) Logger(org.slf4j.Logger) UILabel(org.terasology.nui.widgets.UILabel) CoreScreenLayer(org.terasology.engine.rendering.nui.CoreScreenLayer) UIButton(org.terasology.nui.widgets.UIButton) Comparator(java.util.Comparator) RemoteModuleExtension(org.terasology.engine.core.module.RemoteModuleExtension) Collections(java.util.Collections) Canvas(org.terasology.nui.Canvas) Vector2i(org.joml.Vector2i) Module(org.terasology.gestalt.module.Module) DependencyInfo(org.terasology.gestalt.module.dependencyresolution.DependencyInfo)

Example 17 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class ModuleDetailsScreen method startDownloadingNewestModulesRequiredFor.

private void startDownloadingNewestModulesRequiredFor(final DependencyInfo dependencyInfo) {
    final Set<Module> modulesToDownload;
    try {
        modulesToDownload = moduleManager.getInstallManager().getAllModulesToDownloadFor(dependencyInfo.getId());
    } catch (DependencyResolutionFailedException ex) {
        MessagePopup messagePopup = getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
        messagePopup.setMessage("Error", ex.getMessage());
        return;
    }
    final ConfirmPopup confirmPopup = getManager().pushScreen(ConfirmPopup.ASSET_URI, ConfirmPopup.class);
    confirmPopup.setMessage("Confirm Download", modulesToDownload.size() + " modules will be downloaded");
    confirmPopup.setOkHandler(() -> downloadModules(modulesToDownload));
}
Also used : ConfirmPopup(org.terasology.engine.rendering.nui.layers.mainMenu.ConfirmPopup) DependencyResolutionFailedException(org.terasology.engine.core.module.DependencyResolutionFailedException) MessagePopup(org.terasology.engine.rendering.nui.layers.mainMenu.MessagePopup) Module(org.terasology.gestalt.module.Module)

Example 18 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class AdvancedGameSetupScreen method updateModuleInformation.

private void updateModuleInformation() {
    Iterable<Module> remoteModuleRegistry = moduleManager.getInstallManager().getRemoteRegistry();
    Set<Name> filtered = ImmutableSet.of(TerasologyConstants.ENGINE_MODULE, new Name("engine-test"));
    for (Module remote : remoteModuleRegistry) {
        ModuleSelectionInfo info = modulesLookup.get(remote.getId());
        if (!filtered.contains(remote.getId())) {
            if (info == null) {
                info = ModuleSelectionInfo.remote(remote);
                modulesLookup.put(remote.getId(), info);
            }
            info.setOnlineVersion(remote);
        }
    }
    sortedModules.clear();
    allSortedModules.clear();
    sortedModules.addAll(modulesLookup.values());
    sortedModules.sort(moduleInfoComparator);
    allSortedModules.addAll(sortedModules);
    filterModules();
    refreshSelection();
}
Also used : Module(org.terasology.gestalt.module.Module) Name(org.terasology.gestalt.naming.Name)

Example 19 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class AdvancedGameSetupScreen method downloadModules.

private void downloadModules(Iterable<Module> modulesToDownload) {
    final WaitPopup<List<Module>> popup = getManager().pushScreen(WaitPopup.ASSET_URI, WaitPopup.class);
    popup.onSuccess(newModules -> {
        for (Module module : newModules) {
            modulesLookup.get(module.getId()).setLocalVersion(module);
            updateValidToSelect();
        }
    });
    ModuleInstaller operation = moduleManager.getInstallManager().createInstaller(modulesToDownload, new DownloadPopupProgressListener(popup));
    popup.startOperation(operation, true);
}
Also used : ModuleInstaller(org.terasology.engine.core.module.ModuleInstaller) List(java.util.List) UIList(org.terasology.nui.widgets.UIList) ArrayList(java.util.ArrayList) Module(org.terasology.gestalt.module.Module)

Example 20 with Module

use of org.terasology.gestalt.module.Module in project Terasology by MovingBlocks.

the class AdvancedGameSetupScreen method uncategorizedModuleFilter.

private void uncategorizedModuleFilter() {
    Iterator<ModuleSelectionInfo> iter = sortedModules.iterator();
    while (iter.hasNext()) {
        ModuleSelectionInfo m = iter.next();
        Module module;
        if (m.isPresent()) {
            module = moduleManager.getRegistry().getLatestModuleVersion(m.getMetadata().getId());
        } else {
            module = (m.getOnlineVersion() == null) ? m.getLatestVersion() : m.getOnlineVersion();
        }
        boolean isUncategorized = true;
        Set<StandardModuleExtension> booleanStandardModuleExtensionEnumSet = StandardModuleExtension.booleanPropertySet();
        for (StandardModuleExtension standardModuleExtension : booleanStandardModuleExtensionEnumSet) {
            if (standardModuleExtension.isProvidedBy(module)) {
                isUncategorized = false;
                break;
            }
        }
        if (!isUncategorized) {
            iter.remove();
        }
    }
}
Also used : StandardModuleExtension(org.terasology.engine.core.module.StandardModuleExtension) Module(org.terasology.gestalt.module.Module)

Aggregations

Module (org.terasology.gestalt.module.Module)51 ModuleManager (org.terasology.engine.core.module.ModuleManager)18 Name (org.terasology.gestalt.naming.Name)17 DependencyResolver (org.terasology.gestalt.module.dependencyresolution.DependencyResolver)13 ModuleMetadata (org.terasology.gestalt.module.ModuleMetadata)11 List (java.util.List)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 SimpleUri (org.terasology.engine.core.SimpleUri)9 UILabel (org.terasology.nui.widgets.UILabel)9 UIText (org.terasology.nui.widgets.UIText)9 DependencyInfo (org.terasology.gestalt.module.dependencyresolution.DependencyInfo)8 ResolutionResult (org.terasology.gestalt.module.dependencyresolution.ResolutionResult)8 Canvas (org.terasology.nui.Canvas)8 Collection (java.util.Collection)7 Comparator (java.util.Comparator)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 TranslationSystem (org.terasology.engine.i18n.TranslationSystem)7 In (org.terasology.engine.registry.In)7