public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { this.LoadThumbnail(si, ps); if (si.PackageCacheItem.Type == PackageType.Neighborhood) { Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.IDNO); if (pfds.Length > 0) { Idno idno = new Idno(); idno.ProcessData(pfds[0], si.Package); ps.Data = new uint[2]; ps.Data[0] = (uint)idno.Type; ps.Data[1] = idno.Uid; //check for duplicates if (ids.Contains(idno.Uid)) { ps.State = TriState.False; } else { ps.State = TriState.True; } } } if (si.PackageCacheItem.Thumbnail != null && WaitingScreen.Running) { WaitingScreen.UpdateImage(si.PackageCacheItem.Thumbnail); } UpdateState(si, ps, lvi); }
protected void AddImage(string path) { string name = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), System.IO.Path.GetFileNameWithoutExtension(path) + ".png"); //name = System.IO.Path.Combine(path, name); if (System.IO.File.Exists(name)) { try { System.IO.Stream st = System.IO.File.OpenRead(name); Image img = Image.FromStream(st); st.Close(); st.Dispose(); st = null; if (WaitingScreen.Running) { WaitingScreen.UpdateImage(ImageLoader.Preview(img, WaitingScreen.ImageSize)); } this.ilist.Images.Add(img); return; } catch (System.ArgumentException) { } } this.ilist.Images.Add(new Bitmap(this.GetType().Assembly.GetManifestResourceStream("SimPe.Plugin.Network.png"))); }
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); }