forked from jaildesigner-jailgames/jaildoctors_dilemma
Ya permite establecer el online ID desde el propio juego
This commit is contained in:
@@ -94,6 +94,9 @@ Text::Text(std::string textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
|
||||
// Crea los objetos
|
||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
@@ -111,6 +114,9 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
||||
|
||||
// Crea los objetos
|
||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
||||
|
||||
// Inicializa variables
|
||||
fixedWidth = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -133,7 +139,8 @@ void Text::write(int x, int y, std::string text, int kerning, int lenght)
|
||||
sprite->setPosX(x + shift);
|
||||
sprite->setPosY(y);
|
||||
sprite->render();
|
||||
shift += (offset[int(text[i])].w + kerning);
|
||||
// shift += (offset[int(text[i])].w + kerning);
|
||||
shift += fixedWidth ? boxWidth : (offset[int(text[i])].w + kerning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,4 +232,10 @@ int Text::getCharacterSize()
|
||||
void Text::reLoadTexture()
|
||||
{
|
||||
sprite->getTexture()->reLoad();
|
||||
}
|
||||
|
||||
// Establece si se usa un tamaño fijo de letra
|
||||
void Text::setFixedWidth(bool value)
|
||||
{
|
||||
fixedWidth = value;
|
||||
}
|
||||
@@ -33,11 +33,12 @@ class Text
|
||||
{
|
||||
private:
|
||||
// Objetos y punteros
|
||||
Sprite *sprite; // Objeto con los graficos para el texto
|
||||
Sprite *sprite; // Objeto con los graficos para el 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
|
||||
bool fixedWidth; // Indica si el texto se ha de escribir con longitud fija en todas las letras
|
||||
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
|
||||
public:
|
||||
@@ -71,6 +72,9 @@ public:
|
||||
|
||||
// Recarga la textura
|
||||
void reLoadTexture();
|
||||
|
||||
// Establece si se usa un tamaño fijo de letra
|
||||
void setFixedWidth(bool value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user