use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class CollisionConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Xml root = new Xml(Constant.XML_PREFIX + FeaturableConfig.NODE_FEATURABLE);
final Collision collision = new Collision("test", 0, 1, 2, 3, true);
CollisionConfig.exports(root, collision);
final Media media = Medias.create("collision.xml");
root.save(media);
final CollisionConfig config = CollisionConfig.imports(new Configurer(media));
final Collision imported = config.getCollision("test");
assertEquals("test", imported.getName());
assertEquals(0, imported.getOffsetX());
assertEquals(1, imported.getOffsetY());
assertEquals(2, imported.getWidth());
assertEquals(3, imported.getHeight());
assertTrue(imported.hasMirror());
assertFalse(config.getCollisions().isEmpty());
assertEquals(collision, config.getCollision("test"));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class UtilSetup method createMedia.
/**
* Create the object media.
*
* @param clazz The class type.
* @return The object media.
*/
public static Media createMedia(Class<?> clazz) {
final Xml root = new Xml("test");
root.add(FeaturableConfig.exportClass(clazz.getName()));
final Media media = Medias.create(clazz.getSimpleName() + ".xml");
root.save(media);
return media;
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class UtilTransformable method createMedia.
/**
* Create the object media.
*
* @param caller The caller class.
* @return The object media.
*/
public static Media createMedia(Class<?> caller) {
final Xml root = new Xml("test");
root.add(FeaturableConfig.exportClass(Featurable.class.getName()));
root.add(SizeConfig.exports(new SizeConfig(16, 32)));
final Media media = Medias.create("transformable_" + caller.getSimpleName() + Factory.FILE_DATA_DOT_EXTENSION);
root.save(media);
return media;
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class UtilSetup method createConfig.
/**
* Create a test configuration.
*
* @param caller The caller reference.
* @return The test configuration media.
*/
public static Media createConfig(Class<?> caller) {
final Xml root = new Xml(Constant.XML_PREFIX + "featurable");
final Media media = Medias.create("Object" + caller.getSimpleName() + Factory.FILE_DATA_DOT_EXTENSION);
root.save(media);
return media;
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class PathfindableConfigTest method testNoMovements.
/**
* Test without movements.
*/
@Test
void testNoMovements() {
final Map<String, PathData> map = new HashMap<>();
final PathData data = new PathData("category", 1.0, true, EnumSet.noneOf(MovementTile.class));
map.put(data.getName(), data);
final Xml root = new Xml("test");
root.add(PathfindableConfig.exports(map));
final Media media = Medias.create("pathfindable.xml");
root.save(media);
final Map<String, PathData> imported = PathfindableConfig.imports(new Configurer(media));
assertTrue(imported.get(data.getName()).getAllowedMovements().isEmpty());
assertEquals(map, imported);
assertTrue(media.getFile().delete());
}
Aggregations