Beispiel #1
0
        // 如果 Plist 文件不存在,则抛出 FileNotFoundException 异常
        // 如果不是合法的 PList 文件,则抛出 XTInvalidPListFileException 异常
        public static XTPListFile Create(string file, bool isCache = true)
        {
            XElement  root;
            XDocument doc = XDocument.Load(file);

            try
            {
                root = doc.Element("plist").Element("dict");
                XTPListXML.GetSubElement(root, "frames");                                               // 检测是否有贴图帧
                XTPListXML.GetSubElement(root, "metadata/textureFileName");                             // 检测贴图文件是否存在
            }
            catch
            {
                throw new XTInvalidPListFileException(file);
            }
            return(new XTPListFile(file, root, isCache));
        }
Beispiel #2
0
 public IEnumerable <XTFrame> IterFrames()
 {
     if (this.m_frames == null)
     {
         foreach (PListElement e in XTPListXML.IterSubElements(this.m_root, "frames"))
         {
             yield return(new XTFrame(e.Key, e.Value));
         }
     }
     else
     {
         XTFrame frame;
         foreach (PListElement e in XTPListXML.IterSubElements(this.m_root, "frames"))
         {
             if (!this.m_frames.TryGetValue(e.Key, out frame))
             {
                 frame = new XTFrame(e.Key, e.Value);
                 this.m_frames[e.Key] = frame;
             }
             yield return(frame);
         }
     }
 }
Beispiel #3
0
 public int GetFrameCount()
 {
     return(XTPListXML.GetSubElementCount(this.m_root, "frames"));
 }
Beispiel #4
0
 private bool GetBool(string key)
 {
     return(bool.Parse(XTPListXML.GetSubNodeName(this.m_root, key)));
 }
Beispiel #5
0
 private Rectangle GetRect(string key)
 {
     return(XTPListXML.ExplainRect(XTPListXML.GetSubElementValue(this.m_root, key)));
 }
Beispiel #6
0
 private Size GetSize(string key)
 {
     return(XTPListXML.ExplainSize(XTPListXML.GetSubElementValue(this.m_root, key)));
 }
Beispiel #7
0
 // ----------------------------------------------------------
 // private
 // ----------------------------------------------------------
 private string GetStr(string key)
 {
     return(XTPListXML.GetSubElementValue(this.m_root, key));
 }