/// <summary> /// Allow compare with IPackedFileWrapper and IPackedFileDescriptor Objects /// </summary> /// <param name="obj">The Object to compare to</param> /// <returns>true if the TGI Values are the same</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } //passed a FileWrapper, so extract the FileDescriptor if (typeof(IPackedFileWrapper) == obj.GetType().GetInterface("IPackedFileWrapper")) { IPackedFileWrapper pfw = (IPackedFileWrapper)obj; obj = pfw.FileDescriptor; } else { // Check for null values and compare run-time types. if (((typeof(IPackedFileDescriptor) != obj.GetType().GetInterface("IPackedFileDescriptor")) && (GetType() != obj.GetType()))) { return(false); } } IPackedFileDescriptor pfd = (IPackedFileDescriptor)obj; return((Type == pfd.Type) && (LongInstance == pfd.LongInstance) && (Group == pfd.Group)); }
void PFD_DescriptionChanged(object sender, EventArgs e) { IPackedFileDescriptor pfd = (IPackedFileDescriptor)sender; Entry key = null; foreach (object i in packedFiles.Keys) { if (((Entry)i).PFD == pfd) { key = (Entry)i; break; } } if (key == null) { pfd.DescriptionChanged -= new EventHandler(PFD_DescriptionChanged); return; } Remove(key); key = new Entry(key.Package, pfd, key.IsMaxis, key.IsFixed); Add(key); OnFiletableRefresh(this, new EventArgs()); }
AbstractWrapper findInPackage(String pkg, uint Filetype, IPackedFileDescriptor pfd) { IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg); if (p == null) { return(null); } IPackedFileDescriptor pt = p.FindFile(Filetype, pfd.SubType, pfd.Group, pfd.Instance); if (pt == null) { return(null); } AbstractWrapper tgt; if (Filetype == SimPe.Data.MetaData.REF_FILE) { tgt = new SimPe.Plugin.RefFile(); } else { tgt = new SimPe.PackedFiles.Wrapper.Cpf(); } tgt.ProcessData(pt, p); return(tgt); }
/// <summary> /// Returns the Description File for the passed Sim id /// </summary> /// <param name="simid">id of the Sim</param> /// <returns>The Description file for the Sim</returns> /// <remarks> /// If the Description file does not exist in /// the current Package, it will be added! /// </remarks> /// <exception cref="Exception">Thrown when ProcessData was not called.</exception> public SDesc GetDescriptionFile(uint simid) { if (package == null) { throw new Exception("No package loaded!"); } SDesc sdesc = SDesc.FindForSimId(simid, package); if (sdesc == null) { sdesc = new SDesc(null, null, null); sdesc.SimId = simid; sdesc.CharacterDescription.Age = 28; IPackedFileDescriptor[] files = package.FindFiles(SimPe.Data.MetaData.SIM_DESCRIPTION_FILE); sdesc.Instance = 0; foreach (IPackedFileDescriptor pfd in files) { if (pfd.Instance > sdesc.Instance) { sdesc.Instance = (ushort)pfd.Instance; } } sdesc.Instance++; IPackedFileDescriptor fd = package.Add(SimPe.Data.MetaData.SIM_DESCRIPTION_FILE, 0x0, FileDescriptor.Group, sdesc.Instance); sdesc.Save(fd); } return(sdesc); }
public void Dispose() { this.package = null; this.pfd.ChangedData -= new SimPe.Events.PackedFileChanged(pfd_ChangedData); this.pfd = null; }
protected Alias AddSim(SimPe.Interfaces.Files.IPackageFile fl, IPackedFileDescriptor objdpfd, ref int ct, int step) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(objdpfd, fl); return(AddSim(objd, ref ct, step, false)); }
private AbstractWrapper[] getCpf3idrPairInPkg(IPackedFileDescriptor tgtpfd, String pkg) { IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg); if (p == null) { return(null); } IPackedFileDescriptor pc = p.FindFile(tgtpfd); if (pc == null) { return(null); } IPackedFileDescriptor p3 = p.FindFile(SimPe.Data.MetaData.REF_FILE /*3IDR*/, pc.SubType, pc.Group, pc.Instance); if (p3 == null) { return(null); } AbstractWrapper[] tgt = new AbstractWrapper[] { new SimPe.PackedFiles.Wrapper.Cpf(), new SimPe.Plugin.RefFile() }; tgt[0].ProcessData(pc, p); tgt[1].ProcessData(p3, p); return(tgt); }
private bool has3idr(IPackedFileDescriptor pfd, IPackageFile package) { if (pfd == null || package == null) { return(false); } return(findInPackagelist(objkeys, SimPe.Data.MetaData.REF_FILE, pfd) != null); }
void pfd_ChangedData(IPackedFileDescriptor sender) { if (FileTable.filenames[this] != null) { FileTable.filenames.Remove(this); } FileTable.GFT.OnFiletableRefresh(GFT, new EventArgs()); }
public void ProcessData(IPackedFileDescriptor pfd, IPackageFile package, IPackedFile file, bool catchex) { changed = false; if (pfd == null) { return; } if (package == null) { return; } if (catchex) { try { if (file != null) { this.pfd = pfd; this.package = package; file = package.Read(pfd); System.IO.MemoryStream ms = new System.IO.MemoryStream(file.UncompressedData); if (ms.Length > 0) { Unserialize(new System.IO.BinaryReader(ms)); processed = true; } } else { ProcessData(pfd, package); } } catch (Exception ex) { ExceptionMessage(Localization.Manager.GetString("erropenfile"), ex); } } else { if (file != null) { this.pfd = pfd; this.package = package; file = package.Read(pfd); System.IO.MemoryStream ms = new System.IO.MemoryStream(file.UncompressedData); if (ms.Length > 0) { Unserialize(new System.IO.BinaryReader(ms)); processed = true; } } else { ProcessData(pfd, package); } } }
private bool isInPFDList(IPackedFileDescriptor[] pfdList, IPackedFileDescriptor pfd) { foreach (IPackedFileDescriptor i in pfdList) { if (i.Group == pfd.Group && i.Type == pfd.Type && i.LongInstance == pfd.LongInstance) { return(true); } } return(false); }
private List <AbstractWrapper[]> findFragKeys() { List <AbstractWrapper[]> fragKeys = new List <AbstractWrapper[]>(); foreach (String pkg in fragkeys) { IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg); if (p == null) { continue; } IPackedFileDescriptor[] apfd = p.FindFiles(0x0C560F39 /*BINX*/); SimPe.Wait.SubStart(apfd.Length); foreach (IPackedFileDescriptor bx in apfd) { try { // is there a paired 3idr? IPackedFileDescriptor pfd = p.FindFile(SimPe.Data.MetaData.REF_FILE /*3IDR*/, bx.SubType, bx.Group, bx.Instance); if (pfd == null) { continue; } // load the pair SimPe.Plugin.RefFile fk3idr = new SimPe.Plugin.RefFile(); fk3idr.ProcessData(pfd, p); SimPe.PackedFiles.Wrapper.Cpf fkCpf = new SimPe.PackedFiles.Wrapper.Cpf(); fkCpf.ProcessData(bx, p); // does the pair point to the object we're working on? SimPe.PackedFiles.Wrapper.CpfItem objKeyIdx = fkCpf.GetItem("objectidx"); if (objKeyIdx == null || objKeyIdx.Datatype != SimPe.Data.MetaData.DataTypes.dtUInteger) { continue; } if (!fk3idr.Items[objKeyIdx.UIntegerValue].Equals(objKeyCPF)) { continue; } // success - save the fragkey fragKeys.Add(new AbstractWrapper[] { fkCpf, fk3idr }); } finally { SimPe.Wait.Progress++; } } SimPe.Wait.SubStop(); } return(fragKeys); }
private bool isInPFDList(IPackedFileDescriptor[] pfdList, IPackedFileDescriptor pfd) { foreach (IPackedFileDescriptor i in pfdList) { if (i.Filename.Equals(pfd.Filename)) { return(true); } } return(false); }
AbstractWrapper findInPackagelist(List <string> pkgs, uint Filetype, IPackedFileDescriptor pfd) { foreach (String pkg in pkgs) { AbstractWrapper tgt = findInPackage(pkg, Filetype, pfd); if (tgt != null) { return(tgt); } } return(null); }
public Entry(IPackageFile package, IPackedFileDescriptor pfd, bool isMaxis, bool isFixed) { this.package = package; this.pfd = pfd; this.isMaxis = isMaxis; this.isFixed = isFixed; SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] fiis = SimPe.FileTable.FileIndex.FindFile(pfd, package); this.fii = (fiis.Length == 1) ? fiis[0] : null; this.pfd.ChangedData += new SimPe.Events.PackedFileChanged(pfd_ChangedData); }
private void addFile(IPackageFile p, IPackedFileDescriptor pfd) { if (isInPFDList(currentPackage.Index, pfd) || p.FindExactFile(pfd) == null) { return; } IPackedFileDescriptor npfd = p.FindExactFile(pfd).Clone(); npfd.UserData = p.Read(pfd).UncompressedData; currentPackage.Add(npfd, true); }
private SimPe.Plugin.GenericRcol getRcol(IPackedFileDescriptor tgtpfd, List <String> pkgs) { foreach (String pkg in pkgs) { SimPe.Plugin.GenericRcol tgt = getRcolPkg(tgtpfd, pkg); if (tgt != null) { return(tgt); } } return(null); }
private bool IsReallyEnabled(IPackedFileDescriptor pfd, IPackageFile package) { currentPackage = package; if (pfd != null && pfd.Type == SimPe.Data.MetaData.REF_FILE) { refFilePFD = pfd; } else { refFilePFD = null; } return(package != null && refFilePFD != null); }
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); }
public virtual void Dispose() { if (wrapperinfo != null) { wrapperinfo.Dispose(); } if (ui != null) { ui.Dispose(); } ui = null; package = null; pfd = null; }
public Entry[] this[IPackageFile package, IPackedFileDescriptor pfd] { get { if (package == null || pfd == null) { return(new Entry[0]); } return(this[pfd.Type, pfd.Group, pfd.Instance, pfd.Group == 0xffffffff ? Source.Local //: IsMaxis(package) ? Source.Maxis //: IsFixed(package) ? Source.Fixed : Source.Any]); } }
private bool hasCpf(IPackedFileDescriptor pfd, IPackageFile package) { if (pfd == null || package == null) { return(false); } foreach (uint t in new uint[] { 0x0C1FE246 /*XMOL*/, 0x2C1FD8A1 /*XTOL*/, SimPe.Data.MetaData.GZPS }) { if (findInPackagelist(objkeys, t, pfd) != null) { return(true); } } return(false); }
public void Save(IPackedFileDescriptor pfd) { try { System.IO.BinaryWriter bw = new System.IO.BinaryWriter(new System.IO.MemoryStream()); int size = Save(bw); System.IO.BinaryReader br = new System.IO.BinaryReader(bw.BaseStream); br.BaseStream.Seek(0, System.IO.SeekOrigin.Begin); pfd.UserData = br.ReadBytes(size); } catch (Exception ex) { ExceptionMessage(Localization.Manager.GetString("errwritingfile"), ex); } }
/// <summary> /// Checks wether or not the object is already stored in the List /// </summary> /// <param name="item">The Object you are looking for</param> /// <returns>true, if it was found</returns> public bool Contains(IPackedFileDescriptor item) { if (item == null) { return(false); } foreach (IPackedFileDescriptor pfd in this) { if (item.SameAs(pfd)) { return(true); } } return(false); //return base.Contains(item); }
public bool IsEnabled(IPackedFileDescriptor pfd, IPackageFile package) { #if DEBUG pjse.FileTable.GFT.CurrentPackage = package; #else try { pjse.FileTable.GFT.CurrentPackage = package; } catch (Exception e) { SimPe.Helper.ExceptionMessage(e); throw e; } #endif return(true); }
/// <summary> /// Loads String Resource from the Package /// </summary> /// <param name="list">The List where you want to store the Resource</param> /// <param name="instance">The Instance of the TextFile</param> /// <param name="lang">The Language Number</param> public void LoadData(ref ArrayList list, ushort instance, ushort lang) { list = new ArrayList(); if (BasePackage == null) { return; } IPackedFileDescriptor pfd = BasePackage.FindFile(Data.MetaData.STRING_FILE, 0x00000000, 0x7FE59FD0, instance); SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(pfd, BasePackage); SimPe.PackedFiles.Wrapper.StrItemList sis = str.FallbackedLanguageItems((SimPe.Data.MetaData.Languages)lang); for (ushort i = 0; i < sis.Length; i++) { list.Add(sis[i].Title); } //for }
private void tsmi_Click(object sender, EventArgs e) { pjse.FileTable.Entry fe; SimPe.ExpansionItem exp; int i = cmenuCompare.Items.IndexOf((ToolStripItem)sender); if (i < 0) { throw new ArgumentOutOfRangeException("menuItem", "Unrecognised object triggered event"); } else if (i == 0) { pjse.FileTable.Entry[] items = pjse.FileTable.GFT[wrapper.FileDescriptor.Type, wrapper.FileDescriptor.Group, wrapper.FileDescriptor.Instance, pjse.FileTable.Source.Maxis]; if (items == null || items.Length == 0) { MessageBox.Show(pjse.Localization.GetString("cmpNFCurrent", wrapperName), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } fe = items[0]; exp = null; } else { exp = (SimPe.ExpansionItem)cmenuCompare.Items[i].Tag; SimPe.Packages.GeneratableFile op = SimPe.Packages.GeneratableFile.LoadFromFile( System.IO.Path.Combine(System.IO.Path.Combine(exp.InstallFolder, exp.ObjectsSubFolder), "objects.package")); if (op == null) { throw new Exception("Could not read " + exp.Name + " objects.package"); } IPackedFileDescriptor pfd = op.FindFile(wrapper.FileDescriptor); if (pfd == null) { MessageBox.Show(pjse.Localization.GetString("cmpNFExp", wrapperName, exp.Name), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } fe = new pjse.FileTable.Entry(op, pfd, true, false); } OnCompareWith(this, new CompareWithEventArgs(fe, exp)); }
private void addStr(SimPe.PackedFiles.Wrapper.Cpf srcCpf, SimPe.Plugin.RefFile src3idr) { SimPe.PackedFiles.Wrapper.CpfItem cpfItem = srcCpf.GetItem("stringsetidx"); if (cpfItem == null || cpfItem.Datatype != SimPe.Data.MetaData.DataTypes.dtUInteger) { return; } IPackedFileDescriptor ps = srcCpf.Package.FindFile(src3idr.Items[cpfItem.UIntegerValue]); if (ps == null) { return; } SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(ps, srcCpf.Package); addFile(str); }
private bool IsReallyEnabled(IPackedFileDescriptor pfd, IPackageFile package) { if (pfd == null || package == null) { return(false); } if (txmtpkg == null) { SetPacks(); SimPe.FileTable.FileIndex.FILoad += new EventHandler(FileIndex_FILoad); } if (pfd.Type == SimPe.Data.MetaData.REF_FILE) { return(hasCpf(pfd, package)); } else if (pfd.Type == 0x0C1FE246 /*XMOL*/ || pfd.Type == 0x2C1FD8A1 /*XTOL*/ || pfd.Type == SimPe.Data.MetaData.GZPS) { return(has3idr(pfd, package)); } return(false); }
/// <summary> /// Returns the Number of the File matching the passed Descriptor /// </summary> /// <param name="pfd">A PackedFileDescriptor</param> /// <returns>-1 if none was foudn or the index number of the first matching file</returns> public int FindFile(IPackedFileDescriptor pfd) { if (items == null) { return(-1); } for (int i = 0; i < this.items.Length; i++) { ClstItem lfi = items[i]; if ((lfi.Group == pfd.Group) && (lfi.Instance == pfd.Instance) && ((lfi.SubType == pfd.SubType) || (iformat == Data.MetaData.IndexTypes.ptShortFileIndex)) && (lfi.Type == pfd.Type)) { return(i); } } return(-1); }