Search in sources :

Example 1 with SimpleUri

use of org.terasology.engine.SimpleUri 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 2 with SimpleUri

use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.

the class PlayerSettingsScreen method initialise.

@Override
public void initialise() {
    setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
    storageServiceStatus = find("storageServiceStatus", UILabel.class);
    storageServiceAction = find("storageServiceAction", UIButton.class);
    updateStorageServiceStatus();
    nametext = find("playername", UIText.class);
    if (nametext != null) {
        nametext.setTooltipDelay(0);
        nametext.bindTooltipString(new ReadOnlyBinding<String>() {

            @Override
            public String get() {
                return validateScreen();
            }
        });
    }
    img = find("image", UIImage.class);
    if (img != null) {
        ResourceUrn uri = TextureUtil.getTextureUriForColor(Color.WHITE);
        Texture tex = Assets.get(uri, Texture.class).get();
        img.setImage(tex);
    }
    slider = find("tone", UISlider.class);
    if (slider != null) {
        slider.setIncrement(0.01f);
        // ensure a certain width
        Function<Object, String> constant = Functions.constant("  ");
        slider.setLabelFunction(constant);
    }
    heightSlider = find("height", UISlider.class);
    if (heightSlider != null) {
        heightSlider.setMinimum(1.5f);
        heightSlider.setIncrement(0.1f);
        heightSlider.setRange(0.5f);
        heightSlider.setPrecision(1);
    }
    eyeHeightSlider = find("eye-height", UISlider.class);
    if (eyeHeightSlider != null) {
        eyeHeightSlider.setMinimum(0.5f);
        eyeHeightSlider.setIncrement(0.1f);
        eyeHeightSlider.setRange(1f);
        eyeHeightSlider.setPrecision(1);
    }
    language = find("language", UIDropdownScrollable.class);
    if (language != null) {
        SimpleUri menuUri = new SimpleUri("engine:menu");
        TranslationProject menuProject = translationSystem.getProject(menuUri);
        List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales());
        for (Locale languageExcluded : languagesExcluded) {
            locales.remove(languageExcluded);
        }
        Collections.sort(locales, ((Object o1, Object o2) -> (o1.toString().compareTo(o2.toString()))));
        language.setOptions(Lists.newArrayList(locales));
        // Set maximum number of options visible for scrolling
        language.setVisibleOptions(5);
        language.setOptionRenderer(new LocaleRenderer(translationSystem));
    }
    WidgetUtil.trySubscribe(this, "close", button -> triggerBackAnimation());
    IdentityIOHelper identityIOHelper = new IdentityIOHelper(context);
    WidgetUtil.trySubscribe(this, "importIdentities", button -> identityIOHelper.importIdentities());
    WidgetUtil.trySubscribe(this, "exportIdentities", button -> identityIOHelper.exportIdentities());
    WidgetUtil.trySubscribe(this, "storageServiceAction", widget -> {
        if (storageService.getStatus() == StorageServiceWorkerStatus.LOGGED_IN) {
            ThreeButtonPopup logoutPopup = getManager().pushScreen(ThreeButtonPopup.ASSET_URI, ThreeButtonPopup.class);
            logoutPopup.setMessage(translationSystem.translate("${engine:menu#storage-service-log-out}"), translationSystem.translate("${engine:menu#storage-service-log-out-popup}"));
            logoutPopup.setLeftButton(translationSystem.translate("${engine:menu#dialog-yes}"), () -> storageService.logout(true));
            logoutPopup.setCenterButton(translationSystem.translate("${engine:menu#dialog-no}"), () -> storageService.logout(false));
            logoutPopup.setRightButton(translationSystem.translate("${engine:menu#dialog-cancel}"), () -> {
            });
        } else if (storageService.getStatus() == StorageServiceWorkerStatus.LOGGED_OUT) {
            getManager().pushScreen(StorageServiceLoginPopup.ASSET_URI, StorageServiceLoginPopup.class);
        }
    });
    UIButton okButton = find("ok", UIButton.class);
    if (okButton != null) {
        okButton.subscribe(button -> {
            savePlayerSettings();
            triggerBackAnimation();
        });
        okButton.bindEnabled(new ReadOnlyBinding<Boolean>() {

            @Override
            public Boolean get() {
                return Strings.isNullOrEmpty(validateScreen());
            }
        });
        okButton.setTooltipDelay(0);
        okButton.bindTooltipString(new ReadOnlyBinding<String>() {

            @Override
            public String get() {
                return validateScreen();
            }
        });
    }
}
Also used : UILabel(org.terasology.rendering.nui.widgets.UILabel) Locale(java.util.Locale) UISlider(org.terasology.rendering.nui.widgets.UISlider) UIDropdownScrollable(org.terasology.rendering.nui.widgets.UIDropdownScrollable) SimpleUri(org.terasology.engine.SimpleUri) ArrayList(java.util.ArrayList) Texture(org.terasology.rendering.assets.texture.Texture) StorageServiceLoginPopup(org.terasology.rendering.nui.layers.mainMenu.StorageServiceLoginPopup) TranslationProject(org.terasology.i18n.TranslationProject) UIButton(org.terasology.rendering.nui.widgets.UIButton) UIText(org.terasology.rendering.nui.widgets.UIText) UIImage(org.terasology.rendering.nui.widgets.UIImage) ResourceUrn(org.terasology.assets.ResourceUrn) ThreeButtonPopup(org.terasology.rendering.nui.layers.mainMenu.ThreeButtonPopup)

