Un altre punteret a pendre per cul: options

This commit is contained in:
2024-09-27 19:00:09 +02:00
parent 0de9188547
commit 20de9e4b72
26 changed files with 677 additions and 679 deletions

View File

@@ -1,15 +1,15 @@
#include "notify.h"
#include "options.h"
#include <string>
#include <stdio.h>
#include <iostream>
// Constructor
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile, options_t *options)
Notify::Notify(SDL_Renderer *renderer, std::string iconFile, std::string bitmapFile, std::string textFile, std::string soundFile)
{
// Inicializa variables
this->renderer = renderer;
this->options = options;
bgColor = options->notification.color;
bgColor = options.notification.color;
waitTime = 150;
stack = false;
@@ -64,7 +64,7 @@ void Notify::update()
// Hace sonar la notificación en el primer frame
if (notifications[i].counter == 1)
{
if (options->notification.sound)
if (options.notification.sound)
{
if (notifications[i].state == ns_rising)
{ // Reproduce el sonido de la notificación
@@ -79,7 +79,7 @@ void Notify::update()
const float step = ((float)notifications[i].counter / notifications[i].travelDist);
const int alpha = 255 * step;
if (options->notification.posV == pos_top)
if (options.notification.posV == pos_top)
{
notifications[i].rect.y++;
}
@@ -111,7 +111,7 @@ void Notify::update()
const float step = (notifications[i].counter / (float)notifications[i].travelDist);
const int alpha = 255 * (1 - step);
if (options->notification.posV == pos_top)
if (options.notification.posV == pos_top)
{
notifications[i].rect.y--;
}
@@ -187,35 +187,35 @@ void Notify::showText(std::string text1, std::string text2, int icon)
// Posición horizontal
int despH = 0;
if (options->notification.posH == pos_left)
if (options.notification.posH == pos_left)
{
despH = paddingOut;
}
else if (options->notification.posH == pos_middle)
else if (options.notification.posH == pos_middle)
{
despH = ((options->video.gameWidth / 2) - (width / 2));
despH = ((options.video.gameWidth / 2) - (width / 2));
}
else
{
despH = options->video.gameWidth - width - paddingOut;
despH = options.video.gameWidth - width - paddingOut;
}
// Posición vertical
int despV = 0;
if (options->notification.posV == pos_top)
if (options.notification.posV == pos_top)
{
despV = paddingOut;
}
else
{
despV = options->video.gameHeight - height - paddingOut;
despV = options.video.gameHeight - height - paddingOut;
}
const int travelDist = height + paddingOut;
// Offset
int offset = 0;
if (options->notification.posV == pos_top)
if (options.notification.posV == pos_top)
{
offset = (int)notifications.size() > 0 ? notifications.back().y + travelDist : despV;
}
@@ -235,7 +235,7 @@ void Notify::showText(std::string text1, std::string text2, int icon)
n.text1 = text1;
n.text2 = text2;
n.shape = shape;
if (options->notification.posV == pos_top)
if (options.notification.posV == pos_top)
{
n.rect = {despH, offset - travelDist, width, height};
}