public CryXmlTextFileViewModel(IFile file)
        {
            XmlDocument x;

            using (var s = file.Read())
            {
                x = CryXmlSerializer.ReadStream(s);
            }

            StringBuilder text = new StringBuilder();

            using (TextWriter writer = new StringWriter(text))
            {
                x.Save(writer);
            }

            var p = new Paragraph {
                FontFamily = new FontFamily("Consolas"), FontSize = 10
            };

            p.Inlines.Add(text.ToString());
            var doc = new FlowDocument(p);

            Document = doc;
        }
        public void ReadFile_SCXmlFile()
        {
            string filename = $@"{userHome}\OneDrive\ResourceFiles\SC\asteroid_hangar_landingpad_medium.xmla";

            XmlDocument xml = CryXmlSerializer.ReadFile(filename, true);
            //TODO:  Complete this
        }
        public override void Read(BinaryReader b)
        {
            base.Read(b);

            var bytesToRead = (Int32)(this.Size - Math.Max(b.BaseStream.Position - this.Offset, 0));

            var buffer = b.ReadBytes(bytesToRead);

            using (var memoryStream = new MemoryStream(buffer))
            {
                this.Data = CryXmlSerializer.ReadStream(memoryStream);
            }
        }
        /// <summary>
        /// Open xml and CryXml file.
        /// </summary>
        /// <param name="uri"></param>
        /// <returns></returns>
        public static XDocument Load(string uri)
        {
            XDocument xDoc = new XDocument();

            System.Xml.XmlDocument xmlDoc = CryXmlSerializer.ReadFile(uri);

            if (xmlDoc != null)
            {
                string     xmlString = xmlDoc.InnerXml;
                TextReader tr        = new StringReader(xmlString);
                xDoc = XDocument.Load(tr);
            }
            else
            {
                xDoc = XDocument.Load(uri);
            }

            return(xDoc);
        }
 public SCOC_Entities(byte[] xmlStream)
 {
     using (MemoryStream stream = new MemoryStream(xmlStream))
     {
         using (BinaryReader br = new BinaryReader(stream))
         {
             if (IsSerialized(br))
             {
                 serializedXML = new byte[xmlStream.Length];
                 serializedXML = xmlStream;
                 isSerialized  = true;
             }
             else
             {
                 xml = Encoding.UTF8.GetString(xmlStream);
             }
         }
     }
     if (isSerialized)
     {
         xml = CryXmlSerializer.ReadBytes(xmlStream).InnerXml;
     }
 }
Beispiel #6
0
        public static void CheckScripts(Int64 build, String manifestFile)
        {
            var scripts = HoloXPLOR_App.Scripts;

            HoloXPLOR_App._scriptsPath = HostingEnvironment.MapPath(String.Format("~/App_Data/Scripts-{0}", build));

            if (!Directory.Exists(HoloXPLOR_App._scriptsPath))
            {
                Directory.CreateDirectory(HoloXPLOR_App._scriptsPath);
            }

            if (!File.Exists(Path.Combine(HoloXPLOR_App._scriptsPath, "game.xml")))
            {
                using (WebClient client = new WebClient())
                {
                    // client.DownloadFile(manifestFile, Path.Combine(scriptsPath, String.Format("{0}.json", build)));
                    var manifest = client.DownloadString(manifestFile).FromJSON <Manifest>();

                    #region Download DataXML.pak

                    using (Stream pakStream = client.OpenRead(String.Format("{0}/{1}/{2}", manifest.WebseedUrls[HoloXPLOR_App._random.Next(manifest.WebseedUrls.Length)], manifest.KeyPrefix, "Data/DataXML.pak")))
                    {
                        using (var zipStream = new ZipInputStream(pakStream))
                        {
                            ZipEntry zipEntry = zipStream.GetNextEntry();
                            while (zipEntry != null)
                            {
                                String entryFileName = zipEntry.Name;

                                if (entryFileName.StartsWith("Scripts"))
                                {
                                    String fullZipToPath = Path.Combine(HoloXPLOR_App._scriptsPath, entryFileName).Replace(@"\Scripts\", @"\");
                                    String directoryName = Path.GetDirectoryName(fullZipToPath);

                                    if (directoryName.Length > 0)
                                    {
                                        Directory.CreateDirectory(directoryName);
                                    }

                                    using (var ms = new MemoryStream())
                                    {
                                        zipStream.CopyTo(ms);

                                        ms.Seek(0, SeekOrigin.Begin);

                                        var xml = CryXmlSerializer.ReadStream(ms);
                                        xml.Save(fullZipToPath);
                                    }
                                }

                                zipEntry = zipStream.GetNextEntry();
                            }
                        }
                    }

                    #endregion

                    #region Download GameData.pak

                    using (Stream pakStream = client.OpenRead(String.Format("{0}/{1}/{2}", manifest.WebseedUrls[HoloXPLOR_App._random.Next(manifest.WebseedUrls.Length)], manifest.KeyPrefix, "Data/GameData.pak")))
                    {
                        using (var zipStream = new ZipInputStream(pakStream))
                        {
                            ZipEntry zipEntry = zipStream.GetNextEntry();
                            while (zipEntry != null)
                            {
                                String entryFileName = zipEntry.Name;

                                if (entryFileName.EndsWith(".dcb"))
                                {
                                    String fullZipToPath = Path.Combine(HoloXPLOR_App._scriptsPath, "game.xml");

                                    using (var ms = new MemoryStream())
                                    {
                                        zipStream.CopyTo(ms);
                                        ms.Seek(0, SeekOrigin.Begin);

                                        using (var br = new BinaryReader(ms))
                                        {
                                            var df = new DataForge.DataForge(br);
                                            // df.GenerateXML();
                                            df.Save(fullZipToPath);
                                        }
                                    }
                                }

                                zipEntry = zipStream.GetNextEntry();
                            }
                        }
                    }

                    #endregion
                }

                scripts = new Scripts(HoloXPLOR_App._scriptsPath);
            }

            scripts = scripts ?? new Scripts(HoloXPLOR_App._scriptsPath);

            if (scripts.Ammo.Count > 0 &
                scripts.Items.Count > 0 &&
                scripts.Loadout.Count > 0 &&
                scripts.Localization.Count > 0 &&
                scripts.Vehicles.Count > 0)
            {
                String latestBuildFile = HostingEnvironment.MapPath("~/App_Data/latestBuild.txt");
                File.WriteAllText(latestBuildFile, HoloXPLOR_App._scriptsPath);
                HoloXPLOR_App.Scripts = scripts;
            }
        }
 public override void Read(BinaryReader r)
 {
     base.Read(r);
     var xml = CryXmlSerializer.ReadStream(r.BaseStream, true);
 }
        public void ReadFile_SCXmlFile()
        {
            string filename = "C:\\Users\\Geoff\\Source\\Repos\\Cryengine Importer\\io_cryengine_importer\\CryXmlB\\asteroid_hangar_landingpad_medium.xmla";

            XmlDocument xml = CryXmlSerializer.ReadFile(filename, true);
        }