Пример #1
0
        /// <summary>
        /// Creates a new Insttance
        /// </summary>
        /// <param name="p">The Package this Object describes</param>
        /// <param name="author">Author of this Package</param>
        /// <param name="contact">How to contact the Autor</param>
        /// <param name="title">Title of this Package</param>
        /// <param name="description">Description for the Package</param>
        /// <param name="compressed">true if this Package should be stored compressed</param>
        /// <param name="extension">true, if you wnt to use the Community Extionsins (Will create a textFile in the Package if needed)</param>
        /// <param name="dependency">Objects this one depends on</param>
        public S2CPDescriptor(GeneratableFile p, string author, string contact, string title, string description, Sims2CommunityPack.CompressionStrength compressed, S2CPDescriptorBase[] dependency, bool extension)
            : base(p)
        {
            type             = "Object";
            gameversion      = "2141707388.153.1";
            this.description = description;
            this.compressed  = compressed;
            objectversion    = "1.0";
            crc          = "0";
            this.author  = author;
            this.contact = contact;
            this.title   = title;
            gameguid     = this.GameGuid;

            if (dependency == null)
            {
                dep = new S2CPDescriptorBase[0];
            }
            else
            {
                dep = dependency;
            }

            if (extension)
            {
                if (p != null)
                {
                    guid = GetSetGlobalGuid(p, ref name, ref this.title, ref this.author, ref this.contact, ref this.description, ref gameguid);
                }
            }
        }
Пример #2
0
 internal void SyncFileIndex(GeneratableFile pkg)
 {
     this.FileIndex.Clear();
     if (pkg.Index.Length <= Helper.WindowsRegistry.BigPackageResourceCount)
     {
         this.FileIndex.AddIndexFromPackage(pkg);
     }
 }
Пример #3
0
        /// <summary>
        /// Init the Clone for this Package
        /// </summary>
        /// <returns>An INstance of this Class</returns>
        protected override Interfaces.Files.IPackageFile NewCloneBase()
        {
            GeneratableFile fl = new GeneratableFile((BinaryReader)null);

            fl.header = this.header;

            return(fl);
        }
Пример #4
0
 private void AddPackage(object sender, System.EventArgs e)
 {
     ofd.Filter = "Sims 2 Package (*.package)|*.package|All Files (*.*)|*.*";
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         SimPe.Packages.GeneratableFile package = GeneratableFile.LoadFromFile(ofd.FileName);
         S2CPDescriptor s2cp = new S2CPDescriptor(package, "", "", "", "", Sims2CommunityPack.DEFAULT_COMPRESSION_STRENGTH, new S2CPDescriptorBase[0], extension);
         lblist.Items.Add(s2cp);
         lblist.SelectedIndex = lblist.Items.Count - 1;
     }
 }
Пример #5
0
        /// <summary>
        /// Remove a given Package from the Maintainer
        /// </summary>
        /// <param name="pkg"></param>
        internal void RemovePackage(GeneratableFile pkg)
        {
            if (!Helper.WindowsRegistry.UsePackageMaintainer)
            {
                return;
            }
            if (pkg == null)
            {
                return;
            }

            RemovePackage(pkg.FileName);
        }
Пример #6
0
        public static void Fix(string package, string modelname, FixVersion ver)
        {
            if (System.IO.File.Exists(package))
            {
                SimPe.Packages.GeneratableFile pkg = SimPe.Packages.GeneratableFile.LoadFromFile(package);

                System.Collections.Hashtable map = RenameForm.GetNames((modelname.Trim() != ""), pkg, null, modelname);
                FixObject fo = new FixObject(pkg, ver, false);
                fo.Fix(map, false);
                fo.CleanUp();
                fo.FixGroup();

                pkg.Save();
            }
        }
Пример #7
0
 private void AddPackage(object sender, System.EventArgs e)
 {
     ofd.Filter = "Sims 2 Package (*.package)|*.package|All Files (*.*)|*.*";
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         SimPe.Packages.GeneratableFile package = GeneratableFile.LoadFromFile(ofd.FileName);
         S2CPDescriptorBase             s2cpb   = new S2CPDescriptorBase(package);
         if (s2cpb.Guid == null)
         {
             MessageBox.Show("This Package does not contain a valid GlobalGUID.\nYou can create on by including this File in a diffren Sims2Community Package or by adding a 'Sims2Comunity Identifier' to the Package.");
         }
         else
         {
             lblist.Items.Add(s2cpb);
         }
     }
 }
