Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 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();
 }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 protected virtual void OnLoadContent(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Cache.PackageType type)
 {
 }
Esempio n. 10
0
 protected virtual void DeterminType(SimPe.Interfaces.Files.IPackageFile pkg)
 {
     type = PackageInfo.ClassifyPackage(pkg);
 }
Esempio n. 11
0
 public XTypeHandler(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg, bool countvert, bool rendergmdc)
     : base(type, pkg, countvert, rendergmdc)
 {
 }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
 /// <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);
 }
Esempio n. 14
0
 protected void ClearScreen()
 {
     SimPe.Cache.PackageType t = nfo.Type;
     nfo.Reset();
     nfo.Type = t;
 }
Esempio n. 15
0
 public void AddTypeHandler(SimPe.Cache.PackageType type, Type handler)
 {
     subreg[type] = handler;
 }
Esempio n. 16
0
 protected virtual void OnReset(SimPe.Cache.PackageType type)
 {
 }
Esempio n. 17
0
 protected virtual void AfterLoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg)
 {
     DisposeTmpPkg();
 }
Esempio n. 18
0
 protected virtual void BeforeLoadContent(SimPe.Cache.PackageType type, SimPe.Interfaces.Files.IPackageFile pkg)
 {
 }