Esempio n. 1
0
        // Token: 0x0600467E RID: 18046 RVA: 0x001086EC File Offset: 0x001068EC
        public override void Render(string text, global::dfRenderData destination)
        {
            global::dfDynamicFont.DynamicFontRenderer.textColors.Clear();
            global::dfDynamicFont.DynamicFontRenderer.textColors.Push(Color.white);
            this.tokenize(text);
            global::dfList <global::dfDynamicFont.LineRenderInfo> dfList = this.calculateLinebreaks();
            int     num      = 0;
            int     num2     = 0;
            Vector3 position = (base.VectorOffset / base.PixelRatio).CeilToInt();

            for (int i = 0; i < dfList.Count; i++)
            {
                global::dfDynamicFont.LineRenderInfo lineRenderInfo = dfList[i];
                int count      = destination.Vertices.Count;
                int startIndex = (this.SpriteBuffer == null) ? 0 : this.SpriteBuffer.Vertices.Count;
                this.renderLine(dfList[i], global::dfDynamicFont.DynamicFontRenderer.textColors, position, destination);
                position.y -= lineRenderInfo.lineHeight;
                num         = Mathf.Max((int)lineRenderInfo.lineWidth, num);
                num2       += Mathf.CeilToInt(lineRenderInfo.lineHeight);
                if (lineRenderInfo.lineWidth > base.MaxSize.x)
                {
                    this.clipRight(destination, count);
                    this.clipRight(this.SpriteBuffer, startIndex);
                }
                this.clipBottom(destination, count);
                this.clipBottom(this.SpriteBuffer, startIndex);
            }
            base.RenderedSize = new Vector2(Mathf.Min(base.MaxSize.x, (float)num), Mathf.Min(base.MaxSize.y, (float)num2)) * base.TextScale;
        }
Esempio n. 2
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;
     }
 }
Esempio n. 3
0
 // Token: 0x06004694 RID: 18068 RVA: 0x00109B78 File Offset: 0x00107D78
 public static global::dfDynamicFont.LineRenderInfo Obtain(int start, int end)
 {
     if (global::dfDynamicFont.LineRenderInfo.poolIndex >= global::dfDynamicFont.LineRenderInfo.pool.Count - 1)
     {
         global::dfDynamicFont.LineRenderInfo.pool.Add(new global::dfDynamicFont.LineRenderInfo());
     }
     global::dfDynamicFont.LineRenderInfo lineRenderInfo = global::dfDynamicFont.LineRenderInfo.pool[global::dfDynamicFont.LineRenderInfo.poolIndex++];
     lineRenderInfo.startOffset = start;
     lineRenderInfo.endOffset   = end;
     lineRenderInfo.lineHeight  = 0f;
     return(lineRenderInfo);
 }
Esempio n. 4
0
        // Token: 0x06004687 RID: 18055 RVA: 0x00109298 File Offset: 0x00107498
        private void calculateLineSize(global::dfDynamicFont.LineRenderInfo line)
        {
            global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font;

            line.lineHeight = (float)dfDynamicFont.Baseline * base.TextScale;
            int num = 0;

            for (int i = line.startOffset; i <= line.endOffset; i++)
            {
                num += this.tokens[i].Width;
            }
            line.lineWidth = (float)num;
        }
Esempio n. 5
0
        // Token: 0x06004686 RID: 18054 RVA: 0x0010921C File Offset: 0x0010741C
        private int calculateLineAlignment(global::dfDynamicFont.LineRenderInfo line)
        {
            float lineWidth = line.lineWidth;

            if (base.TextAlign == null || lineWidth < 1f)
            {
                return(0);
            }
            float num;

            if (base.TextAlign == 2)
            {
                num = base.MaxSize.x - lineWidth;
            }
            else
            {
                num = (base.MaxSize.x - lineWidth) * 0.5f;
            }
            return(Mathf.CeilToInt(Mathf.Max(0f, num)));
        }