forked from jaildesigner-jailgames/jaildoctors_dilemma
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);
|
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)
|
std::string Asset::get(std::string text)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mFileList.size(); i++)
|
for (int i = 0; i < mFileList.size(); i++)
|
||||||
@@ -36,9 +36,21 @@ bool Asset::check()
|
|||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
for (int i = 0; i < mFileList.size(); i++)
|
// Comprueba la lista de ficheros clasificandolos por tipo
|
||||||
if (mFileList[i].required)
|
for (int type = 0; type < maxAssetType; type++)
|
||||||
success &= checkFile(mFileList[i].file);
|
{
|
||||||
|
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;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -64,4 +76,33 @@ bool Asset::checkFile(std::string path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
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,
|
bitmap,
|
||||||
music,
|
music,
|
||||||
sound,
|
sound,
|
||||||
data,
|
|
||||||
font,
|
font,
|
||||||
lang
|
lang,
|
||||||
|
data,
|
||||||
|
maxAssetType
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clase Asset
|
// Clase Asset
|
||||||
@@ -34,6 +35,9 @@ private:
|
|||||||
// Comprueba que existe un fichero
|
// Comprueba que existe un fichero
|
||||||
bool checkFile(std::string path);
|
bool checkFile(std::string path);
|
||||||
|
|
||||||
|
// Devuelve el nombre del tipo de recurso
|
||||||
|
std::string getTypeName(int type);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Asset(std::string path);
|
Asset(std::string path);
|
||||||
|
|||||||
Reference in New Issue
Block a user