Пример #1
0
        public static Record ReadXML(string sourceFile, ElderScrollsPlugin master)
        {
            XDocument doc  = XDocument.Load(sourceFile);
            XElement  root = doc.Root;

            Record outRecord = Record.CreateRecord(root.Attribute("Tag").Value);

            outRecord.Flags = root.Element("Flags").ToEnum <RecordFlag>();
            outRecord.FormID.ReadXML(root.Element("FormID"), master);
            outRecord.FormVersion          = root.Element("FormVersion").ToUInt16();
            outRecord.compressionCorrupted = root.Element("CompressionCorrupted").ToBoolean();

            if (outRecord.compressionCorrupted)
            {
                outRecord.corruptedBytes = root.Element("CorruptedBytes").ToBytes();
            }
            else
            {
                outRecord.XMLPreProcessing(root, sourceFile);
                outRecord.ReadDataXML(root.Element("Subrecords"), master);
            }

            return(outRecord);
        }
Пример #2
0
 public override void ReadTypeDataXML(XElement element, ElderScrollsPlugin master)
 {
     CoordX = element.Element("Block").Element("X").ToInt16();
     CoordY = element.Element("Block").Element("Y").ToInt16();
 }
Пример #3
0
 public abstract void WriteDataXML(XElement ele, ElderScrollsPlugin master);
Пример #4
0
 public override void ReadTypeDataXML(XElement element, ElderScrollsPlugin master)
 {
     RecordType = element.Element("RecordType").Value;
 }
Пример #5
0
 public override XElement WriteTypeDataXML(ElderScrollsPlugin master)
 {
     return(new XElement("Block",
                         new XElement("X", CoordX),
                         new XElement("Y", CoordY)));
 }
Пример #6
0
 protected abstract void ReadDataXML(XElement ele, ElderScrollsPlugin master);
Пример #7
0
 public abstract void ReadTypeDataXML(XElement element, ElderScrollsPlugin master);
 public abstract void ReadXML(XElement ele, ElderScrollsPlugin master);
Пример #9
0
 public ESPReader(Stream stream, ElderScrollsPlugin plugin)
     : base(stream, Utility.WesternEncoding)
 {
     Plugin = plugin;
 }
Пример #10
0
 public override void ReadTypeDataXML(XElement element, ElderScrollsPlugin master)
 {
     Index = element.Element("Index").ToInt16();
 }
 public abstract void WriteXML(XElement root, ElderScrollsPlugin master);
Пример #12
0
 public override XElement WriteTypeDataXML(ElderScrollsPlugin master)
 {
     return(new XElement("Index", Index));
 }
Пример #13
0
 public override void ReadTypeDataXML(XElement element, ElderScrollsPlugin master)
 {
     Cell = new FormID();
     Cell.ReadXML(element.Element("Cell"), master);
 }
Пример #14
0
 public override void ReadTypeDataXML(XElement element, ElderScrollsPlugin master)
 {
     Topic = new FormID();
     Topic.ReadXML(element.Element("Topic"), master);
 }
Пример #15
0
 public virtual void WriteXML(XElement root, ElderScrollsPlugin master)
 {
     root.Add(new XAttribute("Tag", Tag));
     WriteDataXML(root, master);
 }
Пример #16
0
 public override void ReadTypeDataXML(XElement element, ElderScrollsPlugin master)
 {
     Worldspace = new FormID();
     Worldspace.ReadXML(element.Element("Worldspace"), master);
 }
Пример #17
0
 public virtual void ReadXML(XElement ele, ElderScrollsPlugin master)
 {
     Tag = ele.Attribute("Tag").Value;
     ReadDataXML(ele, master);
 }
Пример #18
0
 public override XElement WriteTypeDataXML(ElderScrollsPlugin master)
 {
     return(new XElement("RecordType", RecordType));
 }
Пример #19
0
        public static ElderScrollsPlugin ReadBinary(string file)
        {
            ElderScrollsPlugin outPlug = new ElderScrollsPlugin(Path.GetFileNameWithoutExtension(file), new Header());

            outPlug.FileName = Path.GetFileName(file);
            FileInfo fi = new FileInfo(file);

            outPlug.mmf = MemoryMappedFile.CreateFromFile(file, FileMode.Open, Path.GetFileNameWithoutExtension(file), fi.Length, MemoryMappedFileAccess.Read);

            using (MemoryMappedViewStream stream = outPlug.mmf.CreateViewStream(0, fi.Length, MemoryMappedFileAccess.Read))
                using (ESPReader reader = new ESPReader(stream, outPlug))
                {
                    outPlug.Header = new RecordView(reader, outPlug.mmf);

                    outPlug.Masters = new List <string>();

                    outPlug.ReadMasters();

                    outPlug.Masters.Add(outPlug.FileName);

                    Log("Beginning loading plugin " + outPlug.FileName, LogLevel.Plugin);

                    while (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        var group = Group.CreateGroup(reader);

                        group.GroupAdded      += (g) => outPlug.AllGroups.Add(g);
                        group.RecordViewAdded += (r) => outPlug.RecordViews.Add(r);

                        group.ReadBinary(reader, outPlug.mmf);

                        var index = outPlug.TopGroups.FindIndex(g => ((TopGroup)g).RecordType.Equals(((TopGroup)group).RecordType));
                        if (index > 0)
                        {
                            group.MergeGroup(outPlug.TopGroups[index]);
                        }
                        else
                        {
                            outPlug.TopGroups.Add(group);
                            outPlug.AllGroups.Add(group);
                        }
                    }
                    Log("Finished loading plugin " + outPlug.FileName, LogLevel.Plugin);
                }

            ElderScrollsPlugin.LoadedPlugins.Add(outPlug);

            foreach (RecordView view in outPlug.RecordViews)
            {
                LoadOrderFormID loID = new LoadOrderFormID(view.FormID, outPlug);

                Dictionary <uint, List <RecordView> > typeDict;
                List <RecordView> viewList;

                //add view to collection of all views
                if (!ElderScrollsPlugin.LoadedRecordViews.TryGetValue(loID.RawValue, out viewList))
                {
                    viewList = new List <RecordView>();
                    ElderScrollsPlugin.LoadedRecordViews.Add(loID.RawValue, viewList);
                }
                viewList.Add(view);

                //add view to categorized collection of all views
                string tag = view.Tag;
                if (!ElderScrollsPlugin.RecordViewsByType.TryGetValue(tag, out typeDict))
                {
                    typeDict = new Dictionary <uint, List <RecordView> >();
                    ElderScrollsPlugin.RecordViewsByType.Add(tag, typeDict);
                }
                if (!ElderScrollsPlugin.RecordViewsByType[tag].TryGetValue(loID.RawValue, out viewList))
                {
                    viewList = new List <RecordView>();
                    ElderScrollsPlugin.RecordViewsByType[tag].Add(loID.RawValue, viewList);
                }
                viewList.Add(view);
            }
            return(outPlug);
        }
Пример #20
0
 public abstract XElement WriteTypeDataXML(ElderScrollsPlugin master);