Example #1
0
        // ---- PROPERTIES ---------------------------------------------------------------------------------------------

        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            Name       = loader.LoadString();
            Index      = loader.ReadInt32();
            Offset     = loader.ReadUInt16();
            BlockIndex = loader.ReadByte();
            byte padding = loader.ReadByte();
        }
 private Node ReadNode(BfshaFileLoader loader)
 {
     return(new Node()
     {
         Reference = loader.ReadUInt32(),
         IdxLeft = loader.ReadUInt16(),
         IdxRight = loader.ReadUInt16(),
         Key = loader.LoadString(),
     });
 }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            Name = loader.LoadString();
            long   DataOffset = loader.ReadOffset();
            ushort count      = loader.ReadUInt16();

            Type = loader.ReadEnum <UserDataType>(true);

            //      UserDataData = loader.LoadCustom(() => loader.Load<UserDataData>(Type, count), DataOffset);
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            loader.CheckSignature(_signature); //Same binary header as BNSH, BFRES, ETC
            uint padding = loader.ReadUInt32();

            VersionMajor      = loader.ReadInt16();
            VersionMinor      = loader.ReadByte();
            VersionMicro      = loader.ReadByte();
            ByteOrder         = loader.ReadEnum <ByteOrder>(false);
            Alignment         = loader.ReadByte();
            TargetAddressSize = loader.ReadByte();                  //Thanks MasterF0X for pointing out the layout of the these
            uint OffsetToFileName      = loader.ReadUInt32();
            uint OffsetPath            = loader.ReadUInt32();
            uint RelocationTableOffset = loader.ReadUInt32();
            uint sizFile              = loader.ReadUInt32();
            long shaderArchiveOffset  = loader.ReadOffset();
            long StringPoolOffset     = loader.ReadOffset();
            long ShaderingModelOffset = loader.ReadOffset();

            Name = loader.LoadString();
            Path = loader.LoadString();
            long ShaderModelArrayOffset = loader.ReadOffset();

            ShaderModelDict = loader.LoadDict();
            var padding2 = loader.ReadUInt64();
            var unk1     = loader.ReadUInt64();
            var unk2     = loader.ReadUInt64();

            ushort ModelCount = loader.ReadUInt16();
            ushort flag       = loader.ReadUInt16();

            loader.ReadUInt16();
            if (VersionMinor >= 7) //padding
            {
                loader.ReadUInt16();
            }

            ShaderModels = loader.LoadList <ShaderModel>(ModelCount, ShaderModelArrayOffset);
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            Name       = loader.LoadString();
            ChoiceDict = loader.LoadDict();
            long ChoiceValuesOffset = loader.ReadOffset();
            byte choiceCount        = loader.ReadByte();

            DefaultIndex = loader.ReadByte();   //Index to default choice value
            BlockOffset  = loader.ReadUInt16(); // Uniform block offset.
            flag         = loader.ReadByte();
            keyOffset    = loader.ReadByte();   //Offset for key table
            flags0       = loader.ReadByte();   //Flags for choices
            flags1       = loader.ReadByte();
            flags2       = loader.ReadUInt32();
            uint padding = loader.ReadUInt32();

            Choices = loader.LoadCustom(() => loader.ReadUInt32s(choiceCount), ChoiceValuesOffset);
        }
Example #6
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            Name = loader.LoadString();
        }
