public void LoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { nfo = new PackageInfo(pkg); BeforeLoadContent(type, pkg); SetName(pkg); SetImage(pkg); AfterLoadContent(type, pkg); }
public void LoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { this.flname = pkg.SaveFileName; nfo = new PackageInfo(pkg); nfo.Type = type; OnLoadContent(); this.SetFromPackage(pkg); }
public ITypeHandler LoadTypeHandler(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { Type t = subreg[type] as Type; if (t == null) { return(new XTypeHandler()); } return(System.Activator.CreateInstance(t, new object[] {}) as ITypeHandler); }
/// <summary> /// Returns the Type of a given Package. /// </summary> /// <param name="pkg">The package you want to classify</param> /// <returns>The Type of the Package</returns> public static SimPe.Cache.PackageType ClassifyPackage(SimPe.Interfaces.Files.IPackageFile pkg) { SimPe.Cache.PackageType type = SimPe.Cache.PackageType.Undefined; foreach (SimPe.Interfaces.Plugin.Scanner.IIdentifier ident in SimPe.Plugin.Scanner.ScannerRegistry.Global.Identifiers) { if (type != SimPe.Cache.PackageType.Unknown && type != SimPe.Cache.PackageType.Undefined) { break; } type = ident.GetType(pkg); } return(type); }
public PackageHandler(SimPe.Interfaces.Files.IPackageFile pkg) { this.flname = pkg.SaveFileName; type = SimPe.Cache.PackageType.Undefined; DeterminType(pkg); Reset(); if (type == SimPe.Cache.PackageType.Object || type == SimPe.Cache.PackageType.Sim || type == SimPe.Cache.PackageType.MaxisObject) { SimPe.PackedFiles.Wrapper.ObjectComboBox.ObjectCache.ReloadCache(SimPe.Plugin.DownloadsToolFactory.FileIndex, false); } hnd = HandlerRegistry.Global.LoadTypeHandler(type, pkg); LoadContent(pkg); }
public void Reset() { RenderData = null; PostponedRenderer = null; this.Description = ""; this.Name = ""; this.Price = 0; this.Category = ""; this.VertexCount = 0; this.FaceCount = 0; this.Image = null; type = SimPe.Cache.PackageType.Undefined; exp = Expansions.None; ClearGuidList(); }
public void LoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { nfo = new PackageInfo(pkg); bool hasprev = BeforeLoadContent(type, pkg); if (tmppkg != null) { Downloads.XTypeHandler hnd = new XTypeHandler(SimPe.Cache.PackageType.Object, tmppkg, false, false); if (hnd.Objects.Length > 0) { PackageInfo snfo = hnd.Objects[0] as PackageInfo; if (snfo != null) { if (snfo.Name.Trim() == "") { snfo.Name = nfo.Name; } snfo.Image = nfo.Image; snfo.RenderedImage = nfo.RenderedImage; snfo.RenderData = nfo.RenderData; snfo.PostponedRenderer = nfo.PostponedRenderer; nfo.Dispose(); nfo = snfo; nfo.ClearGuidList(); } } hnd.Dispose(); } if (!hasprev) { nfo.Image = WallpaperTypeHandler.SetFromTxtr(pkg); nfo.KnockoutThumbnail = false; } AfterLoadContent(type, pkg); }
private SimPe.StringArrayList SortFilesByType(SimPe.StringArrayList files) { SimPe.StringArrayList objects = new StringArrayList(); SimPe.StringArrayList other = new StringArrayList(); foreach (string file in files) { SimPe.Cache.PackageType type = PackageInfo.ClassifyPackage(file); SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.AddIndexFromPackage(file); if (type == SimPe.Cache.PackageType.Object || type == SimPe.Cache.PackageType.MaxisObject || type == SimPe.Cache.PackageType.Sim) { objects.Add(file); } else { other.Add(file); } } objects.AddRange(other); other.Clear(); other = null; files.Clear(); files = null; return(objects); }
protected virtual void OnLoadContent(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Cache.PackageType type) { }
protected virtual void DeterminType(SimPe.Interfaces.Files.IPackageFile pkg) { type = PackageInfo.ClassifyPackage(pkg); }
public XTypeHandler(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg, bool countvert, bool rendergmdc) : base(type, pkg, countvert, rendergmdc) { }
protected virtual bool BeforeLoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { bool ret = false; DisposeTmpPkg(); SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.MMAT); if (pfds.Length > 0) { SimPe.Plugin.MmatWrapper mmat = new MmatWrapper(); mmat.ProcessData(pfds[0], pkg); nfo.Name = mmat.ModelName + ", " + mmat.SubsetName; if (SimPe.Plugin.DownloadsToolFactory.Settings.LoadBasedataForRecolors) { SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii = SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.AddNewChild(); if (System.IO.File.Exists(pkg.SaveFileName)) { string dir = System.IO.Path.GetDirectoryName(pkg.SaveFileName); string[] files = System.IO.Directory.GetFiles(dir); foreach (string file in files) { if (file.EndsWith(".package") || file.EndsWith(".sims")) { if (!FileTable.FileIndex.Contains(file)) { fii.AddIndexFromPackage(file); } } } } //SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.WriteContentToConsole(); tmppkg = SimPe.Plugin.Tool.Dockable.ObjectWorkshopHelper.CreatCloneByGuid(mmat.ObjectGUID); if (SimPe.Plugin.DownloadsToolFactory.Settings.BuildPreviewForRecolors) { if (tmppkg.Index.Length > 0) { ret = true; } tmppkg.CopyDescriptors(pkg); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in tmppkg.Index) { if (pfd.Equals(mmat.FileDescriptor)) { mmat.ProcessData(pfd, tmppkg); } } string name = "render.tmp"; int index = 0; string rname = null; do { rname = System.IO.Path.Combine(Helper.SimPeTeleportPath, index + "_" + name); index++; } while (System.IO.File.Exists(rname)); tmppkg.Save(rname); nfo.RenderData = new object[] { mmat, tmppkg.SaveFileName }; nfo.PostponedRenderer = new EventHandler(PostponedRender); } fii.CloseAssignedPackages(); SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.RemoveChild(fii); } } return(ret); }
/// <summary> /// Creates a new Instance /// </summary> /// <param name="type">Type of the stored Data in the Package</param> /// <param name="pkg">The package</param> /// <param name="countvert">false, if you don't need to know the number of /// stored vertices (you will not get a Preview if this is set to false!)</param> /// <param name="rendergmdc">If true, SimPE will generate a Preview from /// the GMDC (only if countvert is also true)</param> internal DefaultTypeHandler(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg, bool countvert, bool rendergmdc) : this() { this.rendergmdc = rendergmdc; this.countvert = countvert; LoadContent(type, pkg); }
protected void ClearScreen() { SimPe.Cache.PackageType t = nfo.Type; nfo.Reset(); nfo.Type = t; }
public void AddTypeHandler(SimPe.Cache.PackageType type, Type handler) { subreg[type] = handler; }
protected virtual void OnReset(SimPe.Cache.PackageType type) { }
protected virtual void AfterLoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { DisposeTmpPkg(); }
protected virtual void BeforeLoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg) { }