otitemeditor.Sprite.loadSprites C# (CSharp) Méthode

loadSprites() public static méthode

public static loadSprites ( string filename, Sprite>.Dictionary &sprites, UInt32 signature ) : bool
filename string
sprites Sprite>.Dictionary
signature System.UInt32
Résultat bool
        public static bool loadSprites(string filename, ref Dictionary<UInt16, Sprite> sprites, UInt32 signature)
        {
            FileStream fileStream = new FileStream(filename, FileMode.Open);
            try
            {
                using (BinaryReader reader = new BinaryReader(fileStream))
                {
                    UInt32 sprSignature = reader.ReadUInt32();
                    if (signature != 0 && signature != sprSignature)
                    {
                        return false;
                    }

                    UInt16 totalPics = reader.ReadUInt16();

                    List<UInt32> spriteIndexes = new List<UInt32>();
                    for (uint i = 0; i < totalPics; ++i)
                    {
                        UInt32 index = reader.ReadUInt32();
                        spriteIndexes.Add(index);
                    }

                    UInt16 id = 1;
                    foreach (UInt32 element in spriteIndexes)
                    {
                        UInt32 index = element + 3;
                        reader.BaseStream.Seek(index, SeekOrigin.Begin);
                        UInt16 size = reader.ReadUInt16();

                        Sprite sprite;
                        if (sprites.TryGetValue(id, out sprite))
                        {
                            if (sprite != null && size > 0)
                            {
                                if (sprite.size > 0)
                                {
                                    //generate warning
                                }
                                else
                                {
                                    sprite.id = id;
                                    sprite.size = size;
                                    sprite.dump = reader.ReadBytes(size);

                                    sprites[id] = sprite;
                                }
                            }
                        }
                        else
                        {
                            reader.BaseStream.Seek(size, SeekOrigin.Current);
                        }

                        ++id;
                    }
                }
            }
            finally
            {
                fileStream.Close();
            }

            return true;
        }

Same methods

Sprite::loadSprites ( string filename, Sprite>.Dictionary &sprites, UInt32 signature ) : bool