Example #7
0
        void IResData.Load(BfshaFileLoader loader)
        {
            Name = loader.LoadString();
            long staticOptionArrayOffset = loader.ReadOffset();

            StaticOptionDict = loader.LoadDict();
            long dynamicOptionArrayOffset = loader.ReadOffset();

            DynamiOptionDict = loader.LoadDict();
            long attribArrayOffset = loader.ReadOffset();

            AttributeDict = loader.LoadDict();
            long samplerArrayOffset = loader.ReadOffset();

            SamplersDict = loader.LoadDict();

            if (loader.BfshaFile.VersionMinor >= 8)
            {
                loader.ReadInt64();
                loader.ReadInt64();
            }

            long uniformBlockArrayOffset = loader.ReadOffset();

            UniformBlockDict = loader.LoadDict();
            long uniformArrayOffset = loader.ReadOffset();

            if (loader.BfshaFile.VersionMinor >= 7)
            {
                loader.ReadInt64();
                loader.ReadInt64();
                loader.ReadInt64();
            }

            long shaderProgramArrayOffset = loader.ReadOffset();
            long tableOffset         = loader.ReadOffset();
            long shaderArchiveOffset = loader.ReadOffset();
            long shaderInfoOffset    = loader.ReadOffset();
            long shaderFileOffset    = loader.ReadOffset();

            loader.ReadUInt64();

            if (loader.BfshaFile.VersionMinor >= 7)
            {
                //padding
                loader.ReadInt64();
                loader.ReadInt64();
            }

            loader.ReadUInt64();
            loader.ReadUInt64();

            uint uniformCount = loader.ReadUInt32();

            if (loader.BfshaFile.VersionMinor <= 7)
            {
                loader.ReadUInt32();
            }
            int    defaultProgramIndex = loader.ReadInt32();
            ushort staticOptionCount   = loader.ReadUInt16();
            ushort dynamicOptionCount  = loader.ReadUInt16();
            ushort shaderProgramCount  = loader.ReadUInt16();
            byte   staticKeyLength     = loader.ReadByte();
            byte   dynamicKeyLength    = loader.ReadByte();
            byte   attribCount         = loader.ReadByte();
            byte   samplerCount        = loader.ReadByte();

            if (loader.BfshaFile.VersionMinor >= 8)
            {
                byte imageCount = loader.ReadByte();
            }

            byte uniformBlockCount = loader.ReadByte();

            loader.ReadBytes(5);

            if (loader.BfshaFile.VersionMinor >= 7)
            {
                loader.ReadBytes(6);
            }

            System.Console.WriteLine($"shaderFileOffset " + shaderFileOffset);
            System.Console.WriteLine($"Sampler " + samplerCount);
            System.Console.WriteLine($"attribCount " + attribCount);
            System.Console.WriteLine($"dynamicOptionCount " + dynamicOptionCount);
            System.Console.WriteLine($"staticOptionArrayOffset " + staticOptionArrayOffset);
            System.Console.WriteLine($"staticOptionCount " + staticOptionCount);

            if (loader.BfshaFile.VersionMinor >= 8)
            {
                loader.ReadBytes(7);
            }
            if (loader.BfshaFile.VersionMinor < 7)
            {
                loader.ReadBytes(4);
            }

            System.Console.WriteLine($"end pos " + loader.Position);

            int BnshSize = 0;

            if (shaderFileOffset != 0)
            {
                //Go into the bnsh file and get the file size
                using (loader.TemporarySeek(shaderFileOffset + 0x1C, System.IO.SeekOrigin.Begin))
                {
                    BnshSize = (int)loader.ReadUInt32();
                }
            }

            byte[] BinaryShaderData = loader.LoadCustom(() => loader.ReadBytes(BnshSize), shaderFileOffset);
            BnshFile = new BnshFile(new System.IO.MemoryStream(BinaryShaderData));

            StaticOptions = loader.LoadList <ShaderOption>(staticOptionCount, staticOptionArrayOffset);
            DynamiOptions = loader.LoadList <ShaderOption>(dynamicOptionCount, dynamicOptionArrayOffset);
            Attributes    = loader.LoadList <Attribute>(attribCount, attribArrayOffset);
            Samplers      = loader.LoadList <Sampler>(samplerCount, samplerArrayOffset);
            UniformBlocks = loader.LoadList <UniformBlock>(uniformBlockCount, uniformBlockArrayOffset);
            UniformVars   = loader.LoadList <UniformVar>((int)uniformCount, uniformArrayOffset);
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(BfshaFileLoader loader)
        {
            Extra = loader.LoadString();
            Index = loader.ReadByte();
            loader.Seek(7);
        }