private void findMaterials(ref List <SimPe.Plugin.GenericRcol> rcolChain, SimPe.Plugin.GenericRcol txmt) { ArrayList txtrs = (ArrayList)txmt.ReferenceChains["stdMatBaseTextureName"];//["TXTR"]; if (txtrs != null && txtrs.Count > 0) { SimPe.Plugin.GenericRcol txtr = getRcol((IPackedFileDescriptor)txtrs[0], txtrpkg); if (txtr != null) { rcolChain.Add(txtr); foreach (SimPe.Plugin.ImageData id in txtr.Blocks) { foreach (SimPe.Plugin.MipMapBlock mmb in id.MipMapBlocks) { foreach (SimPe.Plugin.MipMap mm in mmb.MipMaps) { if (mm.DataType == SimPe.Plugin.MipMapType.LifoReference && mm.LifoFile.Length > 0) { SimPe.Plugin.GenericRcol lifo = getRcol(mm.LifoFile, lifopkg); if (lifo != null) { rcolChain.Add(lifo); } } } } } } } }
public ListedMeshBlocks(AnimationMeshBlock amb) { this.amb = amb; cres = amb.FindDefiningCRES(); if (cres != null) { gmdc = amb.FindUsedGMDC(cres); } }
private void llscan_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { #if DEBUG FileTable.FileIndex.Load(); System.IO.StreamWriter sw = System.IO.File.CreateText(@"G:\txmt.txt"); Hashtable ht = new Hashtable(); FileTable.FileIndex.AddIndexFromFolder(@":G:\EA Games\Die Sims 2\"); try { SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(Data.MetaData.TXMT, true); foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { Rcol txmt = new SimPe.Plugin.GenericRcol(null, false); txmt.ProcessData(item); SimPe.Plugin.MaterialDefinition md = (SimPe.Plugin.MaterialDefinition)txmt.Blocks[0]; foreach (MaterialDefinitionProperty mdp in md.Properties) { if (!ht.ContainsKey(mdp.Name)) { ht.Add(mdp.Name, "| " + mdp.Value + " | "); } else { string s = (string)ht[mdp.Name]; if (s.IndexOf("| " + mdp.Value + " |") == -1) { s += mdp.Value + " | "; ht[mdp.Name] = s; } } } } foreach (string k in ht.Keys) { //if (!MaterialDefinition.PropertyParser.Properties.ContainsKey(k)) { string v = (string)ht[k]; string[] parts = v.Split("|".ToCharArray(), 3); sw.Write(k + "; "); sw.WriteLine((string)ht[k]); } } } finally { sw.Close(); sw.Dispose(); sw = null; } #endif }
private SimPe.Plugin.GenericRcol getRcol(String filename, List <String> pkgs) { foreach (String pkg in pkgs) { SimPe.Plugin.GenericRcol tgt = getRcolPkg(filename, pkg); if (tgt != null) { return(tgt); } } return(null); }
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); }
/// <summary> /// Returns the Property Set (=cpf) of a Skin /// </summary> /// <param name="spfd">The File Description of the File you are looking for</param> /// <returns>null or the Property Set File</returns> public string FindTxtrName(string matdname) { if (matdname == null) { return(null); } string file = System.IO.Path.Combine(SimPe.PathProvider.Global[Expansions.BaseGame].InstallFolder, "TSData\\Res\\Sims3D\\Sims02.package"); if (System.IO.File.Exists(file)) { SimPe.Interfaces.Files.IPackageFile package = SimPe.Packages.File.LoadFromFile(file); Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFile(matdname.Replace("CASIE_", ""), 0x49596978); if (pfds.Length == 0) { pfds = package.FindFile(matdname, 0x49596978); } //try another Package /*if (pfds.Length==0) * { * file = System.IO.Path.Combine(Helper.WindowsRegistry.SimsPath, "TSData\\Res\\Sims3D\\Sims07.package"); * if (System.IO.File.Exists(file)) * { * package = SimPe.Packages.GeneratableFile.LoadFromFile(file); * pfds = package.FindFile(matdname, 0x49596978); * } * }*/ //look for the right one foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.Rcol rcol = new SimPe.Plugin.GenericRcol(null, false); rcol.ProcessData(pfd, package); if ((rcol.FileName.Trim().ToLower() == matdname.Trim().ToLower()) || (rcol.FileName.Trim().ToLower() == matdname.Replace("CASIE_", "").Trim().ToLower())) { foreach (SimPe.Plugin.MaterialDefinition md in rcol.Blocks) { return(md.GetProperty("stdMatBaseTextureName").Value + "_txtr"); } } } } return(null); }
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); }
void RemoveFromGMND(SimPe.Plugin.GenericRcol rcol) { uint ct = 0; GeometryNode gn = (GeometryNode)rcol.Blocks[0]; ArrayList delete = new ArrayList(); foreach (SimPe.Interfaces.Scenegraph.IRcolBlock irb in rcol.Blocks) { if (irb is DataListExtension) { DataListExtension dle = (DataListExtension)irb; if (dle.Extension.VarName == "copyright") { ArrayList list = new ArrayList(); foreach (ObjectGraphNodeItem ogni in gn.ObjectGraphNode.Items) { if (ogni.Index != ct) { list.Add(ogni); } } gn.ObjectGraphNode.Items = new ObjectGraphNodeItem[list.Count]; list.CopyTo(gn.ObjectGraphNode.Items); delete.Add(dle); } } ct++; } foreach (DataListExtension dle in delete) { rcol.Blocks = (SimPe.Interfaces.Scenegraph.IRcolBlock[])Helper.Delete(rcol.Blocks, dle, typeof(SimPe.Interfaces.Scenegraph.IRcolBlock)); } if (delete.Count > 0) { rcol.SynchronizeUserData(); } }
private SimPe.Plugin.GenericRcol getRcolPkg(String filename, String pkg) { IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg); if (p == null) { return(null); } IPackedFileDescriptor[] apr = p.FindFile(filename); if (apr == null || apr.Length != 1) { return(null); } SimPe.Plugin.GenericRcol tgt = new SimPe.Plugin.GenericRcol(); tgt.ProcessData(apr[0], p); return(tgt); }
private SimPe.Plugin.GenericRcol getRcolPkg(IPackedFileDescriptor tgtpfd, String pkg) { IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg); if (p == null) { return(null); } IPackedFileDescriptor pr = p.FindFile(tgtpfd); if (pr == null) { return(null); } SimPe.Plugin.GenericRcol tgt = new SimPe.Plugin.GenericRcol(); tgt.ProcessData(pr, p); return(tgt); }
/// <summary> /// Adds the Slave definitions of the passed gmnd to the passed map /// </summary> /// <param name="gmnd">the GMND File</param> /// <param name="map">the Map Table (key=master subset name, value= ArrayList of slave subsets</param> public static void GetSlaveSubsets(SimPe.Plugin.GenericRcol gmnd, Hashtable map) { foreach (IRcolBlock irb in gmnd.Blocks) { if (irb.BlockName == "cDataListExtension") { DataListExtension dle = (DataListExtension)irb; if (dle.Extension.VarName.Trim().ToLower() == "tsdesignmodeslavesubsets") { foreach (ExtensionItem ei in dle.Extension.Items) { string[] slaves = ei.String.Split(",".ToCharArray()); ArrayList slavelist = new ArrayList(); foreach (string s in slaves) { slavelist.Add(s.Trim().ToLower()); } map[ei.Name.Trim().ToLower()] = slavelist; } } } } }
internal static System.Drawing.Image SetFromTxtr(SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.TXTR); if (pfds.Length>0) { SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds) if (p.Size>pfd.Size) pfd = p; SimPe.Plugin.Rcol rcol = new SimPe.Plugin.GenericRcol(); rcol.ProcessData(pfd, pkg); if (rcol.Blocks.Length>0) { SimPe.Plugin.ImageData id = rcol.Blocks[0] as SimPe.Plugin.ImageData; if (id!=null) { SimPe.Plugin.MipMap m = id.GetLargestTexture(new System.Drawing.Size(PackageInfo.IMAGESIZE, PackageInfo.IMAGESIZE)); if (m!=null) return m.Texture; } } } return null; }
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); } } }
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) {} } }
private void SelectFile(object sender, System.EventArgs e) { llcommit.Enabled = false; lldelete.Enabled = false; btup.Enabled = false; btdown.Enabled = false; miAdd.Enabled = false; miRem.Enabled = lldelete.Enabled; if (lblist.SelectedIndex < 0) { return; } llcommit.Enabled = true; lldelete.Enabled = true; btup.Enabled = true; btdown.Enabled = true; miAdd.Enabled = true; miRem.Enabled = lldelete.Enabled; if (tbtype.Tag != null) { return; } try { tbtype.Tag = true; Interfaces.Files.IPackedFileDescriptor pfd = (Interfaces.Files.IPackedFileDescriptor)lblist.Items[lblist.SelectedIndex]; this.tbgroup.Text = "0x" + Helper.HexString(pfd.Group); this.tbinstance.Text = "0x" + Helper.HexString(pfd.Instance); this.tbsubtype.Text = "0x" + Helper.HexString(pfd.SubType); this.tbtype.Text = "0x" + Helper.HexString(pfd.Type); //get Texture if (pfd.GetType() == typeof(RefFileItem)) { RefFile wrp = (RefFile)wrapper; SkinChain sc = ((RefFileItem)pfd).Skin; SimPe.Plugin.GenericRcol txtr = null; if (sc != null) { txtr = sc.TXTR; } //show the Image if (txtr == null) { pb.Image = null; } else { MipMap mm = ((ImageData)txtr.Blocks[0]).GetLargestTexture(pb.Size); if (mm != null) { pb.Image = mm.Texture; } else { pb.Image = null; } } } else { pb.Image = null; } } catch (Exception ex) { Helper.ExceptionMessage(Localization.Manager.GetString("errconvert"), ex); } finally { tbtype.Tag = null; } }
/// <summary> /// Adds the given .package file to the cache /// </summary> /// <param name="flname">Complete name of the .package file</param> /// <returns>true, if the contents had to get updated</returns> public bool AddPackageFile(string flname) { if (!System.IO.File.Exists(flname)) { return(false); } DateTime filemod = System.IO.File.GetLastWriteTime(flname); bool mod = false; SqlCommands.LoadFileRow lfr = new SimPe.Database.SqlCommands.LoadFileRow(sql); lfr.FileName = flname; SQLiteDataReader dr = AddPackageWhenNew(ref filemod, ref mod, lfr); long fid = UpdatePackageModDate(flname, ref filemod, ref mod, lfr, dr); if (mod) { SimPe.Packages.File pkg = SimPe.Packages.File.LoadFromFile(flname); SqlCommands.AddResources ar = new SimPe.Database.SqlCommands.AddResources(sql); ar.PrepareLoop(fid); Dictionary <uint, Performance> dict = new Dictionary <uint, Performance>(); List <Performance> list = new List <Performance>(); foreach (SimPe.Packages.PackedFileDescriptor pfd in pkg.Index) { Performance p, op; if (!dict.ContainsKey(pfd.Type)) { p = new Performance(pfd.Type); list.Add(p); dict[pfd.Type] = p; } else { p = dict[pfd.Type]; } if (!odict.ContainsKey(pfd.Type)) { op = new Performance(pfd.Type); olist.Add(op); odict[pfd.Type] = op; } else { op = odict[pfd.Type]; } DateTime start = DateTime.Now; SimPe.Data.TypeAlias ta = pfd.TypeName; SimPe.Interfaces.Plugin.Internal.IPackedFileWrapper wrp; if (ta.IgnoreDuringCacheBuild) { wrp = null; } else if (pfd.Type == Data.MetaData.LIFO || pfd.Type == Data.MetaData.GMDC) { wrp = new SimPe.Plugin.GenericRcol(null, true); } else { wrp = SimPe.FileTable.WrapperRegistry.FindHandler(pfd.Type); } if (wrp != null) { lock (wrp) { wrp.ProcessData(pfd, pkg, true); ar.AddResourceLoop(fid, pfd, wrp); wrp.Dispose(); } wrp = null; } else { ar.AddResourceLoop(fid, pfd, null); } TimeSpan runtime = DateTime.Now - start; p.Add(runtime); op.Add(runtime); } ShowPerformance(list); list.Clear(); list = null; dict.Clear(); dict = null; ar.FinishLoop(); pkg.Close(); } lfr = null; return(mod); }
/// <summary> /// This will build a SkinTone Replacement for the passed Skintone /// </summary> /// <param name="skintone">the skintone string</param> /// <param name="addtxtr">true, if you want to replace the default TXTR Files</param> /// <param name="addtxmt">true if you want to replace the default TXMT Files</param> /// <param name="sitem"></param> /// <param name="src"></param> /// <returns>the replacement package</returns> public SimPe.Packages.GeneratableFile BuildOverride(ScannerItem sitem, string skintone, string family, SimPe.Interfaces.Files.IPackageFile src, bool addtxmt, bool addtxtr, bool addref) { FileTable.FileIndex.Load(); SimPe.Packages.GeneratableFile pkg = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null); WaitingScreen.Wait(); //Save the old FileTable and the source File FileTable.FileIndex.Load(); FileTable.FileIndex.StoreCurrentState(); FileTable.FileIndex.AddIndexFromPackage(src); bool usefam = (skintone == "00000000-0000-0000-0000-000000000000"); try { //find al description Files that belong to the Skintone that should be replaced ArrayList basecpf = new ArrayList(); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(Data.MetaData.GZPS, true); foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(item); if (cpf.GetSaveItem("skintone").StringValue != skintone) { continue; } //if (usefam) if (cpf.GetSaveItem("family").StringValue != family) { continue; } if (cpf.GetSaveItem("type").StringValue != "skin") { continue; } SimPe.Plugin.SkinChain sc = new SkinChain(cpf); basecpf.Add(sc); WaitingScreen.UpdateMessage(cpf.GetSaveItem("name").StringValue); } ArrayList compare = new ArrayList(); compare.Add("age"); //compare.Add("category"); compare.Add("fitness"); compare.Add("gender"); //compare.Add("outfit"); compare.Add("override0subset"); //compare.Add("override0resourcekeyidx"); //compare.Add("shapekeyidx"); //now select matching Files Interfaces.Files.IPackedFileDescriptor[] pfds = src.FindFiles(Data.MetaData.GZPS); #if DEBUG //we could add Debug Code here to see which cpfs were pulled :) /*SimPe.Packages.GeneratableFile f = SimPe.Packages.GeneratableFile.CreateNew(); * * foreach (SimPe.Plugin.SkinChain sc in basecpf) * { * sc.Cpf.SynchronizeUserData(); * f.Add(sc.Cpf.FileDescriptor); * * RefFile r = sc.ReferenceFile; * if (r!=null) * { * r.SynchronizeUserData(); * f.Add(r.FileDescriptor); * } * * //foreach (GenericRcol rcol in sc.TXTRs) * GenericRcol rcol = sc.TXTR; * if (rcol!=null) * { * rcol.SynchronizeUserData(); * f.Add(rcol.FileDescriptor); * } * * //foreach (GenericRcol rcol in sc.TXMTs) * rcol = sc.TXMT; * if (rcol!=null) * { * rcol.SynchronizeUserData(); * f.Add(rcol.FileDescriptor); * } * } * * f.Save(@"G:\skinbase.package"); * return f;*/ #endif foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { //load a description File for the new Skintone SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf(); cpf.ProcessData(pfd, src); int index = -1; int maxpoint = 0; //check if File is a match for (int i = 0; i < basecpf.Count; i++) { SimPe.Plugin.SkinChain sc = (SimPe.Plugin.SkinChain)basecpf[i]; int point = compare.Count; //scan for valid CPF Files foreach (string s in compare) { if (s == "age" || s == "category" || s == "outfit") { if ((sc.Cpf.GetSaveItem(s).UIntegerValue & cpf.GetSaveItem(s).UIntegerValue) == 0) { point--; } } else if (s == "override0subset") { string s1 = sc.Cpf.GetSaveItem(s).StringValue.Trim().ToLower(); string s2 = cpf.GetSaveItem(s).StringValue.Trim().ToLower(); if (s1 == "bottom") { s1 = "body"; } else if (s1 == "top") { s1 = "body"; } if (s2 == "bottom") { s2 = "body"; } else if (s2 == "top") { s2 = "body"; } if (s1 != s2) { point--; } } else if (sc.Cpf.GetSaveItem(s).UIntegerValue != cpf.GetSaveItem(s).UIntegerValue) { point--; } } if (point > maxpoint) { index = i; maxpoint = point; } } //yes, yes :D this is a match if (index >= 0 && maxpoint == compare.Count) { SimPe.Plugin.SkinChain sc = (SimPe.Plugin.SkinChain)basecpf[index]; SkinChain newsc = new SkinChain(cpf); if (sc.ReferenceFile != null && newsc.ReferenceFile != null && addref) { RefFile r = newsc.ReferenceFile; r.FileDescriptor = sc.ReferenceFile.FileDescriptor.Clone(); r.SynchronizeUserData(); if (pkg.FindFile(r.FileDescriptor) == null) { pkg.Add(r.FileDescriptor); } } if (sc.TXTR != null && newsc.TXTR != null && addtxtr) { SimPe.Plugin.GenericRcol txtr = newsc.TXTR; txtr.FileDescriptor = sc.TXTR.FileDescriptor.Clone(); #if DEBUG #else txtr.FileDescriptor.MarkForReCompress = true; #endif txtr.FileName = sc.TXTR.FileName; txtr.SynchronizeUserData(); if (pkg.FindFile(txtr.FileDescriptor) == null) { pkg.Add(txtr.FileDescriptor); } } if (sc.TXMT != null && newsc.TXMT != null && addtxmt) { SimPe.Plugin.GenericRcol txmt = newsc.TXMT; txmt.FileDescriptor = sc.TXMT.FileDescriptor.Clone(); #if DEBUG #else txmt.FileDescriptor.MarkForReCompress = true; #endif MaterialDefinition md = (MaterialDefinition)txmt.Blocks[0]; MaterialDefinition mdorg = (MaterialDefinition)sc.TXMT.Blocks[0]; txmt.FileName = sc.TXMT.FileName; md.FileDescription = mdorg.FileDescription; txmt.SynchronizeUserData(); if (pkg.FindFile(txmt.FileDescriptor) == null) { pkg.Add(txmt.FileDescriptor); } } } } SimPe.PackedFiles.Wrapper.Str str = new Str(); str.Add(new StrToken(0, 0, "SimPE Skin Override: " + skintone + " (from " + sitem.PackageCacheItem.Name + ")", "")); str.FileDescriptor = new SimPe.Packages.PackedFileDescriptor(); str.FileDescriptor.Type = Data.MetaData.STRING_FILE; str.FileDescriptor.Group = Data.MetaData.LOCAL_GROUP; str.FileDescriptor.LongInstance = 0; str.SynchronizeUserData(); pkg.Add(str.FileDescriptor); } finally { //restore the Previous FileTable FileTable.FileIndex.RestoreLastState(); WaitingScreen.Stop(); } return(pkg); }
/// <summary> /// Load all File referenced by the passed rcol File /// </summary> /// <param name="modelnames">The Modulenames</param> /// <param name="exclude">The Exclude List</param> /// <param name="list">A List containing all Rcol Files</param> /// <param name="itemlist">A List of all FileIndexItems already added</param> /// <param name="rcol">The Rcol File (Scenegraph Resource)</param> /// <param name="item">The Item that was used to load the rcol</param> /// <param name="recursive">true if you want to add all sub Rcols</param> protected static void LoadReferenced(ArrayList modelnames, ArrayList exclude, ArrayList list, ArrayList itemlist, SimPe.Plugin.GenericRcol rcol, SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item, bool recursive, CloneSettings setup) { //if we load a CRES, we also have to add the Modelname! if (rcol.FileDescriptor.Type == Data.MetaData.CRES) { modelnames.Add(rcol.FileName.Trim().ToLower()); } list.Add(rcol); itemlist.Add(item); Hashtable map = rcol.ReferenceChains; foreach (string s in map.Keys) { if (exclude.Contains(s)) { continue; } ArrayList descs = (ArrayList)map[s]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in descs) { if (setup != null) { if (setup.KeepOriginalMesh) { if (pfd.Type == Data.MetaData.GMND) { continue; } if (pfd.Type == Data.MetaData.GMDC) { continue; } } } SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem subitem = FileTable.FileIndex.FindSingleFile(pfd, null, true); if (subitem != null) { if (!itemlist.Contains(subitem)) { try { SimPe.Plugin.GenericRcol sub = new GenericRcol(null, false); sub.ProcessData(subitem.FileDescriptor, subitem.Package, false); if (Scenegraph.excludefiles.Contains(sub.FileName.Trim().ToLower())) { continue; } if (recursive) { LoadReferenced(modelnames, exclude, list, itemlist, sub, subitem, true, setup); } } catch (Exception ex) { Helper.ExceptionMessage("", new CorruptedFileException(subitem, ex)); } } } } } }
private List <SimPe.Plugin.GenericRcol> findrcolChain() { List <SimPe.Plugin.GenericRcol> rcolChain = new List <SimPe.Plugin.GenericRcol>(); SimPe.Plugin.GenericRcol tgt = null; foreach (String s in new String[] { "shapekeyidx", "maskshapekeyidx" }) { tgt = getRcol(objKeyCPF, objKey3IDR, s, shpepkg); if (tgt != null) { rcolChain.Add(tgt); foreach (IPackedFileDescriptor i in tgt.ReferencedFiles) { if (i.Type == SimPe.Data.MetaData.GMND) { SimPe.Plugin.GenericRcol gmnd = getRcol(i, gmndpkg); if (gmnd != null) { rcolChain.Add(gmnd); foreach (IPackedFileDescriptor j in gmnd.ReferencedFiles) { if (j.Type == SimPe.Data.MetaData.GMDC) { SimPe.Plugin.GenericRcol gmdc = getRcol(j, gmdcpkg); if (gmdc != null) { rcolChain.Add(gmdc); } } } } } else if (i.Type == SimPe.Data.MetaData.TXMT) { SimPe.Plugin.GenericRcol txmt = getRcol(i, txmtpkg); if (txmt != null) { rcolChain.Add(txmt); findMaterials(ref rcolChain, txmt); } } } } } foreach (String s in new String[] { "resourcekeyidx", "maskresourcekeyidx" }) { tgt = getRcol(objKeyCPF, objKey3IDR, s, crespkg); if (tgt != null) { rcolChain.Add(tgt); } } uint numOverrides = 0; SimPe.PackedFiles.Wrapper.CpfItem cpfItem = objKeyCPF.GetItem("numoverrides"); if (cpfItem.Datatype == SimPe.Data.MetaData.DataTypes.dtUInteger) { numOverrides = cpfItem.UIntegerValue; } for (int i = 0; i < numOverrides; i++) { tgt = getRcol(objKeyCPF, objKey3IDR, "override" + i.ToString() + "resourcekeyidx", txmtpkg); if (tgt != null) { rcolChain.Add(tgt); findMaterials(ref rcolChain, tgt); } } return(rcolChain); }