示例#1
0
        public static SDKString getHeaderString(
            int langIndex,
            int stringID,
            SDKString stringConst)
        {
            SDKString            sdkString   = stringConst;
            SDKStringActualChunk actualChunk = SDKTextUtils.s_actualChunkArray[0];

            if (stringID >= actualChunk.numStrings)
            {
                return(stringConst);
            }
            int index1 = stringID + (actualChunk.numStrings + 1) * langIndex;

            if (sdkString == null)
            {
                sdkString = new SDKString();
            }
            SDKStringStorageChunk storageChunk = SDKTextUtils.s_storageChunkArray[0];

            sbyte[] stringData   = storageChunk.stringData;
            int     stringOffset = (int)storageChunk.stringOffsetArray[index1];
            ushort  num          = (ushort)((uint)storageChunk.stringOffsetArray[index1 + 1] - (uint)stringOffset);

            char[] chArray = new char[stringData.Length];
            for (int index2 = 0; index2 < chArray.Length; ++index2)
            {
                chArray[index2] = (char)stringData[index2];
            }
            sdkString.setCharData(new string(chArray), stringOffset, (int)num, (sbyte)0);
            return(sdkString);
        }
示例#2
0
        public static SDKString getString(int stringID, SDKString stringConst)
        {
            SDKString sdkString = stringConst;
            int       index1    = -1;
            int       num1      = 0;

            for (int index2 = 0; index2 != (int)SDKTextUtils.s_numActualChunks; ++index2)
            {
                num1 += SDKTextUtils.s_actualChunkArray[index2].numStrings;
                if (stringID < num1)
                {
                    index1 = index2;
                    break;
                }
            }
            SDKStringActualChunk actualChunk = SDKTextUtils.s_actualChunkArray[index1];
            int index3 = stringID - (num1 - actualChunk.numStrings);
            int group  = (int)actualChunk.group;
            SDKStringStorageChunk storageChunk = SDKTextUtils.s_storageChunkArray[group];

            if (sdkString == null)
            {
                sdkString = new SDKString();
            }
            char[] chArray = new char[storageChunk.stringData.Length];
            for (int index2 = 0; index2 < chArray.Length; ++index2)
            {
                chArray[index2] = (char)storageChunk.stringData[index2];
            }
            string data         = new string(chArray);
            int    stringOffset = (int)storageChunk.stringOffsetArray[index3];
            ushort num2         = (ushort)((uint)storageChunk.stringOffsetArray[index3 + 1] - (uint)stringOffset);
            sbyte  encoding     = (sbyte)SDKTextUtils.s_currentLanguage.encoding;

            if (((int)actualChunk.flags & 192) != 0)
            {
                encoding = (sbyte)0;
            }
            sdkString.setCharData(data, stringOffset, (int)num2, encoding);
            return(sdkString);
        }
示例#3
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);
        }
示例#4
0
        public static void loadStringsChunk(int chunkID)
        {
            if (SDKTextUtils.isLoadedStringsChunk(chunkID) && !SDKTextUtils.s_forceChunkLoad)
            {
                return;
            }
            SDKStringActualChunk actualChunk1 = SDKTextUtils.s_actualChunkArray[chunkID];
            int         index1 = ((int)actualChunk1.flags & 64) == 0 ? (int)SDKTextUtils.s_langIndex : 0;
            string      str1   = "";
            InputStream resourceAsStream;

            switch (SDKTextUtils.s_chunkConfig)
            {
            case 0:
                string str2          = str1 + "t_";
                string sourcestring1 = new string(new char[6]);
                int    index2        = -1;
                sbyte  num1;
                do
                {
                    ++index2;
                    num1          = index2 != 5 ? SDKTextUtils.s_languageArray[index1].isoCodeArray[index2] : (sbyte)32;
                    sourcestring1 = StringFunctions.ChangeCharacter(sourcestring1, index2, (char)num1);
                }while (num1 != (sbyte)32);
                string str3 = sourcestring1.Substring(0, index2);
                resourceAsStream = JavaLib.getResourceAsStream(str2 + str3, false);
                ushort[] chunkSizeArray = SDKTextUtils.s_languageArray[index1].chunkSizeArray;
                for (int index3 = 1; index3 != chunkID; ++index3)
                {
                    SDKStringActualChunk actualChunk2 = SDKTextUtils.s_actualChunkArray[index3];
                    if (((int)actualChunk2.flags & 64) == 0 || index1 == 0)
                    {
                        resourceAsStream.skip((long)((actualChunk2.numStrings + 1 << 1) + (int)chunkSizeArray[index3]));
                    }
                }
                break;

            case 1:
                string str4          = str1 + "t_";
                string sourcestring2 = new string(new char[6]);
                int    charindex     = -1;
                sbyte  num2;
                do
                {
                    ++charindex;
                    num2          = charindex != 5 ? SDKTextUtils.s_languageArray[index1].isoCodeArray[charindex] : (sbyte)32;
                    sourcestring2 = StringFunctions.ChangeCharacter(sourcestring2, charindex, (char)num2);
                }while (num2 != (sbyte)32);
                string str5 = StringFunctions.ChangeCharacter(sourcestring2, charindex, char.MinValue);
                resourceAsStream = JavaLib.getResourceAsStream(str4 + str5 + (object)chunkID, false);
                break;

            default:
                return;
            }
            DataInputStream       dataInputStream = new DataInputStream(resourceAsStream);
            int                   num3            = actualChunk1.numStrings + 1;
            int                   group1          = (int)actualChunk1.group;
            SDKStringGroup        group2          = SDKTextUtils.s_groupArray[group1];
            SDKStringStorageChunk storageChunk    = SDKTextUtils.s_storageChunkArray[group1];

            if (storageChunk.stringOffsetArray == null)
            {
                storageChunk.stringOffsetArray = new ushort[(int)group2.maxNumOffsets];
            }
            for (int index3 = 0; index3 != num3; ++index3)
            {
                storageChunk.stringOffsetArray[index3] = (ushort)dataInputStream.readShort();
            }
            if (storageChunk.stringData == null)
            {
                storageChunk.stringData = new sbyte[(int)group2.maxSize];
            }
            dataInputStream.readFully(storageChunk.stringData, (int)SDKTextUtils.s_languageArray[index1].chunkSizeArray[chunkID]);
            group2.map = (sbyte)chunkID;
            dataInputStream.close();
        }