Esempio n. 1
0
 // Token: 0x0600467F RID: 18047 RVA: 0x0010886C File Offset: 0x00106A6C
 private void renderLine(global::dfDynamicFont.LineRenderInfo line, Stack <Color32> colors, Vector3 position, global::dfRenderData destination)
 {
     position.x += (float)this.calculateLineAlignment(line);
     for (int i = line.startOffset; i <= line.endOffset; i++)
     {
         global::dfMarkupToken     dfMarkupToken = this.tokens[i];
         global::dfMarkupTokenType tokenType     = dfMarkupToken.TokenType;
         if (tokenType == global::dfMarkupTokenType.Text)
         {
             this.renderText(dfMarkupToken, colors.Peek(), position, destination);
         }
         else if (tokenType == global::dfMarkupTokenType.StartTag)
         {
             if (dfMarkupToken.Matches("sprite") && this.SpriteAtlas != null && this.SpriteBuffer != null)
             {
                 this.renderSprite(dfMarkupToken, colors.Peek(), position, this.SpriteBuffer);
             }
             else if (dfMarkupToken.Matches("color"))
             {
                 colors.Push(this.parseColor(dfMarkupToken));
             }
         }
         else if (tokenType == global::dfMarkupTokenType.EndTag && dfMarkupToken.Matches("color") && colors.Count > 1)
         {
             colors.Pop();
         }
         position.x += (float)dfMarkupToken.Width;
     }
 }
    // Token: 0x060042FA RID: 17146 RVA: 0x000F74A4 File Offset: 0x000F56A4
    public static global::dfMarkupToken Obtain(string source, global::dfMarkupTokenType type, int startIndex, int endIndex)
    {
        if (global::dfMarkupToken.poolIndex >= global::dfMarkupToken.pool.Count - 1)
        {
            global::dfMarkupToken.pool.Add(new global::dfMarkupToken());
        }
        global::dfMarkupToken dfMarkupToken = global::dfMarkupToken.pool[global::dfMarkupToken.poolIndex++];

        dfMarkupToken.Source              = source;
        dfMarkupToken.TokenType           = type;
        dfMarkupToken.value               = null;
        dfMarkupToken.StartOffset         = startIndex;
        dfMarkupToken.EndOffset           = endIndex;
        dfMarkupToken.AttributeCount      = 0;
        dfMarkupToken.startAttributeIndex = 0;
        dfMarkupToken.Width               = 0;
        dfMarkupToken.Height              = 0;
        return(dfMarkupToken);
    }
Esempio n. 3
0
        // Token: 0x06004685 RID: 18053 RVA: 0x00108FE8 File Offset: 0x001071E8
        private global::dfList <global::dfDynamicFont.LineRenderInfo> calculateLinebreaks()
        {
            global::dfList <global::dfDynamicFont.LineRenderInfo> result;

            try
            {
                if (this.lines != null)
                {
                    result = this.lines;
                }
                else
                {
                    this.lines = global::dfList <global::dfDynamicFont.LineRenderInfo> .Obtain();

                    global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font;
                    int   num  = 0;
                    int   num2 = 0;
                    int   num3 = 0;
                    int   num4 = 0;
                    float num5 = (float)dfDynamicFont.Baseline * base.TextScale;
                    while (num3 < this.tokens.Count && (float)this.lines.Count * num5 <= base.MaxSize.y + num5)
                    {
                        global::dfMarkupToken     dfMarkupToken = this.tokens[num3];
                        global::dfMarkupTokenType tokenType     = dfMarkupToken.TokenType;
                        if (tokenType == global::dfMarkupTokenType.Newline)
                        {
                            this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, num3));
                            num  = (num2 = ++num3);
                            num4 = 0;
                        }
                        else
                        {
                            int  num6 = Mathf.CeilToInt((float)dfMarkupToken.Width);
                            bool flag = base.WordWrap && num > num2 && (tokenType == global::dfMarkupTokenType.Text || (tokenType == global::dfMarkupTokenType.StartTag && dfMarkupToken.Matches("sprite")));
                            if (flag && (float)(num4 + num6) >= base.MaxSize.x)
                            {
                                if (num > num2)
                                {
                                    this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, num - 1));
                                    num3 = (num2 = ++num);
                                    num4 = 0;
                                }
                                else
                                {
                                    this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, num - 1));
                                    num  = (num2 = ++num3);
                                    num4 = 0;
                                }
                            }
                            else
                            {
                                if (tokenType == global::dfMarkupTokenType.Whitespace)
                                {
                                    num = num3;
                                }
                                num4 += num6;
                                num3++;
                            }
                        }
                    }
                    if (num2 < this.tokens.Count)
                    {
                        this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, this.tokens.Count - 1));
                    }
                    for (int i = 0; i < this.lines.Count; i++)
                    {
                        this.calculateLineSize(this.lines[i]);
                    }
                    result = this.lines;
                }
            }
            finally
            {
            }
            return(result);
        }