// 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);
    }
Esempio n. 2
0
    // Token: 0x060042ED RID: 17133 RVA: 0x000F69D8 File Offset: 0x000F4BD8
    private void renderItems(global::dfRenderData buffer)
    {
        if (this.font == null || this.items == null || this.items.Length == 0)
        {
            return;
        }
        float   num = base.PixelsToUnits();
        Vector2 maxSize;

        maxSize..ctor(this.size.x - (float)this.itemPadding.horizontal - (float)this.listPadding.horizontal, (float)(this.itemHeight - this.itemPadding.vertical));
        Vector3 vector       = this.pivot.TransformToUpperLeft(base.Size);
        Vector3 vectorOffset = new Vector3(vector.x + (float)this.itemPadding.left + (float)this.listPadding.left, vector.y - (float)this.itemPadding.top - (float)this.listPadding.top, 0f) * num;

        vectorOffset.y += this.scrollPosition * num;
        Color32 defaultColor = (!base.IsEnabled) ? base.DisabledColor : this.ItemTextColor;
        float   num2         = vector.y * num;
        float   num3         = num2 - this.size.y * num;

        for (int i = 0; i < this.items.Length; i++)
        {
            using (global::dfFontRendererBase dfFontRendererBase = this.font.ObtainRenderer())
            {
                dfFontRendererBase.WordWrap             = false;
                dfFontRendererBase.MaxSize              = maxSize;
                dfFontRendererBase.PixelRatio           = num;
                dfFontRendererBase.TextScale            = this.ItemTextScale * this.getTextScaleMultiplier();
                dfFontRendererBase.VectorOffset         = vectorOffset;
                dfFontRendererBase.MultiLine            = false;
                dfFontRendererBase.TextAlign            = this.ItemAlignment;
                dfFontRendererBase.ProcessMarkup        = true;
                dfFontRendererBase.DefaultColor         = defaultColor;
                dfFontRendererBase.OverrideMarkupColors = false;
                dfFontRendererBase.Opacity              = base.CalculateOpacity();
                dfFontRendererBase.Shadow       = this.Shadow;
                dfFontRendererBase.ShadowColor  = this.ShadowColor;
                dfFontRendererBase.ShadowOffset = this.ShadowOffset;
                global::dfDynamicFont.DynamicFontRenderer dynamicFontRenderer = dfFontRendererBase as global::dfDynamicFont.DynamicFontRenderer;
                if (dynamicFontRenderer != null)
                {
                    dynamicFontRenderer.SpriteAtlas  = base.Atlas;
                    dynamicFontRenderer.SpriteBuffer = this.renderData;
                }
                if (vectorOffset.y - (float)this.itemHeight * num <= num2)
                {
                    dfFontRendererBase.Render(this.items[i], buffer);
                }
                vectorOffset.y -= (float)this.itemHeight * num;
                dfFontRendererBase.VectorOffset = vectorOffset;
                if (vectorOffset.y < num3)
                {
                    break;
                }
            }
        }
    }
 // 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;
     }
 }
    // Token: 0x06004252 RID: 16978 RVA: 0x000F3FA8 File Offset: 0x000F21A8
    private global::dfFontRendererBase obtainRenderer()
    {
        bool    flag    = base.Size.sqrMagnitude <= float.Epsilon;
        Vector2 vector  = base.Size - new Vector2((float)this.padding.horizontal, (float)this.padding.vertical);
        Vector2 maxSize = (!this.autoSize && !flag) ? vector : this.getAutoSizeDefault();

        if (this.autoHeight)
        {
            maxSize..ctor(vector.x, 2.14748365E+09f);
        }
        float   num     = base.PixelsToUnits();
        Vector3 vector2 = (this.pivot.TransformToUpperLeft(base.Size) + new Vector3((float)this.padding.left, (float)(-(float)this.padding.top))) * num;
        float   num2    = this.TextScale * this.getTextScaleMultiplier();
        global::dfFontRendererBase dfFontRendererBase = this.Font.ObtainRenderer();

        dfFontRendererBase.WordWrap             = this.WordWrap;
        dfFontRendererBase.MaxSize              = maxSize;
        dfFontRendererBase.PixelRatio           = num;
        dfFontRendererBase.TextScale            = num2;
        dfFontRendererBase.CharacterSpacing     = this.CharacterSpacing;
        dfFontRendererBase.VectorOffset         = vector2.Quantize(num);
        dfFontRendererBase.MultiLine            = true;
        dfFontRendererBase.TabSize              = this.TabSize;
        dfFontRendererBase.TabStops             = this.TabStops;
        dfFontRendererBase.TextAlign            = ((!this.autoSize) ? this.TextAlignment : 0);
        dfFontRendererBase.ColorizeSymbols      = this.ColorizeSymbols;
        dfFontRendererBase.ProcessMarkup        = this.ProcessMarkup;
        dfFontRendererBase.DefaultColor         = ((!base.IsEnabled) ? base.DisabledColor : base.Color);
        dfFontRendererBase.BottomColor          = ((!this.enableGradient) ? null : new Color32?(this.BottomColor));
        dfFontRendererBase.OverrideMarkupColors = !base.IsEnabled;
        dfFontRendererBase.Opacity              = base.CalculateOpacity();
        dfFontRendererBase.Outline              = this.Outline;
        dfFontRendererBase.OutlineSize          = this.OutlineSize;
        dfFontRendererBase.OutlineColor         = this.OutlineColor;
        dfFontRendererBase.Shadow       = this.Shadow;
        dfFontRendererBase.ShadowColor  = this.ShadowColor;
        dfFontRendererBase.ShadowOffset = this.ShadowOffset;
        global::dfDynamicFont.DynamicFontRenderer dynamicFontRenderer = dfFontRendererBase as global::dfDynamicFont.DynamicFontRenderer;
        if (dynamicFontRenderer != null)
        {
            dynamicFontRenderer.SpriteAtlas  = this.Atlas;
            dynamicFontRenderer.SpriteBuffer = this.renderData;
        }
        if (this.vertAlign != global::dfVerticalAlignment.Top)
        {
            dfFontRendererBase.VectorOffset = this.getVertAlignOffset(dfFontRendererBase);
        }
        return(dfFontRendererBase);
    }
    // Token: 0x06003EDD RID: 16093 RVA: 0x000E4E14 File Offset: 0x000E3014
    private global::dfRenderData renderText()
    {
        if (this.Font == null || !this.Font.IsValid || string.IsNullOrEmpty(this.Text))
        {
            return(null);
        }
        global::dfRenderData renderData = this.renderData;

        if (this.font is global::dfDynamicFont)
        {
            global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)this.font;
            renderData = this.textRenderData;
            renderData.Clear();
            renderData.Material = dfDynamicFont.Material;
        }
        using (global::dfFontRendererBase dfFontRendererBase = this.obtainTextRenderer())
        {
            dfFontRendererBase.Render(this.text, renderData);
        }
        return(renderData);
    }
    // Token: 0x06004053 RID: 16467 RVA: 0x000EBA00 File Offset: 0x000E9C00
    private void renderText(global::dfRenderData buffer)
    {
        if (this.selectedIndex < 0 || this.selectedIndex >= this.items.Length)
        {
            return;
        }
        string  text = this.items[this.selectedIndex];
        float   num  = base.PixelsToUnits();
        Vector2 maxSize;

        maxSize..ctor(this.size.x - (float)this.textFieldPadding.horizontal, this.size.y - (float)this.textFieldPadding.vertical);
        Vector3 vector       = this.pivot.TransformToUpperLeft(base.Size);
        Vector3 vectorOffset = new Vector3(vector.x + (float)this.textFieldPadding.left, vector.y - (float)this.textFieldPadding.top, 0f) * num;
        Color32 defaultColor = (!base.IsEnabled) ? base.DisabledColor : this.TextColor;

        using (global::dfFontRendererBase dfFontRendererBase = this.font.ObtainRenderer())
        {
            dfFontRendererBase.WordWrap             = false;
            dfFontRendererBase.MaxSize              = maxSize;
            dfFontRendererBase.PixelRatio           = num;
            dfFontRendererBase.TextScale            = this.TextScale;
            dfFontRendererBase.VectorOffset         = vectorOffset;
            dfFontRendererBase.MultiLine            = false;
            dfFontRendererBase.TextAlign            = 0;
            dfFontRendererBase.ProcessMarkup        = true;
            dfFontRendererBase.DefaultColor         = defaultColor;
            dfFontRendererBase.OverrideMarkupColors = false;
            dfFontRendererBase.Opacity              = base.CalculateOpacity();
            dfFontRendererBase.Shadow       = this.Shadow;
            dfFontRendererBase.ShadowColor  = this.ShadowColor;
            dfFontRendererBase.ShadowOffset = this.ShadowOffset;
            global::dfDynamicFont.DynamicFontRenderer dynamicFontRenderer = dfFontRendererBase as global::dfDynamicFont.DynamicFontRenderer;
            if (dynamicFontRenderer != null)
            {
                dynamicFontRenderer.SpriteAtlas  = base.Atlas;
                dynamicFontRenderer.SpriteBuffer = buffer;
            }
            dfFontRendererBase.Render(text, buffer);
        }
    }
    // 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);
            }
        }
    }
    // Token: 0x06003EDE RID: 16094 RVA: 0x000E4ED4 File Offset: 0x000E30D4
    private global::dfFontRendererBase obtainTextRenderer()
    {
        Vector2 vector       = base.Size - new Vector2((float)this.padding.horizontal, (float)this.padding.vertical);
        Vector2 maxSize      = (!this.autoSize) ? vector : (Vector2.one * 2.14748365E+09f);
        float   num          = base.PixelsToUnits();
        Vector3 vector2      = (this.pivot.TransformToUpperLeft(base.Size) + new Vector3((float)this.padding.left, (float)(-(float)this.padding.top))) * num;
        float   num2         = this.TextScale * this.getTextScaleMultiplier();
        Color32 defaultColor = base.ApplyOpacity(this.getTextColorForState());
        global::dfFontRendererBase dfFontRendererBase = this.Font.ObtainRenderer();

        dfFontRendererBase.WordWrap             = this.WordWrap;
        dfFontRendererBase.MultiLine            = this.WordWrap;
        dfFontRendererBase.MaxSize              = maxSize;
        dfFontRendererBase.PixelRatio           = num;
        dfFontRendererBase.TextScale            = num2;
        dfFontRendererBase.CharacterSpacing     = 0;
        dfFontRendererBase.VectorOffset         = vector2.Quantize(num);
        dfFontRendererBase.TabSize              = 0;
        dfFontRendererBase.TextAlign            = ((!this.autoSize) ? this.TextAlignment : 0);
        dfFontRendererBase.ProcessMarkup        = true;
        dfFontRendererBase.DefaultColor         = defaultColor;
        dfFontRendererBase.OverrideMarkupColors = false;
        dfFontRendererBase.Opacity              = base.CalculateOpacity();
        dfFontRendererBase.Shadow       = this.Shadow;
        dfFontRendererBase.ShadowColor  = this.ShadowColor;
        dfFontRendererBase.ShadowOffset = this.ShadowOffset;
        global::dfDynamicFont.DynamicFontRenderer dynamicFontRenderer = dfFontRendererBase as global::dfDynamicFont.DynamicFontRenderer;
        if (dynamicFontRenderer != null)
        {
            dynamicFontRenderer.SpriteAtlas  = base.Atlas;
            dynamicFontRenderer.SpriteBuffer = this.renderData;
        }
        if (this.vertAlign != global::dfVerticalAlignment.Top)
        {
            dfFontRendererBase.VectorOffset = this.getVertAlignOffset(dfFontRendererBase);
        }
        return(dfFontRendererBase);
    }
    // Token: 0x06004257 RID: 16983 RVA: 0x000F44B4 File Offset: 0x000F26B4
    public global::dfList <global::dfRenderData> RenderMultiple()
    {
        global::dfList <global::dfRenderData> result;

        try
        {
            if (this.Atlas == null || this.Font == null || !this.isVisible || !this.Font.IsValid)
            {
                result = null;
            }
            else
            {
                if (this.renderData == null)
                {
                    this.renderData           = global::dfRenderData.Obtain();
                    this.textRenderData       = global::dfRenderData.Obtain();
                    this.isControlInvalidated = true;
                }
                if (!this.isControlInvalidated)
                {
                    for (int i = 0; i < this.buffers.Count; i++)
                    {
                        this.buffers[i].Transform = base.transform.localToWorldMatrix;
                    }
                    result = this.buffers;
                }
                else
                {
                    this.buffers.Clear();
                    this.renderData.Clear();
                    this.renderData.Material  = this.Atlas.Material;
                    this.renderData.Transform = base.transform.localToWorldMatrix;
                    this.buffers.Add(this.renderData);
                    this.textRenderData.Clear();
                    this.textRenderData.Material  = this.Atlas.Material;
                    this.textRenderData.Transform = base.transform.localToWorldMatrix;
                    this.buffers.Add(this.textRenderData);
                    this.renderBackground();
                    if (string.IsNullOrEmpty(this.Text))
                    {
                        if (this.AutoSize || this.AutoHeight)
                        {
                            base.Height = (float)Mathf.CeilToInt((float)this.Font.LineHeight * this.TextScale);
                        }
                        result = this.buffers;
                    }
                    else
                    {
                        bool flag = this.size.sqrMagnitude <= float.Epsilon;
                        using (global::dfFontRendererBase dfFontRendererBase = this.obtainRenderer())
                        {
                            dfFontRendererBase.Render(this.text, this.textRenderData);
                            if (this.AutoSize || flag)
                            {
                                base.Size = (dfFontRendererBase.RenderedSize + new Vector2((float)this.padding.horizontal, (float)this.padding.vertical)).CeilToInt();
                            }
                            else if (this.AutoHeight)
                            {
                                base.Size = new Vector2(this.size.x, dfFontRendererBase.RenderedSize.y + (float)this.padding.vertical).CeilToInt();
                            }
                        }
                        this.updateCollider();
                        result = this.buffers;
                    }
                }
            }
        }
        finally
        {
            this.isControlInvalidated = false;
        }
        return(result);
    }