Пример #1
0
        protected virtual pTexture refreshTexture()
        {
            bool existed = false;

            pTexture old = localTexture;

            TextChanged = false;

            if (string.IsNullOrEmpty(Text) && TextBounds.X == 0)
            {
                lastMeasure = TextBounds;
                return(null);
            }

            renderingResolution = GameBase.WindowManager.Height;

            float   size   = (TextRenderSpecific ? (float)GameBase.WindowManager.Height / 768 : 1) * TextSize;
            Vector2 bounds = (TextRenderSpecific ? GameBase.WindowManager.Ratio : 1) * TextBounds;

            Vector4 corners = CornerBounds;
            Vector2 padding = Padding;

            if (corners != Vector4.Zero && TextRenderSpecific)
            {
                corners *= (float)GameBase.WindowManager.Height / 768;
            }

            if (Padding != Vector2.Zero)
            {
                padding *= (float)GameBase.WindowManager.Height / 768;
            }

            float borderWidth = BorderWidth;

            if (borderWidth > 0)
            {
                borderWidth *= (float)GameBase.WindowManager.Height / 768;
            }

            System.Drawing.RectangleF[] regions;
            localTexture = NativeText.CreateText(Text, size, bounds, TextColour, Shadow, TextBold, TextItalic, TextUnderline, TextAlignment,
                                                 TextAa, out lastMeasure, out regions, BackgroundColour, BorderColour, (int)Math.Round(borderWidth), false, false, fontFace, corners, padding, localTexture);

            if (old != null && localTexture != old)
            {
                old.Dispose();
            }

            if (aggressiveCleanup)
            {
                if (localTexture != null)
                {
                    localTexture.TrackAccessTime = true;
                }
                if (old != localTexture)
                {
                    DynamicSpriteCache.Load(this, true);
                }
            }

            DrawWidth  = (int)Math.Round(lastMeasure.X);
            DrawHeight = (int)Math.Round(lastMeasure.Y);

            UpdateTextureSize();
            UpdateTextureAlignment();

            if (OnRefreshTexture != null)
            {
                OnRefreshTexture(this, null);
            }

            return(localTexture);
        }