示例#1
0
    private void _Separate()
    {
        for (int i = 0; i < this.m_StringData.Count; i++)
        {
            this.m_StringData[i].Recycle();
        }
        this.m_StringData.Clear();
        int    num    = 0;
        string text   = (!string.IsNullOrEmpty(this._InputText)) ? this._InputText : string.Empty;
        int    length = text.Length;

        XUILabelSymbol.Type type = XUILabelSymbol.Type.LST_NONE;
        for (int j = 0; j < length; j++)
        {
            if (this._InputText[j] == XUILabelSymbol._EscapedLeftBracket)
            {
                int num2 = this._FindClosingBracket(text, j + 1);
                if (num2 != -1 && num2 - j > 3)
                {
                    int startIndex = j + 1;
                    type = this._GetType(this._InputText, startIndex);
                }
                if (type != XUILabelSymbol.Type.LST_NONE)
                {
                    XUILabelSymbol.StringData data = XDataPool <XUILabelSymbol.StringData> .GetData();

                    data.type = type;
                    if (data.Set(text, j + 4, num2 - j - 4))
                    {
                        if (j > num)
                        {
                            XUILabelSymbol.StringData data2 = XDataPool <XUILabelSymbol.StringData> .GetData();

                            data2.type = XUILabelSymbol.Type.LST_NONE;
                            data2.Set(text, num, j - num);
                            this.m_StringData.Add(data2);
                        }
                        this.m_StringData.Add(data);
                        num = num2 + 1;
                        j   = num2;
                    }
                    else
                    {
                        data.Recycle();
                    }
                    type = XUILabelSymbol.Type.LST_NONE;
                }
            }
        }
        if (num < length)
        {
            XUILabelSymbol.StringData data3 = XDataPool <XUILabelSymbol.StringData> .GetData();

            data3.type = XUILabelSymbol.Type.LST_NONE;
            data3.Set(text, num, length - num);
            this.m_StringData.Add(data3);
        }
    }
示例#2
0
        public static bool CreateHyperLinkSymbolData(XUILabelSymbol.StringData input, out XUILabelSymbol.SymbolData data, out string symbolString)
        {
            int num = input.str.IndexOf(XUILabelSymbol._EscapedSeparator, input.startIndex, input.length);

            if (num == -1)
            {
                data         = null;
                symbolString = null;
                return(false);
            }
            XUILabelSymbol.HyperLinkSymbolData hyperLinkSymbolData = null;
            switch (input.type)
            {
            case XUILabelSymbol.Type.LST_GUILD:
                hyperLinkSymbolData = XDataPool <XUILabelSymbol.GuildHyperLinkSymbolData> .GetData();

                break;

            case XUILabelSymbol.Type.LST_TEAM:
                hyperLinkSymbolData = XDataPool <XUILabelSymbol.TeamHyperLinkSymbolData> .GetData();

                break;

            case XUILabelSymbol.Type.LST_ITEM:
                hyperLinkSymbolData = XDataPool <XUILabelSymbol.ItemHyperLinkSymbolData> .GetData();

                break;

            case XUILabelSymbol.Type.LST_NAME:
                hyperLinkSymbolData = XDataPool <XUILabelSymbol.NameHyperLinkSymbolData> .GetData();

                break;

            case XUILabelSymbol.Type.LST_PK:
                hyperLinkSymbolData = XDataPool <XUILabelSymbol.PkHyperLinkSymbolData> .GetData();

                break;

            case XUILabelSymbol.Type.LST_UI:
                hyperLinkSymbolData = XDataPool <XUILabelSymbol.UIHyperLinkSymbolData> .GetData();

                break;

            case XUILabelSymbol.Type.LST_SPECTATE:
                hyperLinkSymbolData = XDataPool <XUILabelSymbol.SpectateHyperLinkSymbolData> .GetData();

                break;
            }
            symbolString = hyperLinkSymbolData.Set(input.str, input.startIndex, input.length, num);
            if (symbolString == null)
            {
                data = null;
                return(false);
            }
            data = hyperLinkSymbolData;
            return(true);
        }
