This commit is contained in:
2025-10-27 11:53:12 +01:00
parent 231dcd4b3b
commit 5d8811026d
69 changed files with 899 additions and 888 deletions

View File

@@ -8,21 +8,21 @@
#include "utils/utils.hpp" // Para getFileName, printWithDots
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Asset* Asset::asset_ = nullptr;
Asset* Asset::asset = nullptr;
// [SINGLETON] Crearemos el objeto asset con esta función estática
void Asset::init(const std::string& executable_path) {
Asset::asset_ = new Asset(executable_path);
Asset::asset = new Asset(executable_path);
}
// [SINGLETON] Destruiremos el objeto asset con esta función estática
void Asset::destroy() {
delete Asset::asset_;
delete Asset::asset;
}
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
Asset* Asset::get() {
return Asset::asset_;
return Asset::asset;
}
// Añade un elemento a la lista
@@ -39,10 +39,9 @@ std::string Asset::get(const std::string& text) const {
if (it != file_list_.end()) {
return it->file;
} else {
std::cout << "Warning: file " << text << " not found" << std::endl;
return "";
}
std::cout << "Warning: file " << text << " not found" << std::endl;
return "";
}
// Comprueba que existen todos los elementos
@@ -74,8 +73,9 @@ bool Asset::check() const {
success &= checkFile(f.file);
}
}
if (success)
if (success) {
std::cout << " All files are OK." << std::endl;
}
}
}
@@ -86,7 +86,7 @@ bool Asset::check() const {
}
// Comprueba que existe un fichero
bool Asset::checkFile(const std::string& path) const {
bool Asset::checkFile(const std::string& path) {
std::ifstream file(path);
bool success = file.good();
file.close();
@@ -99,7 +99,7 @@ bool Asset::checkFile(const std::string& path) const {
}
// Devuelve el nombre del tipo de recurso
std::string Asset::getTypeName(AssetType type) const {
std::string Asset::getTypeName(AssetType type) {
switch (type) {
case AssetType::DATA:
return "DATA";