clang-tidy modernize

This commit is contained in:
2025-07-20 12:51:24 +02:00
parent bfda842d3c
commit 1f0184fde2
74 changed files with 658 additions and 665 deletions

View File

@@ -2,23 +2,24 @@
#include "texture.h"
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, Uint8, SDL_...
#include <stdint.h> // Para uint32_t
#include <cstdint> // Para uint32_t
#include <cstring> // Para memcpy
#include <fstream> // Para basic_ifstream, basic_istream, basic_ios
#include <sstream> // Para basic_istringstream
#include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, char_traits, operator+, string
#include <vector> // Para vector
#include <utility>
#include <vector> // Para vector
#include "external/gif.h" // Para Gif
#include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_alpha
#include "utils.h" // Para getFileName, Color, printWithDots
// Constructor
Texture::Texture(SDL_Renderer *renderer, const std::string &path)
Texture::Texture(SDL_Renderer *renderer, std::string path)
: renderer_(renderer),
path_(path) {
path_(std::move(path)) {
// Carga el fichero en la textura
if (!path_.empty()) {
// Obtiene la extensión
@@ -53,7 +54,7 @@ Texture::~Texture() {
}
// Carga una imagen desde un fichero
bool Texture::loadFromFile(const std::string &file_path) {
auto Texture::loadFromFile(const std::string &file_path) -> bool {
if (file_path.empty())
return false;
@@ -106,7 +107,7 @@ bool Texture::loadFromFile(const std::string &file_path) {
}
// Crea una textura en blanco
bool Texture::createBlank(int width, int height, SDL_PixelFormat format, SDL_TextureAccess access) {
auto Texture::createBlank(int width, int height, SDL_PixelFormat format, SDL_TextureAccess access) -> bool {
// Crea una textura sin inicializar
texture_ = SDL_CreateTexture(renderer_, format, access, width, height);
if (!texture_) {
@@ -179,22 +180,22 @@ void Texture::setAsRenderTarget(SDL_Renderer *renderer) {
}
// Obtiene el ancho de la imagen
int Texture::getWidth() {
auto Texture::getWidth() -> int {
return width_;
}
// Obtiene el alto de la imagen
int Texture::getHeight() {
auto Texture::getHeight() -> int {
return height_;
}
// Recarga la textura
bool Texture::reLoad() {
auto Texture::reLoad() -> bool {
return loadFromFile(path_);
}
// Obtiene la textura
SDL_Texture *Texture::getSDLTexture() {
auto Texture::getSDLTexture() -> SDL_Texture * {
return texture_;
}
@@ -206,7 +207,7 @@ void Texture::unloadSurface() {
}
// Crea una surface desde un fichero .gif
std::shared_ptr<Surface> Texture::loadSurface(const std::string &file_path) {
auto Texture::loadSurface(const std::string &file_path) -> std::shared_ptr<Surface> {
// Libera la superficie actual
unloadSurface();
@@ -277,7 +278,7 @@ void Texture::setPaletteColor(int palette, int index, Uint32 color) {
}
// Carga una paleta desde un fichero
Palette Texture::loadPaletteFromFile(const std::string &file_path) {
auto Texture::loadPaletteFromFile(const std::string &file_path) -> Palette {
Palette palette;
// Abrir el archivo GIF
@@ -337,10 +338,10 @@ void Texture::setPalette(size_t palette) {
}
// Obtiene el renderizador
SDL_Renderer *Texture::getRenderer() { return renderer_; }
auto Texture::getRenderer() -> SDL_Renderer * { return renderer_; }
// Carga una paleta desde un archivo .pal
Palette Texture::readPalFile(const std::string &file_path) {
auto Texture::readPalFile(const std::string &file_path) -> Palette {
Palette palette{};
palette.fill(0); // Inicializar todo con 0 (transparente por defecto)