Beispiel #1
0
        /// <summary>
        /// Make sure the correct Face Structure is used (as desribed by Nukael)
        /// </summary>
        /// <remarks>http://www.modthesims2.com/showthread.php?t=56241</remarks>
        /// <param name="pkg">The package with the Face Data</param>
        public void UpdateFaceStructure(SimPe.Packages.GeneratableFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds   = pkg.FindFiles((uint)0xCCCEF852);           //LxNR, Face
            SimPe.Interfaces.Files.IPackedFileDescriptor   oldpfd = null;
            SimPe.Interfaces.Files.IPackedFileDescriptor   newpfd = null;

            uint oi = 1;
            uint ni = 2;

            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                if (pfd.Instance <= oi)
                {
                    oldpfd = pfd; oi = pfd.Instance;
                }
                if (pfd.Instance >= ni)
                {
                    newpfd = pfd; ni = pfd.Instance;
                }
            }

            if (oldpfd != null && newpfd != null)
            {
                SimPe.Interfaces.Files.IPackedFile pf = pkg.Read(newpfd);
                oldpfd.UserData = pf.UncompressedData;
                oldpfd.Changed  = true;
            }
        }
Beispiel #2
0
        public void RefreshDock(object sender, SimPe.Events.ResourceEventArgs es)
        {
            rd.button1.Enabled = false;
            if (!rd.dcHex.IsFloating && !rd.dcHex.IsDocked)
            {
                return;
            }
            if (es.HasFileDescriptor)
            {
                foreach (SimPe.Events.ResourceContainer e in es)
                {
                    if (e.HasFileDescriptor && e.HasPackage)
                    {
                        try
                        {
                            rd.hexpfd = e.Resource.FileDescriptor;
                            SimPe.Interfaces.Files.IPackedFile pf = e.Resource.Package.Read(e.Resource.FileDescriptor);
                            rd.hvc.Data        = pf.UncompressedData;
                            rd.button1.Enabled = true;
                            return;
                        }
                        catch {}
                    }
                }
            }

            rd.hvc.Data = null;
        }
Beispiel #3
0
 //all covered by AbstractWrapper
 protected override string GetResourceName(Data.TypeAlias ta)
 {
     if (!SimPe.Helper.FileFormat)
     {
         return(base.GetResourceName(ta));
     }
     SimPe.Interfaces.Files.IPackedFile pf = Package.Read(FileDescriptor);
     byte[] ab = pf.GetUncompressedData(0x48);
     return((ab.Length > 0x44 ? "0x" + Helper.HexString(ab[0x44]) + ": " : "") + Helper.ToString(pf.GetUncompressedData(0x40)));
 }
Beispiel #4
0
        /// <summary>
        /// Load the assigned Wrapper, and initiate the Resource
        /// </summary>
        /// <param name="fii"></param>
        /// <returns></returns>
        public SimPe.Interfaces.Plugin.IFileWrapper GetWrapper(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
        {
            if (fii == null)
            {
                return(null);
            }

            //try by Type
            SimPe.Interfaces.Plugin.IFileWrapper wrapper =
                (SimPe.Interfaces.Plugin.IFileWrapper)FileTable.WrapperRegistry.FindHandler(fii.FileDescriptor.Type);

            //try by Signature
            if (wrapper == null)
            {
                SimPe.Interfaces.Files.IPackedFile pf = pkg.Package.Read(fii.FileDescriptor);
                wrapper = FileTable.WrapperRegistry.FindHandler(pf.GetUncompressedData(0x40));
            }

            return(wrapper);
        }
Beispiel #5
0
        public void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs e)
        {
            if (!ChangeEnabledStateEventHandler(null, e))
            {
                return;
            }

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in e.LoadedPackage.Package.Index)
            {
                //Do we have a registred handler?
                SimPe.Interfaces.Plugin.IFileWrapper wrapper = (SimPe.Interfaces.Plugin.IFileWrapper)FileTable.WrapperRegistry.FindHandler(pfd.Type);
                SimPe.Interfaces.Files.IPackedFile   file    = e.LoadedPackage.Package.Read(pfd);
                if (wrapper == null)
                {
                    wrapper = FileTable.WrapperRegistry.FindHandler(file.UncompressedData);
                }

                if (wrapper != null)
                {
                    wrapper.ProcessData(pfd, e.LoadedPackage.Package);
                    wrapper.Fix(FileTable.WrapperRegistry);
                }
            }
        }
