use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class LayerableConfig method imports.
/**
* Imports the layerable config from node.
*
* @param root The root reference (must not be <code>null</code>).
* @return The layerable data.
* @throws LionEngineException If unable to read node or invalid integer.
*/
public static LayerableConfig imports(Xml root) {
Check.notNull(root);
final Xml node = root.getChild(NODE_LAYERABLE);
final int layerRefresh = node.readInteger(ATT_REFRESH);
final int layerDisplay = node.readInteger(ATT_DISPLAY);
return new LayerableConfig(layerRefresh, layerDisplay);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class CollisionConfig method imports.
/**
* Create the collision data from node.
*
* @param configurer The configurer reference (must not be <code>null</code>).
* @return The collisions data.
* @throws LionEngineException If unable to read node.
*/
public static CollisionConfig imports(Configurer configurer) {
Check.notNull(configurer);
final Map<String, Collision> collisions = new HashMap<>(0);
for (final Xml node : configurer.getRoot().getChildren(NODE_COLLISION)) {
final String coll = node.readString(ATT_NAME);
final Collision collision = createCollision(node);
collisions.put(coll, collision);
}
return new CollisionConfig(collisions);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class LauncherConfig method imports.
/**
* Import the launcher data from node.
*
* @param node The node reference (must not be <code>null</code>).
* @return The launcher data.
* @throws LionEngineException If unable to read node.
*/
public static LauncherConfig imports(Xml node) {
Check.notNull(node);
final Collection<Xml> children = node.getChildren(LaunchableConfig.NODE_LAUNCHABLE);
final Collection<LaunchableConfig> launchables = new ArrayList<>(children.size());
for (final Xml launchable : children) {
launchables.add(LaunchableConfig.imports(launchable));
}
final int level = node.readInteger(0, ATT_RATE);
final int rate = node.readInteger(ATT_RATE);
return new LauncherConfig(level, rate, launchables);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class ProducerConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
public void testExportsImports() {
final ActionRef ref = new ActionRef("ref", false, new ArrayList<ActionRef>());
final ActionRef ref2 = new ActionRef("ref", false, Arrays.asList(ref));
final Collection<ActionRef> refs = Arrays.asList(new ActionRef("test", true, Arrays.asList(ref2)));
final Xml root = new Xml("test");
root.add(ActionsConfig.exports(refs));
final Media media = Medias.create("producer.xml");
root.save(media);
Assert.assertEquals(refs, ActionsConfig.imports(new Xml(media)));
Assert.assertEquals(refs, ActionsConfig.imports(new Configurer(media)));
Assert.assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class ProducerConfigTest method testCancelOnRef.
/**
* Test cancel flag is not used on child reference.
*/
@Test
public void testCancelOnRef() {
final ActionRef ref = new ActionRef("ref", true, new ArrayList<ActionRef>());
final Collection<ActionRef> refs = Arrays.asList(new ActionRef("test", false, Arrays.asList(ref)));
final Xml root = new Xml("test");
root.add(ActionsConfig.exports(refs));
final Media media = Medias.create("producer.xml");
root.save(media);
Assert.assertNotEquals(refs, ActionsConfig.imports(new Xml(media)));
Assert.assertNotEquals(refs, ActionsConfig.imports(new Configurer(media)));
Assert.assertTrue(media.getFile().delete());
}
Aggregations