public void LoadArmorPartsbnd(string partsbndPath, EquipSlot slot) { if (System.IO.File.Exists(partsbndPath)) { if (BND3.Is(partsbndPath)) { LoadArmorPartsbnd(BND3.Read(partsbndPath), slot); } else { LoadArmorPartsbnd(BND4.Read(partsbndPath), slot); } } else { if (slot == EquipSlot.Head) { HeadMesh?.Dispose(); } else if (slot == EquipSlot.Body) { BodyMesh?.Dispose(); } else if (slot == EquipSlot.Arms) { ArmsMesh?.Dispose(); } else if (slot == EquipSlot.Legs) { LegsMesh?.Dispose(); } } }
public static Model LoadObject(string id) { Model obj = null; LoadingTaskMan.DoLoadingTaskSynchronous($"LOAD_OBJ_{id}", $"Loading object {id}...", progress => { if (GameType == GameTypes.DS3) { var chrbnd = BND4.Read($@"{InterrootPath}\obj\{id}.objbnd.dcx"); obj = new Model(progress, id, chrbnd, 0, null, null); } else if (GameType == GameTypes.DS1) { var chrbnd = BND3.Read($@"{InterrootPath}\obj\{id}.objbnd"); obj = new Model(progress, id, chrbnd, 0, null, null); } else if (GameType == GameTypes.DS1R) { var chrbnd = BND4.Read($@"{InterrootPath}\obj\{id}.objbnd.dcx"); obj = new Model(progress, id, chrbnd, 0, null, null); } else if (GameType == GameTypes.BB) { var chrbnd = BND4.Read($@"{InterrootPath}\obj\{id}.objbnd.dcx"); obj = new Model(progress, id, chrbnd, 0, null, null); } Scene.AddModel(obj); var texturesToLoad = obj.MainMesh.GetAllTexNamesToLoad(); LoadingTaskMan.DoLoadingTask($"LOAD_OBJ_{id}_TEX", "Loading additional object textures...", innerProgress => { if (GameType == GameTypes.DS1) { foreach (var tex in texturesToLoad) { TexturePool.AddTpfFromPath($@"{InterrootPath}\map\tx\{tex}.tpf"); } } else if (GameType == GameTypes.DS3) { int objGroup = int.Parse(id.Substring(1)) / 1_0000; var tpfBnds = System.IO.Directory.GetFiles($@"{InterrootPath}\map\m{objGroup:D2}", "*.tpfbhd"); foreach (var t in tpfBnds) { TexturePool.AddSpecificTexturesFromBinder(t, texturesToLoad, directEntryNameMatch: true); } } obj.MainMesh.TextureReloadQueued = true; }); }); return(obj); }
public static ExtractedFile Extract(BND4 bndfile, int ID, string filePath) { var file = new ExtractedFile(bndfile.Files.First(f => f.ID == ID), filePath); System.IO.File.WriteAllBytes(file.Path, file.File.Bytes); return(file); }
public static void ReloadParams() { if (!File.Exists(ParamPath)) { Debug.Log("Data0.bdt not found. This will make treasure editor have less functionality."); return; } BND4 paramBnd = SFUtil.DecryptDS3Regulation(DarkSoulsTools.GetOverridenPath(ParamPath)); DS3Param = PARAM.Read(paramBnd.Files.Find(x => Path.GetFileName(x.Name) == "ItemLotParam.param").Bytes); PARAM.Layout layout = PARAM.Layout.ReadXMLFile($@"{Application.dataPath.Replace('/', '\\')}\dstools\ParamLayouts\DS3\{DS3Param.ID}.xml"); DS3Param.SetLayout(layout); // Build and cache the item name list HashSet <int> usedItemIds = new HashSet <int>(); ItemNameList = new List <Tuple <int, string> >(); foreach (var row in DS3Param.Rows) { ItemLotParam param = new ItemLotParam(row); foreach (int id in param.ItemID) { if (!usedItemIds.Contains(id)) { usedItemIds.Add(id); ItemNameList.Add(new Tuple <int, string>(id, FMGUtils.LookupItemName(id))); } } } ItemNameList.Sort((a, b) => StringComparer.InvariantCulture.Compare(a.Item2, b.Item2)); }
public static void ReloadFMGs() { if (AssetLocator.Type == GameType.Undefined) { return; } if (AssetLocator.Type == GameType.DarkSoulsIISOTFS) { ReloadFMGsDS2(); IsLoaded = true; return; } IBinder fmgBinder; var desc = AssetLocator.GetEnglishItemMsgbnd(); if (AssetLocator.Type == GameType.DemonsSouls || AssetLocator.Type == GameType.DarkSoulsPTDE || AssetLocator.Type == GameType.DarkSoulsRemastered) { fmgBinder = BND3.Read(desc.AssetPath); } else { fmgBinder = BND4.Read(desc.AssetPath); } _fmgs = new Dictionary <ItemFMGTypes, FMG>(); foreach (var file in fmgBinder.Files) { _fmgs.Add((ItemFMGTypes)file.ID, FMG.Read(file.Bytes)); } IsLoaded = true; }
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); }
private static void LoadParamsDS3() { var dir = AssetLocator.GameRootDirectory; var mod = AssetLocator.GameModDirectory; if (!File.Exists($@"{dir}\Data0.bdt")) { MessageBox.Show("Could not find DS3 regulation file. Functionality will be limited.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Load loose params if they exist if (File.Exists($@"{mod}\\param\gameparam\gameparam_dlc2.parambnd.dcx")) { // Load params var lparam = $@"{mod}\param\gameparam\gameparam_dlc2.parambnd.dcx"; BND4 lparamBnd = BND4.Read(lparam); LoadParamFromBinder(lparamBnd); return; } // Load params var param = $@"{mod}\Data0.bdt"; if (!File.Exists(param)) { param = $@"{dir}\Data0.bdt"; } BND4 paramBnd = SFUtil.DecryptDS3Regulation(param); LoadParamFromBinder(paramBnd); }
private static void SaveParamsBBSekiro() { var dir = AssetLocator.GameRootDirectory; var mod = AssetLocator.GameModDirectory; if (!File.Exists($@"{dir}\\param\gameparam\gameparam.parambnd.dcx")) { MessageBox.Show("Could not find param file. Cannot save.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Load params var param = $@"{mod}\param\gameparam\gameparam.parambnd.dcx"; if (!File.Exists(param)) { param = $@"{dir}\param\gameparam\gameparam.parambnd.dcx"; } BND4 paramBnd = BND4.Read(param); // Replace params with edited ones foreach (var p in paramBnd.Files) { if (_params.ContainsKey(Path.GetFileNameWithoutExtension(p.Name))) { p.Bytes = _params[Path.GetFileNameWithoutExtension(p.Name)].Write(); } } Utils.WriteWithBackup(dir, mod, @"param\gameparam\gameparam.parambnd.dcx", paramBnd); }
public static void ReloadMtds() { IBinder mtdBinder = null; if (AssetLocator.Type == GameType.DarkSoulsIII || AssetLocator.Type == GameType.Sekiro) { mtdBinder = BND4.Read(AssetLocator.GetAssetPath($@"mtd\allmaterialbnd.mtdbnd.dcx")); } if (mtdBinder == null) { return; } _mtds = new Dictionary <string, MTD>(); foreach (var f in mtdBinder.Files) { var mtdname = Path.GetFileNameWithoutExtension(f.Name); // Because *certain* mods contain duplicate entries for the same material if (!_mtds.ContainsKey(mtdname)) { _mtds.Add(mtdname, MTD.Read(f.Bytes)); } } }
public static void ReloadParams() { if (!File.Exists(ParamPath)) { Debug.Log("DS2 enc_regulation.bnd.dcx not found"); return; } if (!BND4.Is(DarkSoulsTools.GetOverridenPath(ParamPath))) { Debug.Log("Decrypt your regulation by saving in Yapped"); return; } BND4 paramBnd = BND4.Read(DarkSoulsTools.GetOverridenPath(ParamPath)); EnemyParam = PARAM.Read(paramBnd.Files.Find(x => Path.GetFileName(x.Name) == "EnemyParam.param").Bytes); PARAM.Layout layout = PARAM.Layout.ReadXMLFile($@"{Application.dataPath.Replace('/', '\\')}\dstools\ParamLayouts\DS2SOTFS\{EnemyParam.ID}.xml"); EnemyParam.SetLayout(layout); // Build and cache the enemy param dictionary ParamDictionary = new Dictionary <long, PARAM.Row>(); foreach (var row in EnemyParam.Rows) { ParamDictionary.Add(row.ID, row); } }
// Reads bnd private IBinder ReadBnd(string path) { try { if (BND3.Is(path)) { return(BND3.Read(path)); } else if (BND4.Is(path)) { return(BND4.Read(path)); } else if (Spec.Game == FromGame.DS3 && path.EndsWith("Data0.bdt")) { return(SFUtil.DecryptDS3Regulation(path)); } else { throw new Exception($"Unrecognized bnd format for game {Spec.Game}: {path}"); } } catch (Exception ex) { throw new Exception($"Failed to load {path}: {ex}"); } }
public static BND4 Load(FileInfo path) { return(path.Extension switch { ".bdt" => RegulationFile.DecryptDS3Regulation(path.FullName), ".dcx" => BND4.Read(path.FullName), _ => throw new InvalidOperationException($"{path.Name} is not a valid parambnd or regulation file") });
public static void WriteFile <TFormat>(TFormat file, string path, bool makeBackup = true) where TFormat : SoulsFile <TFormat>, new() { if (path.Contains("|")) { var splitPath = path.Split('|'); if (splitPath.Length != 2) { throw new Exception("Invalid internal BND path format. Expected 'C:\\Path\\To\\BND|Internal_File_Name.Extension'."); } var bndPath = splitPath[0]; var internalPath = splitPath[1]; if (BND3.Is(bndPath)) { var bnd3 = BND3.Read(bndPath); var internalFile = bnd3.Files.LastOrDefault(f => GetFileNameWithoutDirectoryOrExtension(f.Name) == internalPath); if (internalFile == null) { throw new Exception($"Internal BND file path '{internalPath}' not found in BND '{bndPath}'."); } internalFile.Bytes = file.Write(); if (makeBackup) { BackupFile(bndPath); } bnd3.Write(bndPath); } else if (BND4.Is(bndPath)) { var bnd4 = BND4.Read(bndPath); var internalFile = bnd4.Files.LastOrDefault(f => GetFileNameWithoutDirectoryOrExtension(f.Name) == internalPath); if (internalFile == null) { throw new Exception($"Internal BND file path '{internalPath}' not found in BND '{bndPath}'."); } internalFile.Bytes = file.Write(); if (makeBackup) { BackupFile(bndPath); } bnd4.Write(bndPath); } else { throw new Exception("Internal BND path specified but file is not a BND file!"); } } else { if (makeBackup) { BackupFile(path); } file.Write(path); } }
static IBinder ReadIBinder(string name) { if (BND4.Is(name)) { return(BND4.Read(name)); } else { return(BND3.Read(name)); } }
private static void PatchBND(string sourceLangDir, string refLangDir, string[] destFilePath) { foreach (var file in destFilePath)//Patch each file in files Array { if (BND3.IsRead(file, out BND3 destBND3)) { //Set source BND files string sourceLangFiles = $@"{ sourceLangDir }\{ Path.GetFileName(file) }"; BND3 sourceBND = BND3.Read(sourceLangFiles); string refLangFiles = $@"{refLangDir}\{Path.GetFileName(file)}"; //Make null ref BND, and make an actual BND read if it exists BND3 refBND = null; if (File.Exists(refLangFiles)) { refBND = BND3.Read(refLangFiles); } #region Debug Stuff //ConsoleLog(sourceBND.Files.Count); //Debug.WriteLine(Path.GetFileName(sourceBND.Files[0].Name)); //ConsoleLog(destFMG.Entries.Count + " & " + sourceFMG.Entries.Count); #endregion //Patch BND file PatchFMG(sourceBND, destBND3, refBND, file); //Write new BND destBND3.Write(file); } else if (BND4.IsRead(file, out BND4 destBND4)) { //Set source BND files string sourceLangFiles = $@"{sourceLangDir}\{Path.GetFileName(file)}"; BND4 sourceBND = BND4.Read(sourceLangFiles); string refLangFiles = $@"{refLangDir}\{Path.GetFileName(file)}"; //Make null ref BND, and make an actual BND read if it exists BND4 refBND = null; if (File.Exists(refLangFiles)) { refBND = BND4.Read(refLangFiles); } #region Debug Stuff //ConsoleLog(sourceBND.Files.Count); //Debug.WriteLine(Path.GetFileName(sourceBND.Files[0].Name)); //ConsoleLog(destFMG.Entries.Count + " & " + sourceFMG.Entries.Count); #endregion //Patch BND file PatchFMG(sourceBND, destBND4, refBND, file); //Write new BND destBND4.Write(file); } } }
public void LoadFromPath(string file) { ReloadType = TaeFileContainerReloadType.None; containerBND3 = null; containerBND4 = null; taeInBND.Clear(); hkxInBND.Clear(); if (BND3.Is(file)) { ContainerType = TaeFileContainerType.BND3; containerBND3 = BND3.Read(file); foreach (var f in containerBND3.Files) { if (TAE.Is(f.Bytes)) { taeInBND.Add(f.Name, TAE.Read(f.Bytes)); } else if (f.Name.ToUpper().EndsWith(".HKX")) { hkxInBND.Add(f.Name, f.Bytes); } } } else if (BND4.Is(file)) { ContainerType = TaeFileContainerType.BND4; containerBND4 = BND4.Read(file); foreach (var f in containerBND4.Files) { if (TAE.Is(f.Bytes)) { taeInBND.Add(f.Name, TAE.Read(f.Bytes)); } else if (f.Name.ToUpper().EndsWith(".HKX")) { hkxInBND.Add(f.Name, f.Bytes); } } } else if (TAE.Is(file)) { ContainerType = TaeFileContainerType.TAE; taeInBND.Add(file, TAE.Read(file)); } filePath = file; //SFTODO ReloadType = TaeFileContainerReloadType.None; }
private int PackBinder(IBinder binder, string relOutputDir, CancellationToken cancelToken) { int textureCount = 0; foreach (BinderFile file in binder.Files) { if (cancelToken.IsCancellationRequested) { return(textureCount); } if (TPUtil.HasValidExtension(file.Name)) { try { byte[] bytes = file.Bytes; DCX.Type dcxType = DCX.Type.None; if (DCX.Is(bytes)) { bytes = DCX.Decompress(bytes, out dcxType); } if (TPF.IsRead(bytes, out TPF tpf)) { int thisTextureCount = PackTPF(tpf, relOutputDir); if (thisTextureCount > 0) { file.Bytes = tpf.Write(dcxType); } textureCount += thisTextureCount; } else if (BND4.IsRead(bytes, out BND4 bnd)) { int thisTextureCount = PackBinder(bnd, relOutputDir, cancelToken); if (thisTextureCount > 0) { file.Bytes = bnd.Write(dcxType); } textureCount += thisTextureCount; } else { throw new NotSupportedException("Unknown file type."); } } catch (Exception ex) { throw new Exception($"Error in binder file \"{file.Name}\"", ex); } } } return(textureCount); }
private static void SaveParamsDS2(bool loose) { var dir = AssetLocator.GameRootDirectory; var mod = AssetLocator.GameModDirectory; if (!File.Exists($@"{dir}\enc_regulation.bnd.dcx")) { MessageBox.Show("Could not find DS2 regulation file. Cannot save.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Load params var param = $@"{mod}\enc_regulation.bnd.dcx"; if (!File.Exists(param)) { param = $@"{dir}\enc_regulation.bnd.dcx"; } BND4 paramBnd = BND4.Read(param); // If params aren't loose, replace params with edited ones if (!loose) { foreach (var p in paramBnd.Files) { if (_params.ContainsKey(Path.GetFileNameWithoutExtension(p.Name))) { p.Bytes = _params[Path.GetFileNameWithoutExtension(p.Name)].Write(); } } } else { // strip all the params from the regulation List <BinderFile> newFiles = new List <BinderFile>(); foreach (var p in paramBnd.Files) { if (!p.Name.ToUpper().Contains(".PARAM")) { newFiles.Add(p); } } paramBnd.Files = newFiles; // Write all the params out loose foreach (var p in _params) { Utils.WriteWithBackup(dir, mod, $@"Param\{p.Key}.param", p.Value); } } Utils.WriteWithBackup(dir, mod, @"enc_regulation.bnd.dcx", paramBnd); }
private void Browse_Click(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.DefaultExt = ".anibnd.dcx"; fileDialog.Filter = "ANIBND.DCX Files (*.anibnd.dcx)|*.anibnd.dcx"; fileDialog.Title = "Select a .animbnd.dcx file"; fileDialog.CheckFileExists = true; fileDialog.CheckPathExists = true; bool?result = fileDialog.ShowDialog(); if (result == true) { StackPanel.Children.Clear(); Canvas.Children.Clear(); string filePath = fileDialog.FileName; Console.WriteLine(filePath); if (!File.Exists(filePath)) { return; } if (!BND4.Is(DCX.Decompress(filePath))) { return; } anibnd = BND4.Read(filePath); OpenFile.bndPath = filePath; dropdownOptions = new Dictionary <string, Dictionary <string, int> >(); foreach (BND4.File f in anibnd.Files) { if (System.IO.Path.GetExtension(f.Name).Equals(".hkx")) { Console.WriteLine(f.ToString()); string moveset = new DirectoryInfo(f.Name).Parent.Name; string fileName = System.IO.Path.GetFileNameWithoutExtension(f.Name); if (!dropdownOptions.ContainsKey(moveset)) { dropdownOptions[moveset] = new Dictionary <string, int>(); } dropdownOptions[moveset][fileName] = f.ID; } } lbl_anibnd.Content = System.IO.Path.GetFileNameWithoutExtension(filePath); cmb_moveset.ItemsSource = dropdownOptions.Keys.Count > 0 ? dropdownOptions.Keys : Enumerable.Empty <string>(); cmb_animation.ItemsSource = Enumerable.Empty <string>(); } }
public static void AddSpecificTexturesFromBinder(string name, List <string> textures, bool directEntryNameMatch = false) { if (!File.Exists(name)) { return; } IBinder bnd = null; if (BXF4.IsBHD(name)) { bnd = BXF4.Read(name, name.Substring(0, name.Length - 7) + ".tpfbdt"); } else if (BXF4.IsBDT(name)) { bnd = BXF4.Read(name.Substring(0, name.Length - 7) + ".tpfbhd", name); } else if (BXF3.IsBHD(name)) { bnd = BXF3.Read(name, name.Substring(0, name.Length - 7) + ".tpfbdt"); } else if (BXF3.IsBDT(name)) { bnd = BXF3.Read(name.Substring(0, name.Length - 7) + ".tpfbhd", name); } else if (BND4.Is(name)) { bnd = BND4.Read(name); } else if (BND3.Is(name)) { bnd = BND3.Read(name); } foreach (var f in bnd.Files) { if (directEntryNameMatch ? textures.Contains(Utils.GetShortIngameFileName(f.Name).ToLower()) : TPF.Is(f.Bytes)) { var tpf = TPF.Read(f.Bytes); foreach (var tx in tpf.Textures) { var shortTexName = Utils.GetShortIngameFileName(tx.Name).ToLower(); if (textures.Contains(shortTexName)) { AddFetchTPF(tpf, tx.Name.ToLower()); textures.Remove(shortTexName); } } } } }
public static bool CombineSFX(List <string> maps, string outDir) { string inDir = new DirectoryInfo($@"{outDir}\..\sfx").FullName; string commonPath = $@"{inDir}\sfxbnd_commoneffects.ffxbnd.dcx"; if (!File.Exists(commonPath)) { return(false); } Console.WriteLine(commonPath); Console.WriteLine(new FileInfo(commonPath).FullName); BND4 sfxCommon = BND4.Read(commonPath); HashSet <string> sfxFiles = new HashSet <string>(sfxCommon.Files.Select(f => f.Name)); Console.WriteLine(string.Join(",", maps)); foreach (string map in maps.Select(m => m.Substring(0, 3)).Distinct()) { string path = $@"{inDir}\sfxbnd_{map}.ffxbnd.dcx"; if (!File.Exists(path)) { continue; } BND4 sfx = BND4.Read(path); sfx.Files = sfx.Files.Where(file => { if (!sfxFiles.Contains(file.Name)) { sfxCommon.Files.Add(file); sfxFiles.Add(file.Name); return(false); } else { return(false); } }).ToList(); sfx.Write($@"{outDir}\sfx\sfxbnd_{map}.ffxbnd.dcx"); } int startId = 0; foreach (BinderFile file in sfxCommon.Files) { // Ignore prefixes here file.ID = startId++; } sfxCommon.Files.Sort((a, b) => a.ID.CompareTo(b.ID)); sfxCommon.Write($@"{outDir}\sfx\sfxbnd_commoneffects.ffxbnd.dcx"); return(true); }
public static BND4 DecryptDS2Regulation(string path) { byte[] bytes = File.ReadAllBytes(path); byte[] iv = new byte[16]; iv[0] = 0x80; Array.Copy(bytes, 0, iv, 1, 11); iv[15] = 1; byte[] input = new byte[bytes.Length - 32]; Array.Copy(bytes, 32, input, 0, bytes.Length - 32); using (var ms = new MemoryStream(input)) { byte[] decrypted = CryptographyUtility.DecryptAesCtr(ms, ds2RegulationKey, iv); return(BND4.Read(decrypted)); } }
public static void ReloadFmgs() { try { BND4 fmgBnd = BND4.Read(FMGBndPath); ItemFMG = FMG.Read(fmgBnd.Files.Find(x => Path.GetFileName(x.Name) == "アイテム名.fmg").Bytes); } catch (Exception e) { if (!Failwarn) { Debug.Log("Failed to load item fmg file. Item names will not be shown."); Failwarn = true; } } }
public static void EncryptDS2Regulation(string path, BND4 bnd) { //var rand = new Random(); //byte[] iv = new byte[16]; //byte[] ivPart = new byte[11]; //rand.NextBytes(ivPart); //iv[0] = 0x80; //Array.Copy(ivPart, 0, iv, 1, 11); //iv[15] = 1; //byte[] decrypted = bnd.Write(); //byte[] encrypted = CryptographyUtility.EncryptAesCtr(decrypted, ds2RegulationKey, iv); //byte[] output = new byte[encrypted.Length + 11]; Directory.CreateDirectory(Path.GetDirectoryName(path)); bnd.Write(path); // xddddd }
public static void SaveFMGs() { if (AssetLocator.Type == GameType.Undefined) { return; } if (AssetLocator.Type == GameType.DarkSoulsIISOTFS) { SaveFMGsDS2(); return; } // Load the fmg bnd, replace fmgs, and save IBinder fmgBinder; var desc = AssetLocator.GetEnglishItemMsgbnd(); if (AssetLocator.Type == GameType.DemonsSouls || AssetLocator.Type == GameType.DarkSoulsPTDE || AssetLocator.Type == GameType.DarkSoulsRemastered) { fmgBinder = BND3.Read(desc.AssetPath); } else { fmgBinder = BND4.Read(desc.AssetPath); } foreach (var file in fmgBinder.Files) { if (_fmgs.ContainsKey((ItemFMGTypes)file.ID)) { file.Bytes = _fmgs[(ItemFMGTypes)file.ID].Write(); } } var descw = AssetLocator.GetEnglishItemMsgbnd(true); if (fmgBinder is BND3 bnd3) { Utils.WriteWithBackup(AssetLocator.GameRootDirectory, AssetLocator.GameModDirectory, descw.AssetPath, bnd3); } else if (fmgBinder is BND4 bnd4) { Utils.WriteWithBackup(AssetLocator.GameRootDirectory, AssetLocator.GameModDirectory, descw.AssetPath, bnd4); } }
public static void CombineAI(List <string> maps, string outDir) { // Only works for Sekiro, since all other games have additional per-map metadata that actually matters string commonPath = $@"{outDir}\..\script\aicommon.luabnd.dcx"; BND4 aiCommon = BND4.Read(commonPath); HashSet <string> aiFiles = new HashSet <string>(aiCommon.Files.Select(f => f.Name)); foreach (string map in maps) { string aiPath = $@"{outDir}\..\script\{map}.luabnd.dcx"; if (!File.Exists(aiPath)) { continue; } BND4 ai = BND4.Read(aiPath); ai.Files = ai.Files.Where(file => { if (!file.Name.Contains("out")) { return(true); } if (!aiFiles.Contains(file.Name)) { aiCommon.Files.Add(file); aiFiles.Add(file.Name); } return(false); }).ToList(); ai.Write($@"{outDir}\script\{map}.luabnd.dcx"); } int startId = 2000; foreach (BinderFile file in aiCommon.Files) { if (file.ID < 3000) { file.ID = startId++; } Console.WriteLine(file); } aiCommon.Files.Sort((a, b) => a.ID.CompareTo(b.ID)); aiCommon.Write($@"{outDir}\script\aicommon.luabnd.dcx"); }
public ImGuiFxrTextureHandler(BND4 ffxResourcesBin) { this._ffxTexturesIEnumerable = ffxResourcesBin.Files.Where(item => item.Name.Contains("sfx\\tex")); foreach (var binderFileTpf in _ffxTexturesIEnumerable) { var tpfBytes = binderFileTpf.Bytes; var tpfTexturesList = TPF.Read(tpfBytes).Textures; if (tpfTexturesList.Any()) { var tpf = tpfTexturesList.First(); if (int.TryParse(tpf.Name.TrimStart('s'), out int textureId)) { FfxTexturesIdList.Add(textureId); } } } FfxTexturesIdList.Sort(); LoadAllFfxTexturesInMemory(_ffxTexturesIEnumerable); }
public static SoulsFormats.FLVER LoadMapFlver(string noExtensionPath) { if (File.Exists(noExtensionPath + ".mapbnd.dcx")) { // DS3's snowflake packaging of flvers return(SoulsFormats.FLVER.Read(BND4.Read(noExtensionPath + ".mapbnd.dcx").Files[0].Bytes)); } else if (File.Exists(noExtensionPath + ".flver")) { // Usual case for DS1 with udsfm return(SoulsFormats.FLVER.Read(noExtensionPath + ".flver")); } else if (File.Exists(noExtensionPath + ".flver.dcx")) { // Bloodborne and DS1R return(SoulsFormats.FLVER.Read(noExtensionPath + ".flver.dcx")); } return(null); }
private static PARAM GetParam(BND4 parambnd, string paramfile) { var bndfile = parambnd.Files.Find(x => Path.GetFileName(x.Name) == paramfile); if (bndfile != null) { return(PARAM.Read(bndfile.Bytes)); } // Otherwise the param is a loose param if (File.Exists($@"{AssetLocator.GameModDirectory}\Param\{paramfile}")) { return(PARAM.Read($@"{AssetLocator.GameModDirectory}\Param\{paramfile}")); } if (File.Exists($@"{AssetLocator.GameRootDirectory}\Param\{paramfile}")) { return(PARAM.Read($@"{AssetLocator.GameRootDirectory}\Param\{paramfile}")); } return(null); }
public static void Unpack(this BND4 bnd, string sourceName, string targetDir) { Directory.CreateDirectory(targetDir); XmlWriterSettings xws = new XmlWriterSettings(); xws.Indent = true; XmlWriter xw = XmlWriter.Create($"{targetDir}\\_yabber-bnd4.xml", xws); xw.WriteStartElement("bnd4"); 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("flag1", bnd.Flag1.ToString()); xw.WriteElementString("flag2", bnd.Flag2.ToString()); xw.WriteElementString("unicode", bnd.Unicode.ToString()); xw.WriteElementString("extended", $"0x{bnd.Extended:X2}"); xw.WriteStartElement("files"); foreach (BND4.File file in bnd.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(); }