Esempio n. 1
0
        /// <summary>
        /// Add all Files that could be borrowed from the current package by the passed one, to the passed package
        /// </summary>
        /// <param name="orgmodelnames">List of available modelnames in this package</param>
        /// <param name="pkg">The package that should receive the Files</param>
        /// <remarks>Simply Copies MMAT, LIFO, TXTR and TXMT Files</remarks>
        public void AddParentFiles(string[] orgmodelnames, SimPe.Interfaces.Files.IPackageFile pkg)
        {
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Loading Parent Files");
            }
            ArrayList names = new ArrayList();

            foreach (string s in orgmodelnames)
            {
                names.Add(s);
            }

            ArrayList types = new ArrayList();

            types.Add(Data.MetaData.MMAT);
            types.Add(Data.MetaData.TXMT);
            types.Add(Data.MetaData.TXTR);
            types.Add(Data.MetaData.LIFO);

            foreach (uint type in types)
            {
                SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(type);
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    if (pkg.FindFile(pfd) != null)
                    {
                        continue;
                    }

                    SimPe.Interfaces.Files.IPackedFile file = package.Read(pfd);
                    pfd.UserData = file.UncompressedData;

                    //Update the modeName in the MMAT
                    if ((pfd.Type == Data.MetaData.MMAT) && (names.Count > 0))
                    {
                        SimPe.Plugin.MmatWrapper mmat = new MmatWrapper();
                        mmat.ProcessData(pfd, package);

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

                        if (!names.Contains(n))
                        {
                            n = names[0].ToString();
                            //n = n.Substring(0, n.Length-5);
                            mmat.ModelName = n;
                            mmat.SynchronizeUserData();
                        }
                    }

                    pkg.Add(pfd);
                }
            }             //foreach type
        }
Esempio n. 2
0
 public void ProcessData(IPackedFileDescriptor pfd, IPackageFile package, IPackedFile file, bool catchex)
 {
     changed = false;
     if (pfd == null)
     {
         return;
     }
     if (package == null)
     {
         return;
     }
     if (catchex)
     {
         try
         {
             if (file != null)
             {
                 this.pfd     = pfd;
                 this.package = package;
                 file         = package.Read(pfd);
                 System.IO.MemoryStream ms = new System.IO.MemoryStream(file.UncompressedData);
                 if (ms.Length > 0)
                 {
                     Unserialize(new System.IO.BinaryReader(ms));
                     processed = true;
                 }
             }
             else
             {
                 ProcessData(pfd, package);
             }
         }
         catch (Exception ex)
         {
             ExceptionMessage(Localization.Manager.GetString("erropenfile"), ex);
         }
     }
     else
     {
         if (file != null)
         {
             this.pfd     = pfd;
             this.package = package;
             file         = package.Read(pfd);
             System.IO.MemoryStream ms = new System.IO.MemoryStream(file.UncompressedData);
             if (ms.Length > 0)
             {
                 Unserialize(new System.IO.BinaryReader(ms));
                 processed = true;
             }
         }
         else
         {
             ProcessData(pfd, package);
         }
     }
 }
Esempio n. 3
0
        private void addFile(IPackageFile p, IPackedFileDescriptor pfd)
        {
            if (isInPFDList(currentPackage.Index, pfd) || p.FindExactFile(pfd) == null)
            {
                return;
            }

            IPackedFileDescriptor npfd = p.FindExactFile(pfd).Clone();

            npfd.UserData = p.Read(pfd).UncompressedData;
            currentPackage.Add(npfd, true);
        }
Esempio n. 4
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);
        }