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 // 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 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 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 } // 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 // Tipos de control de teclado
enum class ControlScheme { enum class ControlScheme {
CURSOR, CURSOR,
@@ -52,54 +36,18 @@ namespace Options {
// Estructura para las opciones de las notificaciones // Estructura para las opciones de las notificaciones
struct Notification { struct Notification {
NotificationPosition pos; // Ubicación de las notificaciones en pantalla bool sound; // Indica si las notificaciones suenan
bool sound; // Indica si las notificaciones suenan Uint8 color; // Color de las notificaciones
Uint8 color; // Color de las notificaciones
// Constructor por defecto // Constructor por defecto
Notification() Notification()
: pos(GameDefaults::NOTIFICATION_POSITION), : sound(GameDefaults::NOTIFICATION_SOUND),
sound(GameDefaults::NOTIFICATION_SOUND),
color(GameDefaults::NOTIFICATION_COLOR) {} color(GameDefaults::NOTIFICATION_COLOR) {}
// Constructor // Constructor
Notification(NotificationPosition p, bool s, Uint8 c) Notification(bool s, Uint8 c)
: pos(p), : sound(s),
sound(s),
color(c) {} 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 // Estructura para albergar trucos
@@ -308,15 +256,15 @@ struct Game {
}; };
// --- Variables globales (inline C++17+) --- // --- 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 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 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 Cheat cheats{}; // Contiene trucos y ventajas para el juego
inline Game game{}; // Opciones de juego inline Game game{}; // Opciones de juego
inline Video video{}; // Opciones de video inline Video video{}; // Opciones de video
inline Stats stats{}; // Datos con las estadisticas de juego inline Stats stats{}; // Datos con las estadisticas de juego
inline Notification notifications{}; // Opciones relativas a las notificaciones; inline Notification notifications{}; // Opciones relativas a las notificaciones;
inline Window window{}; // Opciones relativas a la ventana inline Window window{}; // Opciones relativas a la ventana
inline Audio audio{}; // Opciones relativas al audio inline Audio audio{}; // Opciones relativas al audio
inline ControlScheme keys{GameDefaults::CONTROL_SCHEME}; // Teclas usadas para jugar inline ControlScheme keys{GameDefaults::CONTROL_SCHEME}; // Teclas usadas para jugar
// --- Funciones --- // --- Funciones ---

View File

@@ -62,7 +62,7 @@ void Notifier::update() {
switch (notification.state) { switch (notification.state) {
case NotificationStatus::RISING: { case NotificationStatus::RISING: {
const int DIRECTION = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1; const int DIRECTION = 1;
notification.rect.y += DIRECTION; notification.rect.y += DIRECTION;
if (notification.rect.y == notification.y) { if (notification.rect.y == notification.y) {
@@ -80,7 +80,7 @@ void Notifier::update() {
} }
case NotificationStatus::VANISHING: { case NotificationStatus::VANISHING: {
const int DIRECTION = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? -1 : 1; const int DIRECTION = -1;
notification.rect.y += DIRECTION; notification.rect.y += DIRECTION;
if (notification.rect.y == notification.y - notification.travel_dist) { 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; const auto SHAPE = NotificationShape::SQUARED;
// Posición horizontal // Posición horizontal
float desp_h = 0; float desp_h = ((Options::game.width / 2) - (WIDTH / 2));
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;
}
// Posición vertical // 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 // Offset
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT; 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; const int OFFSET = !notifications_.empty() ? notifications_.back().y + (TRAVEL_MOD * notifications_.back().travel_dist) : DESP_V;
// Crea la notificacion // Crea la notificacion
@@ -183,7 +167,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
n.texts = texts; n.texts = texts;
n.shape = SHAPE; n.shape = SHAPE;
n.display_duration = display_duration; 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}; n.rect = {desp_h, Y_POS, WIDTH, HEIGHT};
// Crea la textura // 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)); auto director = std::make_unique<Director>(argc, const_cast<const char**>(argv));
// Bucle principal // Bucle principal
return director->run(); return Director::run();
} }