Пример #1
0
        public static void Unpack(this BXF4Reader bxf, string bhdName, string bdtName, string targetDir, IProgress <float> progress)
        {
            Directory.CreateDirectory(targetDir);
            var xws = new XmlWriterSettings();

            xws.Indent = true;
            var xw = XmlWriter.Create($"{targetDir}\\_yabber-bxf4.xml", xws);

            xw.WriteStartElement("bxf4");

            xw.WriteElementString("bhd_filename", bhdName);
            xw.WriteElementString("bdt_filename", bdtName);
            xw.WriteElementString("version", bxf.Version);
            xw.WriteElementString("format", bxf.Format.ToString());
            xw.WriteElementString("bigendian", bxf.BigEndian.ToString());
            xw.WriteElementString("bitbigendian", bxf.BitBigEndian.ToString());
            xw.WriteElementString("unicode", bxf.Unicode.ToString());
            xw.WriteElementString("extended", $"0x{bxf.Extended:X2}");
            xw.WriteElementString("unk04", bxf.Unk04.ToString());
            xw.WriteElementString("unk05", bxf.Unk05.ToString());

            YBinder.WriteBinderFiles(bxf, xw, targetDir, progress);
            xw.WriteEndElement();
            xw.Close();
        }
Пример #2
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);
        }
Пример #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);
        }
Пример #4
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);
        }
Пример #5
0
        public static void Unpack(this BXF3 bxf, string bhdName, string bdtName, string targetDir)
        {
            Directory.CreateDirectory(targetDir);
            var xws = new XmlWriterSettings();

            xws.Indent = true;
            var xw = XmlWriter.Create($"{targetDir}\\_yabber-bxf3.xml", xws);

            xw.WriteStartElement("bxf3");

            xw.WriteElementString("bhd_filename", bhdName);
            xw.WriteElementString("bdt_filename", bdtName);
            xw.WriteElementString("version", bxf.Version);
            xw.WriteElementString("format", bxf.Format.ToString());
            xw.WriteElementString("bigendian", bxf.BigEndian.ToString());
            xw.WriteElementString("bitbigendian", bxf.BitBigEndian.ToString());

            YBinder.WriteBinderFiles(bxf, xw, targetDir);
            xw.WriteEndElement();
            xw.Close();
        }
Пример #6
0
        public static void Unpack(this BND3Reader bnd, string sourceName, string targetDir, IProgress <float> progress)
        {
            Directory.CreateDirectory(targetDir);
            var xws = new XmlWriterSettings();

            xws.Indent = true;
            var xw = XmlWriter.Create($"{targetDir}\\_yabber-bnd3.xml", xws);

            xw.WriteStartElement("bnd3");

            xw.WriteElementString("filename", sourceName);
            xw.WriteElementString("compression", bnd.Compression.ToString());
            xw.WriteElementString("version", bnd.Version);
            xw.WriteElementString("format", bnd.Format.ToString());
            xw.WriteElementString("bigendian", bnd.BigEndian.ToString());
            xw.WriteElementString("bitbigendian", bnd.BitBigEndian.ToString());
            xw.WriteElementString("unk18", $"0x{bnd.Unk18:X}");
            YBinder.WriteBinderFiles(bnd, xw, targetDir, progress);

            xw.WriteEndElement();
            xw.Close();
        }
Пример #7
0
        public static void Unpack(this BND4 bnd, string sourceName, string targetDir)
        {
            Directory.CreateDirectory(targetDir);
            var xws = new XmlWriterSettings();

            xws.Indent = true;
            var xw = XmlWriter.Create($"{targetDir}\\_yabber-bnd4.xml", xws);

            xw.WriteStartElement("bnd4");

            xw.WriteElementString("filename", sourceName);
            xw.WriteElementString("compression", bnd.Compression.ToString());
            xw.WriteElementString("version", bnd.Version);
            xw.WriteElementString("format", bnd.Format.ToString());
            xw.WriteElementString("bigendian", bnd.BigEndian.ToString());
            xw.WriteElementString("bitbigendian", bnd.BitBigEndian.ToString());
            xw.WriteElementString("unicode", bnd.Unicode.ToString());
            xw.WriteElementString("extended", $"0x{bnd.Extended:X2}");
            xw.WriteElementString("unk04", bnd.Unk04.ToString());
            xw.WriteElementString("unk05", bnd.Unk05.ToString());
            YBinder.WriteBinderFiles(bnd, xw, targetDir);
            xw.WriteEndElement();
            xw.Close();
        }
Пример #8
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);
        }