Example #1
0
        private static SpricerSpritesheet ParseText(string[] lines)
        {
            var spritesheet = new SpricerSpritesheet();

            SpricerSpritesheet.Group group = null;
            foreach (var line in lines.Select(x => x.Trim()))
            {
                if (line.StartsWith("#") || line.StartsWith("ColorKey"))
                {
                    continue;
                }

                if (line.StartsWith("["))
                {
                    var data = line.Substring(1).Split(']')[0].Split(':');
                    group = new SpricerSpritesheet.Group(data[1]);
                    spritesheet.Groups.Add(group);
                }
                else if (group != null)
                {
                    var data     = line.Split(':');
                    var index    = int.Parse(data[0]);
                    var position = data[1].Split(',');
                    var x        = int.Parse(position[0]);
                    var y        = int.Parse(position[1]);
                    var size     = data[2].Split(',');
                    var w        = int.Parse(size[0]);
                    var h        = int.Parse(size[1]);
                    group.Sprites.Add(new SpricerSpritesheet.Sprite(index, x, y, w, h));
                }
            }
            return(spritesheet);
        }
Example #2
0
 public static string Convert(SpricerSpritesheet spritesheet)
 {
     return(JsonConvert.SerializeObject(spritesheet.Groups));
 }