예제 #1
0
 /// <summary>
 /// Instancia a classe.
 /// </summary>
 public EngineLabel() : base()
 {
     Text             = string.Empty;
     TextColor        = Color.White;
     TextVisible      = true;
     TextTransparency = byte.MaxValue;
     TextFontStyle    = EngineFontStyle.Regular;
 }
예제 #2
0
 /// <summary>
 /// Carrega um novo arquivo com tamanho definido.
 /// </summary>
 /// <param name="file">Arquivo</param>
 /// <param name="width">Comprimento</param>
 /// <param name="height">Altura</param>
 public EngineLabel(string file, int width, int height)
 {
     Text             = string.Empty;
     TextColor        = Color.White;
     TextVisible      = true;
     TextTransparency = 255;
     TextFontStyle    = EngineFontStyle.Regular;
     Texture          = EngineTexture.TextureFromFile(file, width, height);
     Size             = new Size2(width, height);
     SourceRect       = new Rectangle(0, 0, width, height);
 }
예제 #3
0
        /// <summary>
        /// Carrega um novo arquivo com tamanho definido.
        /// </summary>
        /// <param name="file">Arquivo</param>
        /// <param name="width">Comprimento</param>
        /// <param name="height">Altura</param>
        public EngineLabel(string name, int width, int height) : base()
        {
            var language = Enum.GetName(typeof(Language), Common.Configuration.Language);

            Text             = string.Empty;
            TextColor        = Color.White;
            TextVisible      = true;
            TextTransparency = byte.MaxValue;
            TextFontStyle    = EngineFontStyle.Regular;
            Texture          = EngineTexture.TextureFromFile($"{Common.Configuration.GamePath}\\Data\\Graphics\\{name}.png", width, height);
            Size             = new Size2(width, height);
            SourceRect       = new Rectangle(0, 0, width, height);
        }
예제 #4
0
        /// <summary>
        /// Mede e retorna o comprimento e altura de um texto.
        /// </summary>
        /// <param name="style">Estilo</param>
        /// <param name="text">Texto</param>
        /// <param name="rect">Retangulo</param>
        /// <param name="textformat">Formato</param>
        /// <returns></returns>
        public static Rectangle MeasureString(Sprite sprite, EngineFontStyle style, string text, Rectangle rect, FontDrawFlags textformat)
        {
            if (style == EngineFontStyle.Regular)
            {
                return(regular.MeasureText(null, text, rect, textformat));
            }

            if (style == EngineFontStyle.Bold)
            {
                return(bold.MeasureText(null, text, rect, textformat));
            }

            if (style == EngineFontStyle.Italic)
            {
                return(italic.MeasureText(null, text, rect, textformat));
            }

            return(new Rectangle());
        }
예제 #5
0
        /// <summary>
        /// Desenha o texto na coordenada com quebra de linha.
        /// </summary>
        /// <param name="text">Texto</param>
        /// <param name="rec">Retângulo</param>
        /// <param name="color">Cor</param>
        /// <param name="style">Estilo</param>
        /// <param name="textformat">Formato</param>
        /// <param name="preload">Pré Carregamento</param>
        public static void DrawText(string text, Rectangle rec, Color color, EngineFontStyle style, FontDrawFlags textformat, bool preload = false)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            if (style == EngineFontStyle.Regular)
            {
                if (preload)
                {
                    regular.PreloadText(text);
                }

                regular.DrawText(null, text, rec, textformat, color);
                return;
            }

            if (style == EngineFontStyle.Bold)
            {
                if (preload)
                {
                    bold.PreloadText(text);
                }

                bold.DrawText(null, text, rec, textformat, color);
                return;
            }

            if (style == EngineFontStyle.Italic)
            {
                if (preload)
                {
                    italic.PreloadText(text);
                }

                italic.DrawText(null, text, rec, textformat, color);
            }
        }
예제 #6
0
        /// <summary>
        /// Desenha o texto na coordenada especificada.
        /// </summary>
        /// <param name="sprite">Dispositivo</param>
        /// <param name="text">Texto</param>
        /// <param name="x">Coordenada X</param>
        /// <param name="y">Coordenada Y</param>
        /// <param name="color">Cor</param>
        /// <param name="style">Estilo</param>
        /// <param name="preload">Pré Carregamento</param>
        public static void DrawText(string text, int x, int y, Color color, EngineFontStyle style, bool preload = false)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            if (style == EngineFontStyle.Regular)
            {
                if (preload)
                {
                    regular.PreloadText(text);
                }

                regular.DrawText(null, text, x, y, color);
                return;
            }

            if (style == EngineFontStyle.Bold)
            {
                if (preload)
                {
                    bold.PreloadText(text);
                }

                bold.DrawText(null, text, x, y, color);
                return;
            }

            if (style == EngineFontStyle.Italic)
            {
                if (preload)
                {
                    italic.PreloadText(text);
                }

                italic.DrawText(null, text, x, y, color);
            }
        }
예제 #7
0
        /// <summary>
        /// Desenha o texto centralizado.
        /// </summary>
        /// <param name="text">Texto</param>
        /// <param name="size">Tamanho</param>
        /// <param name="point">Posição</param>
        /// <param name="color">Cor</param>
        /// <param name="style">Estilo</param>
        /// <param name="textformat">Formato</param>
        /// <param name="preload">Pré Carregamento</param>
        public static void DrawText(string text, Size2 size, Point point, Color color, EngineFontStyle style, FontDrawFlags textformat, bool preload = false)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            if (style == EngineFontStyle.Regular)
            {
                rect = regular.MeasureText(null, text, textformat);
                if (preload)
                {
                    regular.PreloadText(text);
                }
                regular.DrawText(null, text, point.X + (size.Width - rect.Width) / 2, (point.Y - 5) + (size.Height - rect.Height) / 2, color);
                return;
            }

            if (style == EngineFontStyle.Bold)
            {
                rect = bold.MeasureText(null, text, textformat);
                if (preload)
                {
                    bold.PreloadText(text);
                }
                bold.DrawText(null, text, point.X + (size.Width - rect.Width) / 2, (point.Y - 5) + (size.Height - rect.Height) / 2, color);
                return;
            }

            if (style == EngineFontStyle.Italic)
            {
                rect = italic.MeasureText(null, text, textformat);
                if (preload)
                {
                    italic.PreloadText(text);
                }
                italic.DrawText(null, text, point.X + (size.Width - rect.Width) / 2, (point.Y - 5) + (size.Height - rect.Height) / 2, color);
            }
        }