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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }