renomena tipus _t/_e a CamelCase (Circle, Color, Section, ...)
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/resource_helper.h" // for loadFile (pack + filesystem fallback)
|
||||
#include "utils/utils.h" // for color_t
|
||||
#include "utils/utils.h" // for Color
|
||||
|
||||
// Parser compartido: rellena un textFile_t desde cualquier istream
|
||||
static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {
|
||||
// Parser compartido: rellena un TextFile desde cualquier istream
|
||||
static void parseTextFileStream(std::istream &rfile, TextFile &tf) {
|
||||
std::string buffer;
|
||||
std::getline(rfile, buffer);
|
||||
std::getline(rfile, buffer);
|
||||
@@ -32,22 +32,22 @@ static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {
|
||||
}
|
||||
}
|
||||
|
||||
static void computeTextFileOffsets(textFile_t &tf) {
|
||||
static void computeTextFileOffsets(TextFile &tf) {
|
||||
for (int i = 32; i < 128; ++i) {
|
||||
tf.offset[i].x = ((i - 32) % 15) * tf.boxWidth;
|
||||
tf.offset[i].y = ((i - 32) / 15) * tf.boxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Llena una estructuta textFile_t desde un fichero (vía ResourceHelper: pack o filesystem)
|
||||
auto LoadTextFile(const std::string &file, bool verbose) -> textFile_t {
|
||||
// Llena una estructuta TextFile desde un fichero (vía ResourceHelper: pack o filesystem)
|
||||
auto LoadTextFile(const std::string &file, bool verbose) -> TextFile {
|
||||
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
||||
auto bytes = ResourceHelper::loadFile(file);
|
||||
if (bytes.empty()) {
|
||||
if (verbose) {
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
|
||||
}
|
||||
textFile_t tf;
|
||||
TextFile tf;
|
||||
tf.boxWidth = 0;
|
||||
tf.boxHeight = 0;
|
||||
for (auto &i : tf.offset) {
|
||||
@@ -64,9 +64,9 @@ auto LoadTextFile(const std::string &file, bool verbose) -> textFile_t {
|
||||
return LoadTextFileFromMemory(bytes, verbose);
|
||||
}
|
||||
|
||||
// Llena una estructura textFile_t desde bytes en memoria
|
||||
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) -> textFile_t {
|
||||
textFile_t tf;
|
||||
// Llena una estructura TextFile desde bytes en memoria
|
||||
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) -> TextFile {
|
||||
TextFile tf;
|
||||
tf.boxWidth = 0;
|
||||
tf.boxHeight = 0;
|
||||
for (auto &i : tf.offset) {
|
||||
@@ -89,7 +89,7 @@ auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) ->
|
||||
// Constructor
|
||||
Text::Text(const std::string &bitmapFile, const std::string &textFile, SDL_Renderer *renderer) {
|
||||
// Carga los offsets desde el fichero
|
||||
textFile_t tf = LoadTextFile(textFile);
|
||||
TextFile tf = LoadTextFile(textFile);
|
||||
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = tf.boxHeight;
|
||||
@@ -111,7 +111,7 @@ Text::Text(const std::string &bitmapFile, const std::string &textFile, SDL_Rende
|
||||
// Constructor
|
||||
Text::Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
// Carga los offsets desde el fichero
|
||||
textFile_t tf = LoadTextFile(textFile);
|
||||
TextFile tf = LoadTextFile(textFile);
|
||||
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = tf.boxHeight;
|
||||
@@ -131,7 +131,7 @@ Text::Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
Text::Text(TextFile *textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
// Inicializa variables desde la estructura
|
||||
boxHeight = textFile->boxHeight;
|
||||
boxWidth = textFile->boxWidth;
|
||||
@@ -151,7 +151,7 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) {
|
||||
|
||||
// Constructor desde bytes
|
||||
Text::Text(const std::vector<uint8_t> &pngBytes, const std::vector<uint8_t> &txtBytes, SDL_Renderer *renderer) {
|
||||
textFile_t tf = LoadTextFileFromMemory(txtBytes);
|
||||
TextFile tf = LoadTextFileFromMemory(txtBytes);
|
||||
boxHeight = tf.boxHeight;
|
||||
boxWidth = tf.boxWidth;
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
@@ -195,14 +195,14 @@ void Text::write(int x, int y, const std::string &text, int kerning, int lenght)
|
||||
}
|
||||
|
||||
// Escribe el texto con colores
|
||||
void Text::writeColored(int x, int y, const std::string &text, color_t color, int kerning, int lenght) {
|
||||
void Text::writeColored(int x, int y, const std::string &text, Color color, int kerning, int lenght) {
|
||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||
write(x, y, text, kerning, lenght);
|
||||
sprite->getTexture()->setColor(255, 255, 255);
|
||||
}
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void Text::writeShadowed(int x, int y, const std::string &text, color_t color, Uint8 shadowDistance, int kerning, int lenght) {
|
||||
void Text::writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadowDistance, int kerning, int lenght) {
|
||||
sprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||
write(x + shadowDistance, y + shadowDistance, text, kerning, lenght);
|
||||
sprite->getTexture()->setColor(255, 255, 255);
|
||||
@@ -216,7 +216,7 @@ void Text::writeCentered(int x, int y, const std::string &text, int kerning, int
|
||||
}
|
||||
|
||||
// Escribe texto con extras
|
||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, color_t textColor, Uint8 shadowDistance, color_t shadowColor, int lenght) {
|
||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color textColor, Uint8 shadowDistance, Color shadowColor, int lenght) {
|
||||
const bool centered = ((flags & TXT_CENTER) == TXT_CENTER);
|
||||
const bool shadowed = ((flags & TXT_SHADOW) == TXT_SHADOW);
|
||||
const bool colored = ((flags & TXT_COLOR) == TXT_COLOR);
|
||||
|
||||
Reference in New Issue
Block a user