コード例 #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);
        }
コード例 #2
0
ファイル: YBXF4.cs プロジェクト: micvb123/Yabber
        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);
        }
コード例 #3
0
        public static void Repack(string sourceFile)
        {
            FMG         fmg = new FMG();
            XmlDocument xml = new XmlDocument();

            xml.Load(sourceFile);
            Enum.TryParse(xml.SelectSingleNode("fmg/compression")?.InnerText ?? "None", out DCX.Type compression);
            fmg.Compression = compression;
            fmg.Version     = (FMG.FMGVersion)Enum.Parse(typeof(FMG.FMGVersion), xml.SelectSingleNode("fmg/version").InnerText);
            fmg.BigEndian   = bool.Parse(xml.SelectSingleNode("fmg/bigendian").InnerText);

            foreach (XmlNode textNode in xml.SelectNodes("fmg/entries/text"))
            {
                int id = int.Parse(textNode.Attributes["id"].InnerText);
                // \r\n is drawn as two newlines ingame
                string text = textNode.InnerText.Replace("\r", "");
                if (text == "%null%")
                {
                    text = null;
                }
                fmg.Entries.Add(new FMG.Entry(id, text));
            }

            string outPath = sourceFile.Replace(".fmg.xml", ".fmg");

            YBUtil.Backup(outPath);
            fmg.Write(outPath);
        }
コード例 #4
0
        public static void Repack(string sourceDir, string targetDir)
        {
            TPF         tpf = new TPF();
            XmlDocument xml = new XmlDocument();

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

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

            Enum.TryParse(xml.SelectSingleNode("tpf/compression")?.InnerText ?? "None", out DCX.Type compression);
            tpf.Compression = compression;
            tpf.Encoding    = Convert.ToByte(xml.SelectSingleNode("tpf/encoding").InnerText, 16);
            tpf.Flag2       = Convert.ToByte(xml.SelectSingleNode("tpf/flag2").InnerText, 16);

            foreach (XmlNode texNode in xml.SelectNodes("tpf/textures/texture"))
            {
                string name   = Path.GetFileNameWithoutExtension(texNode.SelectSingleNode("name").InnerText);
                byte   format = Convert.ToByte(texNode.SelectSingleNode("format").InnerText, 16);
                byte   flags1 = Convert.ToByte(texNode.SelectSingleNode("flags1").InnerText, 16);
                int    flags2 = Convert.ToInt32(texNode.SelectSingleNode("flags2").InnerText, 16);

                byte[] bytes = File.ReadAllBytes($"{sourceDir}\\{name}.dds");
                tpf.Textures.Add(new TPF.Texture(name, format, flags1, bytes));
            }

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

            YBUtil.Backup(outPath);
            tpf.Write(outPath);
        }
コード例 #5
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);
        }
コード例 #6
0
        public static void Repack(string sourceFile)
        {
            FFXDLSE ffx;

            using (var sr = new StreamReader(sourceFile))
                ffx = FFXDLSE.XmlDeserialize(sr);

            string outPath = sourceFile.Replace(".ffx.xml", ".ffx").Replace(".ffx.dcx.xml", ".ffx.dcx");

            YBUtil.Backup(outPath);
            ffx.Write(outPath);
        }
コード例 #7
0
ファイル: BND3.cs プロジェクト: katalash/Yabber
        public static void Unpack(this BND3 bnd, string sourceName, string targetDir)
        {
            Directory.CreateDirectory(targetDir);
            XmlWriterSettings xws = new XmlWriterSettings();

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

            xw.WriteStartElement("bnd3");

            xw.WriteElementString("filename", sourceName);
            xw.WriteElementString("compression", bnd.Compression.ToString());
            xw.WriteElementString("timestamp", bnd.Timestamp);
            xw.WriteElementString("format", $"0x{(byte)bnd.Format:X2}");
            xw.WriteElementString("bigendian", bnd.BigEndian.ToString());
            xw.WriteElementString("unk1", bnd.Unk1.ToString());
            xw.WriteElementString("unk2", $"0x{bnd.Unk2:X8}");

            xw.WriteStartElement("files");
            foreach (BND3.File file in bnd.Files)
            {
                string path, root;
                if (Binder.HasName(bnd.Format))
                {
                    path = YBUtil.UnrootBNDPath(file.Name, out root);
                }
                else
                {
                    root = null;
                    path = file.ID.ToString();
                }

                xw.WriteStartElement("file");
                xw.WriteElementString("id", file.ID.ToString());
                if (Binder.HasName(bnd.Format))
                {
                    xw.WriteElementString("root", root);
                    xw.WriteElementString("path", path);
                }
                xw.WriteElementString("flags", $"0x{(byte)file.Flags:X2}");
                xw.WriteEndElement();

                path = $"{targetDir}\\{path}";
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllBytes(path, file.Bytes);
            }
            xw.WriteEndElement();

            xw.WriteEndElement();
            xw.Close();
        }
