forked from jaildesigner-jailgames/jaildoctors_dilemma
Cambiado el nombre de la carpeta utils a common
This commit is contained in:
69
source/common/text.h
Normal file
69
source/common/text.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include "sprite.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef TEXT_H
|
||||
#define TEXT_H
|
||||
|
||||
#define TXT_COLOR 1
|
||||
#define TXT_SHADOW 2
|
||||
#define TXT_CENTER 4
|
||||
#define TXT_STROKE 8
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||
class Text
|
||||
{
|
||||
private:
|
||||
struct offset_t
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
};
|
||||
|
||||
// Objetos
|
||||
Sprite *sprite; // Objeto con los graficos para el texto
|
||||
LTexture *texture; // Textura con los bitmaps del texto
|
||||
|
||||
// Variables
|
||||
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||
int boxHeight; // Altura de la caja de cada caracter en el png
|
||||
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
|
||||
// Inicializa el vector de offsets desde un fichero
|
||||
void initOffsetFromFile(std::string file);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Text();
|
||||
|
||||
// Escribe el texto en pantalla
|
||||
void write(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, std::string text, color_t color, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void writeShadowed(int x, int y, std::string text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto centrado en un punto x
|
||||
void writeCentered(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 1, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1);
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int lenght(std::string text, int kerning = 1);
|
||||
|
||||
// Devuelve el valor de la variable
|
||||
int getCharacterSize();
|
||||
|
||||
// Recarga la textura
|
||||
void reLoadTexture();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user