Exemple #1
0
        public void Execute(SimPe.Packages.S2CPDescriptor s2cp, bool ronly)
        {
            lblist.Items.Clear();

            this.btdelete.Visible = !ronly;
            this.btadd.Visible    = !ronly;

            foreach (S2CPDescriptorBase s2cpb in s2cp.Dependency)
            {
                lblist.Items.Add(s2cpb);
            }

            if (lblist.Items.Count > 0)
            {
                lblist.SelectedIndex = 0;
            }
            btdelete.Enabled = (lblist.SelectedIndex >= 0);

            this.ShowDialog();

            if (ok)
            {
                S2CPDescriptorBase[] s2cpbs = new S2CPDescriptorBase[lblist.Items.Count];
                for (int i = 0; i < s2cpbs.Length; i++)
                {
                    s2cpbs[i] = (S2CPDescriptorBase)lblist.Items[i];
                }

                s2cp.Dependency = s2cpbs;
            }
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
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);
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// Parse the Dependency Node in an XML
        /// </summary>
        /// <param name="dep">The Dependency Node</param>
        /// <returns>The Descriptor of the DependencyPackage (the package value is NULL)</returns>
        /// <remarks>The Descriptor won't contain the package Data. Yo you have to find the Matching Package
        /// by the returned GUID and Name</remarks>
        protected static S2CPDescriptorBase ParesDependingPackedFile(XmlNode dep)
        {
            S2CPDescriptorBase s2cp = new S2CPDescriptorBase(null);

            s2cp.Optional = false;
            foreach (XmlNode subnode in dep)
            {
                switch (subnode.LocalName)
                {
                case "Name":
                {
                    s2cp.Name = subnode.InnerText;
                    break;
                }

                case "ObjectVersion":
                {
                    s2cp.ObjectVersion = subnode.InnerText;
                    break;
                }

                case "GlobalGUID":
                {
                    s2cp.Guid = subnode.InnerText;
                    break;
                }

                case "Optional":
                {
                    s2cp.Optional = true;
                    break;
                }
                }         //switch
            }             //foreach

            return(s2cp);
        }
Exemple #5
0
        /// <summary>
        /// Parse the packedFile Node in an XML
        /// </summary>
        /// <param name="reader">The source Stream of the S2CP File</param>
        /// <param name="pfile">The PackedFile Node</param>
        /// <param name="offset">The Ofset for the package Data</param>
        /// <returns>The Descriptor of the PackedFile</returns>
        /// <remarks>The GUIDs and the Names of the Descriptors are the ones stored in the
        /// XML Data not the ones from the Package. So you have to <seealso cref="SimPe.Packages.S2CPDescriptorBase.Valid"/><see cref="SimPe.Packages.S2CPDescriptorBase.Valid"/> the Content with the Package.</remarks>
        protected static S2CPDescriptor ParesPackedFile(BinaryReader reader, XmlNode pfile, int offset)
        {
            S2CPDescriptor s2cp      = new S2CPDescriptor(null, "", "", "", "", Sims2CommunityPack.CompressionStrength.None, null, true);
            int            pkglen    = 0;
            int            pkgoffset = 0;

            foreach (XmlNode mainnode in pfile)
            {
                switch (mainnode.LocalName)
                {
                case "Name":
                {
                    s2cp.Name = mainnode.InnerText;
                    break;
                }

                case "Description":
                {
                    s2cp.Description = mainnode.InnerText;
                    break;
                }

                case "Crc":
                {
                    s2cp.Crc = mainnode.InnerText;
                    break;
                }

                case "Length":
                {
                    pkglen = Convert.ToInt32(mainnode.InnerText);
                    break;
                }

                case "Offset":
                {
                    pkgoffset = Convert.ToInt32(mainnode.InnerText);
                    break;
                }

                case "Sims2CommuniytExt":
                {
                    foreach (XmlNode subnode in mainnode)
                    {
                        switch (subnode.LocalName)
                        {
                        case "Author":
                        {
                            foreach (XmlNode authnode in subnode)
                            {
                                switch (authnode.LocalName)
                                {
                                case "PersonalName":
                                {
                                    s2cp.Author = authnode.InnerText;
                                    break;
                                }

                                case "Contact":
                                {
                                    s2cp.Contact = authnode.InnerText;
                                    break;
                                }
                                }                                                //switch
                            }
                            break;
                        }

                        case "Title":
                        {
                            s2cp.Title = subnode.InnerText;
                            break;
                        }

                        case "ObjectVersion":
                        {
                            s2cp.ObjectVersion = subnode.InnerText;
                            break;
                        }

                        case "GlobalGUID":
                        {
                            s2cp.Guid = subnode.InnerText;
                            break;
                        }

                        case "Compressed":
                        {
                            s2cp.Compressed = (CompressionStrength)Convert.ToInt32(subnode.InnerText);
                            break;
                        }

                        case "Dependency":
                        {
                            ArrayList al = new ArrayList();
                            foreach (XmlNode dep in subnode)
                            {
                                if (dep.LocalName == "PackagedFile")
                                {
                                    al.Add(ParesDependingPackedFile(dep));
                                }
                            }
                            S2CPDescriptorBase[] deps = new S2CPDescriptorBase[al.Count];
                            al.CopyTo(deps);
                            s2cp.Dependency = deps;
                            break;
                        }
                        }
                    }
                    break;
                }
                }         //switch
            }             //foreach

            s2cp.Package = LoadPackage(reader, offset + pkgoffset, pkglen, s2cp);
            return(s2cp);
        }