コード例 #1
0
        public string ReadMemEntry(ResourceEntry entry, XmlWriter resourceXML, string name, string memDIR)
        {
            MemFileResource resource = new MemFileResource();

            using (var stream = new MemoryStream(entry.Data))
            {
                resource.Deserialize(entry.Version, stream, _Endian);
                entry.Data = resource.Data;
            }

            if (string.IsNullOrEmpty(name))
            {
                name = resource.Name;
            }

            string[] dirs = name.Split('/');

            string memdir = memDIR;

            for (int z = 0; z != dirs.Length - 1; z++)
            {
                memdir += "/" + dirs[z];
                Directory.CreateDirectory(memdir);
            }
            resourceXML.WriteElementString("File", name);
            resourceXML.WriteElementString("Unk2_V4", resource.Unk2_V4.ToString());
            return(name);
        }
コード例 #2
0
        public ResourceEntry WriteMemFileEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            //get file name from XML.
            nodes.Current.MoveToNext();
            string file = nodes.Current.Value;

            nodes.Current.MoveToNext();
            entry.Version = Convert.ToUInt16(nodes.Current.Value);

            //construct MemResource.
            MemFileResource resource = new MemFileResource
            {
                Name = file,
                Unk1 = 1
            };

            using (BinaryReader reader = new BinaryReader(File.Open(sdsFolder + "/" + file, FileMode.Open)))
            {
                resource.Data         = reader.ReadBytes((int)reader.BaseStream.Length);
                entry.SlotRamRequired = (uint)reader.BaseStream.Length;
            }

            //serialize.
            MemoryStream stream = new MemoryStream();

            resource.Serialize(entry.Version, stream, Endian.Little);

            //set the data.
            entry.Data         = stream.GetBuffer();
            descNode.InnerText = file;
            return(entry);
        }
コード例 #3
0
        public ResourceEntry WriteMemFileEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode)
        {
            //get file name from XML.
            nodes.Current.MoveToNext();
            string file = nodes.Current.Value;

            nodes.Current.MoveToNext();
            uint unk2 = Convert.ToUInt32(nodes.Current.Value);

            nodes.Current.MoveToNext();
            entry.Version = Convert.ToUInt16(nodes.Current.Value);

            //construct MemResource.
            MemFileResource resource = new MemFileResource
            {
                Name    = file,
                Unk1    = 1,
                Unk2_V4 = unk2
            };

            // Read all the data, then allocate memory required
            resource.Data         = File.ReadAllBytes(sdsFolder + "/" + file);
            entry.SlotRamRequired = (uint)resource.Data.Length;

            //serialize.
            using (MemoryStream stream = new MemoryStream())
            {
                resource.Serialize(entry.Version, stream, Endian.Little);
                entry.Data = stream.ToArray();
            }

            descNode.InnerText = file;
            return(entry);
        }
コード例 #4
0
        public void ReadMemEntry(ResourceEntry entry, XmlWriter resourceXML, string name, string memDIR)
        {
            MemFileResource resource = new MemFileResource();

            resource.Deserialize(entry.Data, _Endian);
            entry.Data = resource.Data;

            string[] dirs = name.Split('/');

            string memdir = memDIR;

            for (int z = 0; z != dirs.Length - 1; z++)
            {
                memdir += "/" + dirs[z];
                Directory.CreateDirectory(memdir);
            }
            resourceXML.WriteElementString("File", name);
        }
コード例 #5
0
        public void ReadFromFile(FileInfo info)
        {
            if (!info.Name.Contains("SDSContent") && info.Extension != "xml")
            {
                return;
            }

            parent = info.Directory;
            XmlDocument document = new XmlDocument();

            document.Load(info.FullName);

            XPathNavigator nav   = document.CreateNavigator();
            var            nodes = nav.Select("/SDSResource/ResourceEntry");

            while (nodes.MoveNext() == true)
            {
                nodes.Current.MoveToFirstChild();
                string       resourceType = nodes.Current.Value;
                BaseResource resource     = null;

                if (!resources.ContainsKey(resourceType))
                {
                    resources.Add(resourceType, new List <TreeNode>());
                }

                switch (resourceType)
                {
                case "FrameResource":
                case "Effects":
                case "PREFAB":
                case "ItemDesc":
                case "FrameNameTable":
                case "Actors":
                case "NAV_AIWORLD_DATA":
                case "NAV_OBJ_DATA":
                case "NAV_HPD_DATA":
                case "Cutscene":
                case "FxActor":
                case "FxAnimSet":
                case "Translokator":
                case "Speech":
                case "SoundTable":
                case "AnimalTrafficPaths":
                case "AudioSectors":
                case "Animated Texture":
                case "Collisions":
                case "IndexBufferPool":
                case "VertexBufferPool":
                case "EntityDataStorage":
                case "Animation2":
                case "Mipmap":
                case "Sound":
                    resource = new BaseResource();
                    resource.ReadResourceEntry(nodes);
                    break;

                case "MemFile":
                    resource = new MemFileResource();
                    resource.ReadResourceEntry(nodes);
                    break;

                case "Texture":
                    resource = new TextureResource();
                    resource.ReadResourceEntry(nodes);
                    break;

                case "XML":
                    resource = new XMLResource();
                    resource.ReadResourceEntry(nodes);
                    break;

                case "Script":
                    resource = new ScriptResource();
                    resource.ReadResourceEntry(nodes);
                    break;

                case "Table":
                    resource = new TableResource();
                    resource.ReadResourceEntry(nodes);
                    break;

                default:
                    MessageBox.Show("Did not load type: " + resourceType, "Toolkit", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }

                TreeNode node = BuildResourceTreeNode(resource.GetFileName(), resource);
                resources[resourceType].Add(node);
            }
        }