示例#1
0
        private void CalculateLineFeed(string tarStr)
        {
            if (this.listEmotionData == null || this.listEmotionData.Count == 0)
            {
                int length = tarStr.Length;
                if (length > 15)
                {
                    this.line = 2;
                    tarStr    = tarStr.Insert(15, "\n");
                }
                this.strFinal = tarStr;
                return;
            }
            float num = 0f;

            for (int num2 = 0; num2 != this.listEmotionData.Count; num2++)
            {
                num += this.listEmotionData[num2].totalNonSpace;
            }
            if (num > 15f)
            {
                this.line = 2;
                int num3 = 0;
                for (int num4 = this.listEmotionData.Count - 1; num4 != -1; num4--)
                {
                    float num5 = 0f;
                    for (int num6 = 0; num6 != num4; num6++)
                    {
                        num5 += this.listEmotionData[num6].totalNonSpace;
                    }
                    if (num5 <= 15f)
                    {
                        num3 = num4;
                        break;
                    }
                }
                if (this.listEmotionData.Count == num3 + 1)
                {
                    int startIndex;
                    if ((double)num - 1.5 > 15.0)
                    {
                        startIndex = Convert.ToInt32(num + (float)this.listEmotionData.Count * 4.5f) - Convert.ToInt32((double)num - 1.5 - 15.0 + 6.0);
                    }
                    else
                    {
                        startIndex = Convert.ToInt32(num + (float)this.listEmotionData.Count * 4.5f) - 6;
                    }
                    tarStr        = tarStr.Insert(startIndex, "\n");
                    this.strFinal = tarStr;
                    EmotionData value = this.listEmotionData[num3];
                    value.row = 2;
                    value.position++;
                    this.listEmotionData[num3] = value;
                }
                else
                {
                    int position = this.listEmotionData[num3].position;
                    tarStr        = tarStr.Insert(position, "\n");
                    this.strFinal = tarStr;
                    for (int num7 = num3; num7 != this.listEmotionData.Count; num7++)
                    {
                        EmotionData value2 = this.listEmotionData[num7];
                        value2.row = 2;
                        value2.position++;
                        this.listEmotionData[num7] = value2;
                    }
                }
            }
            else
            {
                int length2 = tarStr.Substring(this.listEmotionData[this.listEmotionData.Count - 1].position + 6).Length;
                if (num + (float)length2 > 15f)
                {
                    this.line = 2;
                    int startIndex2 = Convert.ToInt32(num + (float)this.listEmotionData.Count * 4.5f) + Convert.ToInt32(15f - num);
                    tarStr = tarStr.Insert(startIndex2, "\n");
                }
                this.strFinal = tarStr;
            }
        }
示例#2
0
        private void ParseData(string str)
        {
            this.listEmotionData.Clear();
            int length = str.Length;
            int num    = -6;
            BetterList <string> listOfSprites = this.atlas.GetListOfSprites();

            for (int num2 = 0; num2 != length; num2++)
            {
                if (str[num2] == '#' && num2 + 4 < length && str[num2 + 1] == 'e')
                {
                    EmotionData item = default(EmotionData);
                    item.serialNumber = str.Substring(num2 + 2, 3);
                    if (listOfSprites.Contains(item.serialNumber))
                    {
                        if (this.IsShowVIPStr(str, num2))
                        {
                            int num3 = (num != 0) ? (num + 6) : (num + 7);
                            item.strContent    = str.Substring(num3, num2 + 5 - num3).Replace(str.Substring(num2, 5), (num2 != 0) ? "      " : "       ");
                            item.position      = num2;
                            item.row           = 1;
                            item.totalConSpace = item.strContent.Length;
                            item.totalNonSpace = (float)(str.Substring(num3, num2 + 5 - num3).Length - 5) + 1.5f;
                            this.listEmotionData.Add(item);
                            num = num2;
                            Regex regex = new Regex(str.Substring(num2, 5));
                            str    = regex.Replace(str, (num2 != 0) ? "      " : "       ", 1);
                            length = str.Length;
                        }
                    }
                }
            }
            string text = string.Empty;

            if (this.listEmotionData != null && this.listEmotionData.Count != 0)
            {
                if (this.listEmotionData[this.listEmotionData.Count - 1].position == 0)
                {
                    if (str.Length != 7)
                    {
                        text = str.Substring(this.listEmotionData[this.listEmotionData.Count - 1].position + 7);
                    }
                }
                else
                {
                    text = str.Substring(this.listEmotionData[this.listEmotionData.Count - 1].position + 6);
                }
            }
            else
            {
                text = str;
            }
            string text2 = null;

            for (int num4 = 0; num4 != this.listEmotionData.Count; num4++)
            {
                text2 += this.listEmotionData[num4].strContent;
            }
            if (!string.IsNullOrEmpty(text))
            {
                text2 += text;
            }
            this.CalculateLineFeed(text2);
        }