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());
}
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());
}
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;
}
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;
}
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;
}
Aggregations