Esempio n. 1
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: 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: 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);
    }