Reestructurant la classe Options

This commit is contained in:
2025-02-23 18:12:02 +01:00
parent 3ba4293e8a
commit 2ee0c70319
48 changed files with 898 additions and 984 deletions

View File

@@ -106,11 +106,11 @@ void Notifier::update()
const float step = ((float)notifications_[i].counter / notifications_[i].travelDist);
const int alpha = 255 * step;
if (options.notifications.posV == pos_top)
if (options.notifications.getVerticalPosition() == "UPPER")
{
notifications_[i].rect.y++;
}
else
else if (options.notifications.getVerticalPosition() == "BOTTOM")
{
notifications_[i].rect.y--;
}
@@ -138,11 +138,11 @@ void Notifier::update()
const float step = (notifications_[i].counter / (float)notifications_[i].travelDist);
const int alpha = 255 * (1 - step);
if (options.notifications.posV == pos_top)
if (options.notifications.getVerticalPosition() == "UPPER")
{
notifications_[i].rect.y--;
}
else
else if (options.notifications.getVerticalPosition() == "BOTTOM")
{
notifications_[i].rect.y++;
}
@@ -187,41 +187,41 @@ void Notifier::show(std::string text1, std::string text2, int icon)
// Posición horizontal
int despH = 0;
if (options.notifications.posH == pos_left)
if (options.notifications.getHorizontalPosition() == "LEFT")
{
despH = padding;
}
else if (options.notifications.posH == pos_middle)
else if (options.notifications.getHorizontalPosition() == "CENTER")
{
despH = ((options.screen.windowWidth * options.windowSize) / 2 - (width / 2));
despH = (options.game.width - width) / 2;
}
else
else if (options.notifications.getHorizontalPosition() == "RIGHT")
{
despH = (options.screen.windowWidth * options.windowSize) - width - padding;
despH = options.game.width - width - padding;
}
// Posición vertical
int despV = 0;
if (options.notifications.posV == pos_top)
if (options.notifications.getVerticalPosition() == "UPPER")
{
despV = padding;
}
else
{
despV = (options.screen.windowHeight * options.windowSize) - height - padding;
despV = options.game.height - height - padding;
}
const int travelDist = height + padding;
// Offset
int offset = 0;
if (options.notifications.posV == pos_top)
if (options.notifications.getVerticalPosition() == "UPPER")
{
offset = (int)notifications_.size() > 0 ? notifications_.back().y + travelDist : despV;
offset = static_cast<int>(notifications_.size()) > 0 ? notifications_.back().y + travelDist : despV;
}
else
{
offset = (int)notifications_.size() > 0 ? notifications_.back().y - travelDist : despV;
offset = static_cast<int>(notifications_.size()) > 0 ? notifications_.back().y - travelDist : despV;
}
// Crea la notificacion
@@ -234,7 +234,7 @@ void Notifier::show(std::string text1, std::string text2, int icon)
n.state = ns_rising;
n.text1 = text1;
n.text2 = text2;
if (options.notifications.posV == pos_top)
if (options.notifications.getVerticalPosition() == "UPPER")
{
n.rect = {despH, offset - travelDist, width, height};
}
@@ -277,7 +277,7 @@ void Notifier::show(std::string text1, std::string text2, int icon)
}
// Escribe el texto de la notificación
color_t color = {255, 255, 255};
Color color = {255, 255, 255};
if (text2 != "")
{ // Dos lineas de texto
text_->writeColored(padding + iconSpace, padding, text1, color);