lang class
This commit is contained in:
@@ -21,6 +21,9 @@ Director::Director(std::string path)
|
||||
if (!checkFileList())
|
||||
section = PROG_SECTION_QUIT;
|
||||
|
||||
// Inicializa el objeto de idioma
|
||||
mLang = new Lang(mFileList);
|
||||
|
||||
// Crea el objeto y carga el fichero de configuración
|
||||
mOptions = new options_t;
|
||||
if (!loadConfigFile())
|
||||
@@ -73,9 +76,13 @@ Director::~Director()
|
||||
|
||||
delete mInput1;
|
||||
mInput1 = nullptr;
|
||||
|
||||
delete mInput2;
|
||||
mInput2 = nullptr;
|
||||
|
||||
delete mLang;
|
||||
mLang = nullptr;
|
||||
|
||||
delete mOptions;
|
||||
mOptions = nullptr;
|
||||
|
||||
@@ -95,7 +102,7 @@ void Director::init(Uint8 name)
|
||||
mSection.subsection = 0;
|
||||
|
||||
// Textos
|
||||
initTextStrings(mTextStrings, mOptions->language);
|
||||
mLang->setLang(mOptions->language);
|
||||
|
||||
// Teclado
|
||||
mInput1->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
||||
@@ -194,7 +201,7 @@ bool Director::initSDL()
|
||||
void Director::setFileList()
|
||||
{
|
||||
// Inicializa el vector
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i < MAX_FILE_LIST; i++)
|
||||
mFileList[i] = "";
|
||||
|
||||
// Ficheros binarios
|
||||
@@ -259,6 +266,11 @@ void Director::setFileList()
|
||||
mFileList[47] = mExecutablePath + "/" + "../media/font/smb2_big.txt";
|
||||
mFileList[30] = mExecutablePath + "/" + "../media/font/smb2.png";
|
||||
mFileList[48] = mExecutablePath + "/" + "../media/font/smb2.txt";
|
||||
|
||||
// Textos
|
||||
mFileList[49] = mExecutablePath + "/" + "../media/lang/es_ES.txt";
|
||||
mFileList[50] = mExecutablePath + "/" + "../media/lang/en_UK.txt";
|
||||
mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt";
|
||||
}
|
||||
|
||||
// Comprueba que todos los ficheros existen
|
||||
@@ -274,7 +286,7 @@ bool Director::checkFileList()
|
||||
// Comprueba los ficheros de musica
|
||||
printf(">> MUSIC FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < 100; i++)
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/music/") != std::string::npos)
|
||||
{
|
||||
@@ -298,7 +310,7 @@ bool Director::checkFileList()
|
||||
// Comprueba los ficheros de sonidos
|
||||
printf("\n>> SOUND FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < 100; i++)
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/sound/") != std::string::npos)
|
||||
{
|
||||
@@ -322,7 +334,7 @@ bool Director::checkFileList()
|
||||
// Comprueba los ficheros con graficos
|
||||
printf("\n>> BITMAP FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < 100; i++)
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/gfx/") != std::string::npos)
|
||||
{
|
||||
@@ -346,7 +358,7 @@ bool Director::checkFileList()
|
||||
// Comprueba los ficheros con fuentes de texto
|
||||
printf("\n>> FONT FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < 100; i++)
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/font/") != std::string::npos)
|
||||
{
|
||||
@@ -367,6 +379,30 @@ bool Director::checkFileList()
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba los ficheros con textos en diferentes idiomas
|
||||
printf("\n>> LANG FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < 100; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/lang/") != 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Resultado
|
||||
if (success)
|
||||
printf("\n** All files OK.\n\n");
|
||||
@@ -453,7 +489,7 @@ bool Director::loadConfigFile()
|
||||
// Aplica las opciones
|
||||
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
||||
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
||||
initTextStrings(mTextStrings, mOptions->language);
|
||||
mLang->setLang(mOptions->language);
|
||||
|
||||
// Cierra el fichero
|
||||
SDL_RWclose(file);
|
||||
@@ -526,14 +562,14 @@ void Director::runLogo()
|
||||
|
||||
void Director::runIntro()
|
||||
{
|
||||
mIntro = new Intro(mRenderer, mFileList, mTextStrings);
|
||||
mIntro = new Intro(mRenderer, mFileList, mLang);
|
||||
setSection(mIntro->run());
|
||||
delete mIntro;
|
||||
}
|
||||
|
||||
void Director::runTitle()
|
||||
{
|
||||
mTitle = new Title(mWindow, mRenderer, mInput1, mFileList, mOptions, mTextStrings);
|
||||
mTitle = new Title(mWindow, mRenderer, mInput1, mFileList, mOptions, mLang);
|
||||
setSection(mTitle->run(mSection.subsection));
|
||||
delete mTitle;
|
||||
}
|
||||
@@ -541,9 +577,9 @@ void Director::runTitle()
|
||||
void Director::runGame()
|
||||
{
|
||||
if (mSection.subsection == GAME_SECTION_PLAY_1P)
|
||||
mGame = new Game(1, mRenderer, mFileList, mTextStrings, mInput1, mInput2, false);
|
||||
mGame = new Game(1, mRenderer, mFileList, mLang, mInput1, mInput2, false);
|
||||
if (mSection.subsection == GAME_SECTION_PLAY_2P)
|
||||
mGame = new Game(2, mRenderer, mFileList, mTextStrings, mInput1, mInput2, false);
|
||||
mGame = new Game(2, mRenderer, mFileList, mLang, mInput1, mInput2, false);
|
||||
setSection(mGame->run());
|
||||
delete mGame;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user