private static Dictionary <string, UsageGroup> ReadGroups(XmlDocument doc, Dictionary <string, AnimationDef> animDefs, Dictionary <string, CharSet> charDefs, Dictionary <string, TextDef> textDefs) { XmlNodeList groups = doc.SelectNodes("//group"); Dictionary <string, UsageGroup> groupDefinitions = new Dictionary <string, UsageGroup>(); foreach (XmlNode n in groups) { UsageGroup g = new UsageGroup() { Name = n.Attributes["name"].Value, // don't assign a parent to objects yet, it will be assigned at useGroup Objects = ReadUsage(animDefs, charDefs, textDefs, groupDefinitions, n, null) }; groupDefinitions.Add(g.Name, g); } return(groupDefinitions); }
private static List <Renderable> ReadUsage(Dictionary <string, AnimationDef> animDefs, Dictionary <string, CharSet> charsets, Dictionary <string, TextDef> textDefs, Dictionary <string, UsageGroup> groupDefs, XmlNode time, TimeBlock parent) { List <Renderable> objects = new List <Renderable>(); for (int i = 0; i < time.ChildNodes.Count; i++) { XmlNode use = time.ChildNodes[i]; if (use.Name.ToLower() == "useanim") { //AnimationDef aDef = (from ad in animDefs // where ad.Name == use.Attributes["name"].Value // select ad).ToList()[0]; Animation a = new Animation(parent, animDefs[use.Attributes["name"].Value]) { X = int.Parse(use.Attributes["x"].Value), Y = int.Parse(use.Attributes["y"].Value) }; ReadRenderableParams(i, use, a); // read animation attributes a.Attributes = ReadUsageAttributes(use); objects.Add(a); } else if (use.Name.ToLower() == "usetext") { //TextDef tDef = (from t in textDefs // where t.Name == use.Attributes["name"].Value // select t).ToList()[0]; TextDef tdef; if (use.Attributes["text"] != null && use.Attributes["charset"] != null) { tdef = new TextDef() { CharacterSet = charsets[use.Attributes["charset"].Value], Value = use.Attributes["text"].Value }; } else { tdef = textDefs[use.Attributes["name"].Value]; } Text txt = new Text(parent, tdef) { X = int.Parse(use.Attributes["x"].Value), Y = int.Parse(use.Attributes["y"].Value), }; ReadRenderableParams(i, use, txt); // read text attributes txt.Attributes = ReadUsageAttributes(use); objects.Add(txt); } else if (use.Name.ToLower() == "usegroup") { UsageGroup g = groupDefs[use.Attributes["name"].Value]; foreach (Renderable o in g.Objects) { Renderable oClone = o.Clone(); oClone.ParentBlock = parent; objects.Add(oClone); } } } return(objects); }