Search in sources :

Example 1 with Player

use of limelight.model.api.Player in project limelight by slagyr.

the class JavaPlayerTest method onCastEvent.

@Test
public void onCastEvent() throws Exception {
    final Document doc = Xml.stringToDoc("<player class='SamplePlayer'><onCast>sampleActionWithEvent</onCast></player>");
    final Player player = new JavaPlayer("foo", "/testProduction/aScene/players/foo.xml", samplePlayerClass, doc.getDocumentElement(), "limelight.ui.events.panel.");
    player.cast(prop);
    assertEquals(0, prop.getEventHandler().getActions(CastEvent.class).size());
    assertEquals(1, samplePlayerClass.getField("invocations").get(lastSamplePlayer()));
    assertEquals(CastEvent.class, samplePlayerClass.getField("event").get(lastSamplePlayer()).getClass());
}
Also used : Player(limelight.model.api.Player) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 2 with Player

use of limelight.model.api.Player in project limelight by slagyr.

the class JavaPlayerTest method applyOptions.

@Test
public void applyOptions() throws Exception {
    final Thing thing = new Thing();
    prop.getBackstage().put("thing", thing);
    final Player player = new JavaPlayer("thing", "path", null, null, null);
    Map<String, Object> result = player.applyOptions(prop, Opts.with("value", 1234));
    assertEquals(0, result.size());
    assertEquals(1234, thing.value);
}
Also used : Player(limelight.model.api.Player) Test(org.junit.Test)

Example 3 with Player

use of limelight.model.api.Player in project limelight by slagyr.

the class CastingDirector method castFrom.

private Player castFrom(PropPanel panel, String playerName, PlayerRecruiter playerRecruiter, String playersPath) {
    String normalizedName = StringUtil.spearCase(playerName);
    if (playerRecruiter.canRecruit(normalizedName, playersPath)) {
        final Player player = playerRecruiter.recruitPlayer(normalizedName, playersPath);
        player.cast(panel);
        panel.addPlayer(player);
        return player;
    }
    return null;
}
Also used : Player(limelight.model.api.Player)

Example 4 with Player

use of limelight.model.api.Player in project limelight by slagyr.

the class CastingDirector method castRole.

public Player castRole(PropPanel panel, String playerName, PlayerRecruiter playerRecruiter) {
    Player result;
    final Scene scene = panel.getRoot();
    final String scenePlayersPath = Context.fs().pathTo(scene.getPath(), "players");
    result = castFrom(panel, playerName, playerRecruiter, scenePlayersPath);
    if (result == null && scene.getProduction() != null) {
        final String productionPlayersPath = Context.fs().pathTo(scene.getProduction().getPath(), "players");
        result = castFrom(panel, playerName, playerRecruiter, productionPlayersPath);
    }
    if (result == null)
        result = castFrom(panel, playerName, builtinPlayerRecruiter, BuiltinBeacon.getBuiltinPlayersPath());
    return result;
}
Also used : Player(limelight.model.api.Player) Scene(limelight.ui.model.Scene)

Example 5 with Player

use of limelight.model.api.Player in project limelight by slagyr.

the class JavaPlayerRecruiterTest method cachesKnownPlayers.

@Test
public void cachesKnownPlayers() throws Exception {
    JavaProductionTest.writeSamplePlayerTo(fs.outputStream("/testProduction/classes/SamplePlayer.class"));
    fs.createTextFile("/testProduction/aScene/players/foo.xml", "<player class='SamplePlayer'/>");
    final Player player1 = recruiter.recruitPlayer("foo", "/testProduction/aScene/players");
    final Player player2 = recruiter.recruitPlayer("foo", "/testProduction/aScene/players");
    assertSame(player1, player2);
}
Also used : Player(limelight.model.api.Player) Test(org.junit.Test)

Aggregations

Player (limelight.model.api.Player)6 Test (org.junit.Test)4 Document (org.w3c.dom.Document)2 MouseClickedEvent (limelight.ui.events.panel.MouseClickedEvent)1 Scene (limelight.ui.model.Scene)1