use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class TransitionsConfig method exports.
/**
* Export all transitions to media.
*
* @param media The export media output (must not be <code>null</code>).
* @param transitions The transitions reference (must not be <code>null</code>).
* @throws LionEngineException If error on export.
*/
public static void exports(Media media, Map<Transition, Collection<TileRef>> transitions) {
Check.notNull(media);
Check.notNull(transitions);
final Xml nodeTransitions = new Xml(NODE_TRANSITIONS);
for (final Map.Entry<Transition, Collection<TileRef>> entry : transitions.entrySet()) {
final Transition transition = entry.getKey();
final Xml nodeTransition = nodeTransitions.createChild(NODE_TRANSITION);
nodeTransition.writeString(ATTRIBUTE_TRANSITION_TYPE, transition.getType().name());
nodeTransition.writeString(ATTRIBUTE_GROUP_IN, transition.getIn());
nodeTransition.writeString(ATTRIBUTE_GROUP_OUT, transition.getOut());
exportTiles(nodeTransition, entry.getValue());
}
nodeTransitions.save(media);
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class CircuitsConfig method exportTiles.
/**
* Export all tiles for the circuit.
*
* @param nodeCircuit The circuit node (must not be <code>null</code>).
* @param tilesRef The circuit tiles ref.
*/
private static void exportTiles(Xml nodeCircuit, Collection<TileRef> tilesRef) {
for (final TileRef tileRef : tilesRef) {
final Xml nodeTileRef = TileConfig.exports(tileRef);
nodeCircuit.add(nodeTileRef);
}
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class ActionConfig method exports.
/**
* Export the action node from data.
*
* @param config The config reference (must not be <code>null</code>).
* @return The action node.
* @throws LionEngineException If unable to save.
*/
public static Xml exports(ActionConfig config) {
Check.notNull(config);
final Xml nodeAction = new Xml(NODE_ACTION);
nodeAction.writeString(ATT_NAME, config.getName());
nodeAction.writeString(ATT_DESCRIPTION, config.getDescription());
nodeAction.writeInteger(ATT_X, config.getX());
nodeAction.writeInteger(ATT_Y, config.getY());
nodeAction.writeInteger(ATT_WIDTH, config.getWidth());
nodeAction.writeInteger(ATT_HEIGHT, config.getHeight());
return nodeAction;
}
use of com.b3dgs.lionengine.io.Xml in project lionengine by b3dgs.
the class ActionConfig method imports.
/**
* Import the action data from node.
*
* @param root The root node reference (must not be <code>null</code>).
* @return The action data.
* @throws LionEngineException If unable to read node.
*/
public static ActionConfig imports(Xml root) {
Check.notNull(root);
final Xml nodeAction = root.getChild(NODE_ACTION);
final String name = nodeAction.readString(ATT_NAME);
final String description = nodeAction.readString(ATT_DESCRIPTION);
final int x = nodeAction.readInteger(ATT_X);
final int y = nodeAction.readInteger(ATT_Y);
final int width = nodeAction.readInteger(ATT_WIDTH);
final int height = nodeAction.readInteger(ATT_HEIGHT);
return new ActionConfig(name, description, x, y, width, height);
}
use of com.b3dgs.lionengine.io.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);
nodeAction.writeString(ATT_PATH, action.getPath());
if (action.hasCancel()) {
nodeAction.writeBoolean(ATT_CANCEL, true);
}
for (final ActionRef ref : action.getRefs()) {
exports(nodeAction, ref);
}
}
return node;
}
Aggregations