public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { System.Drawing.Size sz = AbstractScanner.ThumbnailSize; if (si.PackageCacheItem.Type == PackageType.Object || si.PackageCacheItem.Type == PackageType.MaxisObject || si.PackageCacheItem.Type == PackageType.Recolor) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.OBJD_FILE); uint group = 0; if (pfds.Length > 0) { group = pfds[0].Group; } if (group == Data.MetaData.LOCAL_GROUP) { SimPe.Interfaces.Wrapper.IGroupCacheItem gci = FileTable.GroupCache.GetItem(si.FileName); if (gci != null) { group = gci.LocalGroup; } } string[] modelnames = SimPe.Plugin.Scenegraph.FindModelNames(si.Package); foreach (string modelname in modelnames) { System.Drawing.Image img = SimPe.Plugin.Workshop.GetThumbnail(group, modelname); if (img != null) { si.PackageCacheItem.Thumbnail = img; ps.State = TriState.True; break; } } } //no Thumbnail, do we have a Image File? if (ps.State == TriState.Null) { SimPe.PackedFiles.Wrapper.Picture pic = new Picture(); uint[] types = pic.AssignableTypes; foreach (uint type in types) { SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(type); if (pfds.Length > 0) { //get image with smallest Instance SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds) { if (p.Instance < pfd.Instance) { pfd = p; } } pic.ProcessData(pfd, si.Package, false); si.PackageCacheItem.Thumbnail = pic.Image; if (si.PackageCacheItem.Thumbnail != null) { si.PackageCacheItem.Thumbnail = ImageLoader.Preview(si.PackageCacheItem.Thumbnail, sz); ps.State = TriState.True; } break; } } //foreach } //no Thumbnail generated by the Game? if (ps.State == TriState.Null) { //load the Texture Image SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.TXTR); if (pfds.Length > 0) { SimPe.Plugin.GenericRcol rcol = new GenericRcol(null, false); //get biggest texture SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0]; foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in pfds) { if (p.Size > pfd.Size) { pfd = p; } } rcol.ProcessData(pfd, si.Package, false); SimPe.Plugin.ImageData id = (SimPe.Plugin.ImageData)rcol.Blocks[0]; SimPe.Plugin.MipMap mm = id.GetLargestTexture(sz); if (mm.Texture != null) { si.PackageCacheItem.Thumbnail = ImageLoader.Preview(mm.Texture, sz); ps.State = TriState.True; } rcol.Dispose(); } } if (si.PackageCacheItem.Thumbnail != null) { if (WaitingScreen.Running) { WaitingScreen.UpdateImage(si.PackageCacheItem.Thumbnail); } } UpdateState(si, ps, lvi); }