public GraphNode(ResourceGraph graph, IResourceKey originalKey, IResourceNode core, PathPackageTuple origin, ResourceDataActions nodeActions, RFileType fileType = RFileType.Unknown) { this.Graph = graph; this.key = new RK(originalKey); this.OriginalKey = new RK(originalKey); this.ExtensionTag = s3pi.Extensions.ExtList.Ext[originalKey.ResourceType][0]; this.NodeActions = nodeActions; this.Core = core; this.Origin = origin; if (fileType == RFileType.Unknown) { this.fileType = ResourceGraph.GetFileType(originalKey.ResourceType); } else { this.fileType = fileType; } switch (this.fileType) { case RFileType.Game: this.name = NameMap.GameNMap.GetName(originalKey.Instance, origin); break; case RFileType.DDS: this.name = NameMap.DDSNMap.GetName(originalKey.Instance, origin); break; case RFileType.Thum: this.name = NameMap.ThumNMap.GetName(originalKey.Instance, origin); break; } this.originalName = this.name; }
IEnumerable <SpecificResource> Find(PathPackageTuple ppt) { return(ppt.FindAll(rie => stopSearch ? false : criteria.catalogType == 0 ? Enum.IsDefined(typeof(CatalogType), rie.ResourceType) : criteria.catalogType == (CatalogType)rie.ResourceType)); }
public string GetName(ulong instance, PathPackageTuple package) { int i; PNMap pnmap; if (package != null) { for (i = 0; i < namemaps.Count; i++) { pnmap = namemaps[i]; if (package.Equals(pnmap.Package)) { if (pnmap.NMap.ContainsKey(instance)) { return(pnmap.NMap[instance]); } } } } for (i = 0; i < namemaps.Count; i++) { pnmap = namemaps[i]; if (pnmap.NMap.ContainsKey(instance)) { return(pnmap.NMap[instance]); } } return(null); }
Manifest(PathPackageTuple ppt, string packageid, string packagetype, string subtype, string title, string desc, bool createMissingThumb) : base(0, null) { this.ppt = ppt; this.packageid = packageid; this.packagetype = packagetype; this.subtype = subtype; this.title = title; this.desc = desc; this.createMissingThumb = createMissingThumb; }
Manifest(PathPackageTuple ppt, string packageid, string packagetype, string subtype, string title, string desc, bool createMissingThumb) : base(0, null) { this.ppt = ppt; this.packageid = packageid; this.packagetype = packagetype; this.subtype = subtype; this.title = title; this.desc = desc; this.createMissingThumb = createMissingThumb; }
public void LoadThumbnails() { if (this.mThumbnails == null && FileTable.FileTableEnabled) { bool ccEnabled = FileTable.CustomContentEnabled; PathPackageTuple ppt = FileTable.Current; FileTable.CustomContentEnabled = false; FileTable.Current = null; this.mThumbnails = this.LoadPackages( FileTable.Thumbnails, "Thumbnails"); FileTable.CustomContentEnabled = ccEnabled; FileTable.Current = ppt; } }
public void LoadDDSImages() { if (this.mDDSImages == null && FileTable.FileTableEnabled) { bool ccEnabled = FileTable.CustomContentEnabled; PathPackageTuple ppt = FileTable.Current; FileTable.CustomContentEnabled = false; FileTable.Current = null; this.mDDSImages = this.LoadPackages( FileTable.DDSImages, "DDS Images"); FileTable.CustomContentEnabled = ccEnabled; FileTable.Current = ppt; } }
public void LoadGameContent() { if (this.mGameContent == null && FileTable.FileTableEnabled) { bool ccEnabled = FileTable.CustomContentEnabled; PathPackageTuple ppt = FileTable.Current; FileTable.CustomContentEnabled = false; FileTable.Current = null; this.mGameContent = this.LoadPackages( FileTable.GameContent, "Game Content"); FileTable.CustomContentEnabled = ccEnabled; FileTable.Current = ppt; } }
public SaveList(MainForm mainForm, SpecificResource selectedItem, Dictionary<string, IResourceKey> rkList, PathPackageTuple target, bool compress, bool addSTBLs, bool padSTBLs, bool zeroSTBLIID, bool excludeCommonResources, MainForm.updateProgressCallback updateProgressCB, StopSavingCallback stopSavingCB, SaveListComplete savingCompleteCB) { this.mainForm = mainForm; this.selectedItem = selectedItem; this.rkList = rkList; this.target = target; this.compress = compress; this.addSTBLs = addSTBLs; this.padSTBLs = padSTBLs; this.zeroSTBLIID = zeroSTBLIID; this.excludeCommonResources = excludeCommonResources; this.updateProgressCB = updateProgressCB; this.stopSavingCB = stopSavingCB; this.savingCompleteCB = savingCompleteCB; }
public SaveList(MainForm mainForm, SpecificResource selectedItem, Dictionary <string, IResourceKey> rkList, PathPackageTuple target, bool compress, bool addSTBLs, bool padSTBLs, bool zeroSTBLIID, bool excludeCommonResources, MainForm.updateProgressCallback updateProgressCB, StopSavingCallback stopSavingCB, SaveListComplete savingCompleteCB) { this.mainForm = mainForm; this.selectedItem = selectedItem; this.rkList = rkList; this.target = target; this.compress = compress; this.addSTBLs = addSTBLs; this.padSTBLs = padSTBLs; this.zeroSTBLIID = zeroSTBLIID; this.excludeCommonResources = excludeCommonResources; this.updateProgressCB = updateProgressCB; this.stopSavingCB = stopSavingCB; this.savingCompleteCB = savingCompleteCB; }
public static void UpdatePackage(string path, string packageid, string packagetype, string subtype, string title, string desc, bool createMissingThumb) { PathPackageTuple ppt = new PathPackageTuple(path, true); try { FileTable.Current = ppt; ppt.Package.FindAll(rie => rie.ResourceType == 0x73E93EEB).ForEach(rie => rie.IsDeleted = true); Manifest mf = new Manifest(ppt, packageid, packagetype, subtype, title, desc, createMissingThumb); var r = ppt.Package.AddResource(new TGIBlock(0, null, 0x73E93EEB, 0, 0), mf.Stream, false); if (mf.numofCatlgResources == 0) throw new ApplicationException("No objects found in package. Cannot create Sims3Pack."); ppt.Package.SavePackage(); } finally { s3pi.Package.Package.ClosePackage(0, ppt.Package); FileTable.Current = null; } }
public static void UpdatePackage(string path, string packageid, string packagetype, string subtype, string title, string desc, bool createMissingThumb) { PathPackageTuple ppt = new PathPackageTuple(path, true); try { FileTable.Current = ppt; ppt.Package.FindAll(rie => rie.ResourceType == 0x73E93EEB).ForEach(rie => rie.IsDeleted = true); Manifest mf = new Manifest(ppt, packageid, packagetype, subtype, title, desc, createMissingThumb); var r = ppt.Package.AddResource(new TGIBlock(0, null, 0x73E93EEB, 0, 0), mf.Stream, false); if (mf.numofCatlgResources == 0) { throw new ApplicationException("No objects found in package. Cannot create Sims3Pack."); } ppt.Package.SavePackage(); } finally { s3pi.Package.Package.ClosePackage(0, ppt.Package); FileTable.Current = null; } }
static IEnumerable<PathPackageTuple> ccGetList(string ccPath) { List<PathPackageTuple> ppts = new List<PathPackageTuple>(); if (ccPath != null && Directory.Exists(ccPath)) { //Depth-first search foreach (var dir in Directory.GetDirectories(ccPath)) { foreach (var ppt in ccGetList(dir)) yield return ppt; } foreach (string pattern in CCpkgPatterns) foreach (var path in Directory.GetFiles(ccPath, pattern)) { PathPackageTuple ppt = null; try { ppt = new PathPackageTuple(path); } catch (InvalidDataException) { continue; } yield return ppt; } } }
IEnumerable<SpecificResource> Find(PathPackageTuple ppt) { return ppt.FindAll(rie => stopSearch ? false : criteria.catalogType == 0 ? Enum.IsDefined(typeof(CatalogType), rie.ResourceType) : criteria.catalogType == (CatalogType)rie.ResourceType); }
public PNMap(PathPackageTuple package, IDictionary <ulong, string> nmap) { this.Package = package; this.NMap = nmap; }
public void Search() { bool complete = false; bool abort = false; List <ulong> lres = new List <ulong>(); List <string> errors = new List <string>(); try { updateProgress(true, "Searching...", true, FileTable.GameContent.Count + 1, true, 1); for (int p = 0; p < FileTable.GameContent.Count; p++) { if (stopSearch) { return; } PathPackageTuple ppt = FileTable.GameContent[p]; if (criteria.text.Length > 0) { #region Fetch name map if (criteria.resourceName) { updateProgress(true, String.Format("Retrieving name map for package {0} of {1}...", p + 1, FileTable.GameContent.Count), false, -1, false, -1); SpecificResource sr = ppt.Find(rie => rie.ResourceType == 0x0166038C);//NMAP nameMap = sr == null ? null : sr.Resource as IDictionary <ulong, string>; if (stopSearch) { return; } } #endregion #region Fetch STBLs if (criteria.catalogType != CatalogType.CAS_Part) { if (criteria.catalogName || criteria.catalogDesc) { updateProgress(true, String.Format("Retrieving string tables for package {0} of {1}...", p + 1, FileTable.GameContent.Count), true, -1, false, 0); stbls = new List <IDictionary <ulong, string> >(); foreach (var rk in ppt.Package.FindAll(rie => rie.ResourceType == 0x220557DA && //STBL (criteria.allLanguages || rie.Instance >> 56 == 0x00))) { if (stopSearch) { return; } SpecificResource sr = new SpecificResource(ppt, rk); var stbl = sr.Resource as IDictionary <ulong, string>; if (stbl == null) { continue; } stbls.Add(stbl); } } } #endregion } // Find the right type of resource to search and apply matching updateProgress(true, String.Format("Searching package {0} of {1}...", p + 1, FileTable.GameContent.Count), false, -1, false, -1); foreach (var match in Find(ppt).Where(sr => stopSearch || (!lres.Contains(sr.RequestedRK.Instance) && (criteria.text.Length == 0 || Match(sr, errors))))) { if (stopSearch) { return; } lres.Add(match.RequestedRK.Instance); Add(match); } updateProgress(false, "", false, -1, true, p + 2); } complete = true; } catch (ThreadAbortException) { abort = true; } finally { if (!abort) { updateProgress(true, "Search ended", true, -1, false, 0); searchComplete(complete, errors); } } }