예제 #1
0
        private bool addFromPkg(String name, uint type, String pkg)
        {
            IPackageFile p = SimPe.Packages.File.LoadFromFile(pkg);

            if (p == null)
            {
                return(false);
            }

            IPackedFileDescriptor[] pfa = p.FindFiles(SimPe.Data.MetaData.NAME_MAP);
            if (pfa == null || pfa.Length != 1)
            {
                return(false);
            }

            SimPe.Plugin.Nmap nmap = new SimPe.Plugin.Nmap(null);
            nmap.ProcessData(pfa[0], p);
            pfa = nmap.FindFiles(name + "_");
            if (pfa == null || pfa.Length != 1)
            {
                return(false);
            }

            IPackedFileDescriptor pfd = null;

            for (int j = 0; j < p.Index.Length && pfd == null; j++)
            {
                if (p.Index[j].Type == type &&
                    p.Index[j].Group == pfa[0].Group &&
                    p.Index[j].Instance == pfa[0].Instance)
                {
                    pfd = p.Index[j];
                }
            }
            if (pfd == null)
            {
                return(false);
            }
            if (isInPFDList(currentPackage.Index, pfd))
            {
                return(true);
            }

            IPackedFileDescriptor npfd = pfd.Clone();

            npfd.UserData = p.Read(pfd).UncompressedData;
            currentPackage.Add(npfd, true);

            return(true);
        }
예제 #2
0
        protected void LoadSkinImageFormPackage(SimPe.Interfaces.Files.IPackageFile package)
        {
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(0xAC506764);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.RefFile reffile = new SimPe.Plugin.RefFile();
                    reffile.ProcessData(pfd, package);
                    refs.Add(reffile);
                }
                catch (Exception) {}
            }

            pfds = package.FindFiles(0x49596978);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.Rcol matd = new SimPe.Plugin.GenericRcol(null, true);
                    matd.ProcessData(pfd, package);
                    matds.Add(matd);
                }
                catch (Exception) {}
            }

            //Material Files
            Interfaces.Files.IPackedFileDescriptor[] nmap_pfd = package.FindFiles(Data.MetaData.NAME_MAP);
            pfds = package.FindFiles(0x49596978);
            Plugin.Nmap nmap = new SimPe.Plugin.Nmap(null);
            if (nmap_pfd.Length > 0)
            {
                nmap.ProcessData(nmap_pfd[0], package);
            }
            bool check = false;

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.Rcol matd = new SimPe.Plugin.GenericRcol(null, true);
                    check = false;

                    foreach (Interfaces.Files.IPackedFileDescriptor epfd in nmap.Items)
                    {
                        if (
                            (epfd.Group == pfd.Group) &&
                            (epfd.Instance == pfd.Instance)
                            )
                        {
                            matd.FileDescriptor = pfd;
                            matd.Package        = package;
                            matds.Add(matd);
                            check = true;
                        }
                    }

                    //not found in the FileMap, so process Normally
                    if (!check)
                    {
                        matd.ProcessData(pfd, package);
                        matds.Add(matd);
                    }
                }
                catch (Exception) {}
            }

            //Texture Files
            nmap_pfd = package.FindFiles(Data.MetaData.NAME_MAP);
            pfds     = package.FindFiles(0x1C4A276C);
            check    = false;

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                try
                {
                    SimPe.Plugin.Txtr txtr = new SimPe.Plugin.Txtr(null, true);
                    check = false;

                    foreach (Interfaces.Files.IPackedFileDescriptor epfd in nmap.Items)
                    {
                        if (
                            (epfd.Group == pfd.Group) &&
                            (epfd.Instance == pfd.Instance)
                            )
                        {
                            txtr.FileDescriptor = pfd;
                            txtr.Package        = package;
                            txtrs.Add(epfd.Filename, txtr);
                            continue;
                        }
                    }

                    //not found in the FileMap, so process Normally
                    if (!check)
                    {
                        txtr.ProcessData(pfd, package);
                        foreach (SimPe.Plugin.ImageData id in txtr.Blocks)
                        {
                            txtrs.Add(id.NameResource.FileName.ToLower(), txtr);
                        }
                    }
                }
                catch (Exception) {}
            }
        }