using namespace std en todos los ficheros
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "menu.h"
|
||||
|
||||
// Constructor
|
||||
//Menu::Menu(SDL_Renderer *renderer, Resource *resource, Asset *asset, Input *input, std::string file)
|
||||
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
|
||||
//Menu::Menu(SDL_Renderer *renderer, Resource *resource, Asset *asset, Input *input, string file)
|
||||
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, string file)
|
||||
{
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
@@ -91,7 +91,7 @@ Menu::~Menu()
|
||||
}
|
||||
|
||||
// Carga la configuración del menu desde un archivo de texto
|
||||
bool Menu::load(std::string file_path)
|
||||
bool Menu::load(string file_path)
|
||||
{
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
@@ -99,16 +99,16 @@ bool Menu::load(std::string file_path)
|
||||
// Indica si se ha creado ya el objeto de texto
|
||||
bool textAllocated = false;
|
||||
|
||||
const std::string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::string line;
|
||||
std::ifstream file(file_path);
|
||||
const string filename = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
string line;
|
||||
ifstream file(file_path);
|
||||
|
||||
// El fichero se puede abrir
|
||||
if (file.good())
|
||||
{
|
||||
// Procesa el fichero linea a linea
|
||||
std::cout << "Reading file " << filename.c_str() << std::endl;
|
||||
while (std::getline(file, line))
|
||||
cout << "Reading file " << filename.c_str() << endl;
|
||||
while (getline(file, line))
|
||||
{
|
||||
if (line == "[item]")
|
||||
{
|
||||
@@ -122,7 +122,7 @@ bool Menu::load(std::string file_path)
|
||||
do
|
||||
{
|
||||
// Lee la siguiente linea
|
||||
std::getline(file, line);
|
||||
getline(file, line);
|
||||
|
||||
// Encuentra la posición del caracter '='
|
||||
int pos = line.find("=");
|
||||
@@ -130,7 +130,7 @@ bool Menu::load(std::string file_path)
|
||||
// Procesa las dos subcadenas
|
||||
if (!setItem(&item, line.substr(0, pos), line.substr(pos + 1, line.length())))
|
||||
{
|
||||
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
|
||||
cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
|
||||
success = false;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ bool Menu::load(std::string file_path)
|
||||
// Procesa las dos subcadenas
|
||||
if (!setVars(line.substr(0, pos), line.substr(pos + 1, line.length())))
|
||||
{
|
||||
std::cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << std::endl;
|
||||
cout << "Warning: file " << filename.c_str() << "\n, unknown parameter \"" << line.substr(0, pos).c_str() << "\"" << endl;
|
||||
success = false;
|
||||
}
|
||||
|
||||
@@ -161,13 +161,13 @@ bool Menu::load(std::string file_path)
|
||||
}
|
||||
|
||||
// Cierra el fichero
|
||||
std::cout << "Closing file " << filename.c_str() << std::endl;
|
||||
cout << "Closing file " << filename.c_str() << endl;
|
||||
file.close();
|
||||
}
|
||||
// El fichero no se puede abrir
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << std::endl;
|
||||
cout << "Warning: Unable to open " << filename.c_str() << " file" << endl;
|
||||
success = false;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ bool Menu::load(std::string file_path)
|
||||
}
|
||||
|
||||
// Asigna variables a partir de dos cadenas
|
||||
bool Menu::setItem(item_t *item, std::string var, std::string value)
|
||||
bool Menu::setItem(item_t *item, string var, string value)
|
||||
{
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
@@ -187,7 +187,7 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
|
||||
|
||||
else if (var == "hPaddingDown")
|
||||
{
|
||||
item->hPaddingDown = std::stoi(value);
|
||||
item->hPaddingDown = stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "selectable")
|
||||
@@ -218,7 +218,7 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
|
||||
}
|
||||
|
||||
// Asigna variables a partir de dos cadenas
|
||||
bool Menu::setVars(std::string var, std::string value)
|
||||
bool Menu::setVars(string var, string value)
|
||||
{
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
@@ -255,70 +255,70 @@ bool Menu::setVars(std::string var, std::string value)
|
||||
|
||||
else if (var == "x")
|
||||
{
|
||||
x = std::stoi(value);
|
||||
x = stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "centerX")
|
||||
{
|
||||
centerX = std::stoi(value);
|
||||
centerX = stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "centerY")
|
||||
{
|
||||
centerY = std::stoi(value);
|
||||
centerY = stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "y")
|
||||
{
|
||||
y = std::stoi(value);
|
||||
y = stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "backgroundType")
|
||||
{
|
||||
backgroundType = std::stoi(value);
|
||||
backgroundType = stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "backgroundColor")
|
||||
{
|
||||
// Se introducen los valores separados por comas en un vector
|
||||
std::stringstream ss(value);
|
||||
std::string tmp;
|
||||
stringstream ss(value);
|
||||
string tmp;
|
||||
getline(ss, tmp, ',');
|
||||
rectBG.color.r = std::stoi(tmp);
|
||||
rectBG.color.r = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
rectBG.color.g = std::stoi(tmp);
|
||||
rectBG.color.g = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
rectBG.color.b = std::stoi(tmp);
|
||||
rectBG.color.b = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
rectBG.a = std::stoi(tmp);
|
||||
rectBG.a = stoi(tmp);
|
||||
}
|
||||
|
||||
else if (var == "selector_color")
|
||||
{
|
||||
// Se introducen los valores separados por comas en un vector
|
||||
std::stringstream ss(value);
|
||||
std::string tmp;
|
||||
stringstream ss(value);
|
||||
string tmp;
|
||||
getline(ss, tmp, ',');
|
||||
selector.color.r = std::stoi(tmp);
|
||||
selector.color.r = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
selector.color.g = std::stoi(tmp);
|
||||
selector.color.g = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
selector.color.b = std::stoi(tmp);
|
||||
selector.color.b = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
selector.a = std::stoi(tmp);
|
||||
selector.a = stoi(tmp);
|
||||
}
|
||||
|
||||
else if (var == "selector_text_color")
|
||||
{
|
||||
// Se introducen los valores separados por comas en un vector
|
||||
std::stringstream ss(value);
|
||||
std::string tmp;
|
||||
stringstream ss(value);
|
||||
string tmp;
|
||||
getline(ss, tmp, ',');
|
||||
selector.itemColor.r = std::stoi(tmp);
|
||||
selector.itemColor.r = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
selector.itemColor.g = std::stoi(tmp);
|
||||
selector.itemColor.g = stoi(tmp);
|
||||
getline(ss, tmp, ',');
|
||||
selector.itemColor.b = std::stoi(tmp);
|
||||
selector.itemColor.b = stoi(tmp);
|
||||
}
|
||||
|
||||
else if (var == "areElementsCenteredOnX")
|
||||
@@ -338,7 +338,7 @@ bool Menu::setVars(std::string var, std::string value)
|
||||
|
||||
else if (var == "defaultActionWhenCancel")
|
||||
{
|
||||
defaultActionWhenCancel = std::stoi(value);
|
||||
defaultActionWhenCancel = stoi(value);
|
||||
}
|
||||
|
||||
else if (var == "")
|
||||
@@ -354,7 +354,7 @@ bool Menu::setVars(std::string var, std::string value)
|
||||
}
|
||||
|
||||
// Carga los ficheros de audio
|
||||
void Menu::loadAudioFile(std::string file, int sound)
|
||||
void Menu::loadAudioFile(string file, int sound)
|
||||
{
|
||||
switch (sound)
|
||||
{
|
||||
@@ -376,7 +376,7 @@ void Menu::loadAudioFile(std::string file, int sound)
|
||||
}
|
||||
|
||||
// Obtiene el nombre del menu
|
||||
std::string Menu::getName()
|
||||
string Menu::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ int Menu::getWidestItem()
|
||||
// Obtenemos la anchura del item mas ancho
|
||||
for (auto &i : item)
|
||||
{
|
||||
result = std::max(result, i.rect.w);
|
||||
result = max(result, i.rect.w);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -797,7 +797,7 @@ void Menu::centerMenuElementsOnX()
|
||||
}
|
||||
|
||||
// Añade un item al menu
|
||||
void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool greyed, bool linkedDown)
|
||||
void Menu::addItem(string text, int hPaddingDown, bool selectable, bool greyed, bool linkedDown)
|
||||
{
|
||||
item_t temp;
|
||||
|
||||
@@ -833,7 +833,7 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
||||
}
|
||||
|
||||
// Cambia el texto de un item
|
||||
void Menu::setItemCaption(int index, std::string text)
|
||||
void Menu::setItemCaption(int index, string text)
|
||||
{
|
||||
item[index].label = text;
|
||||
item[index].rect.w = this->text->lenght(item[index].label);
|
||||
@@ -954,7 +954,7 @@ int Menu::getSelectorHeight(int value)
|
||||
}
|
||||
|
||||
// Establece el nombre del menu
|
||||
void Menu::setName(std::string name)
|
||||
void Menu::setName(string name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
@@ -973,7 +973,7 @@ void Menu::setBackgroundType(int value)
|
||||
}
|
||||
|
||||
// Establece la fuente de texto que se utilizará
|
||||
void Menu::setText(std::string font_png, std::string font_txt)
|
||||
void Menu::setText(string font_png, string font_txt)
|
||||
{
|
||||
if (!text)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user