using System;
using System.Collections.Generic;
using System.Text;
using Halo3Map.IO;
using System.IO;

namespace Halo3Map.BLF
{
    public abstract class blf
    {
        EndianIO inputStream;
        public EndianIO InputStream
        {
            get { return inputStream; }
        }

        #region blf layout

        public string _blf;//_blf
        public int blfHeaderSize;//0x00000030
        public short unknown1;//0x0001
        public short unknown2;//0x0002
        public short unknown3;//0xFFFE
        public short unknown4;//0x0000
        public string descriptionText;//"halo 3 saved screenshot" //32 bytes
        public BlfType blfType;
        public int dataSize;
        public int unknown6;
        public int unknown7;

        public enum BlfType : int
        {
            mapi = 0x6D617069,
            levl = 0x6C65766C,
            chdr = 0x63686472,
        }

        #endregion

        public blf(string FilePath)
        {
            inputStream = new EndianIO(FilePath, EndianType.BigEndian);
            inputStream.Open();
        }

        public virtual void Read()
        {
            //Move to the start of the file
            InputStream.In.SeekTo(0);

            //Read our layout
            _blf = new string(InputStream.In.ReadChars(4));
            blfHeaderSize = InputStream.In.ReadInt32();
            unknown1 = InputStream.In.ReadInt16();
            unknown2 = InputStream.In.ReadInt16();
            unknown3 = InputStream.In.ReadInt16();
            unknown4 = InputStream.In.ReadInt16();
            descriptionText = new string(InputStream.In.ReadChars(32));

            blfType = (BlfType)InputStream.In.ReadInt32();
            dataSize = InputStream.In.ReadInt32();
            unknown6 = InputStream.In.ReadInt32();
            unknown7 = InputStream.In.ReadInt32();
        }

    }
}