Exemplo n.º 1
0
        public override ArcFile TryOpen(ArcView file)
        {
            int count = file.View.ReadInt32(0x10);

            if (!IsSaneCount(count))
            {
                return(null);
            }

            var  base_name      = Path.GetFileNameWithoutExtension(file.Name);
            uint index_offset   = 0x14;
            uint current_offset = index_offset + (uint)count * 0x28;
            var  dir            = new List <Entry> (count);

            for (int i = 0; i < count; ++i)
            {
                uint size = file.View.ReadUInt32(index_offset + 0x24);
                if (size > 0)
                {
                    var imginfo = new ImageMetaData {
                        OffsetX = file.View.ReadInt32(index_offset + 8),
                        OffsetY = file.View.ReadInt32(index_offset + 0xC),
                        Width   = file.View.ReadUInt32(index_offset + 0x10),
                        Height  = file.View.ReadUInt32(index_offset + 0x14),
                        BPP     = 32,
                    };
                    var entry = new PnaEntry {
                        Name   = string.Format("{0}#{1:D3}.tga", base_name, i),
                        Size   = size,
                        Offset = current_offset,
                        Info   = imginfo,
                    };
                    if (!entry.CheckPlacement(file.MaxOffset))
                    {
                        return(null);
                    }
                    dir.Add(entry);
                    current_offset += entry.Size;
                }
                index_offset += 0x28;
            }
            return(new ArcFile(file, this, dir));
        }
Exemplo n.º 2
0
        public override ArcFile TryOpen(ArcView file)
        {
            int count = file.View.ReadInt32 (0x10);
            if (!IsSaneCount (count))
                return null;

            var base_name = Path.GetFileNameWithoutExtension (file.Name);
            uint index_offset = 0x14;
            uint current_offset = index_offset + (uint)count*0x28;
            var dir = new List<Entry> (count);
            for (int i = 0; i < count; ++i)
            {
                uint size = file.View.ReadUInt32 (index_offset+0x24);
                if (size > 0)
                {
                    var imginfo = new ImageMetaData {
                        OffsetX = file.View.ReadInt32 (index_offset+8),
                        OffsetY = file.View.ReadInt32 (index_offset+0xC),
                        Width   = file.View.ReadUInt32 (index_offset+0x10),
                        Height  = file.View.ReadUInt32 (index_offset+0x14),
                        BPP     = 32,
                    };
                    var entry = new PnaEntry {
                        Name    = string.Format ("{0}#{1:D3}.tga", base_name, i),
                        Size    = size,
                        Offset  = current_offset,
                        Info    = imginfo,
                    };
                    if (!entry.CheckPlacement (file.MaxOffset))
                        return null;
                    dir.Add (entry);
                    current_offset += entry.Size;
                }
                index_offset += 0x28;
            }
            return new ArcFile (file, this, dir);
        }