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)); }
public virtual void SetFromObjectCacheItem(SimPe.Cache.ObjectCacheItem oci) { if (oci == null) { objd = null; ClearScreen(); return; } objd = null; if (oci.Tag != null) { if (oci.Tag is SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem) { objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData((SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag); } } UpdateScreen(); if (oci.Thumbnail == null) { pb.Image = defimg; } else { pb.Image = GenerateImage(pb.Size, oci.Thumbnail, true); } lbName.Text = oci.Name; lbVert.Text = "---"; }
protected void ScanFileTable(uint inst) { if (Helper.StartedGui == Executable.Classic) { return; } SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileDiscardingGroup(Data.MetaData.OBJD_FILE, inst); Wait.MaxProgress = items.Length; int ct = 0; int step = Math.Max(2, Wait.MaxProgress / 100); foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { if (this.HaveToStop) { break; } SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(item); if (objd.Type == Data.ObjectTypes.Person || objd.Type == Data.ObjectTypes.Template) { AddSim(objd, ref ct, step, true); } } }
protected void GetObjd(SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.OBJD_FILE); if (pfds.Length > 0) { foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.ExtObjd mobjd = new SimPe.PackedFiles.Wrapper.ExtObjd(); mobjd.ProcessData(pfd, pkg); nfo.AddGuid(mobjd.Guid); if (objd == null) { objd = mobjd; } if (pfds.Length == 1) { break; } if (mobjd.Data.Length > 0xb) { if (mobjd.Data[0xb] == -1) { objd = mobjd; } } } } }
public virtual void SetFromObjectCacheItem(SimPe.Cache.ObjectCacheItem oci) { ClearScreen(); if (oci == null) { objd = null; return; } objd = null; if (oci.Tag != null) { if (oci.Tag is SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem) { objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData((SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag); } } UpdateScreen(null, false); if (oci.Thumbnail == null) { nfo.Image = null; } else { nfo.Image = oci.Thumbnail; } nfo.Name = oci.Name; nfo.VertexCount = 0; nfo.FaceCount = 0; }
/// <summary> /// Load a List of all available GUIDs in the package /// </summary> /// <returns>The list of GUIDs</returns> public ArrayList GetGuidList() { ArrayList list = new ArrayList(); SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE); foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(pfd, package); list.Add(objd.Guid); } return(list); }
/// <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); }
protected static void UpdateDescription(OWCloneSettings cs, SimPe.Packages.GeneratableFile package) { //change the price in the OBJd SimPe.PackedFiles.Wrapper.ExtObjd obj = new SimPe.PackedFiles.Wrapper.ExtObjd(); SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { obj.ProcessData(pfd, package); SimPe.Interfaces.Files.IPackedFileDescriptor spfd = UpdateDescription(cs, package, obj); if (spfd != null) { str.ProcessData(spfd, package); UpdateDescription(cs, str); } } //change Price, Title, Desc in the XObj Files uint[] types = new uint[] { Data.MetaData.XFNC, Data.MetaData.XROF, Data.MetaData.XFLR, Data.MetaData.XOBJ }; SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf(); foreach (uint t in types) { pfds = package.FindFiles(t); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { cpf.ProcessData(pfd, package); SimPe.Interfaces.Files.IPackedFileDescriptor spfd = UpdateDescription(cs, package, cpf); if (spfd != null) { str.ProcessData(spfd, package); UpdateDescription(cs, str); } } } if (package.FileName != null) { package.Save(); } }
public void DoSearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd) { SimPe.PackedFiles.Wrapper.ExtObjd obj = new SimPe.PackedFiles.Wrapper.ExtObjd(); obj.ProcessData(pfd, pkg); bool found = false; if (name != "") { string n = obj.FileName.Trim().ToLower(); if (compareType == CompareType.Equal) { found = n == name; } else if (compareType == CompareType.Start) { found = n.StartsWith(name); } else if (compareType == CompareType.End) { found = n.EndsWith(name); } else if (compareType == CompareType.Contain) { found = n.IndexOf(name) > -1; } else if (compareType == CompareType.RegExp && reg != null) { found = reg.IsMatch(n); } } if (guid > 0 && (found || name == "")) { found = obj.Guid == guid; } //we have a match, so add the result item if (found) { ResultGui.AddResult(pkg, pfd); } }
/// <summary> /// Make sure the fixes for OBJd Resources are considered /// </summary> /// <remarks> /// Currently this implements the Fixes needed for Rugs /// </remarks> void FixOBJd() { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Updating Object Descriuptions"); } Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE); //OBJd bool updaterugs = false; foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(pfd, package); //is one of the objd's a rug? if (objd.FunctionSubSort == SimPe.Data.ObjFunctionSubSort.Decorative_Rugs) { updaterugs = true; break; } } //found at least one OBJd describing a Rug if (updaterugs) { foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(pfd, package); //make sure the Type of a Rug is not a Tile, but Normal if (objd.Type == SimPe.Data.ObjectTypes.Tiles) { objd.Type = SimPe.Data.ObjectTypes.Normal; objd.SynchronizeUserData(true, true); } } } }
public virtual void SetFromPackage(SimPe.Interfaces.Files.IPackageFile pkg) { if (pkg == null) { objd = null; ClearScreen(); return; } SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(Data.MetaData.OBJD_FILE, 0, 0x41A7); if (pfds.Length > 0) { objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(pfds[0], pkg); } int fct = 0; int vct = 0; pfds = pkg.FindFiles(Data.MetaData.GMDC); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds) { SimPe.Plugin.Rcol rcol = new GenericRcol(); rcol.ProcessData(pfd, pkg, true); SimPe.Plugin.GeometryDataContainer gmdc = rcol.Blocks[0] as SimPe.Plugin.GeometryDataContainer; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { fct += g.FaceCount; vct += g.UsedVertexCount; } rcol.Dispose(); } lbVert.Text = vct.ToString() + " (" + fct.ToString() + " Faces)"; UpdateScreen(); }
public void ReloadCache(SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fileindex, bool save) { Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = fileindex.FindFile(Data.MetaData.OBJD_FILE, true); bool added = false; Wait.MaxProgress = items.Length; Wait.Message = "Updating Cache"; int ct = 0; foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { Interfaces.Scenegraph.IScenegraphFileIndexItem[] citems = this.FileIndex.FindFile(item.GetLocalFileDescriptor(), null); if (citems.Length == 0) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(item); this.AddItem(objd); added = true; } Wait.Progress = ct++; } if (added) { this.map = null; Wait.Message = "Saving Chache"; if (save) { this.Save(this.FileName); } this.LoadMemTable(); this.LoadMemList(); } }
internal static bool DoConsume(Object o, ObjectLoader.LoadItemHandler LoadedItem, SimPe.Data.MetaData.Languages deflang) { SimPe.Cache.ObjectCacheItem oci = (SimPe.Cache.ObjectCacheItem)o; Interfaces.Scenegraph.IScenegraphFileIndexItem nrefitem = (Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag; //this item is new to the cache, so load the Data if ((!oci.Useable || oci.ObjectVersion != SimPe.Cache.ObjectCacheItemVersions.DockableOW) && nrefitem.FileDescriptor.Type == Data.MetaData.OBJD_FILE) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); nrefitem.FileDescriptor.UserData = nrefitem.Package.Read(nrefitem.FileDescriptor).UncompressedData; objd.ProcessData(nrefitem); oci.FileDescriptor = nrefitem.FileDescriptor; oci.LocalGroup = nrefitem.LocalGroup; oci.ObjectType = objd.Type; oci.ObjectFunctionSort = (uint)objd.FunctionSubSort; oci.ObjectFileName = objd.FileName; oci.Useable = true; oci.Class = SimPe.Cache.ObjectClass.Object; //this is needed, so that objects get sorted into the right categories /*if (objd.Type == Data.ObjectTypes.Normal && objd.CTSSInstance==0) * { * oci.Useable = false; * return true; * }*/ //Get the Name of the Object Interfaces.Scenegraph.IScenegraphFileIndexItem[] ctssitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, nrefitem.LocalGroup); if (ctssitems.Length > 0) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(ctssitems[0]); SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(deflang); if (items.Length > 0) { oci.Name = items[0].Title; } else { items = str.LanguageItems(1); if (items.Length > 0) { oci.Name = items[0].Title; } else { oci.Name = ""; } } } else { oci.Name = ""; } if (oci.Name == "") { oci.Name = objd.FileName; } //now the ModeName File Interfaces.Scenegraph.IScenegraphFileIndexItem[] txtitems = FileTable.FileIndex.FindFile(Data.MetaData.STRING_FILE, nrefitem.LocalGroup, 0x85, null); if (txtitems.Length > 0) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(2); str.ProcessData(txtitems[0]); SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1); if (items.Length > 1) { oci.ModelName = items[1].Title; } } ObjectReader.changedcache = true; } //if not loaded from objd if ((!oci.Useable || oci.ObjectVersion != SimPe.Cache.ObjectCacheItemVersions.DockableOW) && nrefitem.FileDescriptor.Type != Data.MetaData.OBJD_FILE) { ConsumeFromXobj(oci, nrefitem, deflang); } if (oci.Thumbnail == null) { oci.Thumbnail = ObjectPreview.GetThumbnail(nrefitem.FileDescriptor.Group, oci.ModelName); if (oci.Thumbnail != null) { Wait.Image = oci.Thumbnail; ObjectReader.changedcache = true; } } #if DEBUG Data.Alias a = new Data.Alias(oci.FileDescriptor.Group, "---"); //, "{name} ({id}: {1}, {2}) "); #else Data.Alias a = new Data.Alias(oci.FileDescriptor.Group, "---"); //, "{name} ({id}: {1}) "); #endif object[] os = new object[4]; os[0] = nrefitem.FileDescriptor; os[1] = nrefitem.LocalGroup; os[2] = oci.ModelName; os[3] = oci; a.Tag = os; if (Helper.WindowsRegistry.ShowObjdNames) { a.Name = oci.ObjectFileName; } else { a.Name = oci.Name; } a.Name += " (cached)"; Image img = oci.Thumbnail; if (LoadedItem != null) { LoadedItem(oci, nrefitem, a); } return(true); }
public void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs e) { if (!ChangeEnabledStateEventHandler(null, e)) { return; } SimPe.FileTable.FileIndex.Load(); System.IO.StreamWriter sw = new System.IO.StreamWriter(new System.IO.MemoryStream()); try { System.Collections.ArrayList guids = new System.Collections.ArrayList(); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = SimPe.FileTable.FileIndex.FindFile(Data.MetaData.OBJD_FILE, true); sw.WriteLine("<?"); sw.WriteLine("$guids = array("); sw.Write(" "); Wait.SubStart(items.Length); int ct = 0; foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); objd.ProcessData(item); if (guids.Contains(objd.Guid)) { continue; } if (objd.Type == SimPe.Data.ObjectTypes.Memory) { continue; } if (objd.Type == SimPe.Data.ObjectTypes.Person) { continue; } if (ct > 0) { sw.Write(","); } ct++; Wait.Progress = ct; sw.Write("array("); sw.Write("0x" + Helper.HexString(objd.Guid)); guids.Add(objd.Guid); sw.Write(", '"); sw.Write("Maxis: " + objd.FileName.Replace("'", "").Replace("\\", "").Replace("\"", "")); /*SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] list = SimPe.FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, objd.FileDescriptor.Group, objd.CTSSInstance, null); * if (list.Length==0) sw.Write(objd.FileName.Replace("'", "").Replace("\\", "").Replace("\"", "")); * else * { * SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(1); * str.ProcessData(list[0]); * SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(SimPe.Data.MetaData.Languages.English); * if (strs.Count==0) sw.Write(objd.FileName.Replace("'", "").Replace("\\", "").Replace("\"", "")); * else sw.Write(strs[0].Title.Replace("'", "").Replace("\\", "").Replace("\"", "")); * }*/ sw.WriteLine("')"); } Wait.SubStop(); sw.WriteLine(");"); sw.WriteLine("?>"); Report f = new Report(); f.Execute(sw); } finally { sw.Close(); } }
/// <summary> /// Loads Memory Files form the Object Package /// </summary> public void LoadMemories() { memories = new Hashtable(); //if (BasePackage==null) return; Registry reg = Helper.WindowsRegistry; ArrayList list = new ArrayList(); Interfaces.Files.IPackedFileDescriptor pfd; SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd(); SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); FileTable.FileIndex.Load(); Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileDiscardingGroup(Data.MetaData.OBJD_FILE, 0x00000000000041A7); string max = " / " + items.Length.ToString(); int ct = 0; if (items.Length != 0) //found anything? { bool wasrunning = WaitingScreen.Running; WaitingScreen.Wait(); try { foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { ct++; if (ct % 137 == 1) { WaitingScreen.UpdateMessage(ct.ToString() + max); } pfd = item.FileDescriptor; string name = ""; objd.ProcessData(item); if (memories.Contains(objd.Guid)) { continue; } try { Interfaces.Scenegraph.IScenegraphFileIndexItem[] sitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, pfd.Group, objd.CTSSInstance, null); if (sitems.Length > 0) { str.ProcessData(sitems[0]); SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(Helper.WindowsRegistry.LanguageCode); if (strs.Length > 0) { name = strs[0].Title; } //not found? if (name == "") { strs = str.LanguageItems(1); if (strs.Length > 0) { name = strs[0].Title; } } } } catch (Exception) { } //still no name? if (name == "") { name = objd.FileName; } #if DEBUG IAlias a = new Alias(objd.Guid, name, "{1}: {name} (0x{id})"); #else IAlias a = new Alias(objd.Guid, name, "{1}: {name}"); #endif object[] o = new object[3]; o[0] = pfd; o[1] = (Data.ObjectTypes)objd.Type; o[2] = null; SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); Interfaces.Scenegraph.IScenegraphFileIndexItem[] iitems = FileTable.FileIndex.FindFile(Data.MetaData.SIM_IMAGE_FILE, pfd.Group, 1, null); if (iitems.Length > 0) { pic.ProcessData(iitems[0]); System.Drawing.Image img = pic.Image; o[2] = img; WaitingScreen.Update(img, ct.ToString() + max); } a.Tag = o; if (!memories.Contains(objd.Guid)) { memories.Add(objd.Guid, a); } } //foreach item } finally { if (!wasrunning) { WaitingScreen.Stop(); } } } // if items>0 //System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal; }