Correcciones en el botón de servicio

This commit is contained in:
2024-09-15 15:27:12 +02:00
parent 41e57064cb
commit 333c905b1a
21 changed files with 224 additions and 105 deletions

View File

@@ -60,7 +60,7 @@ private:
Texture *textTexture; // Textura para la fuente de las notificaciones Texture *textTexture; // Textura para la fuente de las notificaciones
Texture *iconTexture; // Textura para los iconos de las notificaciones Texture *iconTexture; // Textura para los iconos de las notificaciones
Text *text; // Objeto para dibujar texto Text *text; // Objeto para dibujar texto
options_t *options; // Variable con todas las opciones del programa options_t *options; // Opciones del programa
// Variables // Variables
color_t bgColor; // Color de fondo de las notificaciones color_t bgColor; // Color de fondo de las notificaciones
@@ -81,7 +81,7 @@ public:
// Destructor // Destructor
~Notify(); ~Notify();
// Dibuja las notificaciones por pantalla // Dibuja las notificaciones por pantalla
void render(); void render();

View File

@@ -7,6 +7,7 @@
#include "jshader.h" #include "jshader.h"
#endif #endif
#include "dbgtxt.h" #include "dbgtxt.h"
#include "../service.h"
// Constructor // Constructor
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input, options_t *options) 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 #ifdef ARCADE
videoMode = SCREEN_VIDEO_MODE_WINDOW; videoMode = SCREEN_VIDEO_MODE_WINDOW;
//videoMode = SCREEN_VIDEO_MODE_FULLSCREEN; // videoMode = SCREEN_VIDEO_MODE_FULLSCREEN;
#endif #endif
// Si está activo el modo ventana quita el borde // Si está activo el modo ventana quita el borde
@@ -350,6 +351,12 @@ void Screen::checkInput()
{ {
showInfo = !showInfo; showInfo = !showInfo;
} }
// Comprueba el botón de SERVICE
if (checkServiceButton(input) == SERVICE_SHADERS)
{
switchShaders();
}
} }
// Agita la pantalla // Agita la pantalla

View File

@@ -24,7 +24,7 @@ private:
Input *input; // Objeto para leer las entradas de teclado o mando Input *input; // Objeto para leer las entradas de teclado o mando
Notify *notify; // Pinta notificaciones en pantalla Notify *notify; // Pinta notificaciones en pantalla
SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa 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 // Variables
int windowWidth; // Ancho de la pantalla o ventana int windowWidth; // Ancho de la pantalla o ventana

View File

@@ -17,11 +17,11 @@ class DefineButtons
{ {
private: private:
// Objetos // Objetos
Input *input; // Objeto pata gestionar la entrada Input *input; // Objeto pata gestionar la entrada
Text *text; // Objeto para escribir texto Text *text; // Objeto para escribir texto
// Variables // 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 param_t *param; // Puntero con todos los parametros del programa
section_t *section; // Indicador para el bucle del titulo section_t *section; // Indicador para el bucle del titulo
bool enabled; // Indica si el objeto está habilitado bool enabled; // Indica si el objeto está habilitado

View File

@@ -854,7 +854,7 @@ void Director::deleteMusics()
// Ejecuta la sección con el logo // Ejecuta la sección con el logo
void Director::runLogo() void Director::runLogo()
{ {
logo = new Logo(screen, asset, input, param, section); logo = new Logo(screen, asset, input, options, param, section);
logo->run(); logo->run();
delete logo; delete logo;
} }
@@ -862,7 +862,7 @@ void Director::runLogo()
// Ejecuta la sección con la secuencia de introducción // Ejecuta la sección con la secuencia de introducción
void Director::runIntro() 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(); intro->run();
delete intro; delete intro;
} }
@@ -870,7 +870,7 @@ void Director::runIntro()
// Ejecuta la sección con el titulo del juego // Ejecuta la sección con el titulo del juego
void Director::runTitle() 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(); title->run();
delete title; delete title;
} }
@@ -879,7 +879,8 @@ void Director::runTitle()
void Director::runGame() void Director::runGame()
{ {
const int playerID = section->options; 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(); game->run();
delete game; delete game;
} }
@@ -887,7 +888,7 @@ void Director::runGame()
// Ejecuta la sección donde se muestran las instrucciones // Ejecuta la sección donde se muestran las instrucciones
void Director::runInstructions() 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(); instructions->run();
delete instructions; delete instructions;
} }
@@ -895,7 +896,7 @@ void Director::runInstructions()
// Ejecuta la sección donde se muestra la tabla de puntuaciones // Ejecuta la sección donde se muestra la tabla de puntuaciones
void Director::runHiScoreTable() 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(); hiScoreTable->run();
delete hiScoreTable; delete hiScoreTable;
} }
@@ -904,7 +905,8 @@ void Director::runHiScoreTable()
void Director::runDemoGame() void Director::runDemoGame()
{ {
const int playerID = (rand() % 2) + 1; 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(); demoGame->run();
delete demoGame; delete demoGame;
} }