コード例 #8
0
        public static void Unpack(this BXF4 bxf, string bhdName, string bdtName, string targetDir)
        {
            Directory.CreateDirectory(targetDir);
            XmlWriterSettings xws = new XmlWriterSettings();

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

            xw.WriteStartElement("bxf4");

            xw.WriteStartElement("bhd");
            xw.WriteElementString("filename", bhdName);
            xw.WriteElementString("timestamp", bxf.BHD.Timestamp);
            xw.WriteElementString("format", $"0x{(byte)bxf.BHD.Format:X2}");
            xw.WriteElementString("unicode", bxf.BHD.Unicode.ToString());
            xw.WriteElementString("bigendian", bxf.BHD.BigEndian.ToString());
            xw.WriteElementString("flag1", bxf.BHD.Flag1.ToString());
            xw.WriteElementString("flag2", bxf.BHD.Flag2.ToString());
            xw.WriteElementString("extended", $"0x{bxf.BHD.Extended:X2}");
            xw.WriteEndElement();

            xw.WriteStartElement("bdt");
            xw.WriteElementString("filename", bdtName);
            xw.WriteElementString("timestamp", bxf.BDT.Timestamp);
            xw.WriteElementString("bigendian", bxf.BDT.BigEndian.ToString());
            xw.WriteElementString("flag1", bxf.BDT.Flag1.ToString());
            xw.WriteElementString("flag2", bxf.BDT.Flag2.ToString());
            xw.WriteElementString("unk1", $"0x{bxf.BDT.Unk1:X16}");
            xw.WriteEndElement();

            xw.WriteStartElement("files");
            foreach (BXF4.File file in bxf.Files)
            {
                string path = YBUtil.UnrootBNDPath(file.Name, out string root);

                xw.WriteStartElement("file");
                xw.WriteElementString("id", file.ID.ToString());
                xw.WriteElementString("root", root);
                xw.WriteElementString("path", path);
                xw.WriteElementString("flags", $"0x{(byte)file.Flags:X2}");
                xw.WriteEndElement();

                path = $"{targetDir}\\{path}";
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllBytes(path, file.Bytes);
            }
            xw.WriteEndElement();

            xw.WriteEndElement();
            xw.Close();
        }
コード例 #9
0
        public static void Repack(string sourceFile)
        {
            LUAGNL      gnl = new LUAGNL();
            XmlDocument xml = new XmlDocument();

            xml.Load(sourceFile);
            gnl.BigEndian  = bool.Parse(xml.SelectSingleNode("luagnl/bigendian").InnerText);
            gnl.LongFormat = bool.Parse(xml.SelectSingleNode("luagnl/longformat").InnerText);

            foreach (XmlNode node in xml.SelectNodes("luagnl/globals/global"))
            {
                gnl.Globals.Add(node.InnerText);
            }

            string outPath = sourceFile.Replace(".luagnl.xml", ".luagnl");

            YBUtil.Backup(outPath);
            gnl.Write(outPath);
        }
