forked from jaildesigner-jailgames/jaildoctors_dilemma
Commit to continue on other pc
This commit is contained in:
73
source/lang.cpp
Normal file
73
source/lang.cpp
Normal 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];
|
||||
}
|
||||
Reference in New Issue
Block a user