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));
}
}));
}
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));
}
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();
}
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);
}
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();
}
}
}
Aggregations