diff --git a/source/common/notify.h b/source/common/notify.h index 3cc3489..97a3156 100644 --- a/source/common/notify.h +++ b/source/common/notify.h @@ -60,7 +60,7 @@ private: Texture *textTexture; // Textura para la fuente de las notificaciones Texture *iconTexture; // Textura para los iconos de las notificaciones Text *text; // Objeto para dibujar texto - options_t *options; // Variable con todas las opciones del programa + options_t *options; // Opciones del programa // Variables color_t bgColor; // Color de fondo de las notificaciones @@ -81,7 +81,7 @@ public: // Destructor ~Notify(); - + // Dibuja las notificaciones por pantalla void render(); diff --git a/source/common/screen.cpp b/source/common/screen.cpp index b5938aa..42dc4a9 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -7,6 +7,7 @@ #include "jshader.h" #endif #include "dbgtxt.h" +#include "../service.h" // Constructor Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input, options_t *options) @@ -142,7 +143,7 @@ void Screen::setVideoMode(int videoMode) { #ifdef ARCADE videoMode = SCREEN_VIDEO_MODE_WINDOW; - //videoMode = SCREEN_VIDEO_MODE_FULLSCREEN; + // videoMode = SCREEN_VIDEO_MODE_FULLSCREEN; #endif // Si está activo el modo ventana quita el borde @@ -350,6 +351,12 @@ void Screen::checkInput() { showInfo = !showInfo; } + + // Comprueba el botón de SERVICE + if (checkServiceButton(input) == SERVICE_SHADERS) + { + switchShaders(); + } } // Agita la pantalla diff --git a/source/common/screen.h b/source/common/screen.h index f21f302..c573ccc 100644 --- a/source/common/screen.h +++ b/source/common/screen.h @@ -24,7 +24,7 @@ private: Input *input; // Objeto para leer las entradas de teclado o mando Notify *notify; // Pinta notificaciones en pantalla SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa - options_t *options; // Variable con todas las opciones del programa + options_t *options; // Opciones del programa // Variables int windowWidth; // Ancho de la pantalla o ventana diff --git a/source/define_buttons.h b/source/define_buttons.h index 2b79b37..9022045 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -17,11 +17,11 @@ class DefineButtons { private: // Objetos - Input *input; // Objeto pata gestionar la entrada - Text *text; // Objeto para escribir texto + Input *input; // Objeto pata gestionar la entrada + Text *text; // Objeto para escribir texto // Variables - options_t *options; // Variable con todas las variables de las opciones del programa + options_t *options; // Opciones del programa param_t *param; // Puntero con todos los parametros del programa section_t *section; // Indicador para el bucle del titulo bool enabled; // Indica si el objeto está habilitado diff --git a/source/director.cpp b/source/director.cpp index 86d970d..e110472 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -854,7 +854,7 @@ void Director::deleteMusics() // Ejecuta la sección con el logo void Director::runLogo() { - logo = new Logo(screen, asset, input, param, section); + logo = new Logo(screen, asset, input, options, param, section); logo->run(); delete logo; } @@ -862,7 +862,7 @@ void Director::runLogo() // Ejecuta la sección con la secuencia de introducción void Director::runIntro() { - intro = new Intro(screen, asset, input, lang, param, section, getMusic(musics, "intro.ogg")); + intro = new Intro(screen, asset, input, lang, options, param, section, getMusic(musics, "intro.ogg")); intro->run(); delete intro; } @@ -870,7 +870,7 @@ void Director::runIntro() // Ejecuta la sección con el titulo del juego void Director::runTitle() { - title = new Title(screen, asset, input, options, lang, param, section, getMusic(musics, "title.ogg")); + title = new Title(screen, asset, input, lang, options, param, section, getMusic(musics, "title.ogg")); title->run(); delete title; } @@ -879,7 +879,8 @@ void Director::runTitle() void Director::runGame() { const int playerID = section->options; - game = new Game(playerID, 0, screen, asset, lang, input, false, param, options, section, getMusic(musics, "playing.ogg")); + const int currentStage = 0; + game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, lang, options, param, section, getMusic(musics, "playing.ogg")); game->run(); delete game; } @@ -887,7 +888,7 @@ void Director::runGame() // Ejecuta la sección donde se muestran las instrucciones void Director::runInstructions() { - instructions = new Instructions(screen, asset, input, lang, param, section, getMusic(musics, "title.ogg")); + instructions = new Instructions(screen, asset, input, lang, options, param, section, getMusic(musics, "title.ogg")); instructions->run(); delete instructions; } @@ -895,7 +896,7 @@ void Director::runInstructions() // Ejecuta la sección donde se muestra la tabla de puntuaciones void Director::runHiScoreTable() { - hiScoreTable = new HiScoreTable(screen, asset, input, lang, param, options, section, getMusic(musics, "title.ogg")); + hiScoreTable = new HiScoreTable(screen, asset, input, lang, options, param, section, getMusic(musics, "title.ogg")); hiScoreTable->run(); delete hiScoreTable; } @@ -904,7 +905,8 @@ void Director::runHiScoreTable() void Director::runDemoGame() { const int playerID = (rand() % 2) + 1; - demoGame = new Game(playerID, 0, screen, asset, lang, input, true, param, options, section, nullptr); + const int currentStage = 0; + demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, lang, options, param, section, nullptr); demoGame->run(); delete demoGame; } diff --git a/source/director.h b/source/director.h index f77ac9c..5353ed9 100644 --- a/source/director.h +++ b/source/director.h @@ -41,7 +41,7 @@ private: section_t *section; // Sección y subsección actual del programa; // Variables - options_t *options; // Variable con todas las opciones del programa + options_t *options; // Opciones del programa param_t *param; // Variable con todos los parametros del programa std::string executablePath; // Path del ejecutable std::string systemFolder; // Carpeta del sistema donde guardar datos diff --git a/source/game.cpp b/source/game.cpp index b152f11..7b502ea 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -4,7 +4,7 @@ #define GAME_OVER_COUNTER 350 // Constructor -Game::Game(int playerID, int currentStage, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section, JA_Music_t *music) +Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music) { // Copia los punteros this->screen = screen; @@ -2047,21 +2047,8 @@ void Game::checkInput() } // Comprueba el botón de SERVICE - switch (checkServiceButton(input, 0)) + switch (checkServiceButton(input)) { - case SERVICE_EXIT: - { - section->name = SECTION_PROG_QUIT; - section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; - break; - } - - case SERVICE_SHADERS: - { - screen->switchShaders(); - break; - } - case SERVICE_RESET: { section->name = SECTION_PROG_LOGO; diff --git a/source/game.h b/source/game.h index 45d9222..4c6e54d 100644 --- a/source/game.h +++ b/source/game.h @@ -24,6 +24,9 @@ #include "enemy_formations.h" #include +#define GAME_MODE_DEMO_OFF false +#define GAME_MODE_DEMO_ON true + // Cantidad de elementos a escribir en los ficheros de datos #define TOTAL_SCORE_DATA 3 #define TOTAL_DEMO_DATA 2000 @@ -192,7 +195,7 @@ private: int difficulty; // Dificultad del juego float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad color_t difficultyColor; // Color asociado a la dificultad - options_t *options; // Variable con todas las opciones del programa + options_t *options; // Opciones del programa param_t *param; // Puntero con todos los parametros del programa int lastStageReached; // Contiene el número de la última pantalla que se ha alcanzado demo_t demo; // Variable con todas las variables relacionadas con el modo demo @@ -445,7 +448,7 @@ private: public: // Constructor - Game(int playerID, int currentStage, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section, JA_Music_t *music); + Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music); // Destructor ~Game(); diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index 6d8936c..91cf49f 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -3,7 +3,7 @@ #include // Constructor -HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, options_t *options, section_t *section, JA_Music_t *music) +HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music) { // Copia punteros this->screen = screen; @@ -209,20 +209,32 @@ void HiScoreTable::checkInput() } // Comprueba el botón de SERVICE - switch (checkServiceButton(input, 0)) + switch (checkServiceButton(input)) { - case SERVICE_EXIT: - section->name = SECTION_PROG_QUIT; - section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; + case SERVICE_RESET: + { + section->name = SECTION_PROG_LOGO; + screen->showNotification("Reset"); break; + } - case SERVICE_SHADERS: - screen->switchShaders(); + case SERVICE_MUTE: + { + const bool value = !options->audio.music.enabled; + options->audio.music.enabled = value; + options->audio.sound.enabled = value; + JA_EnableMusic(value); + JA_EnableSound(value); + const std::string text = value ? "on" : "off"; + screen->showNotification("Audio " + text); break; + } default: + { break; } + } // Comprueba el input para el resto de objetos screen->checkInput(); diff --git a/source/hiscore_table.h b/source/hiscore_table.h index 1a9c327..172869a 100644 --- a/source/hiscore_table.h +++ b/source/hiscore_table.h @@ -39,7 +39,7 @@ private: Fade *fade; // Objeto para renderizar fades Text *text; // Objeto para escribir texto JA_Music_t *music; // Musica de fondo - options_t *options; // Opciones y parametros del programa + options_t *options; // Opciones del programa section_t *section; // Estado del bucle principal para saber si continua o se sale param_t *param; // Puntero con todos los parametros del programa @@ -80,7 +80,7 @@ private: public: // Constructor - HiScoreTable(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, options_t *options, section_t *section, JA_Music_t *music); + HiScoreTable(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music); // Destructor ~HiScoreTable(); diff --git a/source/instructions.cpp b/source/instructions.cpp index 7ff7001..09fc5b3 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -3,7 +3,7 @@ #include // Constructor -Instructions::Instructions(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music) +Instructions::Instructions(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music) { // Copia los punteros this->screen = screen; @@ -13,6 +13,7 @@ Instructions::Instructions(Screen *screen, Asset *asset, Input *input, Lang *lan this->param = param; this->section = section; this->music = music; + this->options = options; renderer = screen->getRenderer(); // Crea objetos @@ -338,20 +339,32 @@ void Instructions::checkInput() } // Comprueba el botón de SERVICE - switch (checkServiceButton(input, 0)) + switch (checkServiceButton(input)) { - case SERVICE_EXIT: - section->name = SECTION_PROG_QUIT; - section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; + case SERVICE_RESET: + { + section->name = SECTION_PROG_LOGO; + screen->showNotification("Reset"); break; + } - case SERVICE_SHADERS: - screen->switchShaders(); + case SERVICE_MUTE: + { + const bool value = !options->audio.music.enabled; + options->audio.music.enabled = value; + options->audio.sound.enabled = value; + JA_EnableMusic(value); + JA_EnableSound(value); + const std::string text = value ? "on" : "off"; + screen->showNotification("Audio " + text); break; + } default: + { break; } + } // Comprueba el input para el resto de objetos screen->checkInput(); diff --git a/source/instructions.h b/source/instructions.h index ed7d8c3..cb604ca 100644 --- a/source/instructions.h +++ b/source/instructions.h @@ -47,6 +47,7 @@ private: JA_Music_t *music; // Musica de fondo section_t *section; // Estado del bucle principal para saber si continua o se sale param_t *param; // Puntero con todos los parametros del programa + options_t *options; // Opciones del programa // Variables int counter; // Contador @@ -86,7 +87,7 @@ private: public: // Constructor - Instructions(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music); + Instructions(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music); // Destructor ~Instructions(); diff --git a/source/intro.cpp b/source/intro.cpp index 531c9f2..dcc1eb5 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -2,7 +2,7 @@ #include "service.h" // Constructor -Intro::Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music) +Intro::Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music) { // Copia los punteros this->screen = screen; @@ -208,20 +208,32 @@ void Intro::checkInput() } // Comprueba el botón de SERVICE - switch (checkServiceButton(input, 0)) + switch (checkServiceButton(input)) { - case SERVICE_EXIT: - section->name = SECTION_PROG_QUIT; - section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; + case SERVICE_RESET: + { + section->name = SECTION_PROG_LOGO; + screen->showNotification("Reset"); break; + } - case SERVICE_SHADERS: - screen->switchShaders(); + case SERVICE_MUTE: + { + const bool value = !options->audio.music.enabled; + options->audio.music.enabled = value; + options->audio.sound.enabled = value; + JA_EnableMusic(value); + JA_EnableSound(value); + const std::string text = value ? "on" : "off"; + screen->showNotification("Audio " + text); break; + } default: + { break; } + } // Comprueba el input para el resto de objetos screen->checkInput(); diff --git a/source/intro.h b/source/intro.h index a86d9e0..7012c19 100644 --- a/source/intro.h +++ b/source/intro.h @@ -32,6 +32,7 @@ private: std::vector texts; // Textos de la intro Text *text; // Textos de la intro section_t *section; // Estado del bucle principal para saber si continua o se sale + options_t *options; // Opciones del programa param_t *param; // Puntero con todos los parametros del programa // Variables @@ -60,7 +61,7 @@ private: public: // Constructor - Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music); + Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music); // Destructor ~Intro(); diff --git a/source/logo.cpp b/source/logo.cpp index baea64d..4659b0a 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -3,12 +3,13 @@ #include // Constructor -Logo::Logo(Screen *screen, Asset *asset, Input *input, param_t *param, section_t *section) +Logo::Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section) { // Copia la dirección de los objetos this->screen = screen; this->asset = asset; this->input = input; + this->options = options; this->param = param; this->section = section; SDL_Renderer *renderer = screen->getRenderer(); @@ -118,21 +119,40 @@ void Logo::checkInput() } // Comprueba el botón de SERVICE - switch (checkServiceButton(input, 0)) + switch (checkServiceButton(input)) { case SERVICE_EXIT: + { section->name = SECTION_PROG_QUIT; section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; return; break; + } - case SERVICE_SHADERS: - screen->switchShaders(); + case SERVICE_RESET: + { + section->name = SECTION_PROG_LOGO; + screen->showNotification("Reset"); break; + } + + case SERVICE_MUTE: + { + const bool value = !options->audio.music.enabled; + options->audio.music.enabled = value; + options->audio.sound.enabled = value; + JA_EnableMusic(value); + JA_EnableSound(value); + const std::string text = value ? "on" : "off"; + screen->showNotification("Audio " + text); + break; + } default: + { break; } + } // Comprueba el input para el resto de objetos screen->checkInput(); diff --git a/source/logo.h b/source/logo.h index 521cc93..1373909 100644 --- a/source/logo.h +++ b/source/logo.h @@ -33,6 +33,7 @@ private: Sprite *sinceSprite; // Sprite para manejar la sinceTexture section_t *section; // Estado del bucle principal para saber si continua o se sale param_t *param; // Puntero con todos los parametros del programa + options_t *options; // Opciones del programa // Variables std::vector color; // Vector con los colores para el fade @@ -69,7 +70,7 @@ private: public: // Constructor - Logo(Screen *screen, Asset *asset, Input *input, param_t *param, section_t *section); + Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section); // Destructor ~Logo(); diff --git a/source/scoreboard.h b/source/scoreboard.h index 2362d2b..f2d047c 100644 --- a/source/scoreboard.h +++ b/source/scoreboard.h @@ -50,7 +50,7 @@ private: std::vector panelTexture; // Texturas para dibujar cada panel; // Variables - struct options_t *options; // Variable con todas las variables de las opciones del programa + options_t *options; // Opciones del programa int stage; // Número de fase actual std::string name[SCOREBOARD_MAX_PANELS]; // Nom de cada jugador int score[SCOREBOARD_MAX_PANELS]; // Puntuación de los jugadores diff --git a/source/service.cpp b/source/service.cpp index c7439d4..a7eca78 100644 --- a/source/service.cpp +++ b/source/service.cpp @@ -3,41 +3,87 @@ // Comprueba el botón de servicio del controlador "index" int checkServiceButton(Input *input, int index) { - if (input->checkInput(input_service, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + if (index == -1) { - if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + for (int i = 0; i < input->getNumControllers(); ++i) { - return SERVICE_EXIT; - } + if (input->checkInput(input_service, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + return SERVICE_EXIT; + } - else if (input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) - { - return SERVICE_CONFIG; - } + else if (input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + return SERVICE_CONFIG; + } - else if (input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) - { - return SERVICE_SHADERS; - } + else if (input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + return SERVICE_SHADERS; + } - else if (input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) - { - return SERVICE_PAUSE; - } + else if (input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + return SERVICE_PAUSE; + } - else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) - { - return SERVICE_SWAP_CONTROLLERS; - } + else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + return SERVICE_SWAP_CONTROLLERS; + } - else if (input->checkInput(input_down, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) - { - return SERVICE_RESET; - } + else if (input->checkInput(input_down, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + return SERVICE_RESET; + } - else if (input->checkInput(input_left, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + else if (input->checkInput(input_left, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i)) + { + return SERVICE_MUTE; + } + } + } + } + else + { + if (input->checkInput(input_service, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) { - return SERVICE_MUTE; + if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + { + return SERVICE_EXIT; + } + + else if (input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + { + return SERVICE_CONFIG; + } + + else if (input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + { + return SERVICE_SHADERS; + } + + else if (input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + { + return SERVICE_PAUSE; + } + + else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + { + return SERVICE_SWAP_CONTROLLERS; + } + + else if (input->checkInput(input_down, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + { + return SERVICE_RESET; + } + + else if (input->checkInput(input_left, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) + { + return SERVICE_MUTE; + } } } diff --git a/source/service.h b/source/service.h index 4924502..f7d917e 100644 --- a/source/service.h +++ b/source/service.h @@ -18,4 +18,4 @@ enum service_e }; // Comprueba el botón de servicio del controlador "index" -int checkServiceButton(Input *input, int index); \ No newline at end of file +int checkServiceButton(Input *input, int index = -1); \ No newline at end of file diff --git a/source/title.cpp b/source/title.cpp index 73f476f..fb838ad 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -2,7 +2,7 @@ #include "service.h" // Constructor -Title::Title(Screen *screen, Asset *asset, Input *input, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music) +Title::Title(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music) { // Copia las direcciones de los punteros y objetos this->screen = screen; @@ -268,33 +268,47 @@ void Title::checkInput() ////////////////////////////////////////////////// // Comprueba el botón de SERVICE - switch (checkServiceButton(input, 0)) + switch (checkServiceButton(input)) { - case SERVICE_EXIT: - section->name = SECTION_PROG_QUIT; - section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; - break; - case SERVICE_RESET: + { section->name = SECTION_PROG_LOGO; screen->showNotification("Reset"); break; + } - case SERVICE_SHADERS: - screen->switchShaders(); - break; - - case SERVICE_CONFIG: - defineButtons->enable(0); + case SERVICE_MUTE: + { + const bool value = !options->audio.music.enabled; + options->audio.music.enabled = value; + options->audio.sound.enabled = value; + JA_EnableMusic(value); + JA_EnableSound(value); + const std::string text = value ? "on" : "off"; + screen->showNotification("Audio " + text); break; + } case SERVICE_SWAP_CONTROLLERS: + { swapControllers(); break; + } default: + { break; } + } + + // Comprueba si algun mando quiere ser configurado + for (int i = 0; i < input->getNumControllers(); ++i) + { + if (checkServiceButton(input, i) == SERVICE_CONFIG) + { + defineButtons->enable(i); + } + } // Comprueba el botón de START de los mandos for (int i = 0; i < input->getNumControllers(); ++i) diff --git a/source/title.h b/source/title.h index e9dbcc4..291e40a 100644 --- a/source/title.h +++ b/source/title.h @@ -72,7 +72,7 @@ private: section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa int postFade; // Opción a realizar cuando termina el fundido - options_t *options; // Variable con todas las variables de las opciones del programa + options_t *options; // Opciones del programa param_t *param; // Puntero con todos los parametros del programa int numControllers; // Número de mandos conectados @@ -102,7 +102,7 @@ private: public: // Constructor - Title(Screen *screen, Asset *asset, Input *input, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music); + Title(Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options, param_t *param, section_t *section, JA_Music_t *music); // Destructor ~Title();