working on text notifications
This commit is contained in:
@@ -10,15 +10,40 @@
|
||||
// Constructor
|
||||
Director::Director(std::string path)
|
||||
{
|
||||
// Crea los objetos
|
||||
mInput1 = new Input(USE_KEYBOARD);
|
||||
mInput2 = new Input(USE_GAMECONTROLLER);
|
||||
mOptions = new options_t;
|
||||
|
||||
// Inicializa variables
|
||||
// Inicializa la ruta
|
||||
setExecutablePath(path);
|
||||
|
||||
// Establece la lista de ficheros
|
||||
setFileList();
|
||||
checkFileList();
|
||||
|
||||
// Si falta algún fichero no inicies el programa
|
||||
Uint8 section = PROG_SECTION_LOGO;
|
||||
if (!checkFileList())
|
||||
section = PROG_SECTION_QUIT;
|
||||
|
||||
// Crea el objeto y carga el fichero de configuración
|
||||
mOptions = new options_t;
|
||||
if (!loadConfigFile())
|
||||
{
|
||||
mOptions->fullScreenMode = 0;
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->language = en_UK;
|
||||
mOptions->fullScreenMode = 0;
|
||||
mOptions->fullScreenModePrevious = 0;
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->windowSizePrevious = 3;
|
||||
mOptions->language = en_UK;
|
||||
mOptions->languagePrevious = en_UK;
|
||||
mOptions->difficulty = 0;
|
||||
mOptions->player1Input = INPUT_USE_KEYBOARD;
|
||||
mOptions->player2Input = INPUT_USE_GAMECONTROLLER;
|
||||
mOptions->filter = 0;
|
||||
mOptions->vSync = true;
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
mInput1 = new Input(mOptions->player1Input);
|
||||
mInput2 = new Input(mOptions->player2Input);
|
||||
|
||||
// Inicializa SDL
|
||||
initSDL();
|
||||
@@ -39,7 +64,7 @@ Director::Director(std::string path)
|
||||
#endif
|
||||
|
||||
// Inicializa el resto de variables
|
||||
init();
|
||||
init(section);
|
||||
}
|
||||
|
||||
Director::~Director()
|
||||
@@ -63,18 +88,10 @@ Director::~Director()
|
||||
}
|
||||
|
||||
// Inicia las variables necesarias para arrancar el programa
|
||||
void Director::init()
|
||||
void Director::init(Uint8 name)
|
||||
{
|
||||
// Carga el fichero de configuración
|
||||
if (!loadConfigFile())
|
||||
{
|
||||
mOptions->fullScreenMode = 0;
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->language = en_UK;
|
||||
}
|
||||
|
||||
// Sección
|
||||
mSection.name = PROG_SECTION_LOGO;
|
||||
mSection.name = name;
|
||||
mSection.subsection = 0;
|
||||
|
||||
// Textos
|
||||
@@ -96,7 +113,7 @@ void Director::init()
|
||||
mInput1->bindKey(INPUT_BUTTON_2, SDL_SCANCODE_W);
|
||||
mInput1->bindKey(INPUT_BUTTON_3, SDL_SCANCODE_E);
|
||||
#endif
|
||||
mInput1->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE); // PAUSE
|
||||
mInput1->bindKey(INPUT_BUTTON_PAUSE, SDL_SCANCODE_ESCAPE); // PAUSE
|
||||
mInput1->bindKey(INPUT_BUTTON_ESCAPE, SDL_SCANCODE_ESCAPE); // ESCAPE
|
||||
|
||||
mInput2->bindGameController(INPUT_UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||
@@ -108,7 +125,7 @@ void Director::init()
|
||||
mInput2->bindGameController(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_X);
|
||||
mInput2->bindGameController(INPUT_BUTTON_2, SDL_CONTROLLER_BUTTON_Y);
|
||||
mInput2->bindGameController(INPUT_BUTTON_3, SDL_CONTROLLER_BUTTON_B);
|
||||
mInput2->bindGameController(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
||||
mInput2->bindGameController(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
||||
mInput2->bindGameController(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE); // ESCAPE
|
||||
}
|
||||
|
||||
@@ -149,7 +166,8 @@ bool Director::initSDL()
|
||||
else
|
||||
{
|
||||
// Crea un renderizador para la ventana con vsync
|
||||
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
//mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED);
|
||||
if (mRenderer == NULL)
|
||||
{
|
||||
printf("Renderer could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||
@@ -176,7 +194,11 @@ bool Director::initSDL()
|
||||
// Crea el indice de ficheros
|
||||
void Director::setFileList()
|
||||
{
|
||||
// Ficheros binarios
|
||||
// Inicializa el vector
|
||||
for (int i = 0; i < 100; i++)
|
||||
mFileList[i] = "";
|
||||
|
||||
// Ficheros binarios
|
||||
#ifdef __MIPSEL__
|
||||
mFileList[0] = "/media/data/local/home/.coffee_crisis/score.bin";
|
||||
mFileList[1] = "/media/data/local/home/.coffee_crisis/demo.bin";
|
||||
@@ -220,7 +242,6 @@ void Director::setFileList()
|
||||
mFileList[33] = mExecutablePath + "/" + "../media/gfx/intro.png";
|
||||
mFileList[34] = mExecutablePath + "/" + "../media/gfx/items.png";
|
||||
mFileList[35] = mExecutablePath + "/" + "../media/gfx/logo.png";
|
||||
mFileList[36] = mExecutablePath + "/" + "../media/gfx/menu.png";
|
||||
mFileList[37] = mExecutablePath + "/" + "../media/gfx/player1_body.png";
|
||||
mFileList[38] = mExecutablePath + "/" + "../media/gfx/player1_death.png";
|
||||
mFileList[39] = mExecutablePath + "/" + "../media/gfx/player1_legs.png";
|
||||
@@ -237,79 +258,114 @@ void Director::setFileList()
|
||||
mFileList[28] = mExecutablePath + "/" + "../media/font/nokia.png";
|
||||
mFileList[29] = mExecutablePath + "/" + "../media/font/smb2_big.png";
|
||||
mFileList[47] = mExecutablePath + "/" + "../media/font/smb2_big.txt";
|
||||
mFileList[30] = mExecutablePath + "/" + "../media/font/smb2.png";
|
||||
mFileList[48] = mExecutablePath + "/" + "../media/font/smb2.txt";
|
||||
mFileList[30] = mExecutablePath + "/" + "../media/font/smb2.png";
|
||||
mFileList[48] = mExecutablePath + "/" + "../media/font/smb2.txt";
|
||||
}
|
||||
|
||||
// Comprueba que todos los ficheros existen
|
||||
bool Director::checkFileList()
|
||||
{
|
||||
bool success = true;
|
||||
/*std::string p;
|
||||
std::string p;
|
||||
std::string filename;
|
||||
SDL_RWops *file;
|
||||
|
||||
printf("Checking files...\n\n");
|
||||
|
||||
// Comprueba los ficheros de musica
|
||||
printf("\n>> MUSIC FILES\n");
|
||||
printf(">> MUSIC FILES\n");
|
||||
if (success)
|
||||
for (int i = 0; i < TOTAL_MUSIC; i++)
|
||||
for (int i = 3; i < 100; i++)
|
||||
{
|
||||
p = mMusic[i].file.c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file != NULL)
|
||||
if (mFileList[i].find("/media/music/") != std::string::npos)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
|
||||
// Comprueba los ficheros de sonidos
|
||||
printf("\n>> SOUND FILES\n");
|
||||
if (success)
|
||||
for (int i = 0; i < TOTAL_SOUND; i++)
|
||||
for (int i = 3; i < 100; i++)
|
||||
{
|
||||
p = mSound[i].file.c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file != NULL)
|
||||
if (mFileList[i].find("/media/sound/") != std::string::npos)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
|
||||
// Comprueba los ficheros con texturas
|
||||
printf("\n>> TEXTURE FILES\n");
|
||||
// Comprueba los ficheros con graficos
|
||||
printf("\n>> BITMAP FILES\n");
|
||||
if (success)
|
||||
for (int i = 0; i < TOTAL_TEXTURE; i++)
|
||||
for (int i = 3; i < 100; i++)
|
||||
{
|
||||
p = mTexture[i].file.c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file != NULL)
|
||||
if (mFileList[i].find("/media/gfx/") != std::string::npos)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||
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);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
// Comprueba los ficheros con fuentes de texto
|
||||
printf("\n>> FONT FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < 100; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/font/") != std::string::npos)
|
||||
{
|
||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||
success = false;
|
||||
break;
|
||||
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);
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
|
||||
// Resultado
|
||||
@@ -318,7 +374,6 @@ bool Director::checkFileList()
|
||||
else
|
||||
printf("\n** A file is missing. Exiting.\n\n");
|
||||
|
||||
*/
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -329,6 +384,11 @@ bool Director::loadConfigFile()
|
||||
mOptions->fullScreenMode = 0;
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->language = en_UK;
|
||||
mOptions->difficulty = DIFFICULTY_NORMAL;
|
||||
mOptions->player1Input = INPUT_USE_KEYBOARD;
|
||||
mOptions->player2Input = INPUT_USE_GAMECONTROLLER;
|
||||
mOptions->filter = 0;
|
||||
mOptions->vSync = true;
|
||||
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
@@ -352,6 +412,11 @@ bool Director::loadConfigFile()
|
||||
SDL_RWwrite(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
|
||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||
SDL_RWwrite(file, &mOptions->player1Input, sizeof(mOptions->player1Input), 1);
|
||||
SDL_RWwrite(file, &mOptions->player2Input, sizeof(mOptions->player2Input), 1);
|
||||
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||
|
||||
// Cierra el fichero
|
||||
SDL_RWclose(file);
|
||||
@@ -370,6 +435,11 @@ bool Director::loadConfigFile()
|
||||
SDL_RWread(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
|
||||
SDL_RWread(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWread(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
SDL_RWread(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||
SDL_RWread(file, &mOptions->player1Input, sizeof(mOptions->player1Input), 1);
|
||||
SDL_RWread(file, &mOptions->player2Input, sizeof(mOptions->player2Input), 1);
|
||||
SDL_RWread(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||
SDL_RWread(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||
|
||||
// Normaliza los valores
|
||||
if (!((mOptions->fullScreenMode == 0) ||
|
||||
@@ -403,9 +473,14 @@ bool Director::saveConfigFile()
|
||||
if (file != NULL)
|
||||
{
|
||||
// Guarda los datos
|
||||
SDL_RWwrite(file, &mOptions->fullScreenMode, sizeof(Uint32), 1);
|
||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(Uint8), 1);
|
||||
SDL_RWwrite(file, &mOptions->language, sizeof(Uint8), 1);
|
||||
SDL_RWwrite(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
|
||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||
SDL_RWwrite(file, &mOptions->player1Input, sizeof(mOptions->player1Input), 1);
|
||||
SDL_RWwrite(file, &mOptions->player2Input, sizeof(mOptions->player2Input), 1);
|
||||
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||
|
||||
printf("Writing file %s\n", filename.c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user