コード例 #10
0
ファイル: YTPF.cs プロジェクト: micvb123/Yabber
        public static void Repack(string sourceDir, string targetDir)
        {
            TPF         tpf = new TPF();
            XmlDocument xml = new XmlDocument();

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

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

            Enum.TryParse(xml.SelectSingleNode("tpf/compression")?.InnerText ?? "None", out tpf.Compression);
            tpf.Encoding = Convert.ToByte(xml.SelectSingleNode("tpf/encoding").InnerText, 16);
            tpf.Flag2    = Convert.ToByte(xml.SelectSingleNode("tpf/flag2").InnerText, 16);

            foreach (XmlNode texNode in xml.SelectNodes("tpf/textures/texture"))
            {
                string name   = Path.GetFileNameWithoutExtension(texNode.SelectSingleNode("name").InnerText);
                byte   format = Convert.ToByte(texNode.SelectSingleNode("format").InnerText);
                byte   flags1 = Convert.ToByte(texNode.SelectSingleNode("flags1").InnerText, 16);

                TPF.FloatStruct floatStruct = null;
                XmlNode         floatsNode  = texNode.SelectSingleNode("FloatStruct");
                if (floatsNode != null)
                {
                    floatStruct       = new TPF.FloatStruct();
                    floatStruct.Unk00 = int.Parse(floatsNode.Attributes["Unk00"].InnerText);
                    foreach (XmlNode valueNode in floatsNode.SelectNodes("Value"))
                    {
                        floatStruct.Values.Add(float.Parse(valueNode.InnerText));
                    }
                }

                byte[] bytes   = File.ReadAllBytes($"{sourceDir}\\{name}.dds");
                var    texture = new TPF.Texture(name, format, flags1, bytes);
                texture.FloatStruct = floatStruct;
                tpf.Textures.Add(texture);
            }

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

            YBUtil.Backup(outPath);
            tpf.Write(outPath);
        }
コード例 #11
0
        public static void Unpack(this BXF3 bxf, string bhdName, string bdtName, string targetDir)
        {
            Directory.CreateDirectory(targetDir);
            XmlWriterSettings xws = new XmlWriterSettings();

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

            xw.WriteStartElement("bxf3");

            xw.WriteStartElement("bhd");
            xw.WriteElementString("filename", bhdName);
            xw.WriteElementString("timestamp", bxf.BHDTimestamp);
            xw.WriteEndElement();

            xw.WriteStartElement("bdt");
            xw.WriteElementString("filename", bdtName);
            xw.WriteElementString("timestamp", bxf.BDTTimestamp);
            xw.WriteEndElement();

            xw.WriteStartElement("files");
            foreach (BXF3.File file in bxf.Files)
            {
                string path = YBUtil.UnrootBNDPath(file.Name, out string root);

                xw.WriteStartElement("file");
                xw.WriteElementString("id", file.ID.ToString());
                xw.WriteElementString("root", root);
                xw.WriteElementString("path", path);
                xw.WriteEndElement();

                path = $"{targetDir}\\{path}";
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllBytes(path, file.Bytes);
            }
            xw.WriteEndElement();

            xw.WriteEndElement();
            xw.Close();
        }
コード例 #12
0
        public static void Repack(string sourceFile)
        {
            LUAINFO     info = new LUAINFO();
            XmlDocument xml  = new XmlDocument();

            xml.Load(sourceFile);
            info.BigEndian  = bool.Parse(xml.SelectSingleNode("luainfo/bigendian").InnerText);
            info.LongFormat = bool.Parse(xml.SelectSingleNode("luainfo/longformat").InnerText);

            foreach (XmlNode node in xml.SelectNodes("luainfo/goals/goal"))
            {
                int    id                 = int.Parse(node.Attributes["id"].InnerText);
                string name               = node.SelectSingleNode("name").InnerText;
                bool   battleInterrupt    = bool.Parse(node.SelectSingleNode("battleinterrupt").InnerText);
                bool   logicInterrupt     = bool.Parse(node.SelectSingleNode("logicinterrupt").InnerText);
                string logicInterruptName = node.SelectSingleNode("logicinterruptname")?.InnerText;
                info.Goals.Add(new LUAINFO.Goal(id, name, battleInterrupt, logicInterrupt, logicInterruptName));
            }

            string outPath = sourceFile.Replace(".luainfo.xml", ".luainfo");

            YBUtil.Backup(outPath);
            info.Write(outPath);
        }
