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); }
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); }
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); }
private void Main() { if (!MessageBox.Show(L.Get("pjSMLbegin"), L.Get("pjSML"), MessageBoxButtons.OKCancel, MessageBoxIcon.Information).Equals(DialogResult.OK)) { return; } SimPe.Plugin.RefFile refFile = new SimPe.Plugin.RefFile(); refFile.ProcessData(refFilePFD, currentPackage); if (LinkBodyMesh(refFile)) { refFile.SynchronizeUserData(); MessageBox.Show(L.Get("pjSMLdone"), L.Get("pjSML"), MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private SimPe.Plugin.GenericRcol getRcol(SimPe.PackedFiles.Wrapper.Cpf srcCpf, SimPe.Plugin.RefFile src3idr, String cpfItemKey, List <String> pkgs) { SimPe.PackedFiles.Wrapper.CpfItem cpfItem = srcCpf.GetItem(cpfItemKey); if (cpfItem == null || cpfItem.Datatype != SimPe.Data.MetaData.DataTypes.dtUInteger) { return(null); } foreach (String pkg in pkgs) { SimPe.Plugin.GenericRcol tgt = getRcolPkg(src3idr.Items[cpfItem.UIntegerValue], pkg); if (tgt != null) { return(tgt); } } return(null); }
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 void makeCpf3idrPair() { objKeyCPF = null; objKey3IDR = null; if (currentPfd == null || currentPackage == null) { return; } if (currentPfd.Type == 0x0C1FE246 /*XMOL*/ || currentPfd.Type == 0x2C1FD8A1 /*XTOL*/ || currentPfd.Type == SimPe.Data.MetaData.GZPS) { AbstractWrapper p3 = findInPackagelist(objkeys, SimPe.Data.MetaData.REF_FILE, currentPfd); if (p3 != null) { objKeyCPF = new SimPe.PackedFiles.Wrapper.Cpf(); objKeyCPF.ProcessData(currentPfd, currentPackage); addFile(p3); objKey3IDR = new SimPe.Plugin.RefFile(); objKey3IDR.ProcessData(p3.FileDescriptor, p3.Package); } } else if (currentPfd.Type == SimPe.Data.MetaData.REF_FILE /*3IDR*/) { foreach (uint t in new uint[] { 0x0C1FE246 /*XMOL*/, 0x2C1FD8A1 /*XTOL*/, SimPe.Data.MetaData.GZPS }) { AbstractWrapper pc = (SimPe.PackedFiles.Wrapper.Cpf)findInPackagelist(objkeys, t, currentPfd); if (pc != null) { addFile(pc); objKeyCPF = new SimPe.PackedFiles.Wrapper.Cpf(); objKeyCPF.ProcessData(pc.FileDescriptor, pc.Package); objKey3IDR = new SimPe.Plugin.RefFile(); objKey3IDR.ProcessData(currentPfd, currentPackage); break; } } } }
/// <summary> /// Updates the SkinTone References in the 3IDR Files /// </summary> /// <param name="reffile">the 3IDR File</param><param name="skin">the new skintone</param> /// <param name="skinfiles">a Hashtable listing al Proerty Sets for each available skintone (key=skintone string, value= ArrayList of Cpf Objects)</param> void UpdateSkintone(SimPe.Plugin.RefFile reffile, string skin, Hashtable skinfiles) { if (reffile == null) { return; } if (reffile.Items == null) { return; } if (reffile.Package == null) { return; } for (int i = 0; i < reffile.Items.Length; i++) { SimPe.Interfaces.Files.IPackedFileDescriptor pfd = (SimPe.Interfaces.Files.IPackedFileDescriptor)reffile.Items[i]; if (pfd == null) { continue; } if (pfd.Type == Data.MetaData.GZPS) { SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] fii = FileTable.FileIndex.FindFile(pfd, reffile.Package); if (fii.Length > 0) { Cpf skinfile = new Cpf(); skinfile.ProcessData(fii[0]); reffile.Items[i] = UpdateSkintone(skinfile, skin, skinfiles); } } } reffile.SynchronizeUserData(); }
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) {} } }