예제 #1
0
파일: YBND4.cs 프로젝트: micvb123/Yabber
        public static void Repack(string sourceDir, string targetDir)
        {
            var bnd = new BND4();
            var xml = new XmlDocument();

            xml.Load($"{sourceDir}\\_yabber-bnd4.xml");

            string filename = xml.SelectSingleNode("bnd4/filename").InnerText;

            Enum.TryParse(xml.SelectSingleNode("bnd4/compression")?.InnerText ?? "None", out bnd.Compression);
            bnd.Version      = xml.SelectSingleNode("bnd4/version").InnerText;
            bnd.Format       = (Binder.Format)Enum.Parse(typeof(Binder.Format), xml.SelectSingleNode("bnd4/format").InnerText);
            bnd.BigEndian    = bool.Parse(xml.SelectSingleNode("bnd4/bigendian").InnerText);
            bnd.BitBigEndian = bool.Parse(xml.SelectSingleNode("bnd4/bitbigendian").InnerText);
            bnd.Unicode      = bool.Parse(xml.SelectSingleNode("bnd4/unicode").InnerText);
            bnd.Extended     = Convert.ToByte(xml.SelectSingleNode("bnd4/extended").InnerText, 16);
            bnd.Unk04        = bool.Parse(xml.SelectSingleNode("bnd4/unk04").InnerText);
            bnd.Unk05        = bool.Parse(xml.SelectSingleNode("bnd4/unk05").InnerText);
            YBinder.ReadBinderFiles(bnd, xml.SelectSingleNode("bnd4/files"), sourceDir);

            string outPath = $"{targetDir}\\{filename}";

            YBUtil.Backup(outPath);
            bnd.Write(outPath);
        }
예제 #2
0
        public static bool CombineSFX(List <string> maps, string outDir)
        {
            string inDir      = new DirectoryInfo($@"{outDir}\..\sfx").FullName;
            string commonPath = $@"{inDir}\sfxbnd_commoneffects.ffxbnd.dcx";

            if (!File.Exists(commonPath))
            {
                return(false);
            }
            Console.WriteLine(commonPath);
            Console.WriteLine(new FileInfo(commonPath).FullName);
            BND4             sfxCommon = BND4.Read(commonPath);
            HashSet <string> sfxFiles  = new HashSet <string>(sfxCommon.Files.Select(f => f.Name));

            Console.WriteLine(string.Join(",", maps));
            foreach (string map in maps.Select(m => m.Substring(0, 3)).Distinct())
            {
                string path = $@"{inDir}\sfxbnd_{map}.ffxbnd.dcx";
                if (!File.Exists(path))
                {
                    continue;
                }

                BND4 sfx = BND4.Read(path);
                sfx.Files = sfx.Files.Where(file =>
                {
                    if (!sfxFiles.Contains(file.Name))
                    {
                        sfxCommon.Files.Add(file);
                        sfxFiles.Add(file.Name);
                        return(false);
                    }
                    else
                    {
                        return(false);
                    }
                }).ToList();
                sfx.Write($@"{outDir}\sfx\sfxbnd_{map}.ffxbnd.dcx");
            }
            int startId = 0;

            foreach (BinderFile file in sfxCommon.Files)
            {
                // Ignore prefixes here
                file.ID = startId++;
            }
            sfxCommon.Files.Sort((a, b) => a.ID.CompareTo(b.ID));
            sfxCommon.Write($@"{outDir}\sfx\sfxbnd_commoneffects.ffxbnd.dcx");
            return(true);
        }
예제 #3
0
        public static void EncryptDS2Regulation(string path, BND4 bnd)
        {
            //var rand = new Random();
            //byte[] iv = new byte[16];
            //byte[] ivPart = new byte[11];
            //rand.NextBytes(ivPart);
            //iv[0] = 0x80;
            //Array.Copy(ivPart, 0, iv, 1, 11);
            //iv[15] = 1;
            //byte[] decrypted = bnd.Write();
            //byte[] encrypted = CryptographyUtility.EncryptAesCtr(decrypted, ds2RegulationKey, iv);
            //byte[] output = new byte[encrypted.Length + 11];

            Directory.CreateDirectory(Path.GetDirectoryName(path));
            bnd.Write(path); // xddddd
        }
