Ejemplo n.º 1
0
        public static ScriptTable CreateFrom(BinaryReader reader, long beginAt)
        {
            reader.BaseStream.Seek(beginAt, SeekOrigin.Begin);
            //---------------
            //Script table
            //Type          Name                          Description
            //Offset16      defaultLangSys                Offset to DefaultLangSys table-from beginning of Script table-may be NULL
            //uint16        langSysCount                  Number of LangSysRecords for this script-excluding the DefaultLangSys
            //LangSysRecord langSysRecords[langSysCount]  Array of LangSysRecords-listed alphabetically by LangSysTag

            //---------------
            ScriptTable scriptTable          = new ScriptTable();
            ushort      defaultLangSysOffset = reader.ReadUInt16();
            ushort      langSysCount         = reader.ReadUInt16();

            LangSysTable[] langSysTables = scriptTable.langSysTables = new LangSysTable[langSysCount];
            for (int i = 0; i < langSysCount; ++i)
            {
                //-----------------------
                //LangSysRecord
                //Type      Name            Description
                //Tag       langSysTag      4-byte LangSysTag identifier
                //Offset16  langSysOffset   Offset to LangSys table-from beginning of Script table
                //-----------------------

                langSysTables[i] = new LangSysTable(
                    reader.ReadUInt32(),  //	4-byte LangSysTag identifier
                    reader.ReadUInt16()); //offset
            }

            //-----------
            if (defaultLangSysOffset > 0)
            {
                scriptTable.defaultLang = new LangSysTable(0, defaultLangSysOffset);
                reader.BaseStream.Seek(beginAt + defaultLangSysOffset, SeekOrigin.Begin);
                scriptTable.defaultLang.ReadFrom(reader);
            }


            //-----------
            //read actual content of each table
            for (int i = 0; i < langSysCount; ++i)
            {
                LangSysTable langSysTable = langSysTables[i];
                reader.BaseStream.Seek(beginAt + langSysTable.offset, SeekOrigin.Begin);
                langSysTable.ReadFrom(reader);
            }

            return(scriptTable);
        }
Ejemplo n.º 2
0
        public static ScriptTable CreateFrom(BinaryReader reader, long beginAt)
        {
            reader.BaseStream.Seek(beginAt, SeekOrigin.Begin);
            //
            //
            ScriptTable scriptTable          = new ScriptTable();
            short       defaultLangSysOffset = reader.ReadInt16();
            //

            ushort langSysCount = reader.ReadUInt16();

            LangSysTable[] langSysTables = scriptTable.langSysTables = new LangSysTable[langSysCount];
            for (int i = 0; i < langSysCount; ++i)
            {
                langSysTables[i] = new LangSysTable(
                    reader.ReadUInt32(), //langSysTagIdentifier
                    reader.ReadInt16()); //offset
            }

            //-----------
            if (defaultLangSysOffset > 0)
            {
                scriptTable.defaultLang = new LangSysTable(0, defaultLangSysOffset);
                reader.BaseStream.Seek(beginAt + defaultLangSysOffset, SeekOrigin.Begin);
                scriptTable.defaultLang.ReadFrom(reader);
            }


            //-----------
            //read actual content of each table
            for (int i = 0; i < langSysCount; ++i)
            {
                LangSysTable langSysTable = langSysTables[i];
                reader.BaseStream.Seek(beginAt + langSysTable.offset, SeekOrigin.Begin);
                langSysTable.ReadFrom(reader);
            }

            return(scriptTable);
        }