Search in sources :

Example 56 with SimpleUri

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

the class BindCommands method bindKey.

@Command(shortDescription = "Maps a key to a function", requiredPermission = PermissionManager.NO_PERMISSION)
public String bindKey(@CommandParam("key") String key, @CommandParam("function") String bind) {
    Input keyInput = Keyboard.Key.find(key);
    if (keyInput != null) {
        bindsManager.linkBindButtonToKey(keyInput.getId(), new SimpleUri(bind));
        StringBuilder builder = new StringBuilder();
        builder.append("Mapped ").append(keyInput.getDisplayName()).append(" to action ");
        builder.append(bind);
        return builder.toString();
    }
    throw new IllegalArgumentException("Unknown key: " + key);
}
Also used : Input(org.terasology.input.Input) SimpleUri(org.terasology.engine.SimpleUri) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 57 with SimpleUri

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

the class BehaviorNodeFactory method determineAnimationPoolUris.

private List<ComponentFieldUri> determineAnimationPoolUris() {
    final List<ComponentFieldUri> animationSetUris = Lists.newArrayList();
    for (ComponentMetadata<?> componentMetadata : componentLibrary.iterateComponentMetadata()) {
        SimpleUri uri = componentMetadata.getUri();
        for (FieldMetadata<?, ?> fieldMetadata : componentMetadata.getFields()) {
            if (fieldMetadata.getType().isAssignableFrom(List.class)) {
                Type fieldType = fieldMetadata.getField().getGenericType();
                if (fieldType instanceof ParameterizedType) {
                    ParameterizedType parameterizedType = (ParameterizedType) fieldType;
                    Type[] typeArguments = parameterizedType.getActualTypeArguments();
                    if (typeArguments.length == 1) {
                        Class<?> typeClass = ReflectionUtil.getClassOfType(typeArguments[0]);
                        if (typeClass.isAssignableFrom(MeshAnimation.class)) {
                            animationSetUris.add(new ComponentFieldUri(uri, fieldMetadata.getName()));
                        }
                    }
                }
            }
        }
    }
    return animationSetUris;
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) SimpleUri(org.terasology.engine.SimpleUri) ComponentFieldUri(org.terasology.engine.ComponentFieldUri)

Example 58 with SimpleUri

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

the class FlexibleConfigImpl method add.

/**
 * {@inheritDoc}
 */
@Override
public boolean add(Setting setting) {
    SimpleUri id = setting.getId();
    if (id == null) {
        LOGGER.warn("The id of a setting cannot be null.");
        return false;
    } else if (contains(id)) {
        LOGGER.warn("A Setting with the id \"{}\" already exists.", id);
        return false;
    }
    if (temporarilyParkedSettings.containsKey(id)) {
        setting.setValueFromJson(temporarilyParkedSettings.remove(id));
    }
    settings.put(id, setting);
    return true;
}
Also used : SimpleUri(org.terasology.engine.SimpleUri)

Example 59 with SimpleUri

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

the class FlexibleConfigManagerImpl method saveAllConfigs.

@Override
public void saveAllConfigs() {
    for (Entry<SimpleUri, FlexibleConfig> entry : flexibleConfigs.entrySet()) {
        SimpleUri flexibleConfigId = entry.getKey();
        FlexibleConfig flexibleConfig = entry.getValue();
        try (BufferedWriter writer = Files.newBufferedWriter(getPathForFlexibleConfig(flexibleConfigId), TerasologyConstants.CHARSET)) {
            flexibleConfig.save(writer);
        } catch (IOException e) {
            logger.error("Failed to save config", e);
        }
    }
}
Also used : SimpleUri(org.terasology.engine.SimpleUri) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 60 with SimpleUri

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

the class RenderTaskListGeneratorTest method testReducePersistingStateChanges.

@Test
public void testReducePersistingStateChanges() {
    RenderTaskListGenerator renderTaskListGenerator = new RenderTaskListGenerator();
    List<Node> orderedNodes = Lists.newArrayList();
    Node alphaNode = new AlphaNode();
    alphaNode.setUri(new SimpleUri("engine:alphaNode"));
    orderedNodes.add(alphaNode);
    Node bravoNode = new BravoNode();
    bravoNode.setUri(new SimpleUri("engine:bravoNode"));
    orderedNodes.add(bravoNode);
    Node charlieNode = new CharlieNode();
    charlieNode.setUri(new SimpleUri("engine:charlieNode"));
    orderedNodes.add(charlieNode);
    Node deltaNode = new DeltaNode();
    deltaNode.setUri(new SimpleUri("engine:deltaNode"));
    orderedNodes.add(deltaNode);
    List<RenderPipelineTask> taskList = renderTaskListGenerator.generateFrom(orderedNodes);
    assertEquals("----- engine:alphaNode (AlphaNode)", taskList.get(0).toString().trim());
    assertEquals("SetName: foo", taskList.get(1).toString().trim());
    assertEquals("engine:alphaNode (AlphaNode)", taskList.get(2).toString().trim());
    assertEquals("----- engine:bravoNode (BravoNode)", taskList.get(3).toString().trim());
    assertEquals("engine:bravoNode (BravoNode)", taskList.get(4).toString().trim());
    assertEquals("----- engine:charlieNode (CharlieNode)", taskList.get(5).toString().trim());
    assertEquals("engine:charlieNode (CharlieNode)", taskList.get(6).toString().trim());
    assertEquals("----- engine:deltaNode (DeltaNode)", taskList.get(7).toString().trim());
    assertEquals("SetName: delta", taskList.get(8).toString().trim());
    assertEquals("engine:deltaNode (DeltaNode)", taskList.get(9).toString().trim());
    assertEquals("SetName: bar", taskList.get(10).toString().trim());
}
Also used : SimpleUri(org.terasology.engine.SimpleUri) Test(org.junit.Test)

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