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());
}
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);
}
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;
}
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;
}
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);
}
Aggregations