Search in sources :

Example 11 with Xml

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

the class MapTileCollisionModel method loadCollisionGroups.

/**
 * Load the collision groups. All previous groups will be cleared.
 *
 * @param groupsConfig The configuration collision groups file.
 */
private void loadCollisionGroups(Media groupsConfig) {
    Verbose.info(INFO_LOAD_GROUPS, groupsConfig.getFile().getPath());
    this.groupsConfig = groupsConfig;
    final Xml nodeGroups = new Xml(groupsConfig);
    final CollisionGroupConfig config = CollisionGroupConfig.imports(nodeGroups, this);
    loadCollisionGroups(config);
}
Also used : Xml(com.b3dgs.lionengine.io.Xml)

Example 12 with Xml

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

the class TransitionsConfig method importTiles.

/**
 * Import all tiles from their nodes.
 *
 * @param nodesTileRef The tiles nodes (must not be <code>null</code>).
 * @return The imported tiles ref.
 */
private static Collection<TileRef> importTiles(Collection<Xml> nodesTileRef) {
    final Collection<TileRef> tilesRef = new HashSet<>(nodesTileRef.size());
    for (final Xml nodeTileRef : nodesTileRef) {
        final TileRef tileRef = TileConfig.imports(nodeTileRef);
        tilesRef.add(tileRef);
    }
    return tilesRef;
}
Also used : Xml(com.b3dgs.lionengine.io.Xml) TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef) HashSet(java.util.HashSet)

Example 13 with Xml

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

the class TransitionsConfig method exportTiles.

/**
 * Export all tiles for the transition.
 *
 * @param nodeTransition The transition node (must not be <code>null</code>).
 * @param tilesRef The transition tiles ref (must not be <code>null</code>).
 */
private static void exportTiles(Xml nodeTransition, Collection<TileRef> tilesRef) {
    for (final TileRef tileRef : tilesRef) {
        final Xml nodeTileRef = TileConfig.exports(tileRef);
        nodeTransition.add(nodeTileRef);
    }
}
Also used : Xml(com.b3dgs.lionengine.io.Xml) TileRef(com.b3dgs.lionengine.game.feature.tile.TileRef)

Example 14 with Xml

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

the class ActionsConfig method exports.

/**
 * Export the action.
 *
 * @param node The xml node (must not be <code>null</code>).
 * @param action The action to export (must not be <code>null</code>).
 * @throws LionEngineException If unable to write node.
 */
private static void exports(Xml node, ActionRef action) {
    final Xml nodeAction = node.createChild(NODE_ACTION);
    nodeAction.writeString(ATT_PATH, action.getPath());
    for (final ActionRef ref : action.getRefs()) {
        exports(nodeAction, ref);
    }
}
Also used : Xml(com.b3dgs.lionengine.io.Xml)

Example 15 with Xml

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

the class AnimationConfig method imports.

/**
 * Create the animation data from configurer.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The animations configuration instance.
 * @throws LionEngineException If unable to read data.
 */
public static AnimationConfig imports(Xml root) {
    Check.notNull(root);
    final Map<String, Animation> animations = new HashMap<>(0);
    for (final Xml node : root.getChildren(ANIMATION)) {
        final String anim = node.readString(ANIMATION_NAME);
        final Animation animation = createAnimation(node);
        animations.put(anim, animation);
    }
    return new AnimationConfig(animations);
}
Also used : HashMap(java.util.HashMap) Xml(com.b3dgs.lionengine.io.Xml) Animation(com.b3dgs.lionengine.Animation)

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