Eliminada la classe Lang
This commit is contained in:
@@ -2,72 +2,40 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
// Constructor
|
||||
Lang::Lang(Asset *mAsset)
|
||||
{
|
||||
this->mAsset = mAsset;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Lang::~Lang()
|
||||
{
|
||||
}
|
||||
|
||||
// Inicializa los textos del juego en el idioma seleccionado
|
||||
bool Lang::setLang(Uint8 lang)
|
||||
{
|
||||
std::string file;
|
||||
|
||||
switch (lang)
|
||||
namespace lang
|
||||
{
|
||||
// Inicializa los textos del juego en el idioma seleccionado
|
||||
bool loadFromFile(std::string filePath)
|
||||
{
|
||||
case es_ES:
|
||||
file = mAsset->get("es_ES.txt");
|
||||
break;
|
||||
texts.clear();
|
||||
|
||||
case en_UK:
|
||||
file = mAsset->get("en_UK.txt");
|
||||
break;
|
||||
bool success = false;
|
||||
|
||||
case ba_BA:
|
||||
file = mAsset->get("ba_BA.txt");
|
||||
break;
|
||||
|
||||
default:
|
||||
file = mAsset->get("en_UK.txt");
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_TEXT_STRINGS; i++)
|
||||
mTextStrings[i] = "";
|
||||
|
||||
bool success = false;
|
||||
|
||||
std::ifstream rfile(file);
|
||||
if (rfile.is_open() && rfile.good())
|
||||
{
|
||||
success = true;
|
||||
std::string line;
|
||||
|
||||
// lee el resto de datos del fichero
|
||||
int index = 0;
|
||||
while (std::getline(rfile, line))
|
||||
std::ifstream rfile(filePath);
|
||||
if (rfile.is_open() && rfile.good())
|
||||
{
|
||||
// Almacena solo las lineas que no empiezan por # o no esten vacias
|
||||
const bool test1 = line.substr(0,1) != "#";
|
||||
const bool test2 = !line.empty();
|
||||
if (test1 && test2)
|
||||
success = true;
|
||||
std::string line;
|
||||
|
||||
// Lee el resto de datos del fichero
|
||||
while (std::getline(rfile, line))
|
||||
{
|
||||
mTextStrings[index] = line;
|
||||
index++;
|
||||
}
|
||||
};
|
||||
// Almacena solo las lineas que no empiezan por # o no esten vacias
|
||||
const bool test1 = line.substr(0, 1) != "#";
|
||||
const bool test2 = !line.empty();
|
||||
if (test1 && test2)
|
||||
{
|
||||
texts.push_back(line);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Obtiene la cadena de texto del indice
|
||||
std::string Lang::getText(int index)
|
||||
{
|
||||
return mTextStrings[index];
|
||||
// Obtiene la cadena de texto del indice
|
||||
std::string getText(int index)
|
||||
{
|
||||
return texts.at(index);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user