yyl
昨天 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
public class WordAnalysis : TRichAnalysis<WordAnalysis>
{
    public static Regex Word_Regex = new Regex(@"<Word (.*?)/>", RegexOptions.Singleline);
 
    public static Regex Color_Start_Regex = new Regex(@"<color=#[0-9a-zA-Z]+>", RegexOptions.Singleline);
    public static Regex Color_End_Regex = new Regex(@"</color>", RegexOptions.Singleline);
    public static Regex Space_Regex = new Regex(@"<Space=([0-9]*)>", RegexOptions.Singleline);
    public static Regex Size_Start_Regex = new Regex(@"<[Ss]ize=([0-9]+)>", RegexOptions.Singleline);
    public static Regex Size_End_Regex = new Regex(@"</[Ss]ize>", RegexOptions.Singleline);
 
    private static RichTextEventEnum eventType = RichTextEventEnum.TABLE;
 
    private static int presentColor = 0;
    private static bool hasColor = false;
 
    public override string Analysis(string val, bool IsRich)
    {
        if (!Word_Regex.IsMatch(val))
        {
            return val;
        }
        int index = 0;
        m_StringBuilder.Length = 0;
        foreach (Match match in Word_Regex.Matches(val))
        {
            m_StringBuilder.Append(val.Substring(index, match.Index - index));
            AnalysisSplitEvent(match.Groups[1].Value);
            index = match.Index + match.Length;
        }
        m_StringBuilder.Append(val.Substring(index, val.Length - index));
        return m_StringBuilder.ToString();
    }
 
    public override string CalculateTextIndex(string val, int index)
    {
        return string.Empty;
    }
 
    private void AnalysisSplitEvent(string val)
    {
        string[] array = GetSplitEvent(val);
        if (array.Length > 0)
        {
            foreach (var split_event in array)
            {
                AnalysisSplitData(split_event);
            }
        }
    }
 
    private void AnalysisSplitData(string val)
    {
 
        string[] array = GetSplitData(val);
        if (array.Length > 0)
        {
            bool hasAnalysis = true;
            hasColor = false;
            displayDic.Clear();
            string result = string.Empty;
            foreach (var split_data in array)
            {
                hasAnalysis = AnalysisSplitValue(split_data, ref result) && hasAnalysis;
            }
            if (hasAnalysis)
            {
                result = RichTextMgr.Inst.GetDisplay(eventType, displayDic);
            }
            if (hasColor)
            {
                var text = RichTextMgr.Inst.presentRichText;
                int colorType = 0;
                if (text != null)
                {
                    colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1;
                }
                result = Color_Start_Regex.Replace(result, string.Empty);
                result = Color_End_Regex.Replace(result, string.Empty);
                result = UIHelper.AppendColor(presentColor, result, colorType == 1);
            }
            m_StringBuilder.Append(result);
        }
 
    }
 
    private bool AnalysisSplitValue(string val, ref string result)
    {
        string[] array = GetSplitValue(val);
        if (array.Length == 2)
        {
            string split_value = array[0].ToLower();
            switch (split_value)
            {
                case "info":
                    {
                        eventType = RichTextEventEnum.TABLE;
                        displayDic.Add(split_value, array[1].ToLower());
                    }
                    break;
                case "show":
                    {
                        if (array[1].ToLower() == "null")
                        {
                            result = Language.Get("Market_Text_33");
                        }
                        else
                        {
                            result = array[1];
                        }
                        return false;
                    }
                case "color":
                    {
                        presentColor = int.Parse(array[1]);
                        hasColor = true;
                    }
                    break;
                case "exp":
                    {
                        ulong _exp = 0;
                        ulong.TryParse(array[1], out _exp);
                        result = UIHelper.ReplaceLargeNum(_exp);
                        return false;
                    }
                case "time":
                    {
                        int _time = 0;
                        int.TryParse(array[1], out _time);
                        result = TimeUtility.SecondsToDHMSCHS(_time / 1000);
                        return false;
                    }
                case "chatsend":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                    }
                    break;
                case "count":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                    }
                    break;
                case "ancientrobotname":
                    {
                        eventType = RichTextEventEnum.AncientRobotName;
                    }
                    break;
                case "myfightpoint":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.MyFightPoint;
                    }
                    break;
                case "myreikiroot":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.MyReikiRoot;
                    }
                    break;
                case "mydefense":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.MyDefense;
                    }
                    break;
                case "joblabel":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.JobLabel;
                    }
                    break;
                case "blsos":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.BLSOS;
                    }
                    break;
                case "gszd":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.GSZD;
                    }
                    break;
                case "copy":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.COPY;
                    }
                    break;
                case "serveridrangeinfo":
                    {
                        displayDic.Add(split_value, array[1].ToLower());
                        eventType = RichTextEventEnum.XJDHServerIDRangeInfo;
                    }
                    break;
                default:
                    {
                        displayDic.Add(split_value, array[1]);
                    }
                    break;
            }
            return true;
        }
        else
        {
            m_StringBuilder.Append(array[0]);
            return false;
        }
    }
 
    public string ReplaceSpace(string val)
    {
        m_StringBuilder.Length = 0;
        if (!Space_Regex.IsMatch(val))
        {
            return val;
        }
        int index = 0;
        foreach (Match match in Space_Regex.Matches(val))
        {
            m_StringBuilder.Append(val.Substring(index, match.Index - index));
            int spaceCnt = 0;
            if (int.TryParse(match.Groups[1].Value, out spaceCnt))
            {
                if (spaceCnt != 0)
                {
                    for (int i = 0; i < spaceCnt; i++)
                    {
                        m_StringBuilder.Append(UIHelper.no_breaking_space);
                    }
                }
            }
            index = match.Index + match.Length;
        }
        m_StringBuilder.Append(val.Substring(index, val.Length - index));
        return m_StringBuilder.ToString();
    }
}