Ejemplo n.º 1
0
 public static bool ParseRK(string value, out RK result)
 {
     result = null;
     string[] entries = value.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
     if (entries.Length < 3)
         return false;
     uint tid, gid;
     ulong iid;
     if (!uint.TryParse(entries[0], NumberStyles.HexNumber, null, out tid))
         return false;
     if (!uint.TryParse(entries[1], NumberStyles.HexNumber, null, out gid))
         return false;
     if (!ulong.TryParse(entries[2], NumberStyles.HexNumber, null, out iid))
         return false;
     result = new RK(RK.NULL);
     result.ResourceType = tid;
     result.ResourceGroup = gid;
     result.Instance = iid;
     return true;
 }
Ejemplo n.º 2
0
 public RKElem(string name, RK key, XmlElement elem)
 {
     this.Name = name;
     this.OldResourceKey = this.NewResourceKey = key;
     this.Element = elem;
 }
Ejemplo n.º 3
0
Archivo: RK.cs Proyecto: dd-dk/s3pi
 static RK() { NULL = new RK(); }
Ejemplo n.º 4
0
Archivo: RK.cs Proyecto: dd-dk/s3pi
 /// <summary>
 /// Tests whether a string can be converted to an <see cref="IResourceKey"/> and,
 /// if so, sets <paramref name="result"/> to the converted value.
 /// </summary>
 /// <param name="value">A potential string representation of an <see cref="IResourceKey"/>.</param>
 /// <param name="result">The eqivalent <see cref="IResourceKey"/> value for <paramref name="value"/>.</param>
 /// <returns>True if <paramref name="value"/> has the format
 /// "0xHHHHHHHH-0xHHHHHHHH-0xHHHHHHHHHHHHHHHH"; otherwise false.
 /// </returns>
 public static bool TryParse(string value, out IResourceKey result)
 {
     result = new RK();
     return AResourceKey.TryParse(value, result);
 }
Ejemplo n.º 5
0
 public RKPos(RK rk)
 {
     this.OldResourceKey = this.NewResourceKey = rk;
 }
Ejemplo n.º 6
0
        bool allowReplace()
        {
            if (!criteriaEnabled) return false;

            Criteria c = FromCriteria;
            if (c.ResourceType == null && c.ResourceGroup == null && c.Instance == null) return false;
            c = ToCriteria;
            if (c.ResourceType == null && c.ResourceGroup == null && c.Instance == null) return false;

            AResourceKey from = new RK(FromCriteria.ResourceKey);
            AResourceKey to = new RK(ToCriteria.GetValueOrDefault(from));
            bool res = to.Equals(from);
            return !res;
        }
Ejemplo n.º 7
0
        protected override Stream UnParse()
        {
            if (ppt == null)
                throw new InvalidOperationException("PathPackageTuple must not be null.");

            if (packageid == null)
                throw new InvalidOperationException("PackageId must not be null.");

            if (packagetype == null)
                throw new InvalidOperationException("Type of package must not be null.");

            Document = new XmlDocument();
            XmlElement root = Document.CreateElement("manifest");
            Document.AppendChild(root);

            root.SetAttribute("packagesubtype", subtype);
            root.SetAttribute("packagetype", packagetype);
            root.SetAttribute("version", "3");
            root.SetAttribute("true", "false");

            root.AppendChild(CreateElement("gameversion", "0.0.0.11195"));
            root.AppendChild(CreateElement("packagedate", DateTime.UtcNow.ToString("MM/dd/yyyy")));
            root.AppendChild(CreateElement("assetversion", "0"));
            root.AppendChild(CreateElement("mingamever", "1.0.0.0"));
            root.AppendChild(Document.CreateElement("handler"));
            root.AppendChild(CreateDefaultDependencyList());
            root.AppendChild(CreateElement("packageid", packageid));

            root.AppendChild(CreateNumOfThumbs());

            KeyList = Document.CreateElement("keylist");
            ppt.Package.GetResourceList.ForEach(Add);
            root.AppendChild(KeyList);

            if (createMissingThumb && numofthumbs == 0)
            {
                RK newRK;
                System.Drawing.Image newIcon;
                SpecificResource srKey = FindLargestThumb();
                if (srKey != null)
                {
                    newRK = new RK(srKey.ResourceIndexEntry) { ResourceType = 0x2E75C765, };
                    newIcon = System.Drawing.Image.FromStream(srKey.Resource.Stream);
                }
                else
                {
                    srKey = ppt.Find(x => x.ResourceType == 0x0166038C);
                    if (srKey != null)
                        newRK = new RK(srKey.ResourceIndexEntry) { ResourceType = 0x2E75C765, };
                    else
                    {
                        newRK = new RK(RK.NULL)
                        {
                            ResourceType = 0x2E75C765,
                            ResourceGroup = 0,
                            Instance = System.Security.Cryptography.FNV64.GetHash(Path.GetFileNameWithoutExtension(ppt.Path))
                        };
                    }
                    newIcon = S3Pack.Properties.Resources.defaultIcon;
                }
                if (newIcon.Width != 256)
                    newIcon = newIcon.GetThumbnailImage(256, 256, () => false, System.IntPtr.Zero);
                MemoryStream ms = new MemoryStream();
                newIcon.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                Add(ppt.AddResource(newRK, ms).ResourceIndexEntry);
            }

            root.AppendChild(CreateLanguageElementWithChild("localizednames", "localizedname", title));
            root.AppendChild(CreateElement("packagetitle", title));
            root.AppendChild(CreateLanguageElementWithChild("localizeddescriptions", "localizeddescription", desc));
            root.AppendChild(CreateElement("packagedesc", desc));

            byte[] res;
            MemoryStream msXml = new MemoryStream();
            using (XmlWriter xw = XmlWriter.Create(msXml, new XmlWriterSettings()
            {
                CloseOutput = false,
                Encoding = System.Text.UTF8Encoding.UTF8,
                Indent = true,
                IndentChars = "  ",
                NewLineChars = "\n",
            }))
            {
                Document.Save(xw);
                xw.Flush();
                xw.Close();
                res = msXml.ToArray();
            }
            return msXml;
        }
Ejemplo n.º 8
0
 static RK()
 {
     NULL = new RK();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Tests whether a string can be converted to an <see cref="IResourceKey"/> and,
 /// if so, sets <paramref name="result"/> to the converted value.
 /// </summary>
 /// <param name="value">A potential string representation of an <see cref="IResourceKey"/>.</param>
 /// <param name="result">The eqivalent <see cref="IResourceKey"/> value for <paramref name="value"/>.</param>
 /// <returns>True if <paramref name="value"/> has the format
 /// "0xHHHHHHHH-0xHHHHHHHH-0xHHHHHHHHHHHHHHHH"; otherwise false.
 /// </returns>
 public static bool TryParse(string value, out IResourceKey result)
 {
     result = new RK();
     return(AResourceKey.TryParse(value, result));
 }