use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class TileGroupsConfig method importGroup.
/**
* Import the group from its node.
*
* @param nodeGroup The group node (must not be <code>null</code>).
* @return The imported group.
*/
private static TileGroup importGroup(XmlReader nodeGroup) {
final Collection<XmlReader> children = nodeGroup.getChildren(TileConfig.NODE_TILE);
final Set<Integer> tiles = new HashSet<>(children.size());
for (final XmlReader nodeTile : children) {
final Integer tile = Integer.valueOf(TileConfig.imports(nodeTile));
tiles.add(tile);
}
children.clear();
final String groupName = nodeGroup.getString(ATT_GROUP_NAME);
final TileGroupType groupType = nodeGroup.getEnum(TileGroupType.class, TileGroupType.NONE, ATT_GROUP_TYPE);
return new TileGroup(groupName, groupType, tiles);
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class TileSheetsConfig method importSheets.
/**
* Import the defined sheets.
*
* @param nodeSheets The sheets node (must not be <code>null</code>).
* @return The sheets filename.
*/
private static List<String> importSheets(XmlReader nodeSheets) {
final Collection<XmlReader> children = nodeSheets.getChildren(NODE_TILE_SHEET);
final List<String> sheets = new ArrayList<>(children.size());
for (final XmlReader nodeSheet : children) {
final String sheetFilename = nodeSheet.getText();
sheets.add(sheetFilename);
}
children.clear();
return sheets;
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class TileSheetsConfig method imports.
/**
* Import the sheets data from configuration.
*
* @param configSheets The file that define the sheets configuration (must not be <code>null</code>).
* @return The tile sheet configuration.
* @throws LionEngineException If unable to read data.
*/
public static TileSheetsConfig imports(Media configSheets) {
final XmlReader nodeSheets = new XmlReader(configSheets);
final XmlReader nodeTileSize = nodeSheets.getChild(NODE_TILE_SIZE);
final int tileWidth = nodeTileSize.getInteger(ATT_TILE_WIDTH);
final int tileHeight = nodeTileSize.getInteger(ATT_TILE_HEIGHT);
final List<String> sheets = importSheets(nodeSheets);
return new TileSheetsConfig(tileWidth, tileHeight, sheets);
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class LauncherConfig method imports.
/**
* Import the launcher data from configurer.
*
* @param configurer The configurer reference (must not be <code>null</code>).
* @return The launcher data.
* @throws LionEngineException If unable to read node.
*/
public static List<LauncherConfig> imports(Configurer configurer) {
Check.notNull(configurer);
final Collection<XmlReader> children = configurer.getRoot().getChildren(NODE_LAUNCHER);
final List<LauncherConfig> launchers = new ArrayList<>(children.size());
for (final XmlReader launcher : children) {
launchers.add(imports(launcher));
}
children.clear();
return launchers;
}
use of com.b3dgs.lionengine.XmlReader in project lionengine by b3dgs.
the class SpriteFontImpl method loadData.
/**
* Load characters data.
*
* @param mediaData The media data.
*/
private void loadData(Media mediaData) {
final XmlReader letters = new XmlReader(mediaData);
final Collection<XmlReader> children = letters.getChildren();
int id = 0;
for (final XmlReader node : children) {
final double width = node.getDouble("width");
final double height = node.getDouble("height");
final FontCharData data = new FontCharData(id, width, height);
final String c = node.getString("char");
fontData.put(Character.valueOf(c.charAt(0)), data);
id++;
}
children.clear();
}
Aggregations