forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "core/rendering/text.hpp"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#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/utils.hpp" // Para getFileName, stringToColor, 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;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ std::shared_ptr<TextFile> loadTextFile(const std::string& file_path) {
|
||||
|
||||
// El fichero no se puede abrir
|
||||
else {
|
||||
std::cerr << "Error: Fichero no encontrado " << getFileName(file_path) << std::endl;
|
||||
std::cerr << "Error: Fichero no encontrado " << getFileName(file_path) << '\n';
|
||||
throw std::runtime_error("Fichero no encontrado: " + getFileName(file_path));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ std::shared_ptr<TextFile> loadTextFile(const std::string& file_path) {
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(std::shared_ptr<Surface> surface, const std::string& text_file) {
|
||||
Text::Text(const std::shared_ptr<Surface>& surface, const std::string& text_file) {
|
||||
// Carga los offsets desde el fichero
|
||||
auto tf = loadTextFile(text_file);
|
||||
|
||||
@@ -96,7 +96,7 @@ Text::Text(std::shared_ptr<Surface> surface, const std::string& text_file) {
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Text::Text(std::shared_ptr<Surface> surface, std::shared_ptr<TextFile> text_file) {
|
||||
Text::Text(const std::shared_ptr<Surface>& surface, const std::shared_ptr<TextFile>& text_file) {
|
||||
// Inicializa variables desde la estructura
|
||||
box_height_ = text_file->box_height;
|
||||
box_width_ = text_file->box_width;
|
||||
@@ -132,7 +132,7 @@ void Text::write(int x, int y, const std::string& text, int kerning, int lenght)
|
||||
}
|
||||
|
||||
// Escribe el texto en una surface
|
||||
std::shared_ptr<Surface> Text::writeToSurface(const std::string& text, int zoom, int kerning) {
|
||||
auto Text::writeToSurface(const std::string& text, int zoom, int kerning) -> std::shared_ptr<Surface> {
|
||||
auto width = lenght(text, kerning) * zoom;
|
||||
auto height = box_height_ * zoom;
|
||||
auto surface = std::make_shared<Surface>(width, height);
|
||||
@@ -146,7 +146,7 @@ std::shared_ptr<Surface> Text::writeToSurface(const std::string& text, int zoom,
|
||||
}
|
||||
|
||||
// Escribe el texto con extras en una surface
|
||||
std::shared_ptr<Surface> Text::writeDXToSurface(Uint8 flags, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int lenght) {
|
||||
auto Text::writeDXToSurface(Uint8 flags, const std::string& text, int kerning, Uint8 text_color, Uint8 shadow_distance, Uint8 shadow_color, int lenght) -> std::shared_ptr<Surface> {
|
||||
auto width = Text::lenght(text, kerning) + shadow_distance;
|
||||
auto height = box_height_ + shadow_distance;
|
||||
auto surface = std::make_shared<Surface>(width, height);
|
||||
@@ -223,7 +223,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);
|
||||
@@ -234,7 +234,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