public Texture2D PrepareResource(string text, System.Drawing.Font font)
        {
            int identifier = HashCode.Combine(text, font);

            if (!currentResources.TryGetValue(identifier, out Texture2D texture))
            {
                if (!previousResources.TryGetValue(identifier, out texture))
                {
                    texture = TextTextureRenderer.Resize(text, font, Game.GraphicsDevice, measureGraphics);
                    TextTextureRenderer.RenderText(text, font, texture);
                    currentResources.Add(identifier, texture);
                }
                else
                {
                    currentResources.Add(identifier, texture);
                    previousResources.Remove(identifier);
                }
            }
            return(texture);
        }
Beispiel #2
0
 protected virtual void Resize(string text)
 {
     TextTextureRenderer.Resize(text, font, ref texture, Game.GraphicsDevice);
 }