diff --git a/source/asset.cpp b/source/asset.cpp index 11884ab..608009b 100644 --- a/source/asset.cpp +++ b/source/asset.cpp @@ -21,7 +21,7 @@ void Asset::add(std::string file, enum assetType type, bool required) mFileList.push_back(temp); } -// Devuelve un elemento de la lista a partir de una cadena +// Devuelve el fichero de un elemento de la lista a partir de una cadena std::string Asset::get(std::string text) { for (int i = 0; i < mFileList.size(); i++) @@ -36,9 +36,21 @@ bool Asset::check() { bool success = true; - for (int i = 0; i < mFileList.size(); i++) - if (mFileList[i].required) - success &= checkFile(mFileList[i].file); + // Comprueba la lista de ficheros clasificandolos por tipo + for (int type = 0; type < maxAssetType; type++) + { + printf("\n>> %s FILES\n", getTypeName(type).c_str()); + + for (int i = 0; i < mFileList.size(); i++) + if ((mFileList[i].required) && (mFileList[i].type == type)) + success &= checkFile(mFileList[i].file); + } + + // Resultado + if (success) + printf("\n** All files OK.\n\n"); + else + printf("\n** A file is missing. Exiting.\n\n"); return success; } @@ -64,4 +76,33 @@ bool Asset::checkFile(std::string path) } return success; +} + +// Devuelve el nombre del tipo de recurso +std::string Asset::getTypeName(int type) +{ + switch (type) + { + case bitmap: + return "BITMAP"; + break; + case music: + return "MUSIC"; + break; + case sound: + return "SOUND"; + break; + case font: + return "FONT"; + break; + case lang: + return "LANG"; + break; + case data: + return "DATA"; + break; + default: + return "ERROR"; + break; + } } \ No newline at end of file diff --git a/source/asset.h b/source/asset.h index 21e5f7e..5eaba36 100644 --- a/source/asset.h +++ b/source/asset.h @@ -11,9 +11,10 @@ enum assetType bitmap, music, sound, - data, font, - lang + lang, + data, + maxAssetType }; // Clase Asset @@ -34,6 +35,9 @@ private: // Comprueba que existe un fichero bool checkFile(std::string path); + // Devuelve el nombre del tipo de recurso + std::string getTypeName(int type); + public: // Constructor Asset(std::string path);