protected override PListRoot OnToPlist(List <ImageInfo> imageList, Size size, string imageKey) { PListRoot plistRoot = new PListRoot(); PListDict plistDict1 = new PListDict(); plistRoot.Root = (IPListElement)plistDict1; PListDict plistDict2 = new PListDict(); plistDict1.Add("frames", (IPListElement)plistDict2); foreach (ImageInfo image in imageList) { PListDict plistDict3 = new PListDict(); plistDict2.Add(image.Name, (IPListElement)plistDict3); string str1 = PlistFormatHelp.ConvertToString(image.Bounding); plistDict3.Add("frame", (IPListElement) new PListString(str1)); string str2 = PlistFormatHelp.ConvertToString(new Point(image.SourceLocation.X + image.Bounding.Width / 2 - image.SourceSize.Width / 2, image.SourceSize.Height / 2 - (image.SourceLocation.Y + image.Bounding.Height / 2))); plistDict3.Add("offset", (IPListElement) new PListString(str2)); plistDict3.Add("rotated", (IPListElement) new PListBool(image.IsRotation)); string str3 = PlistFormatHelp.ConvertToString(image.SourceSize); plistDict3.Add("sourceSize", (IPListElement) new PListString(str3)); } PListDict plistDict4 = new PListDict(); plistDict1.Add("metadata", (IPListElement)plistDict4); plistDict4.Add("format", (IPListElement) new PListInteger(2L)); plistDict4.Add("textureFileName", (IPListElement) new PListString(imageKey)); plistDict4.Add("realTextureFileName", (IPListElement) new PListString(imageKey)); string str = "{" + (object)size.Width + "," + (object)size.Height + "}"; plistDict4.Add("size", (IPListElement) new PListString(str)); PListDict plistDict5 = new PListDict(); plistDict1.Add("texture", (IPListElement)plistDict5); plistDict5.Add("width", (IPListElement) new PListInteger((long)size.Width)); plistDict5.Add("height", (IPListElement) new PListInteger((long)size.Height)); return(plistRoot); }
public static string ConvertToString(Rectangle rect) { return("{" + PlistFormatHelp.ConvertToString(rect.Location) + "," + PlistFormatHelp.ConvertToString(rect.Size) + "}"); }