/// <summary>
    /// Import atlasData from sparrow xml
    /// </summary>
    protected override OTAtlasData[] Import()
    {
        if (!ValidXML())
        {
            return new OTAtlasData[] { }
        }
        ;

        List <OTAtlasData> data = new List <OTAtlasData>();

        if (xml.rootName == "font")
        {
            OTDataset dsInfo = xml.Dataset("info");

            if (!dsInfo.EOF)
            {
                if (dsInfo.AsString("face") != "")
                {
                    if (name.IndexOf("Container (id=") == 0)
                    {
                        name = "Font " + dsInfo.AsString("face") + "-" + dsInfo.AsString("size");
                        if (dsInfo.AsString("bold") == "1")
                        {
                            name += "b";
                        }
                        if (dsInfo.AsString("italic") == "1")
                        {
                            name += "i";
                        }
                    }

                    metaType = "FONT";
                    OTDataset dsChars = xml.Dataset("chars");
                    while (!dsChars.EOF)
                    {
                        OTAtlasData ad = new OTAtlasData();

                        ad.name     = "" + dsChars.AsInt("id");
                        ad.position = new Vector2(dsChars.AsInt("x"), dsChars.AsInt("y"));
                        ad.size     = new Vector2(dsChars.AsInt("width"), dsChars.AsInt("height"));
                        ad.offset   = new Vector2(dsChars.AsInt("xoffset"), dsChars.AsInt("yoffset"));

                        ad.AddMeta("dx", dsChars.AsString("xadvance"));
                        data.Add(ad);
                        dsChars.Next();
                    }
                }
            }
        }
        return(data.ToArray());
    }
    /// <summary>
    /// Import atlasData from sparrow xml
    /// </summary>
    protected override OTAtlasData[] Import()
    {
        if (!ValidXML())
        {
            return new OTAtlasData[] { }
        }
        ;

        List <OTAtlasData> data = new List <OTAtlasData>();

        if (xml.rootName == "Imageset")
        {
            OTDataset dsTextures = xml.Dataset("Image");

            while (!dsTextures.EOF)
            {
                OTAtlasData ad = new OTAtlasData();

                ad.name      = dsTextures.AsString("Name");
                ad.position  = new Vector2(dsTextures.AsInt("XPos"), dsTextures.AsInt("YPos"));
                ad.size      = new Vector2(dsTextures.AsInt("Width"), dsTextures.AsInt("Height"));
                ad.frameSize = new Vector2(dsTextures.AsInt("Width"), dsTextures.AsInt("Height"));
                ad.offset    = Vector2.zero;

                data.Add(ad);
                dsTextures.Next();
            }
        }
        return(data.ToArray());
    }
}
Beispiel #3
0
    /// <summary>
    /// Import atlasData from sparrow xml
    /// </summary>
    protected override OTAtlasData[] Import()
    {
        if (!ValidXML())
        {
            return new OTAtlasData[] { }
        }
        ;

        List <OTAtlasData> data = new List <OTAtlasData>();

        if (xml.rootName == "TextureAtlas")
        {
            OTDataset dsTextures = xml.Dataset("SubTexture");

            while (!dsTextures.EOF)
            {
                OTAtlasData ad = new OTAtlasData();

                ad.name      = dsTextures.AsString("name");
                ad.position  = new Vector2(dsTextures.AsInt("x"), dsTextures.AsInt("y"));
                ad.size      = new Vector2(dsTextures.AsInt("width"), dsTextures.AsInt("height"));
                ad.frameSize = new Vector2(dsTextures.AsInt("frameWidth"), dsTextures.AsInt("frameHeight"));
                ad.offset    = new Vector2(dsTextures.AsInt("frameX"), dsTextures.AsInt("frameY")) * -1;

                data.Add(ad);
                dsTextures.Next();
            }
        }
        return(data.ToArray());
    }
}