clang-tidy modernize
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "text.h"
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_GetRenderTarget, Uint8
|
||||
#include <stddef.h> // Para size_t
|
||||
|
||||
#include <cstddef> // Para size_t
|
||||
#include <fstream> // Para basic_ifstream, basic_istream, basic_ostream
|
||||
#include <iostream> // Para cerr
|
||||
#include <stdexcept> // Para runtime_error
|
||||
@@ -13,14 +13,14 @@
|
||||
#include "utils.h" // Para Color, getFileName, printWithDots
|
||||
|
||||
// Llena una estructuta TextFile desde un fichero
|
||||
std::shared_ptr<TextFile> loadTextFile(const std::string &file_path) {
|
||||
auto loadTextFile(const std::string &file_path) -> std::shared_ptr<TextFile> {
|
||||
auto tf = std::make_shared<TextFile>();
|
||||
|
||||
// Inicializa a cero el vector con las coordenadas
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
tf->offset[i].x = 0;
|
||||
tf->offset[i].y = 0;
|
||||
tf->offset[i].w = 0;
|
||||
for (auto &i : tf->offset) {
|
||||
i.x = 0;
|
||||
i.y = 0;
|
||||
i.w = 0;
|
||||
tf->box_width = 0;
|
||||
tf->box_height = 0;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void Text::write2X(int x, int y, const std::string &text, int kerning) {
|
||||
}
|
||||
|
||||
// Escribe el texto en una textura
|
||||
std::shared_ptr<Texture> Text::writeToTexture(const std::string &text, int zoom, int kerning) {
|
||||
auto Text::writeToTexture(const std::string &text, int zoom, int kerning) -> std::shared_ptr<Texture> {
|
||||
auto renderer = Screen::get()->getRenderer();
|
||||
auto texture = std::make_shared<Texture>(renderer);
|
||||
auto width = lenght(text, kerning) * zoom;
|
||||
@@ -159,7 +159,7 @@ std::shared_ptr<Texture> Text::writeToTexture(const std::string &text, int zoom,
|
||||
}
|
||||
|
||||
// Escribe el texto con extras en una textura
|
||||
std::shared_ptr<Texture> Text::writeDXToTexture(Uint8 flags, const std::string &text, int kerning, Color text_color, Uint8 shadow_distance, Color shadow_color, int lenght) {
|
||||
auto Text::writeDXToTexture(Uint8 flags, const std::string &text, int kerning, Color text_color, Uint8 shadow_distance, Color shadow_color, int lenght) -> std::shared_ptr<Texture> {
|
||||
auto renderer = Screen::get()->getRenderer();
|
||||
auto texture = std::make_shared<Texture>(renderer);
|
||||
auto width = Text::lenght(text, kerning) + shadow_distance;
|
||||
@@ -230,7 +230,7 @@ void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerni
|
||||
}
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int Text::lenght(const std::string &text, int kerning) const {
|
||||
auto Text::lenght(const std::string &text, int kerning) const -> int {
|
||||
int shift = 0;
|
||||
for (size_t i = 0; i < text.length(); ++i)
|
||||
shift += (offset_[static_cast<int>(text[i])].w + kerning);
|
||||
@@ -240,7 +240,7 @@ int Text::lenght(const std::string &text, int kerning) const {
|
||||
}
|
||||
|
||||
// Devuelve el valor de la variable
|
||||
int Text::getCharacterSize() const {
|
||||
auto Text::getCharacterSize() const -> int {
|
||||
return box_width_;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user