예제 #4
0
        public static void CombineAI(List <string> maps, string outDir)
        {
            // Only works for Sekiro, since all other games have additional per-map metadata that actually matters
            string           commonPath = $@"{outDir}\..\script\aicommon.luabnd.dcx";
            BND4             aiCommon   = BND4.Read(commonPath);
            HashSet <string> aiFiles    = new HashSet <string>(aiCommon.Files.Select(f => f.Name));

            foreach (string map in maps)
            {
                string aiPath = $@"{outDir}\..\script\{map}.luabnd.dcx";
                if (!File.Exists(aiPath))
                {
                    continue;
                }

                BND4 ai = BND4.Read(aiPath);
                ai.Files = ai.Files.Where(file =>
                {
                    if (!file.Name.Contains("out"))
                    {
                        return(true);
                    }
                    if (!aiFiles.Contains(file.Name))
                    {
                        aiCommon.Files.Add(file);
                        aiFiles.Add(file.Name);
                    }
                    return(false);
                }).ToList();
                ai.Write($@"{outDir}\script\{map}.luabnd.dcx");
            }
            int startId = 2000;

            foreach (BinderFile file in aiCommon.Files)
            {
                if (file.ID < 3000)
                {
                    file.ID = startId++;
                }
                Console.WriteLine(file);
            }
            aiCommon.Files.Sort((a, b) => a.ID.CompareTo(b.ID));
            aiCommon.Write($@"{outDir}\script\aicommon.luabnd.dcx");
        }
예제 #5
0
파일: GUI.cs 프로젝트: AinTunez/MegaTAE
        private void saveANIBNDToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ANIBND == null)
            {
                return;
            }

            try
            {
                TAE.Save();
                ANIBND.Write(FilePath);
                UTIL.WriteLog(Path.GetFileName(FilePath) + " saved.");
                forceInGameReloadToolStripMenuItem_Click(sender, e);
            }
            catch (Exception ex)
            {
                UTIL.LogException("Error saving ANIBND", ex);
            }
        }
예제 #6
0
        public void SaveToPath(string file)
        {
            file  = file.ToUpper();
            IsDcx = false;
            if (file.EndsWith(".DCX"))
            {
                IsDcx = true;
            }

            if (ContainerType == TaeFileContainerType.BND3)
            {
                foreach (var f in containerBND3.Files)
                {
                    if (taeInBND.ContainsKey(f.Name))
                    {
                        f.Bytes = taeInBND[f.Name].Write();
                    }
                }

                containerBND3.Write(file);
            }
            else if (ContainerType == TaeFileContainerType.BND4)
            {
                foreach (var f in containerBND4.Files)
                {
                    if (taeInBND.ContainsKey(f.Name))
                    {
                        f.Bytes = taeInBND[f.Name].Write();
                    }
                }

                containerBND4.Write(file);
            }
            else if (ContainerType == TaeFileContainerType.TAE)
            {
                var tae = taeInBND[filePath];
                tae.Write(file);

                taeInBND.Clear();
                taeInBND.Add(file, taeInBND[filePath]);
            }
        }
예제 #7
0
        public static void Repack(string sourceDir, string targetDir)
        {
            BND4        bnd = new BND4();
            XmlDocument xml = new XmlDocument();

            xml.Load($"{sourceDir}\\_yabber-bnd4.xml");

            string filename = xml.SelectSingleNode("bnd4/filename").InnerText;

            Enum.TryParse(xml.SelectSingleNode("bnd4/compression").InnerText, out bnd.Compression);
            bnd.Timestamp = xml.SelectSingleNode("bnd4/timestamp").InnerText;
            bnd.Format    = (Binder.Format)Convert.ToByte(xml.SelectSingleNode("bnd4/format").InnerText, 16);
            bnd.BigEndian = bool.Parse(xml.SelectSingleNode("bnd4/bigendian").InnerText);
            bnd.Flag1     = bool.Parse(xml.SelectSingleNode("bnd4/flag1").InnerText);
            bnd.Flag2     = bool.Parse(xml.SelectSingleNode("bnd4/flag2").InnerText);
            bnd.Unicode   = bool.Parse(xml.SelectSingleNode("bnd4/unicode").InnerText);
            bnd.Extended  = Convert.ToByte(xml.SelectSingleNode("bnd4/extended").InnerText, 16);

            foreach (XmlNode fileNode in xml.SelectNodes("bnd4/files/file"))
            {
                int    id    = int.Parse(fileNode.SelectSingleNode("id").InnerText);
                string root  = fileNode.SelectSingleNode("root").InnerText;
                string path  = fileNode.SelectSingleNode("path").InnerText;
                byte   flags = Convert.ToByte(fileNode.SelectSingleNode("flags").InnerText, 16);

                byte[] bytes = File.ReadAllBytes($"{sourceDir}\\{path}");

                bnd.Files.Add(new BND4.File(id, root + path, (Binder.FileFlags)flags, bytes));
            }

            string outPath = $"{targetDir}\\{filename}";

            if (File.Exists(outPath) && !File.Exists(outPath + ".bak"))
            {
                File.Move(outPath, outPath + ".bak");
            }

            bnd.Write(outPath);
        }
예제 #8
0
 public static void EncryptDS2Regulation(string path, BND4 bnd)
 {
     Directory.CreateDirectory(Path.GetDirectoryName(path));
     bnd.Write(path);
 }