Search in sources :

Example 11 with SimpleUri

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

the class ReflectionUtil method getTypeUri.

public static String getTypeUri(Type type, ModuleEnvironment moduleEnvironment) {
    String typeSimpleName = typeToString(type, true);
    if (getRawType(type).getClassLoader() == null) {
        return typeSimpleName;
    }
    Name moduleProvidingType = moduleEnvironment.getModuleProviding(getRawType(type));
    if (moduleProvidingType == null) {
        return typeSimpleName;
    }
    return new SimpleUri(moduleProvidingType, typeSimpleName).toString();
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) Name(org.terasology.gestalt.naming.Name)

Example 12 with SimpleUri

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

the class ReflectionUtil method getFullyQualifiedSimpleUriFor.

/**
 * Returns the fully qualified {@link SimpleUri} for a type belonging to the {@link ModuleEnvironment}.
 * If the type does not belong to the module environment, null is returned.
 */
public static SimpleUri getFullyQualifiedSimpleUriFor(Type type, ModuleEnvironment environment) {
    Class<?> clazz = getRawType(type);
    if (clazz.getClassLoader() == null) {
        // Loaded with the bootstrap class loader, definitely not part of a module
        return null;
    }
    Name moduleProviding = environment.getModuleProviding(clazz);
    if (moduleProviding == null) {
        return null;
    }
    return new SimpleUri(moduleProviding, clazz.getTypeName());
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) Name(org.terasology.gestalt.naming.Name)

Example 13 with SimpleUri

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

the class GameDetailsScreen method getGeneralInfo.

private String getGeneralInfo(final GameInfo theGameInfo) {
    SimpleUri name = theGameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator();
    WorldGeneratorInfo wgi = worldGeneratorManager.getWorldGeneratorInfo(name);
    String display = "ERROR: generator " + name + " not found.";
    if (wgi != null) {
        display = wgi.getDisplayName();
    }
    return translationSystem.translate("${engine:menu#game-details-game-title} ") + theGameInfo.getManifest().getTitle() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-last-play}: ") + DATE_FORMAT.format(theGameInfo.getTimestamp()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-duration} ") + DateTimeHelper.getDeltaBetweenTimestamps(new Date(0).getTime(), theGameInfo.getManifest().getTime()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-seed} ") + theGameInfo.getManifest().getSeed() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-world-generator}: ") + '\t' + display;
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) Date(java.util.Date) WorldGeneratorInfo(org.terasology.engine.world.generator.internal.WorldGeneratorInfo)

Example 14 with SimpleUri

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

the class InputSettingsScreen method onClosed.

@Override
public void onClosed() {
    super.onClosed();
    bindsManager.registerBinds();
    // TODO: Find a better place to do this in.
    BindsConfig bindsConf = bindsManager.getBindsConfig();
    if (bindsConf != null) {
        bindsConf.getBinds(new SimpleUri("engine:tabbingUI")).stream().findFirst().ifPresent(input -> {
            TabbingManager.tabForwardInput = input;
        });
        bindsConf.getBinds(new SimpleUri("engine:tabbingModifier")).stream().findFirst().ifPresent(input -> {
            TabbingManager.tabBackInputModifier = input;
        });
        bindsConf.getBinds(new SimpleUri("engine:activate")).stream().findFirst().ifPresent(input -> {
            TabbingManager.activateInput = input;
        });
    }
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) BindsConfig(org.terasology.engine.config.BindsConfig)

Example 15 with SimpleUri

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

the class InputSettingsScreen method addInputSection.

private void addInputSection(InputCategory category, ColumnLayout layout, Map<SimpleUri, RegisterBindButton> inputsById) {
    if (category != null) {
        layout.addWidget(new UISpace(new Vector2i(0, 16)));
        UILabel categoryHeader = new UILabel(translationSystem.translate(category.displayName()));
        categoryHeader.setFamily("subheading");
        layout.addWidget(categoryHeader);
        Set<SimpleUri> processedBinds = Sets.newHashSet();
        for (String bindId : category.ordering()) {
            SimpleUri bindUri = new SimpleUri(bindId);
            if (bindUri.isValid()) {
                RegisterBindButton bind = inputsById.get(new SimpleUri(bindId));
                if (bind != null) {
                    addInputBindRow(bindUri, bind, layout);
                    processedBinds.add(bindUri);
                }
            }
        }
        List<ExtensionBind> extensionBindList = Lists.newArrayList();
        for (Map.Entry<SimpleUri, RegisterBindButton> bind : inputsById.entrySet()) {
            if (bind.getValue().category().equals(category.id()) && !processedBinds.contains(bind.getKey())) {
                extensionBindList.add(new ExtensionBind(bind.getKey(), bind.getValue()));
            }
        }
        Collections.sort(extensionBindList);
        for (ExtensionBind extension : extensionBindList) {
            addInputBindRow(extension.uri, extension.bind, layout);
        }
    }
}
Also used : UILabel(org.terasology.nui.widgets.UILabel) RegisterBindButton(org.terasology.engine.input.RegisterBindButton) SimpleUri(org.terasology.engine.core.SimpleUri) UISpace(org.terasology.nui.widgets.UISpace) Vector2i(org.joml.Vector2i) Map(java.util.Map)

Aggregations

SimpleUri (org.terasology.engine.core.SimpleUri)51 Name (org.terasology.gestalt.naming.Name)13 Map (java.util.Map)6 ModuleManager (org.terasology.engine.core.module.ModuleManager)6 FBO (org.terasology.engine.rendering.opengl.FBO)6 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)6 DependencyResolver (org.terasology.gestalt.module.dependencyresolution.DependencyResolver)6 ResolutionResult (org.terasology.gestalt.module.dependencyresolution.ResolutionResult)6 Config (org.terasology.engine.config.Config)5 BindableButton (org.terasology.engine.input.BindableButton)5 Module (org.terasology.gestalt.module.Module)5 Input (org.terasology.input.Input)5 Test (org.junit.jupiter.api.Test)4 RegisterBindButton (org.terasology.engine.input.RegisterBindButton)4 Lists (com.google.common.collect.Lists)3 List (java.util.List)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 GameManifest (org.terasology.engine.game.GameManifest)3 FboConfig (org.terasology.engine.rendering.opengl.FboConfig)3