Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public SDKString concat(string str)
        {
            SDKString str1      = new SDKString(str);
            SDKString sdkString = this.concat(str1);

            str1.Dispose();
            return(sdkString);
        }
Ejemplo n.º 3
0
 public static short[] wrapString(
     SDKString _string,
     short[] offsets,
     int wrapLimit,
     short newline)
 {
     return(SDKTextUtils.wrapSubString(_string, 0, _string.Length(), offsets, wrapLimit, newline));
 }
Ejemplo n.º 4
0
        public SDKString concat(int integer)
        {
            SDKString str       = new SDKString(integer);
            SDKString sdkString = this.concat(str);

            str.Dispose();
            return(sdkString);
        }
Ejemplo n.º 5
0
 public static void drawString(
     SDKString _string,
     int x,
     int y,
     int anchor,
     SDKTextUtils.DrawRegionRoutineDelegate DrawRegionRoutine)
 {
     SDKTextUtils.drawSubString(_string, 0, _string.Length(), x, y, anchor, DrawRegionRoutine);
 }
Ejemplo n.º 6
0
 public SDKString append(SDKString str)
 {
     if (!this.m_mutable)
     {
         return(this);
     }
     JMath.min((int)this.m_capacity - (int)this.m_length, (int)str.m_length);
     this.m_length += (ushort)str.Length();
     this.m_data   += str.m_data;
     return(this);
 }
Ejemplo n.º 7
0
        public static int getSubStringSize(SDKString _string, int offset, int len)
        {
            int num      = 0;
            int encoding = _string.getEncoding();

            for (int index = offset; index < offset + len; ++index)
            {
                num += SDKTextUtils.s_currentFont.getCharAdvance(SDKTextUtils.getCharOffset(_string.charCodeAt(index), encoding));
            }
            return(num);
        }
Ejemplo n.º 8
0
        public SDKString replaceFirst(int integer)
        {
            SDKString[] repl = new SDKString[1]
            {
                new SDKString(integer)
            };
            SDKString sdkString = this.replace(repl);

            repl[0].Dispose();
            return(sdkString);
        }
Ejemplo n.º 9
0
        private static int copyStringData(
            SDKString srcString,
            int srcOffset,
            SDKString dstString,
            int dstOffset,
            int numChars)
        {
            int numChars1 = JMath.min(numChars, JMath.min((int)srcString.m_length - srcOffset, (int)dstString.m_capacity - dstOffset));

            return(SDKString.copyCharArray(srcString.m_data, srcString.m_offset + srcOffset, (int)srcString.m_encoding, dstString.m_data, dstString.m_offset + dstOffset, (int)dstString.m_encoding, numChars1));
        }
Ejemplo n.º 10
0
        public int compareTo(SDKString str)
        {
            int num = JMath.min((int)this.m_length, (int)str.m_length);

            for (int index = 0; index != num; ++index)
            {
                if ((int)this.charCodeAt(index) != (int)str.charCodeAt(index))
                {
                    return((int)this.charCodeAt(index) - (int)str.charCodeAt(index));
                }
            }
            return((int)this.m_length - (int)str.m_length);
        }
Ejemplo n.º 11
0
        public SDKString concat(SDKString str)
        {
            sbyte     encoding1 = (sbyte)this.getEncoding();
            sbyte     encoding2 = (sbyte)str.getEncoding();
            SDKString dstString = new SDKString();

            dstString.m_encoding = (int)encoding1 == (int)encoding2 || encoding2 == (sbyte)1 ? encoding1 : (sbyte)0;
            dstString.allocNewData((int)this.m_length + (int)str.m_length);
            int dstOffset = SDKString.copyStringData(this, 0, dstString, 0, (int)this.m_length);

            SDKString.copyStringData(str, 0, dstString, dstOffset, (int)str.m_length);
            return(dstString);
        }
Ejemplo n.º 12
0
        public static SDKStringIM getHeaderString(
            int langIndex,
            int stringID,
            ref SDKStringIM _string)
        {
            bool      flag         = _string.getEAString() == null;
            SDKString headerString = SDKTextUtils.getHeaderString(langIndex, stringID, _string.getEAString());

            if (flag)
            {
                _string.setEAString(headerString);
            }
            return(_string);
        }
Ejemplo n.º 13
0
        public static SDKStringIM getString(int stringID, ref SDKStringIM _string)
        {
            if (_string == null)
            {
                _string = new SDKStringIM();
            }
            bool      flag     = _string.getEAString() == null;
            SDKString eaString = SDKTextUtils.getString(stringID, _string.getEAString());

            if (flag)
            {
                _string.setEAString(eaString);
            }
            return(_string);
        }
