private void renderLine(dfFont.LineRenderInfo line, Stack <Color32> colors, Vector3 position, dfRenderData destination) { float textScale = base.TextScale * base.PixelRatio; position.x = position.x + (float)this.calculateLineAlignment(line) * textScale; for (int i = line.startOffset; i <= line.endOffset; i++) { dfMarkupToken item = this.tokens[i]; dfMarkupTokenType tokenType = item.TokenType; if (tokenType == dfMarkupTokenType.Text) { this.renderText(item, colors.Peek(), position, destination); } else if (tokenType != dfMarkupTokenType.StartTag) { if (tokenType == dfMarkupTokenType.EndTag && item.Matches("color") && colors.Count > 1) { colors.Pop(); } } else if (item.Matches("sprite")) { this.renderSprite(item, colors.Peek(), position, destination); } else if (item.Matches("color")) { colors.Push(this.parseColor(item)); } position.x = position.x + (float)item.Width * textScale; } }
public static dfMarkupToken Obtain(string source, dfMarkupTokenType type, int startIndex, int endIndex) { var instance = (pool.Count > 0) ? pool.Pop() : new dfMarkupToken(); instance.inUse = true; instance.Source = source; instance.TokenType = type; instance.StartOffset = startIndex; instance.EndOffset = Mathf.Min(source.Length - 1, endIndex); return(instance); }
public static dfMarkupToken Obtain(string source, dfMarkupTokenType type, int startIndex, int endIndex) { if (poolIndex >= (pool.Count - 1)) { pool.Add(new dfMarkupToken()); } dfMarkupToken token = pool[poolIndex++]; token.Source = source; token.TokenType = type; token.value = null; token.StartOffset = startIndex; token.EndOffset = endIndex; token.AttributeCount = 0; token.startAttributeIndex = 0; token.Width = 0; token.Height = 0; return(token); }
public static dfMarkupToken Obtain(string source, dfMarkupTokenType type, int startIndex, int endIndex) { if (dfMarkupToken.poolIndex >= dfMarkupToken.pool.Count - 1) { dfMarkupToken.pool.Add(new dfMarkupToken()); } List <dfMarkupToken> dfMarkupTokens = dfMarkupToken.pool; int num = dfMarkupToken.poolIndex; dfMarkupToken.poolIndex = num + 1; dfMarkupToken item = dfMarkupTokens[num]; item.Source = source; item.TokenType = type; item.@value = null; item.StartOffset = startIndex; item.EndOffset = endIndex; item.AttributeCount = 0; item.startAttributeIndex = 0; item.Width = 0; item.Height = 0; return(item); }
private void renderLine(dfFont.LineRenderInfo line, Stack <Color32> colors, Vector3 position, dfRenderData destination) { float num = base.TextScale * base.PixelRatio; position.x += this.calculateLineAlignment(line) * num; for (int i = line.startOffset; i <= line.endOffset; i++) { dfMarkupToken token = this.tokens[i]; dfMarkupTokenType tokenType = token.TokenType; switch (tokenType) { case dfMarkupTokenType.Text: this.renderText(token, colors.Peek(), position, destination); break; case dfMarkupTokenType.StartTag: if (token.Matches("sprite")) { this.renderSprite(token, colors.Peek(), position, destination); } else if (token.Matches("color")) { colors.Push(this.parseColor(token)); } break; default: if (((tokenType == dfMarkupTokenType.EndTag) && token.Matches("color")) && (colors.Count > 1)) { colors.Pop(); } break; } position.x += token.Width * num; } }
public static dfMarkupToken Obtain(string source, dfMarkupTokenType type, int startIndex, int endIndex) { if (poolIndex >= pool.Count - 1) { pool.Add(new dfMarkupToken()); } var instance = pool[poolIndex++]; instance.Source = source; instance.TokenType = type; instance.value = null; instance.StartOffset = startIndex; instance.EndOffset = endIndex; instance.AttributeCount = 0; instance.startAttributeIndex = 0; instance.Width = 0; instance.Height = 0; return(instance); }
public static dfMarkupToken Obtain( string source, dfMarkupTokenType type, int startIndex, int endIndex ) { if( poolIndex >= pool.Count - 1 ) { pool.Add( new dfMarkupToken() ); } var instance = pool[ poolIndex++ ]; instance.Source = source; instance.TokenType = type; instance.value = null; instance.StartOffset = startIndex; instance.EndOffset = endIndex; instance.AttributeCount = 0; instance.startAttributeIndex = 0; instance.Width = 0; instance.Height = 0; return instance; }
private dfList <dfFont.LineRenderInfo> calculateLinebreaks() { try { if (this.lines == null) { this.lines = dfList <dfFont.LineRenderInfo> .Obtain(); int num = 0; int start = 0; int end = 0; int num4 = 0; float num5 = base.Font.LineHeight * base.TextScale; while ((end < this.tokens.Count) && ((this.lines.Count * num5) < base.MaxSize.y)) { dfMarkupToken token = this.tokens[end]; dfMarkupTokenType tokenType = token.TokenType; if (tokenType == dfMarkupTokenType.Newline) { this.lines.Add(dfFont.LineRenderInfo.Obtain(start, end)); start = num = ++end; num4 = 0; } else { int num6 = Mathf.CeilToInt(token.Width * base.TextScale); if (((base.WordWrap && (num > start)) && ((tokenType == dfMarkupTokenType.Text) || ((tokenType == dfMarkupTokenType.StartTag) && token.Matches("sprite")))) && ((num4 + num6) >= base.MaxSize.x)) { if (num > start) { this.lines.Add(dfFont.LineRenderInfo.Obtain(start, num - 1)); start = end = ++num; num4 = 0; } else { this.lines.Add(dfFont.LineRenderInfo.Obtain(start, num - 1)); start = num = ++end; num4 = 0; } continue; } if (tokenType == dfMarkupTokenType.Whitespace) { num = end; } num4 += num6; end++; } } if (start < this.tokens.Count) { this.lines.Add(dfFont.LineRenderInfo.Obtain(start, this.tokens.Count - 1)); } for (int i = 0; i < this.lines.Count; i++) { this.calculateLineSize(this.lines[i]); } } return(this.lines); } finally { } }
public static dfMarkupToken Obtain(string source, dfMarkupTokenType type, int startIndex, int endIndex) { if (dfMarkupToken.poolIndex >= dfMarkupToken.pool.Count - 1) { dfMarkupToken.pool.Add(new dfMarkupToken()); } List<dfMarkupToken> dfMarkupTokens = dfMarkupToken.pool; int num = dfMarkupToken.poolIndex; dfMarkupToken.poolIndex = num + 1; dfMarkupToken item = dfMarkupTokens[num]; item.Source = source; item.TokenType = type; item.@value = null; item.StartOffset = startIndex; item.EndOffset = endIndex; item.AttributeCount = 0; item.startAttributeIndex = 0; item.Width = 0; item.Height = 0; return item; }
public static dfMarkupToken Obtain( string source, dfMarkupTokenType type, int startIndex, int endIndex ) { var instance = ( pool.Count > 0 ) ? pool.Pop() : new dfMarkupToken(); instance.inUse = true; instance.Source = source; instance.TokenType = type; instance.StartOffset = startIndex; instance.EndOffset = Mathf.Min( source.Length - 1, endIndex ); return instance; }
private dfList <dfFont.LineRenderInfo> calculateLinebreaks() { dfList <dfFont.LineRenderInfo> lineRenderInfos; bool flag; try { if (this.lines == null) { this.lines = dfList <dfFont.LineRenderInfo> .Obtain(); int num = 0; int num1 = 0; int num2 = 0; int num3 = 0; float lineHeight = (float)base.Font.LineHeight * base.TextScale; while (num2 < this.tokens.Count) { Vector2 maxSize = base.MaxSize; if ((float)this.lines.Count * lineHeight >= maxSize.y) { break; } dfMarkupToken item = this.tokens[num2]; dfMarkupTokenType tokenType = item.TokenType; if (tokenType != dfMarkupTokenType.Newline) { int num4 = Mathf.CeilToInt((float)item.Width * base.TextScale); if (!base.WordWrap || num <= num1) { flag = false; } else if (tokenType == dfMarkupTokenType.Text) { flag = true; } else { flag = (tokenType != dfMarkupTokenType.StartTag ? false : item.Matches("sprite")); } if (!flag || (float)(num3 + num4) < base.MaxSize.x) { if (tokenType == dfMarkupTokenType.Whitespace) { num = num2; } num3 = num3 + num4; num2++; } else if (num <= num1) { this.lines.Add(dfFont.LineRenderInfo.Obtain(num1, num - 1)); int num5 = num2 + 1; num2 = num5; num = num5; num1 = num5; num3 = 0; } else { this.lines.Add(dfFont.LineRenderInfo.Obtain(num1, num - 1)); int num6 = num + 1; num = num6; num2 = num6; num1 = num6; num3 = 0; } } else { this.lines.Add(dfFont.LineRenderInfo.Obtain(num1, num2)); int num7 = num2 + 1; num2 = num7; num = num7; num1 = num7; num3 = 0; } } if (num1 < this.tokens.Count) { this.lines.Add(dfFont.LineRenderInfo.Obtain(num1, this.tokens.Count - 1)); } for (int i = 0; i < this.lines.Count; i++) { this.calculateLineSize(this.lines[i]); } lineRenderInfos = this.lines; } else { lineRenderInfos = this.lines; } } finally { } return(lineRenderInfos); }