Example 3 with SimpleUri

use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.

the class DisplayResolutionDependentFBOs method regenerateFbos.

private void regenerateFbos() {
    propertyChangeSupport.firePropertyChange(PRE_FBO_REGENERATION, 0, 1);
    for (SimpleUri urn : fboConfigs.keySet()) {
        FBOConfig fboConfig = getFboConfig(urn);
        fboConfig.setDimensions(fullScale.multiplyBy(fboConfig.getScale()));
        FBO.recreate(get(urn), getFboConfig(urn));
    }
    propertyChangeSupport.firePropertyChange(POST_FBO_REGENERATION, 0, 1);
// Note that the "old" and "new" values (0 and 1) in the above calls aren't actually
// used: they are only necessary to ensure that the event is fired up correctly.
}
Also used : FBOConfig(org.terasology.rendering.opengl.FBOConfig) SimpleUri(org.terasology.engine.SimpleUri)

Example 4 with SimpleUri

use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.

the class DisplayResolutionDependentFBOs method generateDefaultFBOs.

private void generateDefaultFBOs() {
    FBO gBuffer1 = generateWithDimensions(new FBOConfig(new SimpleUri("engine:fbo.gBuffer1"), FULL_SCALE, FBO.Type.HDR).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale);
    FBO gBuffer2 = generateWithDimensions(new FBOConfig(new SimpleUri("engine:fbo.gBuffer2"), FULL_SCALE, FBO.Type.HDR).useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale);
    generateWithDimensions(new FBOConfig(FINAL_BUFFER, FULL_SCALE, FBO.Type.DEFAULT), fullScale);
    gBufferPair = new SwappableFBO(gBuffer1, gBuffer2);
}
Also used : FBOConfig(org.terasology.rendering.opengl.FBOConfig) SwappableFBO(org.terasology.rendering.opengl.SwappableFBO) FBO(org.terasology.rendering.opengl.FBO) SwappableFBO(org.terasology.rendering.opengl.SwappableFBO) SimpleUri(org.terasology.engine.SimpleUri)

Example 5 with SimpleUri

use of org.terasology.engine.SimpleUri in project Terasology by MovingBlocks.

the class ImmutableFBOs method request.

@Override
public FBO request(FBOConfig fboConfig) {
    FBO fbo;
    SimpleUri fboName = fboConfig.getName();
    if (fboConfigs.containsKey(fboName)) {
        if (!fboConfig.equals(fboConfigs.get(fboName))) {
            throw new IllegalArgumentException("Requested FBO is already available with different configuration");
        }
        fbo = fboLookup.get(fboConfig.getName());
    } else {
        fbo = generateWithDimensions(fboConfig, fboConfig.getDimensions());
    }
    retain(fboName);
    return fbo;
}
Also used : FBO(org.terasology.rendering.opengl.FBO) SimpleUri(org.terasology.engine.SimpleUri)

Aggregations

SimpleUri (org.terasology.engine.SimpleUri)71 Test (org.junit.Test)18 Map (java.util.Map)10 Name (org.terasology.naming.Name)9 ResourceUrn (org.terasology.assets.ResourceUrn)7 DefaultClassMetadata (org.terasology.reflection.metadata.DefaultClassMetadata)7 Config (org.terasology.config.Config)6 Input (org.terasology.input.Input)6 FBO (org.terasology.rendering.opengl.FBO)6 ModuleManager (org.terasology.engine.module.ModuleManager)5 Command (org.terasology.logic.console.commandSystem.annotations.Command)5 ModuleEnvironment (org.terasology.module.ModuleEnvironment)5 List (java.util.List)4 DependencyResolver (org.terasology.module.DependencyResolver)4 ResolutionResult (org.terasology.module.ResolutionResult)4 UILabel (org.terasology.rendering.nui.widgets.UILabel)4 Lists (com.google.common.collect.Lists)3 IOException (java.io.IOException)3 Type (java.lang.reflect.Type)3 Locale (java.util.Locale)3