Search in sources :

Example 61 with SimpleUri

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

the class RenderTaskListGeneratorTest method testReducePersistingStateChangesEcho.

@Test
public void testReducePersistingStateChangesEcho() {
    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 echoNode = new EchoNode();
    echoNode.setUri(new SimpleUri("engine:echoNode"));
    orderedNodes.add(echoNode);
    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:echoNode (EchoNode)", taskList.get(5).toString().trim());
    assertEquals("SetName: bar", taskList.get(6).toString().trim());
    assertEquals("engine:echoNode (EchoNode)", taskList.get(7).toString().trim());
    assertEquals("----- engine:charlieNode (CharlieNode)", taskList.get(8).toString().trim());
    assertEquals("SetName: foo", taskList.get(9).toString().trim());
    assertEquals("engine:charlieNode (CharlieNode)", taskList.get(10).toString().trim());
    assertEquals("----- engine:deltaNode (DeltaNode)", taskList.get(11).toString().trim());
    assertEquals("SetName: delta", taskList.get(12).toString().trim());
    assertEquals("engine:deltaNode (DeltaNode)", taskList.get(13).toString().trim());
    assertEquals("SetName: bar", taskList.get(14).toString().trim());
}
Also used : SimpleUri(org.terasology.engine.SimpleUri) Test(org.junit.Test)

Example 62 with SimpleUri

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

the class RenderTaskListGeneratorTest method testSimpleReducePersistingStateChanges.

@Test
public void testSimpleReducePersistingStateChanges() {
    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);
    List<RenderPipelineTask> taskList = renderTaskListGenerator.generateFrom(orderedNodes);
    // Strictly speaking we don't need
    assertEquals("----- engine:alphaNode (AlphaNode)", taskList.get(0).toString().trim());
    // trimming MarkerTask.toString(),
    assertEquals("SetName: foo", taskList.get(1).toString().trim());
    // resulting in "----- <NodeName>"
    assertEquals("engine:alphaNode (AlphaNode)", taskList.get(2).toString().trim());
    // We just do it to avoid attracting
    assertEquals("----- engine:bravoNode (BravoNode)", taskList.get(3).toString().trim());
    // too much attention to it.
    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("SetName: bar", taskList.get(7).toString().trim());
}
Also used : SimpleUri(org.terasology.engine.SimpleUri) Test(org.junit.Test)

Example 63 with SimpleUri

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

the class CoreCommands method setLanguage.

/**
 * Change the UI language
 * @param langTag String containing language code to change
 * @return String containing language or if not recognized error message
 */
@Command(shortDescription = "Changes the UI language")
public String setLanguage(@CommandParam("language-tag") String langTag) {
    Locale locale = Locale.forLanguageTag(langTag);
    TranslationProject proj = translationSystem.getProject(new SimpleUri("engine:menu"));
    // Try if language exists
    if (proj.getAvailableLocales().contains(locale)) {
        config.getSystem().setLocale(locale);
        nuiManager.invalidate();
        String nat = translationSystem.translate("${engine:menu#this-language-native}", locale);
        String eng = translationSystem.translate("${engine:menu#this-language-English}", locale);
        return String.format("Language set to %s (%s)", nat, eng);
    } else {
        return "Unrecognized locale! Try one of: " + proj.getAvailableLocales();
    }
}
Also used : Locale(java.util.Locale) TranslationProject(org.terasology.i18n.TranslationProject) SimpleUri(org.terasology.engine.SimpleUri) Command(org.terasology.logic.console.commandSystem.annotations.Command) ConsoleCommand(org.terasology.logic.console.commandSystem.ConsoleCommand)

Example 64 with SimpleUri

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

the class LocalPlayerSystem method stopAutoMove.

/**
 * Auto move is disabled when the associated key is pressed again.
 * This cancels the simulated repeated key stroke for the forward input button.
 */
private void stopAutoMove() {
    List<Input> inputs = bindsManager.getBindsConfig().getBinds(new SimpleUri("engine:forwards"));
    Input forwardKey = getValidKey(inputs);
    if (forwardKey != null) {
        inputSystem.cancelSimulatedKeyStroke(forwardKey);
        isAutoMove = false;
    }
}
Also used : Input(org.terasology.input.Input) SimpleUri(org.terasology.engine.SimpleUri)

Example 65 with SimpleUri

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

the class PojoEventSystemTests method testChildEventReceivedByUnfilteredHandler.

@Test
public void testChildEventReceivedByUnfilteredHandler() {
    entity.addComponent(new IntegerComponent());
    TestEventHandler handler = new TestEventHandler();
    eventSystem.registerEvent(new SimpleUri("test:childEvent"), TestChildEvent.class);
    eventSystem.registerEventHandler(handler);
    TestChildEvent event = new TestChildEvent();
    eventSystem.send(entity, event);
    assertEquals(1, handler.unfilteredEvents.size());
}
Also used : IntegerComponent(org.terasology.entitySystem.stubs.IntegerComponent) 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