Commit to continue on other pc

This commit is contained in:
2021-09-06 20:02:58 +02:00
parent 2bc504f704
commit 012ad0be08
47 changed files with 23553 additions and 0 deletions

73
source/lang.cpp Normal file
View File

@@ -0,0 +1,73 @@
#include "lang.h"
#include <iostream>
#include <fstream>
// Constructor
Lang::Lang(std::string *fileList)
{
mFileList = fileList;
}
// Destructor
Lang::~Lang()
{
}
// Inicializa los textos del juego en el idioma seleccionado
bool Lang::setLang(Uint8 lang)
{
std::string file;
switch (lang)
{
case es_ES:
file = mFileList[49];
break;
case en_UK:
file = mFileList[50];
break;
case ba_BA:
file = mFileList[51];
break;
default:
file = mFileList[50];
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 buffer;
// lee el resto de datos del fichero
int index = 0;
int line_read = 0;
while (std::getline(rfile, buffer))
{
// Almacena solo las lineas impares
if (line_read % 2 == 1)
mTextStrings[index++] = buffer;
// Limpia el buffer
buffer.clear();
line_read++;
};
}
return success;
}
// Obtiene la cadena de texto del indice
std::string Lang::getText(int index)
{
return mTextStrings[index];
}