コード例 #1
0
        public void ReadScriptEntry(ResourceEntry entry, XmlWriter resourceXML, string scriptDir)
        {
            ScriptResource resource = new ScriptResource();

            resource.Deserialize(entry.Version, new MemoryStream(entry.Data), _Endian);
            resourceXML.WriteElementString("File", resource.Path);
            resourceXML.WriteElementString("ScriptNum", resource.Scripts.Count.ToString());
            for (int x = 0; x != resource.Scripts.Count; x++)
            {
                string   scrdir = scriptDir;
                string[] dirs   = resource.Scripts[x].Name.Split('/');
                for (int z = 0; z != dirs.Length - 1; z++)
                {
                    scrdir += "/" + dirs[z];
                    Directory.CreateDirectory(scrdir);
                }

                using (BinaryWriter writer = new BinaryWriter(
                           File.Open(scriptDir + "/" + resource.Scripts[x].Name, FileMode.Create)))
                {
                    writer.Write(resource.Scripts[x].Data);
                }
                resourceXML.WriteElementString("Name", resource.Scripts[x].Name);
            }
            resourceXML.WriteElementString("Version", entry.Version.ToString());
            resourceXML.WriteEndElement(); //finish early.
        }
コード例 #2
0
        public void ReadScriptEntry(ResourceEntry entry, XmlWriter resourceXML, string scriptDir)
        {
            ScriptResource resource = new ScriptResource();

            resource.Deserialize(entry.Version, new MemoryStream(entry.Data), _Endian);
            resourceXML.WriteElementString("File", resource.Path);
            resourceXML.WriteElementString("ScriptNum", resource.Scripts.Count.ToString());
            for (int x = 0; x != resource.Scripts.Count; x++)
            {
                string   scrdir = scriptDir;
                string[] dirs   = resource.Scripts[x].Name.Split('/');
                for (int z = 0; z != dirs.Length - 1; z++)
                {
                    scrdir += "/" + dirs[z];
                    Directory.CreateDirectory(scrdir);
                }

                File.WriteAllBytes(scriptDir + "/" + resource.Scripts[x].Name, resource.Scripts[x].Data);

                if (ToolkitSettings.DecompileLUA)
                {
                    LuaHelper.ReadFile(new FileInfo(scriptDir + "/" + resource.Scripts[x].Name));
                }

                resourceXML.WriteElementString("Name", resource.Scripts[x].Name);
            }
            resourceXML.WriteElementString("Version", entry.Version.ToString());
            resourceXML.WriteEndElement(); //finish early.
        }
コード例 #3
0
        public void ReadScriptEntry(ResourceEntry entry, XmlWriter resourceXML, string scriptDir)
        {
            ScriptResource resource = new ScriptResource();

            resource.Deserialize(entry.Version, new MemoryStream(entry.Data), _Endian);
            resourceXML.WriteElementString("File", resource.Path);
            resourceXML.WriteElementString("ScriptNum", resource.Scripts.Count.ToString());

            for (int x = 0; x != resource.Scripts.Count; x++)
            {
                // Get the script resource.
                ScriptData ScriptItem = resource.Scripts[x];

                // Get directory and Script name.
                string ScriptDirectory = Path.GetDirectoryName(ScriptItem.Name);
                string ScriptName      = Path.GetFileName(ScriptItem.Name);

                // Create the new directory.
                string NewDirectory = scriptDir + ScriptDirectory;
                Directory.CreateDirectory(NewDirectory);

                // Write the script data to the designated file.
                string ScriptPath = Path.Combine(NewDirectory, ScriptName);
                File.WriteAllBytes(ScriptPath, ScriptItem.Data);

                // If user requests, decompile the Lua file.
                if (ToolkitSettings.DecompileLUA)
                {
                    FileInfo Info    = new FileInfo(ScriptPath);
                    FileLua  LuaFile = new FileLua(Info);
                    LuaFile.TryDecompileBytecode();
                }

                resourceXML.WriteElementString("Name", ScriptItem.Name);
            }
            resourceXML.WriteElementString("Version", entry.Version.ToString());
            resourceXML.WriteEndElement(); // We finish early with scripts, as this has an alternate layout.
        }