private ISectionViewer GetViewer(DRM.SectionType type, bool forceRaw) { if (forceRaw == true) { return(new RawViewer() { MdiParent = this.MdiParent }); } switch (type) { case DRM.SectionType.RenderResource: return(new TextureViewer() { MdiParent = this.MdiParent }); default: return(new RawViewer() { MdiParent = this.MdiParent }); } }
private void BuildTree() { this.entryTreeView.BeginUpdate(); this.entryTreeView.Nodes.Clear(); var root = new TreeNode(Path.GetFileName(this.FilePath)); root.ImageKey = "__DRM"; root.SelectedImageKey = "__DRM"; /* * var parents = new List<DRM.Section>(); * parents.AddRange(this.FileData.Sections); * * var children = new Dictionary<DRM.Section, List<DRM.Section>>(); * * foreach (var section in this.FileData.Sections) * { * children[section] = new List<DRM.Section>(); * * if (section.Resolver == null) * { * continue; * } * * foreach (var resolver in section.Resolver.Unknown1s) * { * var target = this.FileData.Sections[resolver.SectionIndex]; * * if (target != section && * children[section].Contains(target) == false) * { * parents.Remove(target); * children[section].Add(target); * } * } * * foreach (var resolver in section.Resolver.Unknown2s) * { * section.Data.Seek(resolver.PointerOffset, SeekOrigin.Begin); * var id = section.Data.ReadValueU32(); * * var target = this.FileData.Sections * .Single(t => t.Id == id && t.Type == (DRM.SectionType)resolver.SectionType); * * if (target != section && * children[section].Contains(target) == false) * { * parents.Remove(target); * children[section].Add(target); * } * } * * foreach (var resolver in section.Resolver.Unknown4s) * { * section.Data.Seek(resolver.PointerOffset, SeekOrigin.Begin); * var id = section.Data.ReadValueU32(); * * var target = this.FileData.Sections * .Single(t => t.Id == id && t.Type == (DRM.SectionType)resolver.SectionType); * * if (target != section && * children[section].Contains(target) == false) * { * parents.Remove(target); * children[section].Add(target); * } * } * } * * var queue = new Queue<KeyValuePair<DRM.Section, TreeNode>>(); * var done = new List<DRM.Section>(); * * foreach (var parent in parents) * { * queue.Enqueue(new KeyValuePair<DRM.Section, TreeNode>(parent, root)); * } * * while (queue.Count > 0) * { * var kv = queue.Dequeue(); * var section = kv.Key; * var parent = kv.Value; * * var typeName = section.Type.ToString(); * * var name = section.Id.ToString("X8"); * name += " : " + typeName; * name += string.Format(" [{0:X2} {1:X2} {2:X4} {3:X8}]", * section.Flags, * section.Unknown05, * section.Unknown06, * section.Unknown10); * * if (section.Data != null) * { * name += " (" + section.Data.Length.ToString() + ")"; * } * * var node = new TreeNode(name); * * if (this.entryTreeView.ImageList.Images.ContainsKey(typeName) == true) * { * node.ImageKey = typeName; * node.SelectedImageKey = typeName; * } * else * { * node.ImageKey = ""; * node.SelectedImageKey = ""; * } * * node.Tag = section; * parent.Nodes.Add(node); * * if (done.Contains(section) == false && * children.ContainsKey(section) == true) * { * foreach (var child in children[section]) * { * queue.Enqueue(new KeyValuePair<DRM.Section, TreeNode>(child, node)); * } * } * * done.Add(section); * } */ bool displayAll = string.Compare((string)filterTypeBox.SelectedItem, "All", true) == 0; DRM.SectionType filtered = (displayAll ? DRM.SectionType.Object : (DRM.SectionType)Enum.Parse(typeof(DRM.SectionType), (string)filterTypeBox.SelectedItem)); foreach (var section in this.FileData.Sections.OrderBy(s => s.Id)) { if (!displayAll && filtered != section.Type) { continue; } var typeName = section.Type.ToString(); var name = section.Id.ToString("X8"); name += " : " + typeName; name += string.Format(" [{0:X2} {1:X2} {2:X4} {3:X8}]", section.Flags, section.Unknown05, section.Unknown06, section.Unknown10); if (section.Data != null) { name += " (" + section.Data.Length.ToString() + ")"; } var node = new TreeNode(name); if (this.entryTreeView.ImageList.Images.ContainsKey(typeName) == true) { node.ImageKey = typeName; node.SelectedImageKey = typeName; } else { node.ImageKey = ""; node.SelectedImageKey = ""; } node.Tag = section; root.Nodes.Add(node); } this.entryTreeView.Nodes.Add(root); root.Expand(); this.entryTreeView.EndUpdate(); }