Example usage for com.badlogic.gdx.utils XmlWriter attribute

List of usage examples for com.badlogic.gdx.utils XmlWriter attribute

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils XmlWriter attribute.

Prototype

public XmlWriter attribute(String name, Object value) throws IOException 

Source Link

Usage

From source file:at.highstreeto.xnllayoutparser.element.base.ElementParserHelper.java

License:Apache License

public static void writeDefaultAttributes(XmlWriter writer, Actor actor) throws IOException {
    if (actor.getName() != null) {
        writer.attribute("name", actor.getName());
    }/*from  w  w w.j  a v  a  2s  .  co m*/
}

From source file:com.github.fauu.helix.editor.MapRegionWriter.java

License:Open Source License

public static void saveMapRegion(MapRegion mapRegion, FileHandle hmrFile) {
    final StringWriter stringWriter = new StringWriter();
    final XmlWriter xmlWriter = new XmlWriter(stringWriter);
    Writer outputWriter = null;//from  w w w. j av a  2  s  .co m

    stringWriter.write("<?xml version=\"1.0\"?>\n");

    try {
        xmlWriter.element("mapregion");
        xmlWriter.attribute("width", (int) mapRegion.getSize().x);
        xmlWriter.attribute("height", (int) mapRegion.getSize().y);
        xmlWriter.attribute("texturesetid", 0); // FIXME: TextureAtlas needs a wrapper after all I guess
        xmlWriter.attribute("geometrysetid", mapRegion.getGeometrySet().getId());

        xmlWriter.element("tiles");
        for (Tile tile : mapRegion.getTiles()) {
            xmlWriter.element("tile");
            xmlWriter.attribute("x", (int) tile.getPosition().x);
            xmlWriter.attribute("y", (int) tile.getPosition().y);
            xmlWriter.attribute("elevation", tile.getElevation());
            xmlWriter.attribute("textureid", tile.getTextureId());
            xmlWriter.attribute("geometryid", tile.getGeometryId());
            xmlWriter.attribute("facing", tile.getFacing().toString().toLowerCase());
            xmlWriter.attribute("type", tile.getType().toString().toLowerCase());
            xmlWriter.pop();
        }
        xmlWriter.pop();

        xmlWriter.element("objects");
        for (com.github.fauu.helix.core.Object object : mapRegion.getObjects()) {
            xmlWriter.element("object");
            xmlWriter.attribute("x", (int) object.getPosition().x);
            xmlWriter.attribute("y", (int) object.getPosition().y);
            xmlWriter.attribute("model", object.getModelName());
            xmlWriter.attribute("elevation", object.getElevation());
            xmlWriter.attribute("facing", object.getFacing().toString().toLowerCase());
            xmlWriter.pop();
        }
        xmlWriter.pop();

        xmlWriter.pop();

        outputWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(hmrFile.path())));

        outputWriter.write(stringWriter.toString());
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            outputWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.mangecailloux.pebble.constant.ConstantFloat.java

License:Apache License

@Override
protected void internalToXML(XmlWriter _xml) throws IOException {
    _xml.attribute("value", toString());
}

From source file:com.mangecailloux.pebble.directory.DirectoryElement.java

License:Apache License

/**
 * Convert the directoryElement to XML./*  w w  w .  j  a v a 2  s. co  m*/
* @param _xml XmlWriter to convert the directoryElement into XML.
* @throws IOException 
*/
protected void toXML(XmlWriter _xml) throws IOException {
    _xml.element("element");
    _xml.attribute("type", getClass().getName());
    _xml.attribute("name", name);
    internalToXML(_xml);
    _xml.pop();
}

From source file:com.nebula2d.editor.framework.components.AnimatedRenderer.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("currentAnim", currentAnim);
    for (Animation anim : animations)
        anim.build(sceneXml, assetsXml, sceneName);
}

From source file:com.nebula2d.editor.framework.components.Circle.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("r", r);
    sceneXml.pop();//from   w ww  .  ja v  a 2  s.c  om
}

From source file:com.nebula2d.editor.framework.components.SoundEffectSource.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("sfx", soundEffect.getBuildPath());
    assetsXml.element("asset").attribute("path", soundEffect.getBuildPath()).attribute("assetType", "SFX")
            .attribute("sceneName", sceneName);
    assetsXml.pop();/*from  w  ww  .  j av  a2 s  .c  o m*/
}

From source file:com.nebula2d.editor.framework.components.MusicSource.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("track", musicTrack.getBuildPath());
    assetsXml.element("asset").attribute("path", musicTrack.getBuildPath()).attribute("assetType", "MUSIC")
            .attribute("sceneName", sceneName);
    assetsXml.pop();//from   w ww. j  a  va2s .  co  m
}

From source file:com.nebula2d.editor.framework.components.BoundingBox.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("w", w).attribute("h", h);
    sceneXml.pop();//from  ww  w  . j a  v a  2  s .c  o  m
}

From source file:com.nebula2d.editor.framework.components.Collider.java

License:Open Source License

@Override
public void build(XmlWriter sceneXml, XmlWriter assetsXml, String sceneName) throws IOException {
    super.build(sceneXml, assetsXml, sceneName);
    sceneXml.attribute("isSensor", isSensor);
    shape.build(sceneXml, assetsXml, sceneName);
}