private void BuildVoice() { var outBsaPath = Path.Combine(DirTTWOptional, "Fallout3 Player Voice", "TaleOfTwoWastelands - PlayerVoice.bsa"); if (File.Exists(outBsaPath)) { return; } var inBsaPath = Path.Combine(DirFO3Data, "Fallout - Voices.bsa"); using (BSA inBsa = new BSA(inBsaPath), outBsa = new BSA(inBsa.Settings)) { var includedFolders = inBsa .Where(folder => Game.VoicePaths.ContainsKey(folder.Path)) .Select(folder => new BSAFolder(Game.VoicePaths[folder.Path], folder)); foreach (var folder in includedFolders) { outBsa.Add(folder); } outBsa.Save(outBsaPath); } }
public static IEnumerable<Tuple<string, string, string>> CreateRenameQuery(BSA bsa, IDictionary<string, string> renameDict) { //TODO: use dict union var renameGroup = from folder in bsa from file in folder join kvp in renameDict on file.Filename equals kvp.Value let a = new { folder, file, kvp } //group a by kvp.Value into g select a; var renameCopies = from g in renameGroup let newFilename = g.kvp.Key let newDirectory = Path.GetDirectoryName(newFilename) let a = new { g.folder, g.file, newFilename } group a by newDirectory into outs select outs; var newBsaFolders = renameCopies.ToList(); newBsaFolders.ForEach(g => bsa.Add(new BSAFolder(g.Key))); return from g in newBsaFolders from a in g join folder in bsa on g.Key equals folder.Path let newFile = a.file.DeepCopy(g.Key, Path.GetFileName(a.newFilename)) let addedFile = folder.Add(newFile) select Tuple.Create(a.file.Name, newFile.Name, a.newFilename); }
private void BuildSFX() { var fo3BsaPath = Path.Combine(DirFO3Data, "Fallout - Sound.bsa"); var songsPath = Path.Combine("sound", "songs"); bool skipSongs = false, skipSFX = false; if (Directory.Exists(Path.Combine(DirTTWMain, songsPath))) { skipSongs = ShowSkipDialog("Fallout 3 songs"); } var outBsaPath = Path.Combine(DirTTWOptional, "Fallout3 Sound Effects", "TaleOfTwoWastelands - SFX.bsa"); if (File.Exists(outBsaPath)) { skipSFX = ShowSkipDialog("Fallout 3 sound effects"); } if (skipSongs && skipSFX) { return; } var bsaInstaller = DependencyRegistry.Container.GetInstance <BsaInstaller>(); using (BSA inBsa = new BSA(fo3BsaPath), outBsa = new BSA(inBsa.Settings)) { if (!skipSongs) { Log.Display("Extracting songs"); bsaInstaller.Extract(Token, inBsa.Where(folder => folder.Path.StartsWith(songsPath)), "Fallout - Sound", DirTTWMain, false); } if (skipSFX) { return; } Log.Display("Building optional TaleOfTwoWastelands - SFX.bsa..."); var fxuiPath = Path.Combine("sound", "fx", "ui"); var includedFilenames = new HashSet <string>(File.ReadLines(Path.Combine(Paths.AssetsDir, "TTW Data", "TTW_SFXCopy.txt"))); var includedGroups = from folder in inBsa.Where(folder => folder.Path.StartsWith(fxuiPath)) from file in folder where includedFilenames.Contains(file.Filename) group file by folder; foreach (var group in includedGroups) { //make folder only include files that matched includedFilenames @group.Key.IntersectWith(@group); //add folders back into output BSA outBsa.Add(@group.Key); } Log.File("Building TaleOfTwoWastelands - SFX.bsa."); outBsa.Save(outBsaPath); Log.Display("\tDone"); } }