コード例 #13
0
        public static void WriteBinderFiles(IBinder bnd, XmlWriter xw, string targetDir)
        {
            xw.WriteStartElement("files");
            var pathCounts = new Dictionary <string, int>();

            for (int i = 0; i < bnd.Files.Count; i++)
            {
                BinderFile file = bnd.Files[i];

                string root = "";
                string path;
                if (Binder.HasNames(bnd.Format))
                {
                    path = YBUtil.UnrootBNDPath(file.Name, out root);
                }
                else if (Binder.HasIDs(bnd.Format))
                {
                    path = file.ID.ToString();
                }
                else
                {
                    path = i.ToString();
                }

                xw.WriteStartElement("file");
                xw.WriteElementString("flags", file.Flags.ToString());

                if (Binder.HasIDs(bnd.Format))
                {
                    xw.WriteElementString("id", file.ID.ToString());
                }

                if (root != "")
                {
                    xw.WriteElementString("root", root);
                }

                xw.WriteElementString("path", path);

                string suffix = "";
                if (pathCounts.ContainsKey(path))
                {
                    pathCounts[path]++;
                    suffix = $" ({pathCounts[path]})";
                    xw.WriteElementString("suffix", suffix);
                }
                else
                {
                    pathCounts[path] = 1;
                }

                if (file.CompressionType != DCX.Type.Zlib)
                {
                    xw.WriteElementString("compression_type", file.CompressionType.ToString());
                }

                xw.WriteEndElement();

                string outPath = $@"{targetDir}\{Path.GetDirectoryName(path)}\{Path.GetFileNameWithoutExtension(path)}{suffix}{Path.GetExtension(path)}";
                Directory.CreateDirectory(Path.GetDirectoryName(outPath));
                File.WriteAllBytes(outPath, file.Bytes);
            }
            xw.WriteEndElement();
        }
