private bool addFromPkg(String name, uint type, String pkg) { IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg); if (p == null) { return(false); } IPackedFileDescriptor[] pfa = p.FindFiles(SimPe.Data.MetaData.NAME_MAP); if (pfa == null || pfa.Length != 1) { return(false); } SimPe.Plugin.Nmap nmap = new SimPe.Plugin.Nmap(null); nmap.ProcessData(pfa[0], p); pfa = nmap.FindFiles(name + "_"); if (pfa == null || pfa.Length != 1) { return(false); } IPackedFileDescriptor pfd = null; for (int j = 0; j < p.Index.Length && pfd == null; j++) { if (p.Index[j].Type == type && p.Index[j].Group == pfa[0].Group && p.Index[j].Instance == pfa[0].Instance) { pfd = p.Index[j]; } } if (pfd == null) { return(false); } if (isInPFDList(currentPackage.Index, pfd)) { return(true); } IPackedFileDescriptor npfd = pfd.Clone(); npfd.UserData = p.Read(pfd).UncompressedData; currentPackage.Add(npfd, true); return(true); }
protected void LoadSkinImageFormPackage(SimPe.Interfaces.Files.IPackageFile package) { Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(0xAC506764); foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { try { SimPe.Plugin.RefFile reffile = new SimPe.Plugin.RefFile(); reffile.ProcessData(pfd, package); refs.Add(reffile); } catch (Exception) {} } pfds = package.FindFiles(0x49596978); foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { try { SimPe.Plugin.Rcol matd = new SimPe.Plugin.GenericRcol(null, true); matd.ProcessData(pfd, package); matds.Add(matd); } catch (Exception) {} } //Material Files Interfaces.Files.IPackedFileDescriptor[] nmap_pfd = package.FindFiles(Data.MetaData.NAME_MAP); pfds = package.FindFiles(0x49596978); Plugin.Nmap nmap = new SimPe.Plugin.Nmap(null); if (nmap_pfd.Length > 0) { nmap.ProcessData(nmap_pfd[0], package); } bool check = false; foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { try { SimPe.Plugin.Rcol matd = new SimPe.Plugin.GenericRcol(null, true); check = false; foreach (Interfaces.Files.IPackedFileDescriptor epfd in nmap.Items) { if ( (epfd.Group == pfd.Group) && (epfd.Instance == pfd.Instance) ) { matd.FileDescriptor = pfd; matd.Package = package; matds.Add(matd); check = true; } } //not found in the FileMap, so process Normally if (!check) { matd.ProcessData(pfd, package); matds.Add(matd); } } catch (Exception) {} } //Texture Files nmap_pfd = package.FindFiles(Data.MetaData.NAME_MAP); pfds = package.FindFiles(0x1C4A276C); check = false; foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { try { SimPe.Plugin.Txtr txtr = new SimPe.Plugin.Txtr(null, true); check = false; foreach (Interfaces.Files.IPackedFileDescriptor epfd in nmap.Items) { if ( (epfd.Group == pfd.Group) && (epfd.Instance == pfd.Instance) ) { txtr.FileDescriptor = pfd; txtr.Package = package; txtrs.Add(epfd.Filename, txtr); continue; } } //not found in the FileMap, so process Normally if (!check) { txtr.ProcessData(pfd, package); foreach (SimPe.Plugin.ImageData id in txtr.Blocks) { txtrs.Add(id.NameResource.FileName.ToLower(), txtr); } } } catch (Exception) {} } }
public void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs es) { if (!RealChangeEnabledStateEventHandler(null, es)) { System.Windows.Forms.MessageBox.Show(Localization.GetString("This is not an appropriate context in which to use this tool"), Localization.GetString(this.ToString())); return; } SimPe.Interfaces.Files.IPackedFileDescriptor pfd = null; for (int i = 0; i < es.Count; i++) { if (es[i].HasFileDescriptor) { pfd = es[i].Resource.FileDescriptor; break; } } Data.TypeAlias a = Helper.TGILoader.GetByType(pfd.Type); if (Data.MetaData.RcolList.Contains(a.Id)) { SimPe.Packages.PackedFileDescriptor fd = new SimPe.Packages.PackedFileDescriptor(); fd.Type = Data.MetaData.NAME_MAP; fd.Group = 0x52737256; fd.Instance = a.Id; fd.SubType = 0; SimPe.Plugin.Nmap nmap = new SimPe.Plugin.Nmap(FileTable.ProviderRegistry); nmap.FileDescriptor = fd; bool add = false; if (es.LoadedPackage.Package.FindFile(fd) == null) { add = true; } System.Collections.ArrayList list = new System.Collections.ArrayList(); foreach (SimPe.Events.ResourceContainer e in es) { if (!e.HasFileDescriptor) { continue; } if (e.Resource.FileDescriptor.Type != a.Id) { continue; } try { SimPe.Packages.PackedFileDescriptor p = (SimPe.Packages.PackedFileDescriptor)e.Resource.FileDescriptor; SimPe.Plugin.Rcol rcol = new SimPe.Plugin.GenericRcol(null, false); rcol.ProcessData(p, es.LoadedPackage.Package); p.Filename = rcol.FileName; list.Add(p); } catch (Exception) {} } //foreach nmap.Items = new SimPe.Packages.PackedFileDescriptor[list.Count]; list.CopyTo(nmap.Items); nmap.SynchronizeUserData(); if (add) { es.LoadedPackage.Package.Add(nmap.FileDescriptor); } } }