Pequeños cambios en las librerias comunes
This commit is contained in:
@@ -171,9 +171,6 @@ bool Menu::load(std::string file_path)
|
||||
success = false;
|
||||
}
|
||||
|
||||
// Reorganiza el menu con los valores recien cargados
|
||||
// reorganize();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -211,6 +208,7 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
|
||||
else if ((var == "") || (var == "[/item]"))
|
||||
{
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
@@ -355,11 +353,6 @@ bool Menu::setVars(std::string var, std::string value)
|
||||
return success;
|
||||
}
|
||||
|
||||
// Inicializa las variables
|
||||
void Menu::init()
|
||||
{
|
||||
}
|
||||
|
||||
// Carga los ficheros de audio
|
||||
void Menu::loadAudioFile(std::string file, int sound)
|
||||
{
|
||||
@@ -412,7 +405,8 @@ void Menu::updateSelector()
|
||||
selector.moving = false;
|
||||
}
|
||||
}
|
||||
if (selector.despY < 0) // Va hacia arriba
|
||||
|
||||
else if (selector.despY < 0) // Va hacia arriba
|
||||
{
|
||||
if (selector.y < selector.targetY) // Ha llegado al destino
|
||||
{
|
||||
@@ -440,7 +434,8 @@ void Menu::updateSelector()
|
||||
selector.resizing = false;
|
||||
}
|
||||
}
|
||||
if (selector.incH < 0) // Decrece
|
||||
|
||||
else if (selector.incH < 0) // Decrece
|
||||
{
|
||||
if (selector.h < selector.targetH) // Ha llegado al destino
|
||||
{
|
||||
@@ -463,7 +458,7 @@ void Menu::setSelectorPos(int index)
|
||||
if (index < (int)item.size())
|
||||
{
|
||||
selector.index = index;
|
||||
selector.rect.y = selector.y = selector.originY = selector.targetY = item[selector.index].rect.y;
|
||||
selector.rect.y = selector.y = selector.originY = selector.targetY = item.at(selector.index).rect.y;
|
||||
selector.rect.w = rectBG.rect.w;
|
||||
selector.rect.x = rectBG.rect.x;
|
||||
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
||||
@@ -491,13 +486,13 @@ void Menu::reset()
|
||||
{
|
||||
itemSelected = MENU_NO_OPTION;
|
||||
selector.index = 0;
|
||||
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
||||
selector.originH = selector.targetH = item[0].rect.h;
|
||||
selector.originY = selector.targetY = selector.y = item.at(0).rect.y;
|
||||
selector.originH = selector.targetH = item.at(0).rect.h;
|
||||
selector.moving = false;
|
||||
selector.resizing = false;
|
||||
|
||||
// Si el primer elemento no es seleccionable, incrementa el selector
|
||||
if (!item[selector.index].selectable)
|
||||
if (!item.at(selector.index).selectable)
|
||||
{
|
||||
increaseSelectorIndex();
|
||||
setSelectorPos(selector.index);
|
||||
@@ -529,18 +524,18 @@ void Menu::reorganize()
|
||||
bool Menu::increaseSelectorIndex()
|
||||
{
|
||||
// Obten las coordenadas del elemento actual
|
||||
selector.y = selector.originY = item[selector.index].rect.y;
|
||||
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||
|
||||
// Calcula cual es el siguiente elemento
|
||||
++selector.index %= item.size();
|
||||
while (!item[selector.index].selectable)
|
||||
while (!item.at(selector.index).selectable)
|
||||
{
|
||||
++selector.index %= item.size();
|
||||
}
|
||||
|
||||
// Establece las coordenadas y altura de destino
|
||||
selector.targetY = item[selector.index].rect.y;
|
||||
selector.targetY = item.at(selector.index).rect.y;
|
||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||
|
||||
selector.targetH = getSelectorHeight(selector.index);
|
||||
@@ -559,7 +554,7 @@ bool Menu::increaseSelectorIndex()
|
||||
bool Menu::decreaseSelectorIndex()
|
||||
{
|
||||
// Obten las coordenadas del elemento actual
|
||||
selector.y = selector.originY = item[selector.index].rect.y;
|
||||
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||
|
||||
// Calcula cual es el siguiente elemento
|
||||
@@ -572,7 +567,7 @@ bool Menu::decreaseSelectorIndex()
|
||||
selector.index--;
|
||||
}
|
||||
|
||||
while (!item[selector.index].selectable)
|
||||
while (!item.at(selector.index).selectable)
|
||||
{
|
||||
if (selector.index == 0)
|
||||
{
|
||||
@@ -585,7 +580,7 @@ bool Menu::decreaseSelectorIndex()
|
||||
}
|
||||
|
||||
// Establece las coordenadas y altura de destino
|
||||
selector.targetY = item[selector.index].rect.y;
|
||||
selector.targetY = item.at(selector.index).rect.y;
|
||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||
|
||||
selector.targetH = getSelectorHeight(selector.index);
|
||||
@@ -635,28 +630,29 @@ void Menu::render()
|
||||
if (i == selector.index)
|
||||
{
|
||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||
}
|
||||
|
||||
else if (item[i].selectable)
|
||||
else if (item.at(i).selectable)
|
||||
{
|
||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
||||
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||
}
|
||||
|
||||
else if (item[i].greyed)
|
||||
else if (item.at(i).greyed)
|
||||
{
|
||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, colorGreyed);
|
||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed);
|
||||
}
|
||||
|
||||
else
|
||||
{ // No seleccionable
|
||||
if ((item[i].linkedUp) && (i == selector.index + 1))
|
||||
if ((item.at(i).linkedUp) && (i == selector.index + 1))
|
||||
{
|
||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||
}
|
||||
else // No enlazado con el de arriba
|
||||
{
|
||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
||||
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -918,42 +914,42 @@ int Menu::findHeight()
|
||||
// Recoloca los elementos del menu en el eje Y
|
||||
void Menu::replaceElementsOnY()
|
||||
{
|
||||
item[0].rect.y = y;
|
||||
item.at(0).rect.y = y;
|
||||
|
||||
for (int i = 1; i < (int)item.size(); i++)
|
||||
{
|
||||
item[i].rect.y = item[i - 1].rect.y + item[i - 1].rect.h + item[i - 1].hPaddingDown;
|
||||
item.at(i).rect.y = item.at(i - 1).rect.y + item.at(i - 1).rect.h + item.at(i - 1).hPaddingDown;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el estado seleccionable de un item
|
||||
void Menu::setSelectable(int index, bool value)
|
||||
{
|
||||
item[index].selectable = value;
|
||||
item.at(index).selectable = value;
|
||||
}
|
||||
|
||||
// Establece el estado agrisado de un item
|
||||
void Menu::setGreyed(int index, bool value)
|
||||
{
|
||||
item[index].greyed = value;
|
||||
item.at(index).greyed = value;
|
||||
}
|
||||
|
||||
// Establece el estado de enlace de un item
|
||||
void Menu::setLinkedDown(int index, bool value)
|
||||
{
|
||||
item[index].linkedDown = value;
|
||||
item.at(index).linkedDown = value;
|
||||
}
|
||||
|
||||
// Calcula la altura del selector
|
||||
int Menu::getSelectorHeight(int value)
|
||||
{
|
||||
if (item[value].linkedDown)
|
||||
if (item.at(value).linkedDown)
|
||||
{
|
||||
return item[value].rect.h + item[value].hPaddingDown + item[value + 1].rect.h;
|
||||
return item.at(value).rect.h + item.at(value).hPaddingDown + item.at(value + 1).rect.h;
|
||||
}
|
||||
else
|
||||
{
|
||||
return item[value].rect.h;
|
||||
return item.at(value).rect.h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user