コード例 #14
0
ファイル: YGPARAM.cs プロジェクト: micvb123/Yabber
        public static void Repack(string sourceFile)
        {
            var gparam = new GPARAM();
            var xml    = new XmlDocument();

            xml.Load(sourceFile);
            Enum.TryParse(xml.SelectSingleNode("gparam/compression")?.InnerText ?? "None", out gparam.Compression);
            Enum.TryParse(xml.SelectSingleNode("gparam/game").InnerText, out gparam.Game);
            gparam.Unk0D = bool.Parse(xml.SelectSingleNode("gparam/unk0D").InnerText);
            gparam.Unk14 = int.Parse(xml.SelectSingleNode("gparam/unk14").InnerText);
            if (gparam.Game == GPARAM.GPGame.Sekiro)
            {
                gparam.Unk50 = float.Parse(xml.SelectSingleNode("gparam/unk50").InnerText);
            }

            foreach (XmlNode groupNode in xml.SelectNodes("gparam/groups/group"))
            {
                string       groupName1 = groupNode.Attributes["name1"].InnerText;
                GPARAM.Group group;
                if (gparam.Game == GPARAM.GPGame.DarkSouls2)
                {
                    group = new GPARAM.Group(groupName1, null);
                }
                else
                {
                    string groupName2 = groupNode.Attributes["name2"].InnerText;
                    group = new GPARAM.Group(groupName1, groupName2);
                    foreach (XmlNode commentNode in groupNode.SelectNodes("comments/comment"))
                    {
                        group.Comments.Add(commentNode.InnerText);
                    }
                }

                foreach (XmlNode paramNode in groupNode.SelectNodes("param"))
                {
                    string       paramName1 = paramNode.Attributes["name1"].InnerText;
                    var          paramType  = (GPARAM.ParamType)Enum.Parse(typeof(GPARAM.ParamType), paramNode.Attributes["type"].InnerText);
                    GPARAM.Param param;

                    if (gparam.Game == GPARAM.GPGame.DarkSouls2)
                    {
                        param = new GPARAM.Param(paramName1, null, paramType);
                    }
                    else
                    {
                        string paramName2 = paramNode.Attributes["name2"].InnerText;
                        param = new GPARAM.Param(paramName1, paramName2, paramType);
                        if (gparam.Game == GPARAM.GPGame.Sekiro)
                        {
                            param.UnkFloats = new List <float>();
                        }
                    }

                    foreach (XmlNode value in paramNode.SelectNodes("value"))
                    {
                        param.ValueIDs.Add(int.Parse(value.Attributes["id"].InnerText));
                        if (gparam.Game == GPARAM.GPGame.Sekiro)
                        {
                            param.UnkFloats.Add(float.Parse(value.Attributes["float"].InnerText));
                        }

                        switch (param.Type)
                        {
                        case GPARAM.ParamType.BoolA:
                            param.Values.Add(bool.Parse(value.InnerText));
                            break;

                        case GPARAM.ParamType.BoolB:
                            param.Values.Add(bool.Parse(value.InnerText));
                            break;

                        case GPARAM.ParamType.Byte:
                            param.Values.Add(byte.Parse(value.InnerText));
                            break;

                        case GPARAM.ParamType.Byte4:
                            byte[] bytes = value.InnerText.Split(' ').Select(b => byte.Parse(b, NumberStyles.AllowHexSpecifier)).ToArray();
                            param.Values.Add(bytes);
                            break;

                        case GPARAM.ParamType.Float:
                            param.Values.Add(float.Parse(value.InnerText));
                            break;

                        case GPARAM.ParamType.Float2:
                            float[] vec2 = value.InnerText.Split(' ').Select(f => float.Parse(f)).ToArray();
                            param.Values.Add(new Vector2(vec2[0], vec2[1]));
                            break;

                        case GPARAM.ParamType.Float3:
                            float[] vec3 = value.InnerText.Split(' ').Select(f => float.Parse(f)).ToArray();
                            param.Values.Add(new Vector3(vec3[0], vec3[1], vec3[1]));
                            break;

                        case GPARAM.ParamType.Float4:
                            float[] vec4 = value.InnerText.Split(' ').Select(f => float.Parse(f)).ToArray();
                            param.Values.Add(new Vector4(vec4[0], vec4[1], vec4[2], vec4[3]));
                            break;

                        case GPARAM.ParamType.IntA:
                            param.Values.Add(int.Parse(value.InnerText));
                            break;

                        case GPARAM.ParamType.IntB:
                            param.Values.Add(int.Parse(value.InnerText));
                            break;

                        case GPARAM.ParamType.Short:
                            param.Values.Add(short.Parse(value.InnerText));
                            break;
                        }
                    }
                    group.Params.Add(param);
                }
                gparam.Groups.Add(group);
            }

            foreach (XmlNode unk3Node in xml.SelectNodes("gparam/unk3s/unk3"))
            {
                int groupIndex = int.Parse(unk3Node.Attributes["group_index"].InnerText);
                var unk3       = new GPARAM.Unk3(groupIndex);
                if (gparam.Game == GPARAM.GPGame.Sekiro)
                {
                    unk3.Unk0C = int.Parse(unk3Node.Attributes["unk0C"].InnerText);
                }
                foreach (XmlNode value in unk3Node.SelectNodes("value_id"))
                {
                    unk3.ValueIDs.Add(int.Parse(value.InnerText));
                }
                gparam.Unk3s.Add(unk3);
            }

            gparam.UnkBlock2 = xml.SelectSingleNode("gparam/unk_block_2").InnerText
                               .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                               .Select(s => Convert.ToByte(s, 16)).ToArray();

            string outPath;

            if (sourceFile.EndsWith(".gparam.xml"))
            {
                outPath = sourceFile.Replace(".gparam.xml", ".gparam");
            }
            else if (sourceFile.EndsWith(".gparam.dcx.xml"))
            {
                outPath = sourceFile.Replace(".gparam.dcx.xml", ".gparam.dcx");
            }
            else if (sourceFile.EndsWith(".fltparam.xml"))
            {
                outPath = sourceFile.Replace(".fltparam.xml", ".fltparam");
            }
            else if (sourceFile.EndsWith(".fltparam.dcx.xml"))
            {
                outPath = sourceFile.Replace(".fltparam.dcx.xml", ".fltparam.dcx");
            }
            else
            {
                throw new InvalidOperationException("Invalid GPARAM xml filename.");
            }
            YBUtil.Backup(outPath);
            gparam.Write(outPath);
        }
コード例 #15
0
ファイル: YBND3.cs プロジェクト: micvb123/Yabber
        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);
        }