eliminades les opcions de configuracio de posicio de les notificacions

This commit is contained in:
2025-10-27 13:24:43 +01:00
parent cdb9bde6aa
commit aacb14149f
4 changed files with 22 additions and 91 deletions

View File

@@ -59,7 +59,6 @@ constexpr bool SOUND_ENABLED = true; // Sonido habilitado por defecto
// =============================================================================
// NOTIFICATIONS
// =============================================================================
constexpr Options::NotificationPosition NOTIFICATION_POSITION = Options::NotificationPosition::UPPER_LEFT; // Posición de las notificaciones por defecto
constexpr bool NOTIFICATION_SOUND = true; // Sonido de las notificaciones por defecto
const Uint8 NOTIFICATION_COLOR = static_cast<Uint8>(PaletteColor::BLUE); // Color de las notificaciones por defecto

View File

@@ -20,22 +20,6 @@ constexpr int convertVolume(int volume_percent) {
}
} // namespace VolumeHelpers
// Posiciones de las notificaciones
enum class NotificationPosition {
UPPER_LEFT,
UPPER_CENTER,
UPPER_RIGHT,
BOTTOM_LEFT,
BOTTOM_CENTER,
BOTTOM_RIGHT,
TOP,
BOTTOM,
LEFT,
RIGHT,
CENTER,
UNKNOWN,
};
// Tipos de control de teclado
enum class ControlScheme {
CURSOR,
@@ -52,54 +36,18 @@ namespace Options {
// Estructura para las opciones de las notificaciones
struct Notification {
NotificationPosition pos; // Ubicación de las notificaciones en pantalla
bool sound; // Indica si las notificaciones suenan
Uint8 color; // Color de las notificaciones
bool sound; // Indica si las notificaciones suenan
Uint8 color; // Color de las notificaciones
// Constructor por defecto
Notification()
: pos(GameDefaults::NOTIFICATION_POSITION),
sound(GameDefaults::NOTIFICATION_SOUND),
: sound(GameDefaults::NOTIFICATION_SOUND),
color(GameDefaults::NOTIFICATION_COLOR) {}
// Constructor
Notification(NotificationPosition p, bool s, Uint8 c)
: pos(p),
sound(s),
Notification(bool s, Uint8 c)
: sound(s),
color(c) {}
// Método que devuelve la posición horizontal
NotificationPosition getHorizontalPosition() const {
switch (pos) {
case NotificationPosition::UPPER_LEFT:
case NotificationPosition::BOTTOM_LEFT:
return NotificationPosition::LEFT;
case NotificationPosition::UPPER_CENTER:
case NotificationPosition::BOTTOM_CENTER:
return NotificationPosition::CENTER;
case NotificationPosition::UPPER_RIGHT:
case NotificationPosition::BOTTOM_RIGHT:
return NotificationPosition::RIGHT;
default:
return NotificationPosition::UNKNOWN;
}
}
// Método que devuelve la posición vertical
NotificationPosition getVerticalPosition() const {
switch (pos) {
case NotificationPosition::UPPER_LEFT:
case NotificationPosition::UPPER_CENTER:
case NotificationPosition::UPPER_RIGHT:
return NotificationPosition::TOP;
case NotificationPosition::BOTTOM_LEFT:
case NotificationPosition::BOTTOM_CENTER:
case NotificationPosition::BOTTOM_RIGHT:
return NotificationPosition::BOTTOM;
default:
return NotificationPosition::UNKNOWN;
}
}
};
// Estructura para albergar trucos
@@ -308,15 +256,15 @@ struct Game {
};
// --- Variables globales (inline C++17+) ---
inline std::string version{}; // Versión del fichero de configuración. Sirve para saber si las opciones son compatibles
inline bool console{false}; // Indica si ha de mostrar información por la consola de texto
inline Cheat cheats{}; // Contiene trucos y ventajas para el juego
inline Game game{}; // Opciones de juego
inline Video video{}; // Opciones de video
inline Stats stats{}; // Datos con las estadisticas de juego
inline Notification notifications{}; // Opciones relativas a las notificaciones;
inline Window window{}; // Opciones relativas a la ventana
inline Audio audio{}; // Opciones relativas al audio
inline std::string version{}; // Versión del fichero de configuración. Sirve para saber si las opciones son compatibles
inline bool console{false}; // Indica si ha de mostrar información por la consola de texto
inline Cheat cheats{}; // Contiene trucos y ventajas para el juego
inline Game game{}; // Opciones de juego
inline Video video{}; // Opciones de video
inline Stats stats{}; // Datos con las estadisticas de juego
inline Notification notifications{}; // Opciones relativas a las notificaciones;
inline Window window{}; // Opciones relativas a la ventana
inline Audio audio{}; // Opciones relativas al audio
inline ControlScheme keys{GameDefaults::CONTROL_SCHEME}; // Teclas usadas para jugar
// --- Funciones ---

View File

@@ -62,7 +62,7 @@ void Notifier::update() {
switch (notification.state) {
case NotificationStatus::RISING: {
const int DIRECTION = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1;
const int DIRECTION = 1;
notification.rect.y += DIRECTION;
if (notification.rect.y == notification.y) {
@@ -80,7 +80,7 @@ void Notifier::update() {
}
case NotificationStatus::VANISHING: {
const int DIRECTION = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? -1 : 1;
const int DIRECTION = -1;
notification.rect.y += DIRECTION;
if (notification.rect.y == notification.y - notification.travel_dist) {
@@ -145,31 +145,15 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
const auto SHAPE = NotificationShape::SQUARED;
// Posición horizontal
float desp_h = 0;
switch (Options::notifications.getHorizontalPosition()) {
case Options::NotificationPosition::LEFT:
desp_h = PADDING_OUT;
break;
case Options::NotificationPosition::CENTER:
desp_h = ((Options::game.width / 2) - (WIDTH / 2));
break;
case Options::NotificationPosition::RIGHT:
desp_h = Options::game.width - WIDTH - PADDING_OUT;
break;
default:
desp_h = 0;
break;
}
float desp_h = ((Options::game.width / 2) - (WIDTH / 2));
;
// Posición vertical
const int DESP_V = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? PADDING_OUT : Options::game.height - HEIGHT - PADDING_OUT;
const int DESP_V = PADDING_OUT;
// Offset
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT;
const int TRAVEL_MOD = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1;
const int TRAVEL_MOD = 1;
const int OFFSET = !notifications_.empty() ? notifications_.back().y + (TRAVEL_MOD * notifications_.back().travel_dist) : DESP_V;
// Crea la notificacion
@@ -183,7 +167,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
n.texts = texts;
n.shape = SHAPE;
n.display_duration = display_duration;
const float Y_POS = OFFSET + ((Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? -TRAVEL_DIST : TRAVEL_DIST);
const float Y_POS = OFFSET + -TRAVEL_DIST;
n.rect = {desp_h, Y_POS, WIDTH, HEIGHT};
// Crea la textura

View File

@@ -14,5 +14,5 @@ int main(int argc, char* argv[]) {
auto director = std::make_unique<Director>(argc, const_cast<const char**>(argv));
// Bucle principal
return director->run();
return Director::run();
}