Beispiel #6
0
        public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi)
        {
            ps.Data    = new uint[1];
            ps.State   = TriState.True;
            ps.Data[0] = (uint)HealthState.Ok;
            if (si.Package.Header.Version != 0x100000001)
            {
                ps.Data[0] = (uint)HealthState.UnknownVersion;
            }
            else
            {
                if (si.Package.FileListFile != null)
                {
                    foreach (SimPe.PackedFiles.Wrapper.ClstItem item in si.Package.FileListFile.Items)
                    {
                        SimPe.Interfaces.Files.IPackedFileDescriptor p = si.Package.FindFile(item.Type, item.SubType, item.Group, item.Instance);
                        if (p == null)
                        {
                            ps.Data[0] = (uint)HealthState.WrongDirectory;
                            break;
                        }
                    }

                    if (ps.Data[0] == (uint)HealthState.Ok)
                    {
                        foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in si.Package.Index)
                        {
                            SimPe.Interfaces.Files.IPackedFile fl = si.Package.Read(pfd);

                            if (pfd.Type == Data.MetaData.OBJD_FILE)
                            {
                                SimPe.PackedFiles.Wrapper.ExtObjd obj = new ExtObjd();
                                obj.ProcessData(pfd, si.Package);

                                if (obj.Ok != SimPe.PackedFiles.Wrapper.ObjdHealth.Ok)
                                {
                                    ps.Data[0] = (uint)HealthState.NonDefaultObjd;
                                }
                                if (obj.Ok == SimPe.PackedFiles.Wrapper.ObjdHealth.UnmatchingFilenames && Helper.WindowsRegistry.HiddenMode)
                                {
                                    ps.Data[0] = (uint)HealthState.FaultyNamedObjd;
                                }
                                if (obj.Ok == ObjdHealth.OverLength)
                                {
                                    ps.Data[0] = (uint)HealthState.FaultySizedObjd;
                                }
                            }
                            if (pfd.Type == Data.MetaData.GMDC)
                            {
                                SimPe.Plugin.GenericRcol rcol = new GenericRcol();
                                rcol.ProcessData(pfd, si.Package);

                                SimPe.Plugin.GeometryDataContainer gmdc = (SimPe.Plugin.GeometryDataContainer)rcol.Blocks[0];
                                foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups)
                                {
                                    if (g.FaceCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_FACE_AMOUNT)
                                    {
                                        ps.Data[0] = (uint)HealthState.BigMeshGeometry;
                                    }
                                    else if (g.UsedVertexCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_VERTEX_AMOUNT)
                                    {
                                        ps.Data[0] = (uint)HealthState.BigMeshGeometry;
                                    }
                                }
                            }
                            if (!fl.IsCompressed)
                            {
                                continue;
                            }

                            int pos = si.Package.FileListFile.FindFile(pfd);
                            if (pos == -1)
                            {
                                ps.Data[0] = (uint)HealthState.IncompleteDirectory;
                                break;
                            }

                            SimPe.PackedFiles.Wrapper.ClstItem item = si.Package.FileListFile.Items[pos];
                            if (fl.UncompressedSize != item.UncompressedSize)
                            {
                                ps.Data[0] = (uint)HealthState.WrongCompressionSize;
                                break;
                            }
                        }
                    }
                }
                if (ps.Data[0] != (uint)HealthState.Ok)
                {
                    ps.State = TriState.False;
                }
            }

            UpdateState(si, ps, lvi);
        }
Beispiel #7
0
        /// <summary>
        /// this Operation is fixing selected Packages that wer marked as problematic
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FixCompression(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (selection == null)
            {
                return;
            }

            WaitingScreen.Wait();
            bool chg = false;

            try
            {
                foreach (ScannerItem si in selection)
                {
                    if (si.PackageCacheItem.Thumbnail != null)
                    {
                        WaitingScreen.Update(si.PackageCacheItem.Thumbnail, si.FileName);
                    }
                    else
                    {
                        WaitingScreen.UpdateMessage(si.FileName);
                    }

                    SimPe.Cache.PackageState ps = si.PackageCacheItem.FindState(this.Uid, true);
                    if ((ps.State != TriState.Null) && (ps.Data.Length > 0))
                    {
                        if ((HealthState)ps.Data[0] != HealthState.Ok)
                        {
                            ps.State   = TriState.True;
                            ps.Data[0] = (uint)HealthState.Ok;
                            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in si.Package.Index)
                            {
                                SimPe.Interfaces.Files.IPackedFile file = si.Package.Read(pfd);
                                pfd.UserData          = file.UncompressedData;
                                pfd.MarkForReCompress = (file.IsCompressed || Data.MetaData.CompressionCandidates.Contains(pfd.Type));

                                if (pfd.Type == Data.MetaData.OBJD_FILE)
                                {
                                    SimPe.PackedFiles.Wrapper.ExtObjd objd = new ExtObjd();
                                    objd.ProcessData(pfd, si.Package);

                                    if (objd.Ok != SimPe.PackedFiles.Wrapper.ObjdHealth.Ok)
                                    {
                                        objd.SynchronizeUserData();
                                        objd.ProcessData(pfd, si.Package);

                                        if (objd.Ok != ObjdHealth.Ok)
                                        {
                                            ps.State   = TriState.False;
                                            ps.Data[0] = (uint)HealthState.NonDefaultObjd;
                                            if (objd.Ok == SimPe.PackedFiles.Wrapper.ObjdHealth.UnmatchingFilenames && Helper.WindowsRegistry.HiddenMode)
                                            {
                                                ps.Data[0] = (uint)HealthState.FaultyNamedObjd;
                                            }
                                            if (objd.Ok == ObjdHealth.OverLength)
                                            {
                                                ps.Data[0] = (uint)HealthState.FaultySizedObjd;
                                            }
                                        }
                                    }
                                }
                            }

                            si.Package.Save();
                            chg = true;
                            si.ListViewItem.ForeColor = System.Drawing.Color.Black;
                            this.ScanPackage(si, ps, si.ListViewItem);
                        }
                    }
                }

                if (chg && this.CallbackFinish != null)
                {
                    this.CallbackFinish(false, false);
                }
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage("", ex);
            }
            finally
            {
                WaitingScreen.Stop();
            }
        }
Beispiel #8
0
 void SimPe.Interfaces.Plugin.Internal.IPackedFileWrapper.ProcessData(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile package, SimPe.Interfaces.Files.IPackedFile file)
 {
 }