Example #1
0
 private void ParseAllTemplates(XDocument doc)
 {
     Logger.WriteVerbose("Parsing template group elements ...");
     foreach (XElement item in from item in doc.Descendants("templategroup")
              select(item))
     {
         TgxTemplateGroup tgxTemplateGroup = TgxTemplateGroup.FromXml(item, this);
         if (tgxTemplateGroup != null)
         {
             TemplateGroups.Add(tgxTemplateGroup);
         }
     }
 }
Example #2
0
        public static TgxTemplateGroup FromXml(XElement xml, TmxMap map)
        {
            TgxTemplateGroup tgxTemplateGroup = new TgxTemplateGroup(map);

            tgxTemplateGroup.FirstTemplateId = TmxHelper.GetAttributeAsUInt(xml, "firsttid");
            tgxTemplateGroup.Source          = Path.GetFullPath(TmxHelper.GetAttributeAsString(xml, "source"));
            if (File.Exists(tgxTemplateGroup.Source))
            {
                using (new ChDir(tgxTemplateGroup.Source))
                {
                    XDocument xDocument = TmxMap.LoadDocument(tgxTemplateGroup.Source);
                    tgxTemplateGroup.ParseTemplateGroupXml(xDocument.Root);
                }
            }
            else
            {
                Logger.WriteError("Template group file does not exist: {0}", tgxTemplateGroup.Source);
            }
            tgxTemplateGroup.Templates.ForEach(delegate(TgxTemplate t)
            {
                map.Templates.Add(t.GlobalId, t);
            });
            return(tgxTemplateGroup);
        }