refactor jail_audio: namespace Ja, enum class, tipus sense prefix JA_
This commit is contained in:
@@ -27,7 +27,9 @@
|
||||
#include "game/entities/player.h" // for Player
|
||||
#include "game/options.hpp" // for Options
|
||||
#include "game/ui/menu.h" // for Menu
|
||||
struct JA_Sound_t;
|
||||
namespace Ja {
|
||||
struct Sound;
|
||||
} // namespace Ja
|
||||
|
||||
namespace {
|
||||
// Constantes geométricas y temporales compartidas por los helpers de initEnemyFormations
|
||||
@@ -1521,7 +1523,7 @@ void Game::updateDeath() {
|
||||
// Hace sonar aleatoriamente uno de los 4 sonidos de burbujas
|
||||
if (!demo_.enabled) {
|
||||
const Uint8 INDEX = rand() % 4;
|
||||
JA_Sound_t *sound[4] = {bubble1_sound_, bubble2_sound_, bubble3_sound_, bubble4_sound_};
|
||||
Ja::Sound *sound[4] = {bubble1_sound_, bubble2_sound_, bubble3_sound_, bubble4_sound_};
|
||||
Audio::get()->playSound(sound[INDEX]);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-18
@@ -18,8 +18,10 @@ class SmartSprite;
|
||||
class Sprite;
|
||||
class Text;
|
||||
class Texture;
|
||||
struct JA_Music_t;
|
||||
struct JA_Sound_t;
|
||||
namespace Ja {
|
||||
struct Music;
|
||||
struct Sound;
|
||||
} // namespace Ja
|
||||
|
||||
// Clase Game
|
||||
class Game {
|
||||
@@ -315,23 +317,23 @@ class Game {
|
||||
Sprite *game_over_sprite_; // Sprite para dibujar los graficos del game over
|
||||
Sprite *game_over_end_sprite_; // Sprite para dibujar los graficos del game over de acabar el juego
|
||||
|
||||
JA_Sound_t *balloon_sound_; // Sonido para la explosión del globo
|
||||
JA_Sound_t *bullet_sound_; // Sonido para los disparos
|
||||
JA_Sound_t *player_collision_sound_; // Sonido para la colisión del jugador con un enemigo
|
||||
JA_Sound_t *hi_score_sound_; // Sonido para cuando se alcanza la máxima puntuación
|
||||
JA_Sound_t *item_drop_sound_; // Sonido para cuando se genera un item
|
||||
JA_Sound_t *item_pick_up_sound_; // Sonido para cuando se recoge un item
|
||||
JA_Sound_t *coffee_out_sound_; // Sonido para cuando el jugador pierde el café al recibir un impacto
|
||||
JA_Sound_t *stage_change_sound_; // Sonido para cuando se cambia de fase
|
||||
JA_Sound_t *bubble1_sound_; // Sonido para cuando el jugador muere
|
||||
JA_Sound_t *bubble2_sound_; // Sonido para cuando el jugador muere
|
||||
JA_Sound_t *bubble3_sound_; // Sonido para cuando el jugador muere
|
||||
JA_Sound_t *bubble4_sound_; // Sonido para cuando el jugador muere
|
||||
JA_Sound_t *clock_sound_; // Sonido para cuando se detiene el tiempo con el item reloj
|
||||
JA_Sound_t *power_ball_sound_; // Sonido para cuando se explota una Power Ball
|
||||
JA_Sound_t *coffee_machine_sound_; // Sonido para cuando la máquina de café toca el suelo
|
||||
Ja::Sound *balloon_sound_; // Sonido para la explosión del globo
|
||||
Ja::Sound *bullet_sound_; // Sonido para los disparos
|
||||
Ja::Sound *player_collision_sound_; // Sonido para la colisión del jugador con un enemigo
|
||||
Ja::Sound *hi_score_sound_; // Sonido para cuando se alcanza la máxima puntuación
|
||||
Ja::Sound *item_drop_sound_; // Sonido para cuando se genera un item
|
||||
Ja::Sound *item_pick_up_sound_; // Sonido para cuando se recoge un item
|
||||
Ja::Sound *coffee_out_sound_; // Sonido para cuando el jugador pierde el café al recibir un impacto
|
||||
Ja::Sound *stage_change_sound_; // Sonido para cuando se cambia de fase
|
||||
Ja::Sound *bubble1_sound_; // Sonido para cuando el jugador muere
|
||||
Ja::Sound *bubble2_sound_; // Sonido para cuando el jugador muere
|
||||
Ja::Sound *bubble3_sound_; // Sonido para cuando el jugador muere
|
||||
Ja::Sound *bubble4_sound_; // Sonido para cuando el jugador muere
|
||||
Ja::Sound *clock_sound_; // Sonido para cuando se detiene el tiempo con el item reloj
|
||||
Ja::Sound *power_ball_sound_; // Sonido para cuando se explota una Power Ball
|
||||
Ja::Sound *coffee_machine_sound_; // Sonido para cuando la máquina de café toca el suelo
|
||||
|
||||
JA_Music_t *game_music_; // Musica de fondo
|
||||
Ja::Music *game_music_; // Musica de fondo
|
||||
|
||||
// Variables
|
||||
int num_players_; // Numero de jugadores
|
||||
|
||||
@@ -7,8 +7,10 @@ class SmartSprite;
|
||||
class Text;
|
||||
class Texture;
|
||||
class Writer;
|
||||
struct JA_Music_t;
|
||||
struct Section;
|
||||
namespace Ja {
|
||||
struct Music;
|
||||
} // namespace Ja
|
||||
|
||||
// Clase Intro
|
||||
class Intro {
|
||||
@@ -36,7 +38,7 @@ class Intro {
|
||||
// Variables
|
||||
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 ticks_speed_; // Velocidad a la que se repiten los bucles del programa
|
||||
JA_Music_t *music_; // Musica para la intro
|
||||
Ja::Music *music_; // Musica para la intro
|
||||
int scene_; // Indica que escena está activa
|
||||
|
||||
void update(); // Actualiza las variables del objeto
|
||||
|
||||
@@ -15,8 +15,10 @@ class SmartSprite;
|
||||
class Sprite;
|
||||
class Text;
|
||||
class Texture;
|
||||
struct JA_Music_t;
|
||||
struct JA_Sound_t;
|
||||
namespace Ja {
|
||||
struct Music;
|
||||
struct Sound;
|
||||
} // namespace Ja
|
||||
|
||||
class Title {
|
||||
public:
|
||||
@@ -70,8 +72,8 @@ class Title {
|
||||
Fade *fade_; // Objeto para realizar fundidos en pantalla
|
||||
|
||||
// Variables
|
||||
JA_Music_t *title_music_; // Musica para el titulo
|
||||
JA_Sound_t *crash_sound_; // Sonido con el impacto del título
|
||||
Ja::Music *title_music_; // Musica para el titulo
|
||||
Ja::Sound *crash_sound_; // Sonido con el impacto del título
|
||||
int background_counter_; // Temporizador para el fondo de tiles de la pantalla de titulo
|
||||
int counter_; // Temporizador para la pantalla de titulo
|
||||
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
||||
|
||||
+14
-14
@@ -6,7 +6,7 @@
|
||||
#include <sstream> // for basic_stringstream
|
||||
|
||||
#include "core/audio/audio.hpp" // for Audio::get (playSound)
|
||||
#include "core/audio/jail_audio.hpp" // for JA_LoadSound, JA_DeleteSound (propietat local)
|
||||
#include "core/audio/jail_audio.hpp" // for Ja::loadSound, Ja::deleteSound (propietat local)
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, InputAction
|
||||
#include "core/rendering/text.h" // for Text
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
@@ -40,7 +40,7 @@ Menu::Menu(SDL_Renderer *renderer, const std::string &file)
|
||||
center_x_ = 0;
|
||||
center_y_ = 0;
|
||||
widest_item_ = 0;
|
||||
default_action_when_cancel = 0;
|
||||
default_action_when_cancel_ = 0;
|
||||
|
||||
// Selector
|
||||
selector_.origin_y = 0;
|
||||
@@ -73,15 +73,15 @@ Menu::~Menu() {
|
||||
renderer_ = nullptr;
|
||||
|
||||
if (sound_move_ != nullptr) {
|
||||
JA_DeleteSound(sound_move_);
|
||||
Ja::deleteSound(sound_move_);
|
||||
}
|
||||
|
||||
if (sound_accept_ != nullptr) {
|
||||
JA_DeleteSound(sound_accept_);
|
||||
Ja::deleteSound(sound_accept_);
|
||||
}
|
||||
|
||||
if (sound_cancel_ != nullptr) {
|
||||
JA_DeleteSound(sound_cancel_);
|
||||
Ja::deleteSound(sound_cancel_);
|
||||
}
|
||||
|
||||
delete text_;
|
||||
@@ -229,21 +229,21 @@ auto Menu::setVars(const std::string &var, const std::string &value) -> bool {
|
||||
else if (var == "sound_cancel") {
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) {
|
||||
sound_cancel_ = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
sound_cancel_ = Ja::loadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "sound_accept") {
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) {
|
||||
sound_accept_ = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
sound_accept_ = Ja::loadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
else if (var == "sound_move") {
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) {
|
||||
sound_move_ = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
sound_move_ = Ja::loadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ auto Menu::setVars(const std::string &var, const std::string &value) -> bool {
|
||||
}
|
||||
|
||||
else if (var == "defaultActionWhenCancel") {
|
||||
default_action_when_cancel = std::stoi(value);
|
||||
default_action_when_cancel_ = std::stoi(value);
|
||||
}
|
||||
|
||||
else if (var.empty()) {
|
||||
@@ -341,15 +341,15 @@ auto Menu::setVars(const std::string &var, const std::string &value) -> bool {
|
||||
void Menu::loadAudioFile(const std::string &file, int sound) {
|
||||
switch (sound) {
|
||||
case SOUND_ACCEPT:
|
||||
sound_accept_ = JA_LoadSound(file.c_str());
|
||||
sound_accept_ = Ja::loadSound(file.c_str());
|
||||
break;
|
||||
|
||||
case SOUND_CANCEL:
|
||||
sound_cancel_ = JA_LoadSound(file.c_str());
|
||||
sound_cancel_ = Ja::loadSound(file.c_str());
|
||||
break;
|
||||
|
||||
case SOUND_MOVE:
|
||||
sound_move_ = JA_LoadSound(file.c_str());
|
||||
sound_move_ = Ja::loadSound(file.c_str());
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -770,7 +770,7 @@ void Menu::setItemCaption(int index, const std::string &text) {
|
||||
|
||||
// Establece el indice del itemm que se usará por defecto al cancelar el menu
|
||||
void Menu::setDefaultActionWhenCancel(int item) {
|
||||
default_action_when_cancel = item;
|
||||
default_action_when_cancel_ = item;
|
||||
}
|
||||
|
||||
// Gestiona la entrada de teclado y mando durante el menu
|
||||
@@ -797,7 +797,7 @@ void Menu::checkInput() {
|
||||
}
|
||||
|
||||
if (Input::get()->checkInput(CANCEL, REPEAT_FALSE)) {
|
||||
item_selected_ = default_action_when_cancel;
|
||||
item_selected_ = default_action_when_cancel_;
|
||||
if (sound_cancel_ != nullptr) {
|
||||
Audio::get()->playSound(sound_cancel_);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
#include "utils/utils.h" // for Color
|
||||
class Text;
|
||||
struct JA_Sound_t;
|
||||
namespace Ja {
|
||||
struct Sound;
|
||||
} // namespace Ja
|
||||
|
||||
// Tipos de fondos para el menú
|
||||
constexpr int MENU_BACKGROUND_TRANSPARENT = 0;
|
||||
@@ -140,9 +142,9 @@ class Menu {
|
||||
bool is_centered_on_y_; // Variable para saber si el menu debe estar centrado respecto a un punto en el eje Y
|
||||
bool are_elements_centered_on_x_; // Variable para saber si los elementos van centrados en el eje X
|
||||
int widest_item_; // Anchura del elemento más ancho
|
||||
JA_Sound_t *sound_accept_; // Sonido al aceptar o elegir una opción del menu
|
||||
JA_Sound_t *sound_cancel_; // Sonido al cancelar el menu
|
||||
JA_Sound_t *sound_move_; // Sonido al mover el selector
|
||||
Ja::Sound *sound_accept_; // Sonido al aceptar o elegir una opción del menu
|
||||
Ja::Sound *sound_cancel_; // Sonido al cancelar el menu
|
||||
Ja::Sound *sound_move_; // Sonido al mover el selector
|
||||
Color color_greyed_; // Color para los elementos agrisados
|
||||
Rectangle rect_bg_; // Rectangulo de fondo del menu
|
||||
std::vector<Item> items_; // Estructura para cada elemento del menu
|
||||
|
||||
Reference in New Issue
Block a user