View File

@@ -41,7 +41,7 @@ private:
section_t *section; // Sección y subsección actual del programa; section_t *section; // Sección y subsección actual del programa;
// Variables // 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 param_t *param; // Variable con todos los parametros del programa
std::string executablePath; // Path del ejecutable std::string executablePath; // Path del ejecutable
std::string systemFolder; // Carpeta del sistema donde guardar datos std::string systemFolder; // Carpeta del sistema donde guardar datos

View File

@@ -4,7 +4,7 @@
#define GAME_OVER_COUNTER 350 #define GAME_OVER_COUNTER 350
// Constructor // 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 // Copia los punteros
this->screen = screen; this->screen = screen;
@@ -2047,21 +2047,8 @@ void Game::checkInput()
} }
// Comprueba el botón de SERVICE // 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: case SERVICE_RESET:
{ {
section->name = SECTION_PROG_LOGO; section->name = SECTION_PROG_LOGO;

View File

@@ -24,6 +24,9 @@
#include "enemy_formations.h" #include "enemy_formations.h"
#include <iostream> #include <iostream>
#define GAME_MODE_DEMO_OFF false
#define GAME_MODE_DEMO_ON true
// Cantidad de elementos a escribir en los ficheros de datos // Cantidad de elementos a escribir en los ficheros de datos
#define TOTAL_SCORE_DATA 3 #define TOTAL_SCORE_DATA 3
#define TOTAL_DEMO_DATA 2000 #define TOTAL_DEMO_DATA 2000
@@ -192,7 +195,7 @@ private:
int difficulty; // Dificultad del juego int difficulty; // Dificultad del juego
float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad
color_t difficultyColor; // Color asociado a 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 param_t *param; // Puntero con todos los parametros del programa
int lastStageReached; // Contiene el número de la última pantalla que se ha alcanzado 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 demo_t demo; // Variable con todas las variables relacionadas con el modo demo
@@ -445,7 +448,7 @@ private:
public: public:
// Constructor // 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 // Destructor
~Game(); ~Game();

View File

@@ -3,7 +3,7 @@
#include <iostream> #include <iostream>
// Constructor // 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 // Copia punteros
this->screen = screen; this->screen = screen;
@@ -209,20 +209,32 @@ void HiScoreTable::checkInput()
} }
// Comprueba el botón de SERVICE // Comprueba el botón de SERVICE
switch (checkServiceButton(input, 0)) switch (checkServiceButton(input))
{ {
case SERVICE_EXIT: case SERVICE_RESET:
section->name = SECTION_PROG_QUIT; {
section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; section->name = SECTION_PROG_LOGO;
screen->showNotification("Reset");
break; break;
}
case SERVICE_SHADERS: case SERVICE_MUTE:
screen->switchShaders(); {
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; break;
}
default: default:
{
break; break;
} }
}
// Comprueba el input para el resto de objetos // Comprueba el input para el resto de objetos
screen->checkInput(); screen->checkInput();

View File

@@ -39,7 +39,7 @@ private:
Fade *fade; // Objeto para renderizar fades Fade *fade; // Objeto para renderizar fades
Text *text; // Objeto para escribir texto Text *text; // Objeto para escribir texto
JA_Music_t *music; // Musica de fondo 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 section_t *section; // Estado del bucle principal para saber si continua o se sale
param_t *param; // Puntero con todos los parametros del programa param_t *param; // Puntero con todos los parametros del programa
@@ -80,7 +80,7 @@ private:
public: public:
// Constructor // 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 // Destructor
~HiScoreTable(); ~HiScoreTable();

View File

