Afegit global_inputs.c
El audio no es podía mutejar amb el teclat, soles amb els mandos
This commit is contained in:
84
source/global_inputs.cpp
Normal file
84
source/global_inputs.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "global_inputs.h"
|
||||
#include "section.h"
|
||||
#include "screen.h"
|
||||
#include "input.h"
|
||||
#include "lang.h"
|
||||
#include "options.h"
|
||||
|
||||
// Termina
|
||||
void quit(section::options_e code)
|
||||
{
|
||||
if (Screen::get()->notificationsAreActive())
|
||||
{
|
||||
section::name = section::NAME_QUIT;
|
||||
section::options = code;
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen::get()->showNotification(lang::getText(94));
|
||||
}
|
||||
}
|
||||
|
||||
// Reinicia
|
||||
void reset()
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
Screen::get()->showNotification("Reset");
|
||||
}
|
||||
|
||||
// Activa o desactiva el audio
|
||||
void switchAudio()
|
||||
{
|
||||
options.audio.sound.enabled = options.audio.music.enabled = !options.audio.music.enabled;
|
||||
JA_EnableMusic(options.audio.music.enabled);
|
||||
JA_EnableSound(options.audio.sound.enabled);
|
||||
Screen::get()->showNotification("Audio " + boolToOnOff(options.audio.music.enabled));
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
void checkGlobalInputs()
|
||||
{
|
||||
// Comprueba si se sale con el teclado
|
||||
if (Input::get()->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
else if (Input::get()->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
else if (Input::get()->checkInput(input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
switchAudio();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Input::get()->getNumControllers(); ++i)
|
||||
{
|
||||
// Comprueba si se sale con el mando
|
||||
if (Input::get()->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_SHUTDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
else if (Input::get()->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a activar o desactivar el audio
|
||||
else if (Input::get()->checkModInput(input_service, input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
switchAudio();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
source/global_inputs.h
Normal file
2
source/global_inputs.h
Normal file
@@ -0,0 +1,2 @@
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
void checkGlobalInputs();
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "hiscore_table.h"
|
||||
#include "param.h"
|
||||
#include "options.h"
|
||||
#include <iostream>
|
||||
#include "global_inputs.h"
|
||||
#include "hiscore_table.h"
|
||||
#include "options.h"
|
||||
#include "param.h"
|
||||
|
||||
// Constructor
|
||||
HiScoreTable::HiScoreTable(JA_Music_t *music)
|
||||
@@ -192,21 +193,6 @@ void HiScoreTable::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void HiScoreTable::checkInput()
|
||||
{
|
||||
// Comprueba si se sale con el teclado
|
||||
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (input->checkAnyButtonPressed())
|
||||
{
|
||||
@@ -216,36 +202,11 @@ void HiScoreTable::checkInput()
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < input->getNumControllers(); ++i)
|
||||
{
|
||||
// Comprueba si se sale con el mando
|
||||
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_SHUTDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
section::name = section::NAME_LOGO;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a activar o desactivar el audio
|
||||
if (input->checkModInput(input_service, input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
options.audio.sound.enabled = options.audio.music.enabled = !options.audio.music.enabled;
|
||||
JA_EnableMusic(options.audio.music.enabled);
|
||||
JA_EnableSound(options.audio.sound.enabled);
|
||||
screen->showNotification("Audio " + boolToOnOff(options.audio.music.enabled));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
screen->checkInput();
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
checkGlobalInputs();
|
||||
}
|
||||
|
||||
// Bucle para la pantalla de instrucciones
|
||||
@@ -342,17 +303,3 @@ std::string HiScoreTable::format(int number)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Termina
|
||||
void HiScoreTable::quit(section::options_e code)
|
||||
{
|
||||
if (screen->notificationsAreActive())
|
||||
{
|
||||
section::name = section::NAME_QUIT;
|
||||
section::options = code;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showNotification(lang::getText(94));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "instructions.h"
|
||||
#include "param.h"
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
@@ -322,21 +323,6 @@ void Instructions::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Instructions::checkInput()
|
||||
{
|
||||
// Comprueba si se sale con el teclado
|
||||
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (input->checkAnyButtonPressed())
|
||||
{
|
||||
@@ -346,36 +332,11 @@ void Instructions::checkInput()
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < input->getNumControllers(); ++i)
|
||||
{
|
||||
// Comprueba si se sale con el mando
|
||||
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_SHUTDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
section::name = section::NAME_LOGO;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a activar o desactivar el audio
|
||||
if (input->checkModInput(input_service, input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
options.audio.sound.enabled = options.audio.music.enabled = !options.audio.music.enabled;
|
||||
JA_EnableMusic(options.audio.music.enabled);
|
||||
JA_EnableSound(options.audio.sound.enabled);
|
||||
screen->showNotification("Audio " + boolToOnOff(options.audio.music.enabled));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
screen->checkInput();
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
checkGlobalInputs();
|
||||
}
|
||||
|
||||
// Bucle para la pantalla de instrucciones
|
||||
@@ -389,17 +350,3 @@ void Instructions::run()
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
// Termina
|
||||
void Instructions::quit(section::options_e code)
|
||||
{
|
||||
if (screen->notificationsAreActive())
|
||||
{
|
||||
section::name = section::NAME_QUIT;
|
||||
section::options = code;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showNotification(lang::getText(94));
|
||||
}
|
||||
}
|
||||
@@ -81,9 +81,6 @@ private:
|
||||
// Recarga todas las texturas
|
||||
void reloadTextures();
|
||||
|
||||
// Termina
|
||||
void quit(section::options_e code);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Instructions(JA_Music_t *music);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "global_inputs.h"
|
||||
#include "intro.h"
|
||||
#include "param.h"
|
||||
#include "options.h"
|
||||
#include "param.h"
|
||||
|
||||
// Constructor
|
||||
Intro::Intro(JA_Music_t *music)
|
||||
@@ -192,21 +193,6 @@ void Intro::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Intro::checkInput()
|
||||
{
|
||||
// Comprueba si se sale con el teclado
|
||||
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (input->checkAnyButtonPressed())
|
||||
{
|
||||
@@ -216,36 +202,11 @@ void Intro::checkInput()
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < input->getNumControllers(); ++i)
|
||||
{
|
||||
// Comprueba si se sale con el mando
|
||||
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_SHUTDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a activar o desactivar el audio
|
||||
if (input->checkModInput(input_service, input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
options.audio.sound.enabled = options.audio.music.enabled = !options.audio.music.enabled;
|
||||
JA_EnableMusic(options.audio.music.enabled);
|
||||
JA_EnableSound(options.audio.sound.enabled);
|
||||
screen->showNotification("Audio " + boolToOnOff(options.audio.music.enabled));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
screen->checkInput();
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
checkGlobalInputs();
|
||||
}
|
||||
|
||||
// Actualiza las escenas de la intro
|
||||
@@ -468,17 +429,3 @@ void Intro::run()
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
// Termina
|
||||
void Intro::quit(section::options_e code)
|
||||
{
|
||||
if (screen->notificationsAreActive())
|
||||
{
|
||||
section::name = section::NAME_QUIT;
|
||||
section::options = code;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showNotification(lang::getText(94));
|
||||
}
|
||||
}
|
||||
@@ -55,9 +55,6 @@ private:
|
||||
// Recarga todas las texturas
|
||||
void reloadTextures();
|
||||
|
||||
// Termina
|
||||
void quit(section::options_e code);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Intro(JA_Music_t *music);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "logo.h"
|
||||
#include "param.h"
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
#include <iostream>
|
||||
|
||||
// Constructor
|
||||
@@ -103,21 +104,6 @@ void Logo::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Logo::checkInput()
|
||||
{
|
||||
// Comprueba si se sale con el teclado
|
||||
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (input->checkAnyButtonPressed())
|
||||
{
|
||||
@@ -127,36 +113,11 @@ void Logo::checkInput()
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < input->getNumControllers(); ++i)
|
||||
{
|
||||
// Comprueba si se sale con el mando
|
||||
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_SHUTDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a activar o desactivar el audio
|
||||
if (input->checkModInput(input_service, input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
options.audio.sound.enabled = options.audio.music.enabled = !options.audio.music.enabled;
|
||||
JA_EnableMusic(options.audio.music.enabled);
|
||||
JA_EnableSound(options.audio.sound.enabled);
|
||||
screen->showNotification("Audio " + boolToOnOff(options.audio.music.enabled));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
screen->checkInput();
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
checkGlobalInputs();
|
||||
}
|
||||
|
||||
// Gestiona el logo de JAILGAME
|
||||
@@ -349,17 +310,3 @@ void Logo::run()
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
// Termina
|
||||
void Logo::quit(section::options_e code)
|
||||
{
|
||||
if (screen->notificationsAreActive())
|
||||
{
|
||||
section::name = section::NAME_QUIT;
|
||||
section::options = code;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showNotification(lang::getText(94));
|
||||
}
|
||||
}
|
||||
@@ -66,9 +66,6 @@ private:
|
||||
// Recarga todas las texturas
|
||||
void reloadTextures();
|
||||
|
||||
// Termina
|
||||
void quit(section::options_e code);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Logo();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "title.h"
|
||||
#include "param.h"
|
||||
#include "global_inputs.h"
|
||||
#include "options.h"
|
||||
#include "param.h"
|
||||
#include "title.h"
|
||||
|
||||
// Constructor
|
||||
Title::Title(JA_Music_t *music)
|
||||
@@ -247,21 +248,6 @@ void Title::checkInput()
|
||||
// TECLADO //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
// Comprueba si se sale con el teclado
|
||||
if (input->checkInput(input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkInput(input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
section::name = section::NAME_INIT;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba el teclado para empezar a jugar
|
||||
if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
{
|
||||
@@ -278,32 +264,6 @@ void Title::checkInput()
|
||||
|
||||
for (int i = 0; i < input->getNumControllers(); ++i)
|
||||
{
|
||||
|
||||
// Comprueba si se sale con el mando
|
||||
if (input->checkModInput(input_service, input_exit, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
quit(section::OPTIONS_QUIT_SHUTDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a resetear el juego
|
||||
if (input->checkModInput(input_service, input_reset, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
section::name = section::NAME_LOGO;
|
||||
screen->showNotification("Reset");
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a activar o desactivar el audio
|
||||
if (input->checkModInput(input_service, input_mute, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
options.audio.sound.enabled = options.audio.music.enabled = !options.audio.music.enabled;
|
||||
JA_EnableMusic(options.audio.music.enabled);
|
||||
JA_EnableSound(options.audio.sound.enabled);
|
||||
screen->showNotification("Audio " + boolToOnOff(options.audio.music.enabled));
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si se va a intercambiar la asignación de mandos a jugadores
|
||||
if (input->checkModInput(input_service, input_swap_controllers, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
@@ -334,6 +294,9 @@ void Title::checkInput()
|
||||
// Comprueba el input para el resto de objetos
|
||||
screen->checkInput();
|
||||
defineButtons->checkInput();
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
checkGlobalInputs();
|
||||
}
|
||||
|
||||
// Bucle para el titulo del juego
|
||||
@@ -403,17 +366,3 @@ void Title::swapControllers()
|
||||
|
||||
resetCounter();
|
||||
}
|
||||
|
||||
// Termina
|
||||
void Title::quit(section::options_e code)
|
||||
{
|
||||
if (screen->notificationsAreActive())
|
||||
{
|
||||
section::name = section::NAME_QUIT;
|
||||
section::options = code;
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->showNotification(lang::getText(94));
|
||||
}
|
||||
}
|
||||
@@ -96,9 +96,6 @@ private:
|
||||
// Intercambia la asignación de mandos a los jugadores
|
||||
void swapControllers();
|
||||
|
||||
// Termina
|
||||
void quit(section::options_e code);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Title(JA_Music_t *music);
|
||||
|
||||
Reference in New Issue
Block a user