Ejemplo n.º 14
0
        public int indexOf(SDKString str, int fromIndex)
        {
            int num = str.Length();

            for (int index1 = fromIndex; index1 != (int)this.m_length - (num - 1); ++index1)
            {
                for (int index2 = 0; index2 != num && (int)this.charCodeAt(index1 + index2) == (int)str.charCodeAt(index2); ++index2)
                {
                    if (index2 != num - 1)
                    {
                        return(index1);
                    }
                }
            }
            return(-1);
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        public SDKString substring(int startIndex, int endIndex)
        {
            SDKString sdkString = new SDKString();

            sdkString.m_encoding = this.m_encoding;
            sdkString.allocNewData(endIndex - startIndex);
            int    num1 = this.bytesPerChar();
            string data = sdkString.m_data;
            int    num2 = (this.m_offset + startIndex) * num1;
            int    num3 = (this.m_offset + endIndex) * num1;
            int    num4 = 0;

            char[] charArray = data.ToCharArray();
            for (int index = num2; index != num3; ++index)
            {
                charArray[num4++] = this.m_data[index];
            }
            string str = new string(charArray);

            return(sdkString);
        }
Ejemplo n.º 17
0
 private int bytesPerChar()
 {
     return(SDKString.bytesPerChar((int)this.m_encoding));
 }
Ejemplo n.º 18
0
        public static void drawWrappedString(
            SDKString _string,
            short[] offsets,
            int startLine,
            int lineCount,
            int xConst,
            int yConst,
            int anchorConst,
            SDKTextUtils.DrawRegionRoutineDelegate DrawRegionRoutine)
        {
            int xConst1  = xConst;
            int yConst1  = yConst;
            int anchor   = anchorConst;
            int lineSize = SDKTextUtils.getLineSize();
            int num1     = 0;
            int num2     = 0;
            int num3     = 0;

            if ((anchor & 2) != 0)
            {
                num3 = (int)offsets[0] * lineSize - SDKTextUtils.s_currentFont.getLeading() >> 1;
            }
            else if ((anchor & 4) != 0)
            {
                num3    = (int)offsets[0] * lineSize - SDKTextUtils.s_currentFont.getLeading();
                anchor ^= 4;
            }
            switch (SDKTextUtils.s_currentFont.m_transLineDirection)
            {
            case 1:
                xConst1 -= num3;
                num1     = lineSize;
                break;

            case 2:
                yConst1 -= num3;
                num2     = lineSize;
                break;

            case 4:
                xConst1 += num3;
                num1     = -lineSize;
                break;

            default:
                yConst1 += num3;
                num2     = -lineSize;
                break;
            }
            int offset1 = (int)offsets[(int)offsets[0] + 2];

            for (int index = startLine; index < startLine + lineCount; ++index)
            {
                int offset2 = (int)offsets[index];
                int len     = (int)offsets[index + 1] - offset2;
                int num4    = (int)_string.charCodeAt((int)offsets[index + 1] - 1);
                if (num4 == offset1 || num4 == 32)
                {
                    --len;
                }
                SDKTextUtils.drawSubString(_string, offset2, len, xConst1, yConst1, anchor, DrawRegionRoutine);
                xConst1 += num1;
                yConst1 += num2;
            }
        }
Ejemplo n.º 19
0
        public static short[] wrapSubString(
            SDKString _string,
            int offset,
            int len,
            short[] offsetsConst,
            int wrapLimit,
            short newline)
        {
            short[] numArray1 = offsetsConst;
            bool    flag      = false;

            if (numArray1 == null)
            {
                if (SDKTextUtils.s_wrapOffsets == null)
                {
                    SDKTextUtils.s_wrapOffsets = new short[50];
                }
                numArray1 = SDKTextUtils.s_wrapOffsets;
                flag      = true;
            }
            int encoding = _string.getEncoding();
            int num1     = 0;
            int num2     = 0;
            int num3     = -1;

            numArray1[1] = (short)offset;
            int index1 = 2;

            for (int index2 = offset; index2 != len + offset; ++index2)
            {
                ushort code = _string.charCodeAt(index2);
                if (flag && index1 + 3 >= SDKTextUtils.s_wrapOffsets.Length)
                {
                    short[] wrapOffsets = SDKTextUtils.s_wrapOffsets;
                    SDKTextUtils.s_wrapOffsets = new short[SDKTextUtils.s_wrapOffsets.Length + 50];
                    for (int index3 = 0; index3 != wrapOffsets.Length; ++index3)
                    {
                        SDKTextUtils.s_wrapOffsets[index3] = wrapOffsets[index3];
                    }
                    numArray1 = SDKTextUtils.s_wrapOffsets;
                }
                if ((int)code == (int)newline)
                {
                    numArray1[index1++] = (short)(index2 + 1);
                    num1 = 0;
                    num2 = 0;
                    num3 = -1;
                }
                else
                {
                    ushort charOffset  = SDKTextUtils.getCharOffset(code, encoding);
                    int    charAdvance = SDKTextUtils.s_currentFont.getCharAdvance(charOffset);
                    num1 += charAdvance;
                    num2 += charAdvance;
                    if (num1 > wrapLimit)
                    {
                        if (num3 == -1)
                        {
                            numArray1[index1++] = (short)index2;
                            num1 = charAdvance;
                            num2 = 0;
                        }
                        else
                        {
                            numArray1[index1++] = (short)(num3 + 1);
                            num3 = code == (ushort)32 || code == (ushort)173 ? index2 : -1;
                            num1 = num2;
                            num2 = 0;
                        }
                    }
                    else if (code == (ushort)32 || code == (ushort)173)
                    {
                        num3 = index2;
                        num2 = 0;
                    }
                }
            }
            numArray1[0]          = (short)(index1 - 1);
            numArray1[index1]     = (short)(len + offset);
            numArray1[index1 + 1] = newline;
            if (flag)
            {
                short[] numArray2 = new short[index1 + 2];
                for (int index2 = 0; index2 != index1 + 2; ++index2)
                {
                    numArray2[index2] = numArray1[index2];
                }
                numArray1 = numArray2;
            }
            return(numArray1);
        }
Ejemplo n.º 20
0
 public static int getStringSize(SDKString _string)
 {
     return(SDKTextUtils.getSubStringSize(_string, 0, _string.Length()));
 }
Ejemplo n.º 21
0
 public SDKString replaceFirst(SDKString str)
 {
     return(this.replace(new SDKString[1] {
         str
     }));
 }
Ejemplo n.º 22
0
        public SDKString replace(SDKString[] repl)
        {
            SDKString dstString = new SDKString();

            dstString.m_encoding = (sbyte)this.getEncoding();
            dstString.m_offset   = 0;
            int num1 = 0;

            for (int index1 = 0; index1 != (int)this.m_length; ++index1)
            {
                if (this.charCodeAt(index1) == (ushort)92)
                {
                    ++index1;
                    if (index1 < (int)this.m_length)
                    {
                        short num2 = (short)this.charCodeAt(index1);
                        if (num2 == (short)92)
                        {
                            --num1;
                        }
                        else if (num2 >= (short)48 && num2 <= (short)90)
                        {
                            int index2 = (int)num2 - 48;
                            if (repl[index2].getEncoding() != dstString.getEncoding())
                            {
                                dstString.m_encoding = (sbyte)0;
                            }
                            num1 += repl[index2].Length() - 2;
                        }
                    }
                }
            }
            dstString.allocNewData((int)this.m_length + num1);
            int srcOffset = 0;
            int dstOffset = 0;

            for (int index1 = 0; index1 != (int)this.m_length; ++index1)
            {
                if (this.charCodeAt(index1) == (ushort)92)
                {
                    dstOffset += SDKString.copyStringData(this, srcOffset, dstString, dstOffset, index1 - srcOffset);
                    srcOffset  = index1++;
                    if (index1 < (int)this.m_length)
                    {
                        short num2 = (short)this.charCodeAt(index1);
                        if (num2 == (short)92)
                        {
                            srcOffset = index1;
                        }
                        else if (num2 >= (short)48 && num2 <= (short)90)
                        {
                            int       index2    = (int)num2 - 48;
                            SDKString srcString = repl[index2];
                            dstOffset += SDKString.copyStringData(srcString, 0, dstString, dstOffset, (int)srcString.m_length);
                            srcOffset  = index1 + 1;
                        }
                    }
                }
            }
            SDKString.copyStringData(this, srcOffset, dstString, dstOffset, (int)this.m_length - srcOffset);
            return(dstString);
        }
Ejemplo n.º 23
0
        public static void drawSubString(
            SDKString _string,
            int offset,
            int len,
            int xConst,
            int yConst,
            int anchor,
            SDKTextUtils.DrawRegionRoutineDelegate DrawRegionRoutine)
        {
            int num1 = xConst;
            int num2 = yConst;

            if (SDKTextUtils.s_currentFont == null)
            {
                return;
            }
            object fontImage = SDKTextUtils.s_currentFont.getFontImage();
            int    ascent    = SDKTextUtils.s_currentFont.getAscent();
            int    lineSize  = SDKTextUtils.s_currentFont.getLineSize();
            int    textDir   = SDKTextUtils.s_currentFont.getTextDir();
            int    lineDir   = SDKTextUtils.s_currentFont.getLineDir();

            if (SDKTextUtils.s_currentFont.m_charData == null)
            {
                return;
            }
            int num3 = 0;
            int num4 = 0;

            if ((anchor & 32) != 0)
            {
                num3 -= SDKTextUtils.getSubStringSize(_string, offset, len);
            }
            else if ((anchor & 16) != 0)
            {
                num3 -= SDKTextUtils.getSubStringSize(_string, offset, len) >> 1;
            }
            if ((anchor & 64) != 0)
            {
                num4 -= ascent;
            }
            else if ((anchor & 4) != 0)
            {
                num4 -= lineSize;
            }
            switch (textDir)
            {
            case 1:
                num1 += num3;
                num2 += num4;
                break;

            case 2:
                num1 -= num4;
                num2 += num3;
                break;

            case 4:
                num1 -= num3;
                num2 -= num4;
                break;

            case 8:
                num1 -= num4;
                num2 -= num3;
                break;
            }
            int[] p = new int[2] {
                num1, num2
            };
            int encoding = _string.getEncoding();

            switch (encoding)
            {
            case 0:
            case 1:
                bool  flag1 = (textDir & 5) != 0;
                sbyte num5  = (sbyte)((textDir & 4) >> 1);
                sbyte num6  = (sbyte)(((lineDir & 1) << 1) + ((~lineDir & 2) >> 1));
                sbyte num7  = flag1 ? num5 : num6;
                bool  flag2 = (textDir & 10) != 0;
                sbyte num8  = (sbyte)((textDir & 8) >> 2);
                sbyte num9  = (sbyte)((lineDir & 2) + (~lineDir & 1));
                sbyte num10 = flag2 ? num8 : num9;
                for (int index1 = offset; index1 != offset + len; ++index1)
                {
                    ushort code = _string.charCodeAt(index1);
                    if (code != (ushort)173 || index1 == offset + len - 1)
                    {
                        ushort charOffset  = SDKTextUtils.getCharOffset(code, encoding);
                        int    charAdvance = SDKTextUtils.s_currentFont.getCharAdvance(charOffset);
                        if (charOffset == ushort.MaxValue)
                        {
                            if (code == (ushort)32)
                            {
                                ;
                            }
                        }
                        else
                        {
                            ushort  num11      = (ushort)((uint)charOffset + 1U);
                            sbyte[] mCharData1 = SDKTextUtils.s_currentFont.m_charData;
                            int     index2     = (int)num11;
                            ushort  num12      = (ushort)(index2 + 1);
                            int     num13      = (int)mCharData1[index2] & (int)byte.MaxValue;
                            for (int index3 = 0; index3 != num13; ++index3)
                            {
                                sbyte[] mCharData2 = SDKTextUtils.s_currentFont.m_charData;
                                int     index4     = (int)num12;
                                ushort  num14      = (ushort)(index4 + 1);
                                int     num15      = (int)mCharData2[index4] & (int)byte.MaxValue;
                                sbyte[] mCharData3 = SDKTextUtils.s_currentFont.m_charData;
                                int     index5     = (int)num14;
                                ushort  num16      = (ushort)(index5 + 1);
                                int     num17      = (int)mCharData3[index5] & (int)byte.MaxValue;
                                sbyte[] mCharData4 = SDKTextUtils.s_currentFont.m_charData;
                                int     index6     = (int)num16;
                                ushort  num18      = (ushort)(index6 + 1);
                                int     num19      = (int)mCharData4[index6];
                                sbyte[] mCharData5 = SDKTextUtils.s_currentFont.m_charData;
                                int     index7     = (int)num18;
                                ushort  num20      = (ushort)(index7 + 1);
                                int     num21      = (int)mCharData5[index7];
                                sbyte[] mCharData6 = SDKTextUtils.s_currentFont.m_charData;
                                int     index8     = (int)num20;
                                ushort  num22      = (ushort)(index8 + 1);
                                int     num23      = (int)mCharData6[index8] & (int)byte.MaxValue;
                                sbyte[] mCharData7 = SDKTextUtils.s_currentFont.m_charData;
                                int     index9     = (int)num22;
                                num12 = (ushort)(index9 + 1);
                                int   num24    = (int)mCharData7[index9] & (int)byte.MaxValue;
                                int[] numArray = new int[4]
                                {
                                    num19,
                                    num21 - ascent,
                                    -num19 - num23,
                                    ascent - num21 - num24
                                };
                                int num25 = p[0] + numArray[(int)num7];
                                int num26 = p[1] + numArray[(int)num10];
                                DrawRegionRoutine(fontImage, (short)num25, (short)num26, (short)num23, (short)num24, (short)num15, (short)num17);
                            }
                        }
                        SDKTextUtils.s_currentFont.advance(p, charAdvance);
                    }
                }
                break;

            default:
                if (encoding != SDKTextUtils.s_currentLanguage.encoding)
                {
                    JSystem.println("ERROR: SDKTextUtils::drawString: SDKString has encoding " + encoding.ToString() + ", but the currently set language has encoding " + SDKTextUtils.s_currentLanguage.encoding.ToString());
                    goto case 0;
                }
                else
                {
                    goto case 0;
                }
            }
        }