Eliminado el resto de accesos a vector mediante at()
This commit is contained in:
@@ -458,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.at(selector.index).rect.y;
|
||||
selector.rect.y = selector.y = selector.originY = selector.targetY = item[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);
|
||||
@@ -486,13 +486,13 @@ void Menu::reset()
|
||||
{
|
||||
itemSelected = MENU_NO_OPTION;
|
||||
selector.index = 0;
|
||||
selector.originY = selector.targetY = selector.y = item.at(0).rect.y;
|
||||
selector.originH = selector.targetH = item.at(0).rect.h;
|
||||
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
||||
selector.originH = selector.targetH = item[0].rect.h;
|
||||
selector.moving = false;
|
||||
selector.resizing = false;
|
||||
|
||||
// Si el primer elemento no es seleccionable, incrementa el selector
|
||||
if (!item.at(selector.index).selectable)
|
||||
if (!item[selector.index].selectable)
|
||||
{
|
||||
increaseSelectorIndex();
|
||||
setSelectorPos(selector.index);
|
||||
@@ -524,18 +524,18 @@ void Menu::reorganize()
|
||||
bool Menu::increaseSelectorIndex()
|
||||
{
|
||||
// Obten las coordenadas del elemento actual
|
||||
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||
selector.y = selector.originY = item[selector.index].rect.y;
|
||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||
|
||||
// Calcula cual es el siguiente elemento
|
||||
++selector.index %= item.size();
|
||||
while (!item.at(selector.index).selectable)
|
||||
while (!item[selector.index].selectable)
|
||||
{
|
||||
++selector.index %= item.size();
|
||||
}
|
||||
|
||||
// Establece las coordenadas y altura de destino
|
||||
selector.targetY = item.at(selector.index).rect.y;
|
||||
selector.targetY = item[selector.index].rect.y;
|
||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||
|
||||
selector.targetH = getSelectorHeight(selector.index);
|
||||
@@ -554,7 +554,7 @@ bool Menu::increaseSelectorIndex()
|
||||
bool Menu::decreaseSelectorIndex()
|
||||
{
|
||||
// Obten las coordenadas del elemento actual
|
||||
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||
selector.y = selector.originY = item[selector.index].rect.y;
|
||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||
|
||||
// Calcula cual es el siguiente elemento
|
||||
@@ -567,7 +567,7 @@ bool Menu::decreaseSelectorIndex()
|
||||
selector.index--;
|
||||
}
|
||||
|
||||
while (!item.at(selector.index).selectable)
|
||||
while (!item[selector.index].selectable)
|
||||
{
|
||||
if (selector.index == 0)
|
||||
{
|
||||
@@ -580,7 +580,7 @@ bool Menu::decreaseSelectorIndex()
|
||||
}
|
||||
|
||||
// Establece las coordenadas y altura de destino
|
||||
selector.targetY = item.at(selector.index).rect.y;
|
||||
selector.targetY = item[selector.index].rect.y;
|
||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||
|
||||
selector.targetH = getSelectorHeight(selector.index);
|
||||
@@ -630,29 +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.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
||||
}
|
||||
|
||||
else if (item.at(i).selectable)
|
||||
else if (item[i].selectable)
|
||||
{
|
||||
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
||||
}
|
||||
|
||||
else if (item.at(i).greyed)
|
||||
else if (item[i].greyed)
|
||||
{
|
||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed);
|
||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, colorGreyed);
|
||||
}
|
||||
|
||||
else
|
||||
{ // No seleccionable
|
||||
if ((item.at(i).linkedUp) && (i == selector.index + 1))
|
||||
if ((item[i].linkedUp) && (i == selector.index + 1))
|
||||
{
|
||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
||||
}
|
||||
else // No enlazado con el de arriba
|
||||
{
|
||||
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -822,7 +822,7 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
||||
|
||||
if (item.size() > 1)
|
||||
{
|
||||
if (item.at(item.size() - 2).linkedDown)
|
||||
if (item[item.size() - 2].linkedDown)
|
||||
{
|
||||
item.back().linkedUp = true;
|
||||
}
|
||||
@@ -835,9 +835,9 @@ 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)
|
||||
{
|
||||
item.at(index).label = text;
|
||||
item.at(index).rect.w = this->text->lenght(item.at(index).label);
|
||||
item.at(index).rect.h = this->text->getCharacterSize();
|
||||
item[index].label = text;
|
||||
item[index].rect.w = this->text->lenght(item[index].label);
|
||||
item[index].rect.h = this->text->getCharacterSize();
|
||||
reorganize();
|
||||
}
|
||||
|
||||
@@ -914,42 +914,42 @@ int Menu::findHeight()
|
||||
// Recoloca los elementos del menu en el eje Y
|
||||
void Menu::replaceElementsOnY()
|
||||
{
|
||||
item.at(0).rect.y = y;
|
||||
item[0].rect.y = y;
|
||||
|
||||
for (int i = 1; i < (int)item.size(); i++)
|
||||
{
|
||||
item.at(i).rect.y = item.at(i - 1).rect.y + item.at(i - 1).rect.h + item.at(i - 1).hPaddingDown;
|
||||
item[i].rect.y = item[i - 1].rect.y + item[i - 1].rect.h + item[i - 1].hPaddingDown;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el estado seleccionable de un item
|
||||
void Menu::setSelectable(int index, bool value)
|
||||
{
|
||||
item.at(index).selectable = value;
|
||||
item[index].selectable = value;
|
||||
}
|
||||
|
||||
// Establece el estado agrisado de un item
|
||||
void Menu::setGreyed(int index, bool value)
|
||||
{
|
||||
item.at(index).greyed = value;
|
||||
item[index].greyed = value;
|
||||
}
|
||||
|
||||
// Establece el estado de enlace de un item
|
||||
void Menu::setLinkedDown(int index, bool value)
|
||||
{
|
||||
item.at(index).linkedDown = value;
|
||||
item[index].linkedDown = value;
|
||||
}
|
||||
|
||||
// Calcula la altura del selector
|
||||
int Menu::getSelectorHeight(int value)
|
||||
{
|
||||
if (item.at(value).linkedDown)
|
||||
if (item[value].linkedDown)
|
||||
{
|
||||
return item.at(value).rect.h + item.at(value).hPaddingDown + item.at(value + 1).rect.h;
|
||||
return item[value].rect.h + item[value].hPaddingDown + item[value + 1].rect.h;
|
||||
}
|
||||
else
|
||||
{
|
||||
return item.at(value).rect.h;
|
||||
return item[value].rect.h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user