use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class PathfindableConfig method exportAllowedMovements.
/**
* Export the allowed movements.
*
* @param root The root node (must not be <code>null</code>).
* @param movements The movements node (must not be <code>null</code>).
*/
private static void exportAllowedMovements(Xml root, Collection<MovementTile> movements) {
for (final MovementTile movement : movements) {
final Xml node = root.createChild(NODE_MOVEMENT);
node.setText(movement.name());
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FramesConfig method exports.
/**
* Exports the frames node from config.
*
* @param config The config reference (must not be <code>null</code>).
* @return The frames node.
* @throws LionEngineException If unable to read node or invalid integer.
*/
public static Xml exports(FramesConfig config) {
Check.notNull(config);
final Xml node = new Xml(NODE_FRAMES);
node.writeInteger(ATT_HORIZONTAL, config.getHorizontal());
node.writeInteger(ATT_VERTICAL, config.getVertical());
node.writeInteger(ATT_OFFSET_X, config.getOffsetX());
node.writeInteger(ATT_OFFSET_Y, config.getOffsetY());
return node;
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class AnimationConfig method exports.
/**
* Create an XML node from an animation.
*
* @param root The node root (must not be <code>null</code>).
* @param animation The animation reference (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Xml root, Animation animation) {
Check.notNull(root);
Check.notNull(animation);
final Xml animations;
if (root.hasNode(NODE_ANIMATIONS)) {
animations = root.getChildXml(NODE_ANIMATIONS);
} else {
animations = root.createChild(NODE_ANIMATIONS);
}
final Xml node = animations.createChild(NODE_ANIMATION);
node.writeString(ANIMATION_NAME, animation.getName());
node.writeInteger(ANIMATION_START, animation.getFirst());
node.writeInteger(ANIMATION_END, animation.getLast());
node.writeDouble(ANIMATION_SPEED, animation.getSpeed());
node.writeBoolean(ANIMATION_REVERSED, animation.hasReverse());
node.writeBoolean(ANIMATION_REPEAT, animation.hasRepeat());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class MinimapConfig method exports.
/**
* Export tiles colors data to configuration media.
*
* @param configMinimap The configuration media output (must not be <code>null</code>).
* @param tiles The tiles data (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Media configMinimap, Map<Integer, ColorRgba> tiles) {
Check.notNull(configMinimap);
Check.notNull(tiles);
final Map<ColorRgba, Collection<Integer>> colors = convertToColorKey(tiles);
final Xml nodeMinimap = new Xml(NODE_MINIMAP);
for (final Map.Entry<ColorRgba, Collection<Integer>> entry : colors.entrySet()) {
final ColorRgba color = entry.getKey();
final Xml nodeColor = nodeMinimap.createChild(NODE_COLOR);
nodeColor.writeInteger(ATT_COLOR_RED, color.getRed());
nodeColor.writeInteger(ATT_COLOR_GREEN, color.getGreen());
nodeColor.writeInteger(ATT_COLOR_BLUE, color.getBlue());
for (final Integer number : entry.getValue()) {
final Xml nodeTile = TileConfig.exports(number.intValue());
nodeColor.add(nodeTile);
}
}
nodeMinimap.save(configMinimap);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class TileGroupsConfig method exports.
/**
* Export groups to configuration file.
*
* @param groupsConfig The export media (must not be <code>null</code>).
* @param groups The groups to export (must not be <code>null</code>).
* @throws LionEngineException If unable to write to media.
*/
public static void exports(Media groupsConfig, Iterable<TileGroup> groups) {
Check.notNull(groupsConfig);
Check.notNull(groups);
final Xml nodeGroups = new Xml(NODE_GROUPS);
nodeGroups.writeString(Constant.XML_HEADER, Constant.ENGINE_WEBSITE);
for (final TileGroup group : groups) {
exportGroup(nodeGroups, group);
}
nodeGroups.save(groupsConfig);
}
Aggregations