use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class ProducerConfigTest method testImportNoNode.
/**
* Test import without node.
*/
@Test
public void testImportNoNode() {
final Media media = Medias.create("producer.xml");
final Xml root = new Xml("test");
root.save(media);
Assert.assertTrue(ActionsConfig.imports(new Xml(media)).isEmpty());
Assert.assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class RasterData method load.
/**
* Load raster data from node.
*
* @param root The raster node.
* @param color The raster color name.
* @return The raster data.
*/
public static RasterData load(Xml root, String color) {
final Xml node = root.getChild(color);
final int start = Integer.decode(node.readString(ATT_START)).intValue();
final int step = Integer.decode(node.readString(ATT_STEP)).intValue();
final int force = node.readInteger(ATT_FORCE);
final int amplitude = node.readInteger(ATT_AMPLITUDE);
final int offset = node.readInteger(ATT_OFFSET);
final int type = node.readInteger(ATT_TYPE);
return new RasterData(start, step, force, amplitude, offset, type);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class StateAnimationBasedTest method setUp.
/**
* Prepare test.
*/
@BeforeClass
public static void setUp() {
Medias.setResourcesDirectory(System.getProperty("java.io.tmpdir"));
media = Medias.create("animations.xml");
final Xml root = new Xml("test");
final Animation idle = new Animation("idle", 1, 2, 3.0, false, true);
AnimationConfig.exports(root, idle);
final Animation walk = new Animation("walk", 1, 2, 3.0, false, true);
AnimationConfig.exports(root, walk);
final Animation jump = new Animation("jump", 1, 2, 3.0, false, true);
AnimationConfig.exports(root, jump);
root.save(media);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class UtilActionnable method createAction.
/**
* Create a default action.
*
* @param description The description.
* @param rectangle The button.
* @return The temp media.
*/
public static Media createAction(String description, Rectangle rectangle) {
final Media media = Medias.create("action.xml");
final String name = "name";
final ActionConfig action = new ActionConfig(name, description, (int) rectangle.getX(), (int) rectangle.getY(), rectangle.getWidth(), rectangle.getHeight());
final Xml root = new Xml("test");
root.add(ActionConfig.exports(action));
root.save(media);
return media;
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class TileGroupsConfig method importGroup.
/**
* Import the group from its node.
*
* @param nodeGroup The group node (must not be <code>null</code>).
* @return The imported group.
*/
private static TileGroup importGroup(Xml nodeGroup) {
final Collection<Xml> children = nodeGroup.getChildren(TileConfig.NODE_TILE);
final Collection<TileRef> tiles = new ArrayList<>(children.size());
for (final Xml nodeTileRef : children) {
final TileRef tileRef = TileConfig.imports(nodeTileRef);
tiles.add(tileRef);
}
final String groupName = nodeGroup.readString(ATT_GROUP_NAME);
final TileGroupType groupType = TileGroupType.from(nodeGroup.readString(TileGroupType.NONE.name(), ATT_GROUP_TYPE));
return new TileGroup(groupName, groupType, tiles);
}
Aggregations