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); }
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); }
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; } } }