@@ -3,7 +3,7 @@
#include <iostream> #include <iostream>
// Constructor // 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 // Copia los punteros
this->screen = screen; this->screen = screen;
@@ -13,6 +13,7 @@ Instructions::Instructions(Screen *screen, Asset *asset, Input *input, Lang *lan
this->param = param; this->param = param;
this->section = section; this->section = section;
this->music = music; this->music = music;
this->options = options;
renderer = screen->getRenderer(); renderer = screen->getRenderer();
// Crea objetos // Crea objetos
@@ -338,20 +339,32 @@ void Instructions::checkInput()
} }
// Comprueba el botón de SERVICE // Comprueba el botón de SERVICE
switch (checkServiceButton(input, 0)) switch (checkServiceButton(input))
{ {
case SERVICE_EXIT: case SERVICE_RESET:
section->name = SECTION_PROG_QUIT; {
section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; section->name = SECTION_PROG_LOGO;
screen->showNotification("Reset");
break; break;
}
case SERVICE_SHADERS: case SERVICE_MUTE:
screen->switchShaders(); {
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; break;
}
default: default:
{
break; break;
} }
}
// Comprueba el input para el resto de objetos // Comprueba el input para el resto de objetos
screen->checkInput(); screen->checkInput();

View File

@@ -47,6 +47,7 @@ private:
JA_Music_t *music; // Musica de fondo JA_Music_t *music; // Musica de fondo
section_t *section; // Estado del bucle principal para saber si continua o se sale section_t *section; // Estado del bucle principal para saber si continua o se sale
param_t *param; // Puntero con todos los parametros del programa param_t *param; // Puntero con todos los parametros del programa
options_t *options; // Opciones del programa
// Variables // Variables
int counter; // Contador int counter; // Contador
@@ -86,7 +87,7 @@ private:
public: public:
// Constructor // 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 // Destructor
~Instructions(); ~Instructions();

View File

@@ -2,7 +2,7 @@
#include "service.h" #include "service.h"
// Constructor // 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 // Copia los punteros
this->screen = screen; this->screen = screen;
@@ -208,20 +208,32 @@ void Intro::checkInput()
} }
// Comprueba el botón de SERVICE // Comprueba el botón de SERVICE
switch (checkServiceButton(input, 0)) switch (checkServiceButton(input))
{ {
case SERVICE_EXIT: case SERVICE_RESET:
section->name = SECTION_PROG_QUIT; {
section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; section->name = SECTION_PROG_LOGO;
screen->showNotification("Reset");
break; break;
}
case SERVICE_SHADERS: case SERVICE_MUTE:
screen->switchShaders(); {
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; break;
}
default: default:
{
break; break;
} }
}
// Comprueba el input para el resto de objetos // Comprueba el input para el resto de objetos
screen->checkInput(); screen->checkInput();

View File

@@ -32,6 +32,7 @@ private:
std::vector<Writer *> texts; // Textos de la intro std::vector<Writer *> texts; // Textos de la intro
Text *text; // Textos de la intro Text *text; // Textos de la intro
section_t *section; // Estado del bucle principal para saber si continua o se sale 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 param_t *param; // Puntero con todos los parametros del programa
// Variables // Variables
@@ -60,7 +61,7 @@ private:
public: public:
// Constructor // 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 // Destructor
~Intro(); ~Intro();

View File

