Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Version 1.1: FMG support
Browse files Browse the repository at this point in the history
  • Loading branch information
JKAnderson committed Jan 10, 2019
1 parent 36472c6 commit 97598d3
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Yabber
An unpacker/repacker for Demon's Souls, Dark Souls 1-3, and Bloodborne container formats. Supports .bnd, .bhd/.bdt, .tpf, and .dcx.
An unpacker/repacker for Demon's Souls, Dark Souls 1-3, and Bloodborne container formats. Supports .bnd, .bhd/.bdt, .fmg, .tpf, and .dcx.
Does not support dvdbnds (dvdbnd0.bhd5 etc in DS1, GameDataEbl.bhd etc in DS2, Data1.bhd etc in DS3); use [UDSFM](https://www.nexusmods.com/darksouls/mods/1304) or [UXM](https://www.nexusmods.com/darksouls3/mods/286) to unpack those first.
Requires [.NET 4.7.2](https://www.microsoft.com/net/download/thank-you/net472) - Windows 10 users should already have this.
[NexusMods Page](https://www.nexusmods.com/darksouls3/mods/305)

Please see the included readme for detailed instructions.

# Changelog
### 1.1
* Add FMG support

### 1.0.2
* Fix repacking DX10 textures

Expand Down
4 changes: 2 additions & 2 deletions Yabber.Context/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1")]
4 changes: 2 additions & 2 deletions Yabber.DCX/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1")]
61 changes: 61 additions & 0 deletions Yabber/Formats/FMG.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using SoulsFormats;
using System;
using System.IO;
using System.Xml;

namespace Yabber
{
static class YFMG
{
public static void Unpack(this FMG fmg, string sourceFile)
{
XmlWriterSettings xws = new XmlWriterSettings();
// You need Indent for it to write newlines
xws.Indent = true;
// But don't actually indent so there's more room for the text
xws.IndentChars = "";
XmlWriter xw = XmlWriter.Create($"{sourceFile}.xml", xws);
xw.WriteStartElement("fmg");
xw.WriteElementString("version", fmg.Version.ToString());
xw.WriteElementString("bigendian", fmg.BigEndian.ToString());
xw.WriteStartElement("entries");

// I think they're sorted already, but whatever
fmg.Entries.Sort((e1, e2) => e1.ID.CompareTo(e2.ID));
foreach (FMG.Entry entry in fmg.Entries)
{
xw.WriteStartElement("text");
xw.WriteAttributeString("id", entry.ID.ToString());
xw.WriteString(entry.Text ?? "%null%");
xw.WriteEndElement();
}

xw.WriteEndElement();
xw.WriteEndElement();
xw.Close();
}

public static void Repack(string sourceFile)
{
FMG fmg = new FMG();
XmlDocument xml = new XmlDocument();
xml.Load(sourceFile);
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);
string text = textNode.InnerText;
if (text == "%null%")
text = null;
fmg.Entries.Add(new FMG.Entry(id, text));
}

string outPath = sourceFile.Replace(".fmg.xml", ".fmg");
if (File.Exists(outPath) && !File.Exists(outPath + ".bak"))
File.Copy(outPath, outPath + ".bak");
fmg.Write(outPath);
}
}
}
12 changes: 12 additions & 0 deletions Yabber/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void Main(string[] args)
}
else if (File.Exists(path))
{

pause |= UnpackFile(path);
}
else
Expand Down Expand Up @@ -155,6 +156,17 @@ private static bool UnpackFile(string sourceFile)
TPF tpf = TPF.Read(sourceFile);
tpf.Unpack(filename, targetDir);
}
else if (sourceFile.EndsWith(".fmg"))
{
Console.WriteLine($"Unpacking FMG: {filename}...");
FMG fmg = FMG.Read(sourceFile);
fmg.Unpack(sourceFile);
}
else if (sourceFile.EndsWith(".fmg.xml"))
{
Console.WriteLine($"Repacking FMG: {filename}...");
YFMG.Repack(sourceFile);
}
else
{
Console.WriteLine($"File format not recognized: {filename}");
Expand Down
4 changes: 2 additions & 2 deletions Yabber/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1")]
1 change: 1 addition & 0 deletions Yabber/Yabber.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Compile Include="Formats\BXF4.cs" />
<Compile Include="Formats\BND4.cs" />
<Compile Include="Formats\BND3.cs" />
<Compile Include="Formats\FMG.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Formats\TPF.cs" />
Expand Down
16 changes: 13 additions & 3 deletions dist/readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

--| Yabber 1.0.2
--| Yabber 1.1
--| By TKGP
--| https://www.nexusmods.com/darksouls3/mods/305
--| https://github.com/JKAnderson/Yabber

An unpacker/repacker for Demon's Souls, Dark Souls 1-3, and Bloodborne container formats. Supports .bnd, .bhd/.bdt, .tpf, and .dcx.
An unpacker/repacker for Demon's Souls, Dark Souls 1-3, and Bloodborne container formats. Supports .bnd, .bhd/.bdt, .fmg, .tpf, and .dcx.
Does not support dvdbnds (dvdbnd0.bhd5 etc in DS1, GameDataEbl.bhd etc in DS2, Data1.bhd etc in DS3); use UDSFM or UXM to unpack those first.
https://www.nexusmods.com/darksouls/mods/1304
https://www.nexusmods.com/darksouls3/mods/286
Expand All @@ -14,10 +14,13 @@ https://www.microsoft.com/net/download/thank-you/net472

--| Yabber.exe

This program is for unpacking and repacking container files. Drag and drop a file (bnd, bhd, or tpf) onto the exe to unpack it; drag and drop an unpacked folder to repack it. Multiple files or folders can be selected and dropped at a time.
This program is for unpacking and repacking container files. Drag and drop a file (bnd, bhd, fmg, or tpf) onto the exe to unpack it; drag and drop an unpacked folder to repack it. Multiple files or folders can be selected and dropped at a time.
DCX versions of supported formats can be dropped directly onto Yabber.exe without decompressing them separately; they will automatically be recompressed when repacking.
Edit the .xml file in the unpacked folder to add, remove or rename files before repacking.

FMG files are simply extracted to an xml file with the same name. Drop the .xml back onto Yabber to repack it to the FMG.
In the output xml, "%null%" is a special value that indicates the ID is present in the file but has no text.


--| Yabber.DCX.exe

Expand Down Expand Up @@ -53,13 +56,20 @@ DCX
Extension: .dcx
A single compressed file, used in all games.

FMG
Extension: .fmg
A collection of text strings with an associated ID number, used in all games.

TPF
Extension: .tpf
A DDS texture container, used in all games. Console versions are not supported.


--| Changelog

1.1
Add FMG support

1.0.2
Fix repacking DX10 textures

Expand Down

0 comments on commit 97598d3

Please sign in to comment.