neteja tidy a source/core i encamina Texture::loadFromFile pel ResourceHelper

This commit is contained in:
2026-05-14 20:22:54 +02:00
parent 88fa3f296f
commit 1912200b21
40 changed files with 699 additions and 578 deletions
+16 -18
View File
@@ -1,8 +1,8 @@
#include "core/resources/asset.h"
#include <SDL3/SDL.h>
#include <stddef.h> // for size_t
#include <cstddef> // for size_t
#include <iostream> // for basic_ostream, operator<<, cout, endl
#include "core/resources/resource_helper.h"
@@ -26,9 +26,7 @@ auto Asset::get() -> Asset * {
// Constructor
Asset::Asset(const std::string &executablePath)
: longestName(0),
executablePath(executablePath.substr(0, executablePath.find_last_of("\\/"))),
verbose(true) {
: executablePath(executablePath.substr(0, executablePath.find_last_of("\\/"))) {
}
// Añade un elemento a la lista
@@ -44,10 +42,10 @@ void Asset::add(const std::string &file, enum assetType type, bool required, boo
}
// Devuelve el fichero de un elemento de la lista a partir de una cadena
std::string Asset::get(const std::string &text) {
auto Asset::get(const std::string &text) -> std::string {
for (const auto &f : fileList) {
const size_t lastIndex = f.file.find_last_of("/") + 1;
const std::string file = f.file.substr(lastIndex, std::string::npos);
const size_t lastIndex = f.file.find_last_of('/') + 1;
const std::string file = f.file.substr(lastIndex);
if (file == text) {
return f.file;
@@ -55,20 +53,20 @@ std::string Asset::get(const std::string &text) {
}
if (verbose) {
std::cout << "Warning: file " << text.c_str() << " not found" << std::endl;
std::cout << "Warning: file " << text.c_str() << " not found" << '\n';
}
return "";
}
// Comprueba que existen todos los elementos
bool Asset::check() {
auto Asset::check() -> bool {
bool success = true;
if (verbose) {
std::cout << "\n** Checking files" << std::endl;
std::cout << "\n** Checking files" << '\n';
std::cout << "Executable path is: " << executablePath << std::endl;
std::cout << "Sample filepath: " << fileList.back().file << std::endl;
std::cout << "Executable path is: " << executablePath << '\n';
std::cout << "Sample filepath: " << fileList.back().file << '\n';
}
// Comprueba la lista de ficheros clasificandolos por tipo
@@ -85,7 +83,7 @@ bool Asset::check() {
// Si hay ficheros de ese tipo, comprueba si existen
if (any) {
if (verbose) {
std::cout << "\n>> " << getTypeName(type).c_str() << " FILES" << std::endl;
std::cout << "\n>> " << getTypeName(type).c_str() << " FILES" << '\n';
}
for (const auto &f : fileList) {
@@ -100,10 +98,10 @@ bool Asset::check() {
if (verbose) {
if (success) {
std::cout << "\n** All files OK.\n"
<< std::endl;
<< '\n';
} else {
std::cout << "\n** A file is missing. Exiting.\n"
<< std::endl;
<< '\n';
}
}
@@ -111,7 +109,7 @@ bool Asset::check() {
}
// Comprueba que existe un fichero
bool Asset::checkFile(const std::string &path) {
auto Asset::checkFile(const std::string &path) const -> bool {
bool success = false;
std::string result = "ERROR";
@@ -138,14 +136,14 @@ bool Asset::checkFile(const std::string &path) {
std::cout.width(longestName + 2);
std::cout.fill('.');
std::cout << filename + " ";
std::cout << " [" + result + "]" << std::endl;
std::cout << " [" + result + "]" << '\n';
}
return success;
}
// Devuelve el nombre del tipo de recurso
std::string Asset::getTypeName(int type) {
auto Asset::getTypeName(int type) -> std::string {
switch (type) {
case t_bitmap:
return "BITMAP";