Example #1
0
        public static void Repack(string sourceDir, string targetDir)
        {
            var bxf = new BXF3();
            var xml = new XmlDocument();

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

            string bhdFilename = xml.SelectSingleNode("bxf3/bhd_filename").InnerText;
            string bdtFilename = xml.SelectSingleNode("bxf3/bdt_filename").InnerText;

            bxf.Version      = xml.SelectSingleNode("bxf3/version").InnerText;
            bxf.Format       = (Binder.Format)Enum.Parse(typeof(Binder.Format), xml.SelectSingleNode("bxf3/format").InnerText);
            bxf.BigEndian    = bool.Parse(xml.SelectSingleNode("bxf3/bigendian").InnerText);
            bxf.BitBigEndian = bool.Parse(xml.SelectSingleNode("bxf3/bitbigendian").InnerText);

            YBinder.ReadBinderFiles(bxf, xml.SelectSingleNode("bxf3/files"), sourceDir);

            string bhdPath = $"{targetDir}\\{bhdFilename}";

            YBUtil.Backup(bhdPath);
            string bdtPath = $"{targetDir}\\{bdtFilename}";

            YBUtil.Backup(bdtPath);
            bxf.Write(bhdPath, bdtPath);
        }
Example #2
0
        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);
        }
Example #3
0
        public static void Repack(string sourceDir, string targetDir)
        {
            BXF4        bxf = new BXF4();
            XmlDocument xml = new XmlDocument();

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

            string bhdFilename = xml.SelectSingleNode("bxf4/bhd_filename").InnerText;
            string bdtFilename = xml.SelectSingleNode("bxf4/bdt_filename").InnerText;

            bxf.Version      = xml.SelectSingleNode("bxf4/version").InnerText;
            bxf.Format       = (Binder.Format)Enum.Parse(typeof(Binder.Format), xml.SelectSingleNode("bxf4/format").InnerText);
            bxf.BigEndian    = bool.Parse(xml.SelectSingleNode("bxf4/bigendian").InnerText);
            bxf.BitBigEndian = bool.Parse(xml.SelectSingleNode("bxf4/bitbigendian").InnerText);
            bxf.Unicode      = bool.Parse(xml.SelectSingleNode("bxf4/unicode").InnerText);
            bxf.Extended     = Convert.ToByte(xml.SelectSingleNode("bxf4/extended").InnerText, 16);
            bxf.Unk04        = bool.Parse(xml.SelectSingleNode("bxf4/unk04").InnerText);
            bxf.Unk05        = bool.Parse(xml.SelectSingleNode("bxf4/unk05").InnerText);

            YBinder.ReadBinderFiles(bxf, xml.SelectSingleNode("bxf4/files"), sourceDir);

            string bhdPath = $"{targetDir}\\{bhdFilename}";

            YBUtil.Backup(bhdPath);
            string bdtPath = $"{targetDir}\\{bdtFilename}";

            YBUtil.Backup(bdtPath);
            bxf.Write(bhdPath, bdtPath);
        }
Example #4
0
        public static void Repack(string sourceDir, string targetDir)
        {
            var bnd = new BND3();
            var xml = new XmlDocument();

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

            if (xml.SelectSingleNode("bnd3/filename") == null)
            {
                throw new FriendlyException("Missing filename tag.");
            }

            string filename       = xml.SelectSingleNode("bnd3/filename").InnerText;
            string strCompression = xml.SelectSingleNode("bnd3/compression")?.InnerText ?? "None";

            bnd.Version = xml.SelectSingleNode("bnd3/version")?.InnerText ?? "07D7R6";
            string strFormat       = xml.SelectSingleNode("bnd3/format")?.InnerText ?? "IDs, Names1, Names2, Compression";
            string strBigEndian    = xml.SelectSingleNode("bnd3/bigendian")?.InnerText ?? "False";
            string strBitBigEndian = xml.SelectSingleNode("bnd3/bitbigendian")?.InnerText ?? "False";
            string strUnk18        = xml.SelectSingleNode("bnd3/unk18")?.InnerText ?? "0x0";

            if (!Enum.TryParse(strCompression, out bnd.Compression))
            {
                throw new FriendlyException($"Could not parse compression type: {strCompression}");
            }

            try
            {
                bnd.Format = (Binder.Format)Enum.Parse(typeof(Binder.Format), strFormat);
            }
            catch
            {
                throw new FriendlyException($"Could not parse format: {strFormat}\nFormat must be a comma-separated list of flags.");
            }

            if (!bool.TryParse(strBigEndian, out bool bigEndian))
            {
                throw new FriendlyException($"Could not parse big-endianness: {strBigEndian}\nBig-endianness must be true or false.");
            }
            bnd.BigEndian = bigEndian;

            if (!bool.TryParse(strBitBigEndian, out bool bitBigEndian))
            {
                throw new FriendlyException($"Could not parse bit big-endianness: {strBitBigEndian}\nBit big-endianness must be true or false.");
            }
            bnd.BitBigEndian = bitBigEndian;

            try
            {
                bnd.Unk18 = Convert.ToInt32(strUnk18, 16);
            }
            catch
            {
                throw new FriendlyException($"Could not parse unk18: {strUnk18}\nUnk18 must be a hex value.");
            }

            if (xml.SelectSingleNode("bnd3/files") != null)
            {
                YBinder.ReadBinderFiles(bnd, xml.SelectSingleNode("bnd3/files"), sourceDir);
            }

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

            YBUtil.Backup(outPath);
            bnd.Write(outPath);
        }