@@ -3,12 +3,13 @@
#include <iostream> #include <iostream>
// Constructor // 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 // Copia la dirección de los objetos
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input; this->input = input;
this->options = options;
this->param = param; this->param = param;
this->section = section; this->section = section;
SDL_Renderer *renderer = screen->getRenderer(); SDL_Renderer *renderer = screen->getRenderer();
@@ -118,21 +119,40 @@ void Logo::checkInput()
} }
// Comprueba el botón de SERVICE // Comprueba el botón de SERVICE
switch (checkServiceButton(input, 0)) switch (checkServiceButton(input))
{ {
case SERVICE_EXIT: case SERVICE_EXIT:
{
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
section->options = SECTION_OPTIONS_QUIT_SHUTDOWN; section->options = SECTION_OPTIONS_QUIT_SHUTDOWN;
return; return;
break; break;
}
case SERVICE_SHADERS: case SERVICE_RESET:
screen->switchShaders(); {
section->name = SECTION_PROG_LOGO;
screen->showNotification("Reset");
break; 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: default:
{
break; break;
} }
}
// Comprueba el input para el resto de objetos // Comprueba el input para el resto de objetos
screen->checkInput(); screen->checkInput();

View File

@@ -33,6 +33,7 @@ private:
Sprite *sinceSprite; // Sprite para manejar la sinceTexture Sprite *sinceSprite; // Sprite para manejar la sinceTexture
section_t *section; // Estado del bucle principal para saber si continua o se sale section_t *section; // Estado del bucle principal para saber si continua o se sale
param_t *param; // Puntero con todos los parametros del programa param_t *param; // Puntero con todos los parametros del programa
options_t *options; // Opciones del programa
// Variables // Variables
std::vector<color_t> color; // Vector con los colores para el fade std::vector<color_t> color; // Vector con los colores para el fade
@@ -69,7 +70,7 @@ private:
public: public:
// Constructor // 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 // Destructor
~Logo(); ~Logo();

View File

@@ -50,7 +50,7 @@ private:
std::vector<SDL_Texture *> panelTexture; // Texturas para dibujar cada panel; std::vector<SDL_Texture *> panelTexture; // Texturas para dibujar cada panel;
// Variables // 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 int stage; // Número de fase actual
std::string name[SCOREBOARD_MAX_PANELS]; // Nom de cada jugador std::string name[SCOREBOARD_MAX_PANELS]; // Nom de cada jugador
int score[SCOREBOARD_MAX_PANELS]; // Puntuación de los jugadores int score[SCOREBOARD_MAX_PANELS]; // Puntuación de los jugadores

View File

@@ -3,41 +3,87 @@
// Comprueba el botón de servicio del controlador "index" // Comprueba el botón de servicio del controlador "index"
int checkServiceButton(Input *input, int 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)) else if (input->checkInput(input_fire_left, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
return SERVICE_CONFIG; return SERVICE_CONFIG;
} }
else if (input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) else if (input->checkInput(input_fire_center, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
return SERVICE_SHADERS; return SERVICE_SHADERS;
} }
else if (input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) else if (input->checkInput(input_fire_right, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
return SERVICE_PAUSE; return SERVICE_PAUSE;
} }
else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) else if (input->checkInput(input_up, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
return SERVICE_SWAP_CONTROLLERS; return SERVICE_SWAP_CONTROLLERS;
} }
else if (input->checkInput(input_down, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, index)) else if (input->checkInput(input_down, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
{ {
return SERVICE_RESET; 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;
}
} }
} }

View File

@@ -18,4 +18,4 @@ enum service_e
}; };
// Comprueba el botón de servicio del controlador "index" // Comprueba el botón de servicio del controlador "index"
int checkServiceButton(Input *input, int index); int checkServiceButton(Input *input, int index = -1);

View File

@@ -2,7 +2,7 @@
#include "service.h" #include "service.h"
// Constructor // 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 // Copia las direcciones de los punteros y objetos
this->screen = screen; this->screen = screen;
@@ -268,33 +268,47 @@ void Title::checkInput()
////////////////////////////////////////////////// //////////////////////////////////////////////////
// Comprueba el botón de SERVICE // 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: case SERVICE_RESET:
{
section->name = SECTION_PROG_LOGO; section->name = SECTION_PROG_LOGO;
screen->showNotification("Reset"); screen->showNotification("Reset");
break; break;
}
case SERVICE_SHADERS: case SERVICE_MUTE:
screen->switchShaders(); {
break; const bool value = !options->audio.music.enabled;
options->audio.music.enabled = value;
case SERVICE_CONFIG: options->audio.sound.enabled = value;
defineButtons->enable(0); JA_EnableMusic(value);
JA_EnableSound(value);
const std::string text = value ? "on" : "off";
screen->showNotification("Audio " + text);
break; break;
}
case SERVICE_SWAP_CONTROLLERS: case SERVICE_SWAP_CONTROLLERS:
{
swapControllers(); swapControllers();
break; break;
}
default: default:
{
break; 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 // Comprueba el botón de START de los mandos
for (int i = 0; i < input->getNumControllers(); ++i) for (int i = 0; i < input->getNumControllers(); ++i)

View File

@@ -72,7 +72,7 @@ private:
section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo 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 Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
int postFade; // Opción a realizar cuando termina el fundido 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 param_t *param; // Puntero con todos los parametros del programa
int numControllers; // Número de mandos conectados int numControllers; // Número de mandos conectados
@@ -102,7 +102,7 @@ private:
public: public:
// Constructor // 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 // Destructor
~Title(); ~Title();