Acabada la clase asset

This commit is contained in:
2021-09-08 20:09:52 +02:00
parent 94a06dcc2d
commit 726a1b3064
2 changed files with 51 additions and 6 deletions

View File

@@ -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;
}
}