Eliminados la mayor parte de accesos a vector mediante at()

This commit is contained in:
2022-11-30 12:03:37 +01:00
parent 62c1e2715e
commit 357eec20b1
9 changed files with 165 additions and 165 deletions

View File

@@ -38,7 +38,7 @@ void Notify::render()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
notifications.at(i).sprite->render();
notifications[i].sprite->render();
}
}
@@ -47,63 +47,63 @@ void Notify::update()
{
for (int i = 0; i < (int)notifications.size(); ++i)
{
notifications.at(i).counter++;
notifications[i].counter++;
// Comprueba los estados
if (notifications.at(i).state == ns_rising)
if (notifications[i].state == ns_rising)
{
const float step = ((float)notifications.at(i).counter / notifications.at(i).travelDist);
const float step = ((float)notifications[i].counter / notifications[i].travelDist);
const int alpha = 255 * step;
if (options->notifications.posV == pos_top)
{
notifications.at(i).rect.y++;
notifications[i].rect.y++;
}
else
{
notifications.at(i).rect.y--;
notifications[i].rect.y--;
}
notifications.at(i).texture->setAlpha(alpha);
notifications[i].texture->setAlpha(alpha);
if (notifications.at(i).rect.y == notifications.at(i).y)
if (notifications[i].rect.y == notifications[i].y)
{
notifications.at(i).state = ns_stay;
notifications.at(i).texture->setAlpha(255);
notifications.at(i).counter = 0;
notifications[i].state = ns_stay;
notifications[i].texture->setAlpha(255);
notifications[i].counter = 0;
}
}
else if (notifications.at(i).state == ns_stay)
else if (notifications[i].state == ns_stay)
{
if (notifications.at(i).counter == waitTime)
if (notifications[i].counter == waitTime)
{
notifications.at(i).state = ns_vanishing;
notifications.at(i).counter = 0;
notifications[i].state = ns_vanishing;
notifications[i].counter = 0;
}
}
else if (notifications.at(i).state == ns_vanishing)
else if (notifications[i].state == ns_vanishing)
{
const float step = (notifications.at(i).counter / (float)notifications.at(i).travelDist);
const float step = (notifications[i].counter / (float)notifications[i].travelDist);
const int alpha = 255 * (1 - step);
if (options->notifications.posV == pos_top)
{
notifications.at(i).rect.y--;
notifications[i].rect.y--;
}
else
{
notifications.at(i).rect.y++;
notifications[i].rect.y++;
}
notifications.at(i).texture->setAlpha(alpha);
notifications[i].texture->setAlpha(alpha);
if (notifications.at(i).rect.y == notifications.at(i).y - notifications.at(i).travelDist)
if (notifications[i].rect.y == notifications[i].y - notifications[i].travelDist)
{
notifications.at(i).state = ns_finished;
notifications[i].state = ns_finished;
}
}
notifications.at(i).sprite->setRect(notifications.at(i).rect);
notifications[i].sprite->setRect(notifications[i].rect);
}
clearFinishedNotifications();
@@ -114,10 +114,10 @@ void Notify::clearFinishedNotifications()
{
for (int i = (int)notifications.size() - 1; i >= 0; --i)
{
if (notifications.at(i).state == ns_finished)
if (notifications[i].state == ns_finished)
{
delete notifications.at(i).sprite;
delete notifications.at(i).texture;
delete notifications[i].sprite;
delete notifications[i].texture;
notifications.erase(notifications.begin() + i);
}
}