Search in sources :

Example 16 with Xml

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

the class FramesConfig method imports.

/**
 * Imports the frames config from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The frames data.
 * @throws LionEngineException If unable to read node or invalid integer.
 */
public static FramesConfig imports(Xml root) {
    Check.notNull(root);
    final Xml node = root.getChild(NODE_FRAMES);
    final int horizontals = node.readInteger(ATT_HORIZONTAL);
    final int verticals = node.readInteger(ATT_VERTICAL);
    final int offsetX = node.readInteger(0, ATT_OFFSET_X);
    final int offsetY = node.readInteger(0, ATT_OFFSET_Y);
    return new FramesConfig(horizontals, verticals, offsetX, offsetY);
}
Also used : Xml(com.b3dgs.lionengine.io.Xml)

Example 17 with Xml

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

the class SizeConfig method imports.

/**
 * Import the size data from configurer.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The size data.
 * @throws LionEngineException If unable to read node.
 */
public static SizeConfig imports(Xml root) {
    Check.notNull(root);
    final Xml node = root.getChild(NODE_SIZE);
    final int width = node.readInteger(ATT_WIDTH);
    final int height = node.readInteger(ATT_HEIGHT);
    return new SizeConfig(width, height);
}
Also used : Xml(com.b3dgs.lionengine.io.Xml)

Example 18 with Xml

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

the class ProducibleConfig method imports.

/**
 * Create the producible data from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The producible data.
 * @throws LionEngineException If unable to read node.
 */
public static ProducibleConfig imports(Xml root) {
    Check.notNull(root);
    final Xml node = root.getChild(NODE_PRODUCIBLE);
    final SizeConfig size = SizeConfig.imports(root);
    final int time = node.readInteger(ATT_STEPS);
    return new ProducibleConfig(time, size.getWidth(), size.getHeight());
}
Also used : Xml(com.b3dgs.lionengine.io.Xml) SizeConfig(com.b3dgs.lionengine.game.SizeConfig)

Example 19 with Xml

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

the class TileConfig method exports.

/**
 * Export the tile as a node.
 *
 * @param tileRef The tile to export (must not be <code>null</code>).
 * @return The exported node.
 * @throws LionEngineException If <code>null</code> argument or error on writing.
 */
public static Xml exports(TileRef tileRef) {
    Check.notNull(tileRef);
    final Xml node = new Xml(NODE_TILE);
    node.writeInteger(ATT_TILE_SHEET, tileRef.getSheet().intValue());
    node.writeInteger(ATT_TILE_NUMBER, tileRef.getNumber());
    return node;
}
Also used : Xml(com.b3dgs.lionengine.io.Xml)

Example 20 with Xml

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

the class Raster method load.

/**
 * Load raster from media.
 *
 * @param media The raster media (must not be <code>null</code>).
 * @return The raster channels data.
 * @throws LionEngineException If <code>null</code> argument or unable to read data.
 */
public static Raster load(Media media) {
    Check.notNull(media);
    final Xml root = new Xml(media);
    final RasterData dataRed = RasterData.load(root, CHANNEL_RED);
    final RasterData dataGreen = RasterData.load(root, CHANNEL_GREEN);
    final RasterData dataBlue = RasterData.load(root, CHANNEL_BLUE);
    return new Raster(dataRed, dataGreen, dataBlue);
}
Also used : Xml(com.b3dgs.lionengine.io.Xml)

Aggregations

Xml (com.b3dgs.lionengine.io.Xml)45 ArrayList (java.util.ArrayList)8 Media (com.b3dgs.lionengine.Media)6 HashMap (java.util.HashMap)6 TileRef (com.b3dgs.lionengine.game.feature.tile.TileRef)5 Test (org.junit.Test)4 LionEngineException (com.b3dgs.lionengine.LionEngineException)3 Collection (java.util.Collection)3 Map (java.util.Map)3 Animation (com.b3dgs.lionengine.Animation)2 ActionRef (com.b3dgs.lionengine.game.ActionRef)2 Configurer (com.b3dgs.lionengine.game.Configurer)2 HashSet (java.util.HashSet)2 ActionConfig (com.b3dgs.lionengine.game.ActionConfig)1 Orientation (com.b3dgs.lionengine.game.Orientation)1 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)1 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)1 BeforeClass (org.junit.BeforeClass)1