示例#1
0
        public ResourceEntry WriteScriptEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            //get xml data.
            nodes.Current.MoveToNext();
            string path = nodes.Current.Value;

            nodes.Current.MoveToNext();
            int numScripts = Convert.ToInt32(nodes.Current.Value);

            //main stuff
            ScriptResource resource = new ScriptResource();

            resource.Path = path;

            for (int i = 0; i != numScripts; i++)
            {
                ScriptData data = new ScriptData();
                nodes.Current.MoveToNext();
                data.Name = nodes.Current.Value;
                data.Data = File.ReadAllBytes(sdsFolder + data.Name);
                resource.Scripts.Add(data);
            }

            //finish
            nodes.Current.MoveToNext();
            ushort       version = Convert.ToUInt16(nodes.Current.Value);
            MemoryStream stream  = new MemoryStream();

            resource.Serialize(version, stream, Endian.Little);
            entry.Version      = version;
            entry.Data         = stream.GetBuffer();
            descNode.InnerText = path;
            return(entry);
        }
        public ResourceEntry WriteScriptEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            // Get data from Xml.
            nodes.Current.MoveToNext();
            string path = nodes.Current.Value;

            nodes.Current.MoveToNext();
            int numScripts = Convert.ToInt32(nodes.Current.Value);

            // Create the new resource, add path.
            ScriptResource resource = new ScriptResource();

            resource.Path = path;

            // Iterate through scripts, reading each one and pushing them into the list.
            for (int i = 0; i < numScripts; i++)
            {
                ScriptData data = new ScriptData();
                nodes.Current.MoveToNext();
                data.Name = nodes.Current.Value;
                data.Data = File.ReadAllBytes(sdsFolder + data.Name);
                resource.Scripts.Add(data);
            }

            // Finish reading the Xml by getting the version.
            nodes.Current.MoveToNext();
            ushort version = Convert.ToUInt16(nodes.Current.Value);

            // Create the stream and serialize the resource package into said stream.
            using (MemoryStream stream = new MemoryStream())
            {
                resource.Serialize(version, stream, Endian.Little);
                entry.Data = stream.ToArray();

                entry.SlotRamRequired = resource.GetRawBytes();
            }

            // Set the entry version and setup the data for the meta info.
            entry.Version      = version;
            descNode.InnerText = "not available";
            return(entry);
        }