Пример #8
0
        /// <summary>
        /// Reads a package from the Stream
        /// </summary>
        /// <param name="reader">The S2CP Stream</param>
        /// <param name="offset">The starting offset</param>
        /// <param name="length">The Length of the Package</param>
        /// <param name="desc">Package Description</param>
        /// <returns>The Package</returns>
        protected static SimPe.Packages.GeneratableFile LoadPackage(BinaryReader reader, int offset, int length, SimPe.Packages.S2CPDescriptor desc)
        {
            reader.BaseStream.Seek(offset, System.IO.SeekOrigin.Begin);
            MemoryStream ms = new MemoryStream(reader.ReadBytes(length));

            if (desc.Compressed == CompressionStrength.None)
            {
                SimPe.Packages.GeneratableFile pkg = GeneratableFile.LoadFromStream(new BinaryReader(ms));
                return(pkg);
            }
            else
            {
                MemoryStream unc = new MemoryStream();
                Decompress(ms, unc);
                SimPe.Packages.GeneratableFile pkg = GeneratableFile.LoadFromStream(new BinaryReader(unc));
                pkg.FileName = desc.Name;
                return(pkg);
            }
        }
Пример #9
0
        /// <summary>
        /// Creates a new Instance
        /// </summary>
        /// <param name="p">The Package this Object describes</param>
        public S2CPDescriptorBase(GeneratableFile p)
        {
            package       = p;
            objectversion = "0";

            if (p != null)
            {
                name = System.IO.Path.GetFileName(p.FileName);
                if (name == "")
                {
                    name = Localization.Manager.GetString("Unknown") + ".package";
                }

                string author      = "";
                string title       = "";
                string description = "";
                string contact     = "";
                string gameguid    = "";
                guid = GetGlobalGuid(p, ref name, ref title, ref author, ref contact, ref description, ref gameguid);
            }
        }
Пример #10
0
        /// <summary>
        /// Load a Package File from the Maintainer
        /// </summary>
        /// <param name="filename">the name of the package</param>
        /// <param name="sync">true, if the package should be synchronized with the Filesystem befor it is returned</param>
        /// <returns>an instance of <see cref="SimPe.Packages.GeneratableFile"/> for the given Filename</returns>
        /// <remarks>
        /// If the package was loaded once in this session, this Method will return an instance to the
        /// last loaded Version. Otherwise it wil create a new instance
        /// </remarks>
        public GeneratableFile LoadPackageFromFile(string filename, bool sync)
        {
            GeneratableFile ret = null;

            if (filename == null)
            {
                ret = GeneratableFile.CreateNew();
            }
            else
            {
                if (!Helper.WindowsRegistry.UsePackageMaintainer)
                {
                    ret = new GeneratableFile(filename);
                }
                else
                {
                    if (!ht.ContainsKey(filename))
                    {
                        ht[filename] = new GeneratableFile(filename);
                    }
                    else if (sync)
                    {
                        SimPe.FileTableBase.FileIndex.ClosePackage((GeneratableFile)ht[filename]);
                        //((GeneratableFile)ht[filename]).Close(true);
                        ((GeneratableFile)ht[filename]).ReloadFromFile(filename);
                    }

                    ret = (GeneratableFile)ht[filename];
                }
            }

            if (sync)
            {
                this.SyncFileIndex(ret);
            }

            return(ret);
        }
Пример #11
0
        /// <summary>
        /// Creates a new Isntance
        /// </summary>
        /// <param name="package">The Object you want to Recolor</param>
        public ObjectRecolor(IPackageFile package)
        {
            this.package = package;

            if (System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE))
            {
                dn_pkg = SimPe.Packages.GeneratableFile.LoadFromFile(ScenegraphHelper.GMND_PACKAGE);
            }
            else
            {
                dn_pkg          = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null);
                dn_pkg.FileName = ScenegraphHelper.GMND_PACKAGE;
            }

            if (System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE))
            {
                gm_pkg = SimPe.Packages.GeneratableFile.LoadFromFile(ScenegraphHelper.MMAT_PACKAGE);
            }
            else
            {
                gm_pkg          = SimPe.Packages.GeneratableFile.LoadFromStream((System.IO.BinaryReader)null);
                gm_pkg.FileName = ScenegraphHelper.MMAT_PACKAGE;
            }
        }
Пример #12
0
        /// <summary>
        /// saves the packed File
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="dscfile"></param>
        public static void SavePackedFile(string filename, bool dscfile, SimPe.Packages.PackedFileDescriptor pfd, SimPe.Packages.GeneratableFile package)
        {
#if !DEBUG
            try
#endif
            {
                pfd.Path     = System.IO.Path.GetDirectoryName(filename);
                pfd.Path     = ".\\";
                pfd.Filename = System.IO.Path.GetFileName(filename);
                package.SavePackedFile(filename, null, pfd, dscfile);
            }
#if !DEBUG
            catch (Exception ex)
            {
                Helper.ExceptionMessage(Localization.Manager.GetString("errwritingfile") + filename, ex);
            }
#endif
        }