Exemplo n.º 1
0
    // Token: 0x06004255 RID: 16981 RVA: 0x000F4314 File Offset: 0x000F2514
    private Vector3 getVertAlignOffset(global::dfFontRendererBase textRenderer)
    {
        float   num          = base.PixelsToUnits();
        Vector2 vector       = textRenderer.MeasureString(this.text) * num;
        Vector3 vectorOffset = textRenderer.VectorOffset;
        float   num2         = (base.Height - (float)this.padding.vertical) * num;

        if (vector.y >= num2)
        {
            return(vectorOffset);
        }
        global::dfVerticalAlignment dfVerticalAlignment = this.vertAlign;

        if (dfVerticalAlignment != global::dfVerticalAlignment.Middle)
        {
            if (dfVerticalAlignment == global::dfVerticalAlignment.Bottom)
            {
                vectorOffset.y -= num2 - vector.y;
            }
        }
        else
        {
            vectorOffset.y -= (num2 - vector.y) * 0.5f;
        }
        return(vectorOffset);
    }
 // Token: 0x06003EDC RID: 16092 RVA: 0x000E4D5C File Offset: 0x000E2F5C
 private void autoSizeToText()
 {
     if (this.Font == null || !this.Font.IsValid || string.IsNullOrEmpty(this.Text))
     {
         return;
     }
     using (global::dfFontRendererBase dfFontRendererBase = this.obtainTextRenderer())
     {
         Vector2 vector = dfFontRendererBase.MeasureString(this.Text);
         Vector2 size;
         size..ctor(vector.x + (float)this.padding.horizontal, vector.y + (float)this.padding.vertical);
         base.Size = size;
     }
 }
Exemplo n.º 3
0
    // Token: 0x06004251 RID: 16977 RVA: 0x000F3E24 File Offset: 0x000F2024
    public override void Invalidate()
    {
        base.Invalidate();
        if (this.Font == null || !this.Font.IsValid)
        {
            return;
        }
        bool flag = this.size.sqrMagnitude <= float.Epsilon;

        if (!this.autoSize && !this.autoHeight && !flag)
        {
            return;
        }
        if (string.IsNullOrEmpty(this.Text))
        {
            if (flag)
            {
                base.Size = new Vector2(150f, 24f);
            }
            if (this.AutoSize || this.AutoHeight)
            {
                base.Height = (float)Mathf.CeilToInt((float)this.Font.LineHeight * this.TextScale);
            }
            return;
        }
        using (global::dfFontRendererBase dfFontRendererBase = this.obtainRenderer())
        {
            Vector2 vector = dfFontRendererBase.MeasureString(this.text).RoundToInt();
            if (this.AutoSize || flag)
            {
                this.size = vector + new Vector2((float)this.padding.horizontal, (float)this.padding.vertical);
            }
            else if (this.AutoHeight)
            {
                this.size = new Vector2(this.size.x, vector.y + (float)this.padding.vertical);
            }
        }
    }