Search in sources :

Example 36 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class LauncherConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final LaunchableConfig launchable = new LaunchableConfig("media", "sfx", 10, 1, 2, new Force(1.0, 2.0));
    final LauncherConfig launcher = new LauncherConfig(10, 10, true, Arrays.asList(launchable));
    final Xml root = new Xml("test");
    root.add(LauncherConfig.exports(launcher));
    final Media media = Medias.create("launcher.xml");
    root.save(media);
    assertEquals(launcher, LauncherConfig.imports(new Xml(media).getChild(LauncherConfig.NODE_LAUNCHER)));
    assertEquals(Arrays.asList(launcher), LauncherConfig.imports(new Configurer(media)));
    assertTrue(media.getFile().delete());
}
Also used : Force(com.b3dgs.lionengine.game.Force) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 37 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class UtilLaunchable method createLauncherMedia.

/**
 * Create the media.
 *
 * @param launchableMedia The launchable.
 * @param delay The desired delay.
 * @return The media.
 */
public static Media createLauncherMedia(Media launchableMedia, int delay) {
    final Media media = Medias.create("launcher.xml");
    final LaunchableConfig launchableConfig = new LaunchableConfig(launchableMedia.getPath(), null, delay, 1, 2, new Force(1.0, 2.0));
    final LauncherConfig launcherConfig = new LauncherConfig(0, 10, false, Arrays.asList(launchableConfig));
    final Xml root = new Xml("test");
    root.add(LauncherConfig.exports(launcherConfig));
    root.add(LauncherConfig.exports(new LauncherConfig(1, 50, false, Arrays.asList(launchableConfig))));
    root.save(media);
    return media;
}
Also used : Force(com.b3dgs.lionengine.game.Force) Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media)

Example 38 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class TileConfigTest method testExports.

/**
 * Test exports.
 */
@Test
void testExports() {
    final int number = 1;
    final Xml nodeTile = TileConfig.exports(number);
    assertEquals(number, nodeTile.getInteger(TileConfig.ATT_TILE_NUMBER));
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 39 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class StateConfigTest method testNoNode.

/**
 * Test with no node.
 */
@Test
void testNoNode() {
    final Xml root = new Xml("test");
    assertFalse(StateConfig.imports(root).isPresent());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 40 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class OriginConfig method exports.

/**
 * Export the node from config.
 *
 * @param origin The origin reference (must not be <code>null</code>).
 * @return The node.
 * @throws LionEngineException If unable to write node.
 */
public static Xml exports(Origin origin) {
    Check.notNull(origin);
    final Xml node = new Xml(NODE_ORIGIN);
    node.setText(origin.name());
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Aggregations

Xml (com.b3dgs.lionengine.Xml)133 Test (org.junit.jupiter.api.Test)73 Media (com.b3dgs.lionengine.Media)63 Configurer (com.b3dgs.lionengine.game.Configurer)25 Setup (com.b3dgs.lionengine.game.feature.Setup)11 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 Animation (com.b3dgs.lionengine.Animation)4 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)4 Feature (com.b3dgs.lionengine.game.Feature)3 Force (com.b3dgs.lionengine.game.Force)3 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)3 Services (com.b3dgs.lionengine.game.feature.Services)3 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)3 Map (java.util.Map)3 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 Origin (com.b3dgs.lionengine.Origin)1 UtilAssert.assertThrows (com.b3dgs.lionengine.UtilAssert.assertThrows)1 XmlReader (com.b3dgs.lionengine.XmlReader)1 Orientation (com.b3dgs.lionengine.game.Orientation)1