Search in sources :

Example 21 with Xml

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

the class LayerableConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final Xml root = new Xml("test");
    final LayerableConfig config = new LayerableConfig(0, 1);
    root.add(LayerableConfig.exports(config));
    final Media media = Medias.create("Object.xml");
    root.save(media);
    assertEquals(config, LayerableConfig.imports(new Xml(media)));
    assertEquals(config, LayerableConfig.imports(new Configurer(media)));
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 22 with Xml

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

the class SizeConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final SizeConfig config = new SizeConfig(16, 32);
    final Xml root = new Xml("test");
    root.add(SizeConfig.exports(config));
    final Media media = Medias.create("Object.xml");
    root.save(media);
    assertEquals(config, SizeConfig.imports(new Xml(media)));
    assertEquals(config, SizeConfig.imports(new Configurer(media)));
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Example 23 with Xml

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

the class FeaturableConfig method exportSetup.

/**
 * Export the featurable node from setup data.
 *
 * @param setup The setup name (must not be <code>null</code>).
 * @return The setup node.
 * @throws LionEngineException If unable to export node.
 */
public static Xml exportSetup(String setup) {
    Check.notNull(setup);
    final Xml node = new Xml(ATT_SETUP);
    node.setText(setup);
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 24 with Xml

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

the class ActionsConfig method exports.

/**
 * Export the action node from config.
 *
 * @param actions The allowed actions (must not be <code>null</code>).
 * @return The actions node.
 * @throws LionEngineException If unable to write node.
 */
public static Xml exports(Collection<ActionRef> actions) {
    Check.notNull(actions);
    final Xml node = new Xml(NODE_ACTIONS);
    for (final ActionRef action : actions) {
        final Xml nodeAction = node.createChild(NODE_ACTION_REF);
        nodeAction.writeString(ATT_PATH, action.getPath());
        if (action.hasCancel()) {
            nodeAction.writeBoolean(ATT_CANCEL, true);
        }
        if (action.hasCancel()) {
            nodeAction.writeBoolean(ATT_UNIQUE, true);
        }
        for (final ActionRef ref : action.getRefs()) {
            exports(nodeAction, ref);
        }
    }
    return node;
}
Also used : Xml(com.b3dgs.lionengine.Xml)

Example 25 with Xml

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

the class SizeConfig method exports.

/**
 * Export the size node from data.
 *
 * @param config The config reference (must not be <code>null</code>).
 * @return The size node.
 * @throws LionEngineException If unable to read node.
 */
public static Xml exports(SizeConfig config) {
    Check.notNull(config);
    final Xml node = new Xml(NODE_SIZE);
    node.writeInteger(ATT_WIDTH, config.getWidth());
    node.writeInteger(ATT_HEIGHT, config.getHeight());
    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