public bool LinkBodyMesh(SimPe.Plugin.RefFile refFile) { if (refFile.Items[0].Type != SimPe.Data.MetaData.CRES || refFile.Items[1].Type != SimPe.Data.MetaData.SHPE) { MessageBox.Show(L.Get("noCRESSHPE"), L.Get("pjSML"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } String meshPackage = getFilename(); if (meshPackage == null || meshPackage.Length == 0) { return(false); } IPackageFile p = null; try { p = SimPe.Packages.File.LoadFromFile(meshPackage); } catch { p = null; } if (p == null) { MessageBox.Show(L.Get("didNotOpen") + "\r\n" + meshPackage, L.Get("pjSML"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } IPackedFileDescriptor[] pfa = p.FindFiles(SimPe.Data.MetaData.CRES); IPackedFileDescriptor[] pfb = p.FindFiles(SimPe.Data.MetaData.SHPE); if (pfa == null || pfa.Length != 1 || pfb == null || pfb.Length != 1) { MessageBox.Show(L.Get("badMeshPackage") + "\r\n" + meshPackage, L.Get("pjSML"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } refFile.Items[0].Group = pfa[0].Group; refFile.Items[0].SubType = pfa[0].SubType; refFile.Items[0].Instance = pfa[0].Instance; refFile.Items[1].Group = pfb[0].Group; refFile.Items[1].SubType = pfb[0].SubType; refFile.Items[1].Instance = pfb[0].Instance; return(true); }
/// <summary> /// Returns the Primary Guid of the Object /// </summary> /// <returns>0 or the default guid</returns> public uint GetPrimaryGuid() { uint guid = 0; SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFile(Data.MetaData.OBJD_FILE, 0, 0x41A7); if (pfds.Length == 0) { pfds = package.FindFiles(Data.MetaData.OBJD_FILE); } if (pfds.Length > 0) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(pfds[0], package); guid = objd.Guid; } return(guid); }
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); }
/// <summary> /// ind the ResourceNode that is referencing the passed Shape /// </summary> /// <param name="shpe"></param> /// <returns></returns> protected SimPe.Plugin.Rcol FindResourceNode(SimPe.Plugin.Rcol shpe) { Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(0xE519C933); Interfaces.Files.IPackedFileDescriptor pfd = shpe.FileDescriptor; foreach (Interfaces.Files.IPackedFileDescriptor cpfd in pfds) { SimPe.Plugin.Rcol cres = new GenericRcol(null, false); cres.ProcessData(cpfd, package); foreach (Interfaces.Files.IPackedFileDescriptor rpfd in cres.ReferencedFiles) { if ((rpfd.Group == pfd.Group) && (rpfd.Instance == pfd.Instance) && (rpfd.SubType == pfd.SubType) && (rpfd.Type == pfd.Type)) { return(cres); } } } return(new GenericRcol(null, false)); }
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); }
/// <summary> /// Changes all guids (Depends on the passed Replacement Map) /// </summary> /// <param name="guids">List of GuidSet Objects</param> public void FixGuids(ArrayList guids) { Interfaces.Files.IPackedFileDescriptor[] mpfds = package.FindFiles(Data.MetaData.MMAT); foreach (Interfaces.Files.IPackedFileDescriptor pfd in mpfds) { SimPe.PackedFiles.Wrapper.Cpf mmat = new SimPe.PackedFiles.Wrapper.Cpf(); mmat.ProcessData(pfd, package); if (guids != null) { foreach (GuidSet sget in guids) { if (mmat.GetSaveItem("objectGUID").UIntegerValue == sget.oldguid) { mmat.GetSaveItem("objectGUID").UIntegerValue = sget.guid; mmat.SynchronizeUserData(); } } } } }
private void Main() { ArrayList al = new ArrayList(); #region Prompt for mesh name or browse for package and extract names GetMeshName gmn = new GetMeshName(); DialogResult dr = gmn.ShowDialog(); if (dr.Equals(DialogResult.OK)) { if (gmn.MeshName.Length > 0) { al.Add(gmn.MeshName); } else { MessageBox.Show(L.Get("noMeshName"), L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else if (dr.Equals(DialogResult.Retry)) // nasty... { #region Get body mesh package file name and open the package String bodyMeshPackage = getFilename(); if (bodyMeshPackage == null) { return; } IPackageFile p = SimPe.Packages.File.LoadFromFile(bodyMeshPackage); if (p == null) { return; } #endregion #region Find the Property Set or XML Mesh Overlay IPackedFileDescriptor[] pfa = p.FindFiles(SimPe.Data.MetaData.GZPS); IPackedFileDescriptor[] pfb = p.FindFiles(0x0C1FE246); // XMOL? if ((pfa == null || pfa.Length == 0) && (pfb == null || pfb.Length == 0)) { MessageBox.Show(L.Get("noGZPSXMOL"), L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion #region Get the mesh name(s) bool prompted = false; SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf(); for (int i = 0; i < pfa.Length + pfb.Length; i++) { if (i < pfa.Length) { cpf.ProcessData(pfa[i], p); } else { cpf.ProcessData(pfb[i - pfa.Length], p); } for (int j = 0; j < cpf.Items.Length; j++) { if (cpf.Items[j].Name.ToLower().Equals("name")) { al.Add(cpf.Items[j].StringValue); } if (al.Count > 1 && !prompted) { if (MessageBox.Show(L.Get("multipleMeshes"), L.Get("pjSME"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } prompted = true; } } } if (al.Count == 0) { MessageBox.Show(L.Get("noMeshPkg"), L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion } else { return; } #endregion #region For each mesh, find the GMDC, GMND, SHPE and CRES and add them to the current package foreach (String m in al) { String[] ma = m.Split('_'); String mesh = ma[ma[0].Equals("CASIE") ? 1 : 0]; if (mesh.ToLower().StartsWith("ym")) { mesh = "am" + mesh.Substring(2); } if (mesh.ToLower().StartsWith("yf")) { mesh = "af" + mesh.Substring(2); } bool success = true; SimPe.RemoteControl.ApplicationForm.Cursor = Cursors.WaitCursor; success = success && findAndAdd(mesh, SimPe.Data.MetaData.GMDC, "Sims03.package"); success = success && findAndAdd(mesh, SimPe.Data.MetaData.GMND, "Sims04.package"); success = success && findAndAdd(mesh, SimPe.Data.MetaData.SHPE, "Sims05.package"); success = success && findAndAdd(mesh, SimPe.Data.MetaData.CRES, "Sims06.package"); SimPe.RemoteControl.ApplicationForm.Cursor = Cursors.Default; if (!success) { MessageBox.Show(L.Get("notAllPartsFound") + m, L.Get("pjSME"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } #endregion }