示例#1
0
        public static bool setCurrentLanguage(int index)
        {
            sbyte langIndex = SDKTextUtils.s_langIndex;

            if (SDKTextUtils.s_languageArray != null && index >= 0 && index < (int)SDKTextUtils.s_numLangs)
            {
                SDKTextUtils.s_langIndex       = (sbyte)index;
                SDKTextUtils.s_currentLanguage = SDKTextUtils.s_languageArray[index];
            }
            if ((int)SDKTextUtils.s_langIndex != (int)langIndex)
            {
                SDKTextUtils.s_forceChunkLoad = true;
                for (int chunkID = 1; chunkID != (int)SDKTextUtils.s_numActualChunks; ++chunkID)
                {
                    if (SDKTextUtils.isLoadedStringsChunk(chunkID) && ((int)SDKTextUtils.s_actualChunkArray[chunkID].flags & 64) == 0)
                    {
                        SDKTextUtils.loadStringsChunk(chunkID);
                    }
                }
                SDKTextUtils.s_forceChunkLoad = false;
                sbyte encoding1 = (sbyte)SDKTextUtils.s_languageArray[(int)langIndex].encoding;
                sbyte encoding2 = (sbyte)SDKTextUtils.s_languageArray[index].encoding;
                if ((int)encoding1 != (int)encoding2 && encoding2 > (sbyte)1)
                {
                    SDKTextUtils.loadCharMap(encoding2);
                }
            }
            return((int)SDKTextUtils.s_langIndex != index);
        }
示例#2
0
        public static int loadTextHeader(sbyte[] textHeader)
        {
            DataInputStream dataInputStream = new DataInputStream((InputStream) new ByteArrayInputStream(textHeader, 1024));
            int             num1            = (int)dataInputStream.readByte();

            SDKTextUtils.s_chunkConfig   = dataInputStream.readByte();
            SDKTextUtils.s_textEncodings = (uint)((int)dataInputStream.readByte() << 16 | (int)dataInputStream.readByte() << 8) | (uint)dataInputStream.readByte();
            int num2 = (int)dataInputStream.readShort();

            SDKTextUtils.s_numLangs = dataInputStream.readByte();
            sbyte num3 = dataInputStream.readByte();
            sbyte num4 = dataInputStream.readByte();

            SDKTextUtils.s_numStorageChunks = (sbyte)((int)num3 + 1);
            SDKTextUtils.s_numActualChunks  = (sbyte)((int)num4 + 1);
            SDKTextUtils.s_languageArray    = new SDKStringLanguage[(int)SDKTextUtils.s_numLangs];
            SDKTextUtils.s_groupArray       = new SDKStringGroup[(int)SDKTextUtils.s_numActualChunks];
            SDKTextUtils.s_actualChunkArray = new SDKStringActualChunk[(int)SDKTextUtils.s_numActualChunks];
            for (int index = 0; index < (int)SDKTextUtils.s_numActualChunks; ++index)
            {
                SDKTextUtils.s_groupArray[index]       = new SDKStringGroup();
                SDKTextUtils.s_actualChunkArray[index] = new SDKStringActualChunk();
            }
            SDKTextUtils.s_storageChunkArray = new SDKStringStorageChunk[(int)SDKTextUtils.s_numStorageChunks];
            for (int index = 0; index < (int)SDKTextUtils.s_numStorageChunks; ++index)
            {
                SDKTextUtils.s_storageChunkArray[index] = new SDKStringStorageChunk();
            }
            SDKStringActualChunk  actualChunk1 = SDKTextUtils.s_actualChunkArray[0];
            SDKStringStorageChunk storageChunk = SDKTextUtils.s_storageChunkArray[0];

            actualChunk1.numStrings = num2;
            actualChunk1.flags      = sbyte.MinValue;
            actualChunk1.group      = (sbyte)0;
            for (int index = 0; index != (int)SDKTextUtils.s_numLangs; ++index)
            {
                SDKTextUtils.s_languageArray[index] = new SDKStringLanguage();
                SDKTextUtils.s_languageArray[index].chunkSizeArray = new ushort[(int)SDKTextUtils.s_numActualChunks];
            }
            int num5 = num2 + 1;

            for (int index1 = 0; index1 != (int)SDKTextUtils.s_numLangs; ++index1)
            {
                SDKStringLanguage language = SDKTextUtils.s_languageArray[index1];
                language.isoCodeArray = new sbyte[5];
                for (int index2 = 0; index2 != 5; ++index2)
                {
                    language.isoCodeArray[index2] = dataInputStream.readByte();
                }
                language.encoding           = (int)dataInputStream.readByte();
                language.fontDifferentiator = dataInputStream.readByte();
                if (num2 > 0)
                {
                    if (storageChunk.stringOffsetArray == null)
                    {
                        storageChunk.stringOffsetArray = new ushort[(int)SDKTextUtils.s_numLangs * num5];
                    }
                    for (int index2 = 0; index2 != num5; ++index2)
                    {
                        storageChunk.stringOffsetArray[index1 * num5 + index2] = (ushort)dataInputStream.readShort();
                    }
                }
            }
            if (num2 > 0)
            {
                int stringOffset = (int)storageChunk.stringOffsetArray[(int)SDKTextUtils.s_numLangs * num5 - 1];
                storageChunk.stringData = new sbyte[stringOffset];
                dataInputStream.readFully(storageChunk.stringData, stringOffset);
            }
            for (int index1 = 1; index1 != (int)SDKTextUtils.s_numActualChunks; ++index1)
            {
                SDKStringActualChunk actualChunk2 = SDKTextUtils.s_actualChunkArray[index1];
                int num6 = (int)dataInputStream.readByte();
                actualChunk2.flags      = (sbyte)(num6 & 192);
                actualChunk2.group      = (sbyte)(num6 & 63);
                actualChunk2.numStrings = (int)dataInputStream.readShort();
                SDKStringGroup group = SDKTextUtils.s_groupArray[(int)actualChunk2.group];
                ushort         num7  = (ushort)(actualChunk2.numStrings + 1);
                if ((int)num7 > (int)group.maxNumOffsets)
                {
                    group.maxNumOffsets = num7;
                }
                for (int index2 = 0; index2 != (int)SDKTextUtils.s_numLangs; ++index2)
                {
                    int num8 = dataInputStream.readUnsignedShort();
                    SDKTextUtils.s_languageArray[index2].chunkSizeArray[index1] = (ushort)num8;
                    if (num8 > (int)group.maxSize)
                    {
                        group.maxSize = (ushort)num8;
                    }
                }
            }
            SDKTextUtils.s_currentLanguage = SDKTextUtils.s_languageArray[(int)SDKTextUtils.s_langIndex];
            if (SDKTextUtils.s_currentLanguage.encoding > 1)
            {
                SDKTextUtils.loadCharMap((sbyte)SDKTextUtils.s_currentLanguage.encoding);
            }
            SDKTextUtils.s_hdrLoaded = true;
            dataInputStream.close();
            return((int)SDKTextUtils.s_numLangs);
        }