This commit is contained in:
2025-10-27 18:35:53 +01:00
parent b1dca32a5b
commit 3179a08dac
63 changed files with 686 additions and 693 deletions

View File

@@ -21,7 +21,7 @@ void Asset::destroy() {
}
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
Asset* Asset::get() {
auto Asset::get() -> Asset* {
return Asset::asset;
}
@@ -32,23 +32,23 @@ void Asset::add(const std::string& file, AssetType type, bool required, bool abs
}
// Devuelve la ruta completa a un fichero a partir de una cadena
std::string Asset::get(const std::string& text) const {
auto it = std::find_if(file_list_.begin(), file_list_.end(), [&text](const auto& f) {
auto Asset::get(const std::string& text) const -> std::string {
auto it = std::ranges::find_if(file_list_, [&text](const auto& f) {
return getFileName(f.file) == text;
});
if (it != file_list_.end()) {
return it->file;
}
std::cout << "Warning: file " << text << " not found" << std::endl;
std::cout << "Warning: file " << text << " not found" << '\n';
return "";
}
// Comprueba que existen todos los elementos
bool Asset::check() const {
auto Asset::check() const -> bool {
bool success = true;
std::cout << "\n** CHECKING FILES" << std::endl;
std::cout << "\n** CHECKING FILES" << '\n';
// std::cout << "Executable path is: " << executable_path_ << std::endl;
// std::cout << "Sample filepath: " << file_list_.back().file << std::endl;
@@ -66,7 +66,7 @@ bool Asset::check() const {
// Si hay ficheros de ese tipo, comprueba si existen
if (any) {
std::cout << "\n>> " << getTypeName(static_cast<AssetType>(type)).c_str() << " FILES" << std::endl;
std::cout << "\n>> " << getTypeName(static_cast<AssetType>(type)).c_str() << " FILES" << '\n';
for (const auto& f : file_list_) {
if (f.required && f.type == static_cast<AssetType>(type)) {
@@ -74,19 +74,19 @@ bool Asset::check() const {
}
}
if (success) {
std::cout << " All files are OK." << std::endl;
std::cout << " All files are OK." << '\n';
}
}
}
// Resultado
std::cout << (success ? "\n** CHECKING FILES COMPLETED.\n" : "\n** CHECKING FILES FAILED.\n") << std::endl;
std::cout << (success ? "\n** CHECKING FILES COMPLETED.\n" : "\n** CHECKING FILES FAILED.\n") << '\n';
return success;
}
// Comprueba que existe un fichero
bool Asset::checkFile(const std::string& path) {
auto Asset::checkFile(const std::string& path) -> bool {
std::ifstream file(path);
bool success = file.good();
file.close();
@@ -99,7 +99,7 @@ bool Asset::checkFile(const std::string& path) {
}
// Devuelve el nombre del tipo de recurso
std::string Asset::getTypeName(AssetType type) {
auto Asset::getTypeName(AssetType type) -> std::string {
switch (type) {
case AssetType::DATA:
return "DATA";
@@ -144,10 +144,10 @@ std::string Asset::getTypeName(AssetType type) {
}
// Devuelve la lista de recursos de un tipo
std::vector<std::string> Asset::getListByType(AssetType type) const {
auto Asset::getListByType(AssetType type) const -> std::vector<std::string> {
std::vector<std::string> list;
for (auto f : file_list_) {
for (const auto& f : file_list_) {
if (f.type == type) {
list.push_back(f.file);
}