Example #1
0
        public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.MMAT);
            //ArrayList list = new ArrayList();

            ps.State = TriState.True;
            //FileTable.FileIndex.StoreCurrentState();
            if (!FileTable.FileIndex.ContainsPath(System.IO.Path.GetDirectoryName(si.FileName)))
            {
                FileIndex.AddIndexFromFolder(System.IO.Path.GetDirectoryName(si.FileName));
            }

            FileIndex.AddIndexFromPackage(si.Package);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.MmatWrapper mmat = new MmatWrapper();
                mmat.ProcessData(pfd, si.Package, false);

                string m = mmat.ModelName.Trim().ToLower();
                if (!m.EndsWith("_cres"))
                {
                    m += "_cres";
                }

                //Add the current package
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(m, Data.MetaData.CRES, Data.MetaData.LOCAL_GROUP, true);

                if (item == null)
                {
                    ps.State = TriState.False;
                }

                item = null;
                mmat.Dispose();
                m = null;
            }
            //FileTable.FileIndex.RestoreLastState();

            UpdateState(si, ps, lvi);
        }
Example #2
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);
        }