private void FillFileExtensionCB(IWitcherArchiveManager manager) { var fileExtensions = manager.Extensions; fileExtensions.Sort(); fileExtensionsCB.Items.AddRange(fileExtensions.ToArray()); fileExtensionsCB.SelectedIndex = 0; }
/// <summary> /// Unbundles a file with the given relativepath from either the Game or the Mod BundleManager /// and adds it to the depot, optionally copying to the project /// </summary> /// <param name="relativePath"></param> /// <param name="isDLC"></param> /// <param name="projectFolder"></param> /// <param name="bundleType"></param> /// <param name="alternateOutDirectory"></param> /// <param name="loadmods"></param> /// <param name="silent"></param> /// <returns></returns> public static string UnbundleFile(string relativePath, bool isDLC, EProjectFolders projectFolder, EBundleType bundleType = EBundleType.Bundle, string alternateOutDirectory = "", bool loadmods = false, bool silent = false) { string extension = Path.GetExtension(relativePath); string filename = Path.GetFileName(relativePath); // Jato said not to add textures to an fbx // so I am keeping meshes violet :) //if (extension == ".xbm" && bundleType == EBundleType.Bundle) //{ // //var uncookTask = Task.Run(() => UncookFileToPath(relativePath, isDLC, alternateOutDirectory)); // //Task.WaitAll(uncookTask); // //return relativePath; // UnbundleFile(relativePath, isDLC, projectFolder, EBundleType.TextureCache, alternateOutDirectory, // loadmods, silent); //} IWitcherArchiveManager manager = MainController.Get().GetManagers(loadmods).FirstOrDefault(_ => _.TypeName == bundleType); if (manager != null && manager.Items.Any(x => x.Value.Any(y => y.Name == relativePath))) { var archives = manager.FileList .Where(x => x.Name == relativePath) .Select(y => new KeyValuePair <string, IWitcherFile>(y.Bundle.ArchiveAbsolutePath, y)) .ToList(); // Extract try { // if more than one archive get the last var archive = archives.Last().Value; string newpath = ""; if (string.IsNullOrWhiteSpace(alternateOutDirectory)) { switch (projectFolder) { case EProjectFolders.Cooked: newpath = Path.Combine(isDLC ? ActiveMod.DlcCookedDirectory : ActiveMod.ModCookedDirectory, relativePath); break; case EProjectFolders.Uncooked: newpath = Path.Combine(isDLC ? ActiveMod.DlcUncookedDirectory : ActiveMod.ModUncookedDirectory, relativePath); break; case EProjectFolders.Raw: default: break; } } else { newpath = Path.Combine(alternateOutDirectory, relativePath); } if (string.IsNullOrWhiteSpace(newpath)) { return(""); } if (!(extension == ".xbm" && bundleType == EBundleType.Bundle) || !File.Exists(newpath)) { string extractedfile = archive.Extract(new BundleFileExtractArgs(newpath, MainController.Get().Configuration.UncookExtension)); if (!silent) { Logger.LogString($"Succesfully unbundled {filename}.", Logtype.Success); } } else if (!silent) { Logger.LogString($"File already exists in mod project: {filename}.", Logtype.Success); } return(newpath); } catch (Exception ex) { Logger.LogString(ex.ToString(), Logtype.Error); return(""); } } return(""); }