示例#3
0
    private void _Parse()
    {
        for (int i = 0; i < this.m_Symbols.Count; i++)
        {
            this.m_Symbols[i].Recycle();
        }
        this.m_Symbols.Clear();
        this.m_Label.text = string.Empty;
        this.m_Label.ProcessText();
        this.m_Label.UpdateDefaultPrintedSize();
        if (this._UniSpaceWidth < 0f)
        {
            this._UniSpaceWidth = NGUIText.CalculatePrintedSize(new string(XUILabelSymbol._UniSpace, 1), 1000).x;
            this._SpaceWidth    = NGUIText.CalculatePrintedSize(" ", 1000).x;
            if (Mathf.Abs(this._SpaceWidth) < 0.01f)
            {
                XSingleton <XDebug> .singleton.AddErrorLog("_SpaceWidth = ", this._SpaceWidth.ToString(), " gameobject = ", base.gameObject.ToString(), null, null);
            }
        }
        this._CheckAttachments();
        string text = string.Empty;
        int    num  = 0;
        int    j    = 0;
        int    k    = 0;
        int    num2 = this.m_Label.width;

        if (this.m_Label.overflowMethod == UILabel.Overflow.ResizeFreely)
        {
            num2 = 10000;
        }
        string text2 = null;

        XUILabelSymbol.SymbolData symbolData = null;
        int l = 0;

        while (l < this.m_StringData.Count)
        {
            if (num != 0 && num >= text.Length)
            {
                break;
            }
            XUILabelSymbol.StringData stringData = this.m_StringData[l];
            if (XUILabelSymbol.SymbolData.IsImage(stringData.type))
            {
                XUILabelSymbol.ImageSymbolData data = XDataPool <XUILabelSymbol.ImageSymbolData> .GetData();

                text2 = data.SetSprite(this, stringData.str, stringData.startIndex, stringData.length, ref j);
                if (text2 != null)
                {
                    symbolData = data;
                    goto IL_224;
                }
                data.Recycle();
            }
            else if (XUILabelSymbol.SymbolData.IsAnimation(stringData.type))
            {
                XUILabelSymbol.AnimationSymbolData data2 = XDataPool <XUILabelSymbol.AnimationSymbolData> .GetData();

                text2 = data2.SetSprite(this, stringData.str, stringData.startIndex, stringData.length, ref k);
                if (text2 != null)
                {
                    symbolData = data2;
                    goto IL_224;
                }
                data2.Recycle();
            }
            else
            {
                if (XUILabelSymbol.SymbolData.IsHyperLink(stringData.type))
                {
                    XUILabelSymbol.HyperLinkSymbolData.CreateHyperLinkSymbolData(stringData, out symbolData, out text2);
                    goto IL_224;
                }
                goto IL_224;
            }
IL_3B7:
            l++;
            continue;
IL_224:
            if (text2 != null)
            {
                XUILabelSymbol.s_TempSB.Length = 0;
                XUILabelSymbol.s_TempSB.Append(text, num, text.Length - num);
                XUILabelSymbol.s_TempSB.Append(text2);
                int num3 = Mathf.CeilToInt(NGUIText.CalculatePrintedSize(XUILabelSymbol.s_TempSB.ToString(), num2 + 1000).x);
                if (num3 > num2)
                {
                    symbolData.startIndex = text.Length + 1;
                    num = text.Length + 1;
                    XUILabelSymbol.s_TempSB.Length = 0;
                    XUILabelSymbol.s_TempSB.Append(text);
                    XUILabelSymbol.s_TempSB.Append('\n');
                    XUILabelSymbol.s_TempSB.Append(text2);
                    text = XUILabelSymbol.s_TempSB.ToString();
                }
                else
                {
                    symbolData.startIndex          = text.Length;
                    XUILabelSymbol.s_TempSB.Length = 0;
                    XUILabelSymbol.s_TempSB.Append(text);
                    XUILabelSymbol.s_TempSB.Append(text2);
                    text = XUILabelSymbol.s_TempSB.ToString();
                }
                symbolData.endIndex = symbolData.startIndex + text2.Length;
                this.m_Symbols.Add(symbolData);
                NGUIText.WrapText(text, out text, false);
                text2 = null;
                goto IL_3B7;
            }
            XUILabelSymbol.s_TempSB.Length = 0;
            XUILabelSymbol.s_TempSB.Append(text);
            XUILabelSymbol.s_TempSB.Append(stringData.str, stringData.startIndex, stringData.length);
            NGUIText.WrapText(XUILabelSymbol.s_TempSB.ToString(), out text, false);
            num = text.LastIndexOf('\n');
            if (num == -1)
            {
                num = 0;
                goto IL_3B7;
            }
            num++;
            goto IL_3B7;
        }
        while (j < this.m_SpriteList.Count)
        {
            this.m_SpriteList[j].gameObject.SetActive(false);
            j++;
        }
        while (k < this.m_AnimationList.Count)
        {
            this.m_AnimationList[k].gameObject.SetActive(false);
            k++;
        }
        this.m_Label.text = text;
    }