示例#1
0
 // Token: 0x06004682 RID: 18050 RVA: 0x00108E54 File Offset: 0x00107054
 private void renderSprite(global::dfMarkupToken token, Color32 color, Vector3 position, global::dfRenderData destination)
 {
     try
     {
         string value = token.GetAttribute(0).Value.Value;
         global::dfAtlas.ItemInfo itemInfo = this.SpriteAtlas[value];
         if (!(itemInfo == null))
         {
             global::dfSprite.RenderOptions options = new global::dfSprite.RenderOptions
             {
                 atlas         = this.SpriteAtlas,
                 color         = color,
                 fillAmount    = 1f,
                 offset        = position,
                 pixelsToUnits = base.PixelRatio,
                 size          = new Vector2((float)token.Width, (float)token.Height),
                 spriteInfo    = itemInfo
             };
             global::dfSprite.renderSprite(this.SpriteBuffer, options);
         }
     }
     finally
     {
     }
 }
 // Token: 0x060040E0 RID: 16608 RVA: 0x000EE198 File Offset: 0x000EC398
 private void calculateTokenRenderSize(global::dfMarkupToken token)
 {
     try
     {
         global::dfFont dfFont       = (global::dfFont)base.Font;
         int            num          = 0;
         char           previousChar = '\0';
         bool           flag         = token.TokenType == global::dfMarkupTokenType.Whitespace || token.TokenType == global::dfMarkupTokenType.Text;
         if (flag)
         {
             int i = 0;
             while (i < token.Length)
             {
                 char c = token[i];
                 if (c == '\t')
                 {
                     num += base.TabSize;
                 }
                 else
                 {
                     global::dfFont.GlyphDefinition glyph = dfFont.GetGlyph(c);
                     if (glyph != null)
                     {
                         if (i > 0)
                         {
                             num += dfFont.GetKerning(previousChar, c);
                             num += base.CharacterSpacing;
                         }
                         num += glyph.xadvance;
                     }
                 }
                 i++;
                 previousChar = c;
             }
         }
         else if (token.TokenType == global::dfMarkupTokenType.StartTag && token.Matches("sprite"))
         {
             if (token.AttributeCount < 1)
             {
                 throw new Exception("Missing sprite name in markup");
             }
             Texture texture    = dfFont.Texture;
             int     lineHeight = dfFont.LineHeight;
             string  value      = token.GetAttribute(0).Value.Value;
             global::dfAtlas.ItemInfo itemInfo = dfFont.atlas[value];
             if (itemInfo != null)
             {
                 float num2 = itemInfo.region.width * (float)texture.width / (itemInfo.region.height * (float)texture.height);
                 num = Mathf.CeilToInt((float)lineHeight * num2);
             }
         }
         token.Height = base.Font.LineHeight;
         token.Width  = num;
     }
     finally
     {
     }
 }
示例#3
0
 // Token: 0x06004689 RID: 18057 RVA: 0x001093D8 File Offset: 0x001075D8
 private void calculateTokenRenderSize(global::dfMarkupToken token)
 {
     try
     {
         int  num  = 0;
         bool flag = token.TokenType == global::dfMarkupTokenType.Whitespace || token.TokenType == global::dfMarkupTokenType.Text;
         global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font;
         if (flag)
         {
             int             size  = Mathf.CeilToInt((float)dfDynamicFont.FontSize * base.TextScale);
             CharacterInfo[] array = dfDynamicFont.RequestCharacters(token.Value, size, 0);
             for (int i = 0; i < token.Length; i++)
             {
                 char c = token[i];
                 if (c == '\t')
                 {
                     num += base.TabSize;
                 }
                 else
                 {
                     CharacterInfo characterInfo = array[i];
                     num += ((c == ' ') ? Mathf.CeilToInt(characterInfo.width) : Mathf.CeilToInt(characterInfo.vert.x + characterInfo.vert.width));
                     if (i > 0)
                     {
                         num += Mathf.CeilToInt((float)base.CharacterSpacing * base.TextScale);
                     }
                 }
             }
             token.Height = base.Font.LineHeight;
             token.Width  = num;
         }
         else if (token.TokenType == global::dfMarkupTokenType.StartTag && token.Matches("sprite") && this.SpriteAtlas != null && token.AttributeCount == 1)
         {
             Texture2D texture = this.SpriteAtlas.Texture;
             float     num2    = (float)dfDynamicFont.Baseline * base.TextScale;
             string    value   = token.GetAttribute(0).Value.Value;
             global::dfAtlas.ItemInfo itemInfo = this.SpriteAtlas[value];
             if (itemInfo != null)
             {
                 float num3 = itemInfo.region.width * (float)texture.width / (itemInfo.region.height * (float)texture.height);
                 num = Mathf.CeilToInt(num2 * num3);
             }
             token.Height = Mathf.CeilToInt(num2);
             token.Width  = num;
         }
     }
     finally
     {
     }
 }
 // Token: 0x060040D9 RID: 16601 RVA: 0x000EDAE0 File Offset: 0x000EBCE0
 private void renderSprite(global::dfMarkupToken token, Color32 color, Vector3 position, global::dfRenderData destination)
 {
     try
     {
         global::dfList <Vector3> vertices  = destination.Vertices;
         global::dfList <int>     triangles = destination.Triangles;
         global::dfList <Color32> colors    = destination.Colors;
         global::dfList <Vector2> uv        = destination.UV;
         global::dfFont           dfFont    = (global::dfFont)base.Font;
         string value = token.GetAttribute(0).Value.Value;
         global::dfAtlas.ItemInfo itemInfo = dfFont.Atlas[value];
         if (!(itemInfo == null))
         {
             float num   = (float)token.Height * base.TextScale * base.PixelRatio;
             float num2  = (float)token.Width * base.TextScale * base.PixelRatio;
             float x     = position.x;
             float y     = position.y;
             int   count = vertices.Count;
             vertices.Add(new Vector3(x, y));
             vertices.Add(new Vector3(x + num2, y));
             vertices.Add(new Vector3(x + num2, y - num));
             vertices.Add(new Vector3(x, y - num));
             triangles.Add(count);
             triangles.Add(count + 1);
             triangles.Add(count + 3);
             triangles.Add(count + 3);
             triangles.Add(count + 1);
             triangles.Add(count + 2);
             Color32 item = (!base.ColorizeSymbols) ? this.applyOpacity(base.DefaultColor) : this.applyOpacity(color);
             colors.Add(item);
             colors.Add(item);
             colors.Add(item);
             colors.Add(item);
             Rect region = itemInfo.region;
             uv.Add(new Vector2(region.x, region.yMax));
             uv.Add(new Vector2(region.xMax, region.yMax));
             uv.Add(new Vector2(region.xMax, region.y));
             uv.Add(new Vector2(region.x, region.y));
         }
     }
     finally
     {
     }
 }
示例#5
0
        // Token: 0x06004683 RID: 18051 RVA: 0x00108F24 File Offset: 0x00107124
        private Color32 parseColor(global::dfMarkupToken token)
        {
            Color color = Color.white;

            if (token.AttributeCount == 1)
            {
                string value = token.GetAttribute(0).Value.Value;
                if (value.Length == 7 && value[0] == '#')
                {
                    uint num = 0u;
                    uint.TryParse(value.Substring(1), NumberStyles.HexNumber, null, out num);
                    color = this.UIntToColor(num | 4278190080u);
                }
                else
                {
                    color = global::dfMarkupStyle.ParseColor(value, base.DefaultColor);
                }
            }
            return(this.applyOpacity(color));
        }