use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class TileGroupsConfig method exportGroup.
/**
* Export the group data as a node.
*
* @param nodeGroups The root node (must not be <code>null</code>).
* @param group The group to export (must not be <code>null</code>).
*/
private static void exportGroup(Xml nodeGroups, TileGroup group) {
final Xml nodeGroup = nodeGroups.createChild(NODE_GROUP);
nodeGroup.writeString(ATT_GROUP_NAME, group.getName());
nodeGroup.writeEnum(ATT_GROUP_TYPE, group.getType());
for (final Integer tile : group.getTiles()) {
final Xml nodeTileRef = TileConfig.exports(tile.intValue());
nodeGroup.add(nodeTileRef);
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class TileSheetsConfig method exports.
/**
* Export the sheets configuration.
*
* @param configSheets The export media (must not be <code>null</code>).
* @param tileWidth The tile width.
* @param tileHeight The tile height.
* @param sheets The sheets filename (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Media configSheets, int tileWidth, int tileHeight, List<String> sheets) {
Check.notNull(configSheets);
Check.notNull(sheets);
final Xml nodeSheets = new Xml(NODE_TILE_SHEETS);
nodeSheets.writeString(Constant.XML_HEADER, Constant.ENGINE_WEBSITE);
final Xml tileSize = nodeSheets.createChild(NODE_TILE_SIZE);
tileSize.writeString(ATT_TILE_WIDTH, String.valueOf(tileWidth));
tileSize.writeString(ATT_TILE_HEIGHT, String.valueOf(tileHeight));
exportSheets(nodeSheets, sheets);
nodeSheets.save(configSheets);
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class TileSheetsConfig method exportSheets.
/**
* Export the defined sheets.
*
* @param nodeSheets Sheets node (must not be <code>null</code>).
* @param sheets Sheets defined (must not be <code>null</code>).
*/
private static void exportSheets(Xml nodeSheets, List<String> sheets) {
for (final String sheet : sheets) {
final Xml nodeSheet = nodeSheets.createChild(NODE_TILE_SHEET);
nodeSheet.setText(sheet);
}
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FeaturableModelTest method testAddFeatures.
/**
* Test the add features.
*/
@Test
void testAddFeatures() {
final Media media = Medias.create("Features.xml");
final Xml root = new Xml(FeaturableConfig.NODE_FEATURABLE);
final Xml unknown = root.createChild(FeaturableConfig.NODE_FEATURE);
unknown.setText(MyFeature.class.getName());
root.save(media);
Featurable featurable = new FeaturableModel(new Services(), new Setup(media));
featurable.checkListener(featurable);
assertEquals(media, featurable.getMedia());
for (final Feature next : featurable.getFeatures()) {
assertTrue(MyFeature.class.equals(next.getClass()) || Identifiable.class.isAssignableFrom(next.getClass()) || Recycler.class.isAssignableFrom(next.getClass()), next.getClass().getName());
}
featurable = new FeaturableModel(new Services(), new Setup(media));
UtilFile.deleteFile(media.getFile());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ActionConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final ActionConfig action = new ActionConfig("name", "description", 0, 1, 16, 32);
final Xml root = new Xml("test");
root.add(ActionConfig.exports(action));
final Media media = Medias.create("action.xml");
root.save(media);
assertEquals(action, ActionConfig.imports(new Xml(media)));
assertEquals(action, ActionConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
Aggregations