Acabada la clase asset
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -65,3 +77,32 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user