/// <summary> /// Returns the Thumbnail of an Object /// </summary> /// <param name="group"></param> /// <param name="modelname"></param> /// <returns>The Thumbnail</returns> public static Image GetThumbnail(string message, uint[] types, uint group, uint inst, SimPe.Packages.File thumbs) { foreach (uint type in types) { //0x6C2A22C3 Interfaces.Files.IPackedFileDescriptor[] pfds = thumbs.FindFile(type, group, inst); if (pfds.Length == 0) { pfds = thumbs.FindFile(type, 0, inst); } if (pfds.Length > 0) { Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; try { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(pfd, thumbs); Bitmap bm = (Bitmap)ImageLoader.Preview(pic.Image, WaitingScreen.ImageSize); if (WaitingScreen.Running) { WaitingScreen.Update(bm, message); } return(pic.Image); } catch (Exception) {} } } return(null); }
protected void SetImage(uint type, SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(type); if (pfds.Length > 0) { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(pfds[0], pkg); nfo.Image = pic.Image; } nfo.KnockoutThumbnail = false; }
/// <summary> /// Returns the Thumbnail of an Object /// </summary> /// <param name="group"></param> /// <param name="modelname"></param> /// <returns>The Thumbnail</returns> public static Image GetThumbnail(string message, uint[] types, uint group, uint inst, SimPe.Packages.File thumbs) { /*ArrayList types = new ArrayList(); * types.Add(0xAC2950C1); // Objects * types.Add(0xEC3126C4); // Terrain * types.Add(0xCC48C51F); //chimney * types.Add(0x2C30E040); //fence Arch * types.Add(0xCC30CDF8); //fences * types.Add(0x8C311262); //floors * types.Add(0x2C43CBD4); //foundtaion / pools * types.Add(0xCC44B5EC); //modular Stairs * types.Add(0xCC489E46); //roof * types.Add(0x8C31125E); //wall*/ foreach (uint type in types) { //0x6C2A22C3 Interfaces.Files.IPackedFileDescriptor[] pfds = thumbs.FindFile(type, group, inst); if (pfds.Length == 0) { pfds = thumbs.FindFile(type, 0, inst); } if (pfds.Length > 0) { Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; try { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(pfd, thumbs); Bitmap bm = (Bitmap)ImageLoader.Preview(pic.Image, WaitingScreen.ImageSize); if (WaitingScreen.Running) { WaitingScreen.Update(bm, message); } return(pic.Image); } catch (Exception) { } } } return(null); }
protected override void SetImage(SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(0x856DDBAC, 0, Data.MetaData.LOCAL_GROUP, 0x35CA0002); if (pfd == null) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(0x856DDBAC); if (pfds.Length > 0) { pfd = pfds[0]; } } if (pfd != null) { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(pfd, pkg); nfo.Image = pic.Image; } nfo.KnockoutThumbnail = false; }
/// <summary> /// Returns the Icon File for the passed Want /// </summary> /// <param name="wnt">The Want File</param> /// <returns>The Picture File or null if none was found</returns> public static SimPe.PackedFiles.Wrapper.Picture LoadIcon(XWant wnt) { if (wnt == null) { return(null); } if (txtpkg == null) { LoadTextPackage(); } Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(wnt.IconFileDescriptor, null); if (items.Length > 0) { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); items[0].FileDescriptor.UserData = items[0].Package.Read(items[0].FileDescriptor).UncompressedData; pic.ProcessData(items[0]); return(pic); } return(null); }
/// <summary> /// Add a MaterialOverride to the Cache /// </summary> /// <param name="objd">The Object Data File</param> public MemoryCacheItem AddItem(SimPe.PackedFiles.Wrapper.ExtObjd objd) { CacheContainer mycc = this.UseConatiner(ContainerType.Memory, objd.Package.FileName); MemoryCacheItem mci = new MemoryCacheItem(); mci.FileDescriptor = objd.FileDescriptor; mci.Guid = objd.Guid; mci.ObjectType = objd.Type; mci.ObjdName = objd.FileName; mci.ParentCacheContainer = mycc; try { Interfaces.Scenegraph.IScenegraphFileIndexItem[] sitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, objd.FileDescriptor.Group, objd.CTSSInstance, null); if (sitems.Length > 0) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(sitems[0]); SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(Helper.WindowsRegistry.LanguageCode); if (strs.Length > 0) { mci.Name = strs[0].Title; } //not found? if (mci.Name == "") { strs = str.LanguageItems(1); if (strs.Length > 0) { mci.Name = strs[0].Title; } } } } catch (Exception) {} try { Interfaces.Scenegraph.IScenegraphFileIndexItem[] sitems = FileTable.FileIndex.FindFile(Data.MetaData.STRING_FILE, objd.FileDescriptor.Group, 0x100, null); if (sitems.Length > 0) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(sitems[0]); SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(Data.MetaData.Languages.English); string[] res = new string[strs.Count]; for (int i = 0; i < res.Length; i++) { res[i] = strs[i].Title; } mci.ValueNames = res; } } catch (Exception) {} //still no name? if (mci.Name == "") { mci.Name = objd.FileName; } //having an icon? SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); Interfaces.Scenegraph.IScenegraphFileIndexItem[] iitems = FileTable.FileIndex.FindFile(Data.MetaData.SIM_IMAGE_FILE, objd.FileDescriptor.Group, 1, null); if (iitems.Length > 0) { pic.ProcessData(iitems[0]); mci.Icon = pic.Image; Wait.Image = mci.Icon; } Wait.Message = mci.Name; //mci.ParentCacheContainer = mycc; //why was this disbaled? mycc.Items.Add(mci); return(mci); }
protected override void StartThread() { lotfi.Load(); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = lotfi.FindFile(0x856DDBAC, Data.MetaData.LOCAL_GROUP, 0x35CA0002, null); bool run = Wait.Running; if (!run) { Wait.Start(); } Wait.SubStart(items.Length); try { int ct = 0; int step = Math.Max(2, Wait.MaxProgress / 100); foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items) { if (this.HaveToStop) { break; } SimPe.Interfaces.Files.IPackageFile pkg = item.Package; SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(Data.MetaData.STRING_FILE, 0, Data.MetaData.LOCAL_GROUP, 0x00000A46); string name = SimPe.Localization.GetString("Unknown"); if (pfd != null) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(pfd, pkg); SimPe.PackedFiles.Wrapper.StrItemList list = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode); if (list.Count > 0) { name = list[0].Title; } } SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(item); uint inst = GetInstanceFromFilename(pkg.SaveFileName); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] ltxtitems = ngbhfi.FindFile(0x0BF999E7, Data.MetaData.LOCAL_GROUP, inst, null); SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem ltxt = null; if (ltxtitems.Length > 0) { ltxt = ltxtitems[0]; } LotItem li = new LotItem(inst, name, pic.Image, ltxt); if (LoadingLot != null) { LoadingLot(this, li); } content[li.Instance] = li; ct++; if (ct % step == 0) { Wait.Message = name; Wait.Progress = ct; } } //foreach } #if !DEBUG catch (Exception ex) { Helper.ExceptionMessage(ex); } #endif finally { Wait.SubStop(); if (!run) { Wait.Stop(); } } ended.Set(); }
/// <summary> /// Adds a Sim to the List /// </summary> /// <param name="objd"></param> /// <param name="ct"></param> /// <param name="step"></param> /// <returns>The Alias for that Sim</returns> /// <remarks> /// Alias.Tag has the following Structure: /// [0] : FileName of Character File (if NPC, this will be null) /// [1] : Thumbnail /// [2] : FamilyName /// [3] : Contains Age Data /// [4] : When NPC, this will get the Filename /// </remarks> protected Alias AddSim(SimPe.PackedFiles.Wrapper.ExtObjd objd, ref int ct, int step, bool npc) { //if (objd.Type!=Data.ObjectTypes.Person) return null; SimPe.Interfaces.Files.IPackageFile fl = objd.Package; //BinaryReader br = new BinaryReader(File.OpenRead(file));//new StreamReader(file) bool hasagedata = fl.FindFiles(0xAC598EAC).Length > 0; //has Age Data object[] tags = new object[5]; tags[0] = fl.FileName; tags[1] = null; tags[2] = Localization.Manager.GetString("Unknown"); tags[3] = hasagedata; tags[4] = null; /*if (Helper.WindowsRegistry.HiddenMode) * tags[5] = (!hasagedata) && (fl.FindFiles(0xAC506764).Length>0); //if this is true, the Sim has a Problem, and the package was probably split * else * tags[5] = false;*/ //set stuff for NPCs if (npc) { tags[4] = tags[0]; tags[0] = ""; tags[2] += " (NPC)"; } Alias a = null; Interfaces.Files.IPackedFileDescriptor str_pfd = fl.FindFile(Data.MetaData.CTSS_FILE, 0, objd.FileDescriptor.Group, objd.CTSSInstance); if (str_pfd != null) { SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(); str.ProcessData(str_pfd, fl); SimPe.PackedFiles.Wrapper.StrItemList its = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode); if (its.Length > 0) { #if DEBUG a = new Alias(objd.Guid, its[0].Title, "{name} {2} (0x{id})"); #else a = new Alias(objd.Guid, its[0].Title, "{name} {2} (0x{id})"); #endif if (its.Length > 2) { tags[2] = its[2].Title; } } } if (a != null) { IPackedFileDescriptor[] piclist = fl.FindFiles(Data.MetaData.SIM_IMAGE_FILE); foreach (IPackedFileDescriptor pfd in piclist) { if (pfd.Group != objd.FileDescriptor.Group) { continue; } if (pfd.Instance < 0x200) { SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture(); pic.ProcessData(pfd, fl); /*if (Helper.StartedGui==Executable.Classic) * WaitingScreen.UpdateImage(pic.Image); * else * Wait.Image = pic.Image; */ tags[1] = pic.Image; break; } } a.Tag = tags; //if (Helper.StartedGui!=Executable.Classic) { ct++; if (ct % step == 1) { Wait.Message = a.ToString(); Wait.Progress = ct; } } //set stuff for NPCs if (npc) { a.Tag[2] = a.Tag[2].ToString() + " (NPC)"; } if (names == null) { return(null); } if (!names.Contains(objd.Guid)) { names.Add(objd.Guid, a); } } return(a); }
/// <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; }