Reduced checkFileList function
This commit is contained in:
@@ -114,7 +114,7 @@ void Director::init(Uint8 name)
|
|||||||
mInput->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_W);
|
mInput->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_W);
|
||||||
mInput->bindKey(INPUT_BUTTON_3, SDL_SCANCODE_E);
|
mInput->bindKey(INPUT_BUTTON_3, SDL_SCANCODE_E);
|
||||||
#endif
|
#endif
|
||||||
mInput->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE); // PAUSE
|
mInput->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE); // PAUSE
|
||||||
mInput->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE); // ESCAPE
|
mInput->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE); // ESCAPE
|
||||||
|
|
||||||
mInput->bindGameController(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
mInput->bindGameController(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||||
@@ -271,135 +271,59 @@ void Director::setFileList()
|
|||||||
mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt";
|
mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba que todos los ficheros existen
|
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
|
||||||
bool Director::checkFileList()
|
bool Director::checkFolder(std::string name, std::string path)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
std::string p;
|
std::string p;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
SDL_RWops *file;
|
SDL_RWops *file;
|
||||||
|
|
||||||
printf("Checking files...\n\n");
|
// Comprueba los ficheros de la carpeta
|
||||||
|
printf("\n>> %s FILES\n", name.c_str());
|
||||||
// Comprueba los ficheros de musica
|
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||||
printf(">> MUSIC FILES\n");
|
{
|
||||||
if (success)
|
if (mFileList[i].find(path.c_str()) != std::string::npos)
|
||||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
|
||||||
{
|
{
|
||||||
if (mFileList[i].find("/media/music/") != std::string::npos)
|
p = mFileList[i].c_str();
|
||||||
|
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||||
|
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||||
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
p = mFileList[i].c_str();
|
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
|
||||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
|
||||||
if (file != NULL)
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||||
|
success = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SDL_RWclose(file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba los ficheros de sonidos
|
// Comprueba que todos los ficheros existen
|
||||||
printf("\n>> SOUND FILES\n");
|
bool Director::checkFileList()
|
||||||
if (success)
|
{
|
||||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
bool success = true;
|
||||||
{
|
printf("Checking files...\n");
|
||||||
if (mFileList[i].find("/media/sound/") != std::string::npos)
|
|
||||||
{
|
|
||||||
p = mFileList[i].c_str();
|
|
||||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
|
||||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
|
||||||
if (file != NULL)
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba los ficheros con graficos
|
|
||||||
printf("\n>> BITMAP FILES\n");
|
|
||||||
if (success)
|
if (success)
|
||||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
success &= checkFolder("MUSIC", "/media/music/");
|
||||||
{
|
|
||||||
if (mFileList[i].find("/media/gfx/") != std::string::npos)
|
|
||||||
{
|
|
||||||
p = mFileList[i].c_str();
|
|
||||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
|
||||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
|
||||||
if (file != NULL)
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba los ficheros con fuentes de texto
|
|
||||||
printf("\n>> FONT FILES\n");
|
|
||||||
if (success)
|
if (success)
|
||||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
success &= checkFolder("SOUND", "/media/sound/");
|
||||||
{
|
|
||||||
if (mFileList[i].find("/media/font/") != std::string::npos)
|
|
||||||
{
|
|
||||||
p = mFileList[i].c_str();
|
|
||||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
|
||||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
|
||||||
if (file != NULL)
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba los ficheros con textos en diferentes idiomas
|
|
||||||
printf("\n>> LANG FILES\n");
|
|
||||||
if (success)
|
if (success)
|
||||||
for (int i = 3; i < 100; i++)
|
success &= checkFolder("GFX", "/media/gfx/");
|
||||||
{
|
|
||||||
if (mFileList[i].find("/media/lang/") != std::string::npos)
|
if (success)
|
||||||
{
|
success &= checkFolder("FONT", "/media/font/");
|
||||||
p = mFileList[i].c_str();
|
|
||||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
if (success)
|
||||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
success &= checkFolder("LANG", "/media/lang/");
|
||||||
if (file != NULL)
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_RWclose(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resultado
|
// Resultado
|
||||||
if (success)
|
if (success)
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ private:
|
|||||||
// Ejecuta la seccion de juego donde se juega
|
// Ejecuta la seccion de juego donde se juega
|
||||||
void runGame();
|
void runGame();
|
||||||
|
|
||||||
|
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
|
||||||
|
bool checkFolder(std::string name, std::string path);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Director(std::string path);
|
Director(std::string path);
|
||||||
|
|||||||
Reference in New Issue
Block a user