Search in sources :

Example 6 with XmlReader

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);
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader) HashSet(java.util.HashSet)

Example 7 with XmlReader

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;
}
Also used : ArrayList(java.util.ArrayList) XmlReader(com.b3dgs.lionengine.XmlReader)

Example 8 with XmlReader

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);
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader)

Example 9 with XmlReader

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;
}
Also used : ArrayList(java.util.ArrayList) XmlReader(com.b3dgs.lionengine.XmlReader)

Example 10 with XmlReader

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();
}
Also used : XmlReader(com.b3dgs.lionengine.XmlReader)

Aggregations

XmlReader (com.b3dgs.lionengine.XmlReader)45 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)12 LionEngineException (com.b3dgs.lionengine.LionEngineException)6 HashSet (java.util.HashSet)6 Collection (java.util.Collection)4 Xml (com.b3dgs.lionengine.Xml)2 Configurer (com.b3dgs.lionengine.game.Configurer)2 DeviceAxis (com.b3dgs.lionengine.io.DeviceAxis)2 DeviceMapper (com.b3dgs.lionengine.io.DeviceMapper)2 Set (java.util.Set)2 Animation (com.b3dgs.lionengine.Animation)1 Check (com.b3dgs.lionengine.Check)1 Constant (com.b3dgs.lionengine.Constant)1 AnimationConfig (com.b3dgs.lionengine.game.AnimationConfig)1 Feature (com.b3dgs.lionengine.game.Feature)1 Orientation (com.b3dgs.lionengine.game.Orientation)1 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)1 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)1 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)1