Ya funcionan los nuevos inputs de teclado y mando durante la tabla de records

This commit is contained in:
2023-02-12 19:24:45 +01:00
parent b8bb1b144f
commit c4eaeefb13
3 changed files with 48 additions and 15 deletions

View File

@@ -5,12 +5,13 @@
const Uint8 SELF = 0; const Uint8 SELF = 0;
// Constructor // Constructor
HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, options_t *options) HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options)
{ {
// Copia los punteros // Copia los punteros
this->renderer = renderer; this->renderer = renderer;
this->screen = screen; this->screen = screen;
this->asset = asset; this->asset = asset;
this->input = input;
this->lang = lang; this->lang = lang;
// Reserva memoria para los punteros // Reserva memoria para los punteros
@@ -52,6 +53,9 @@ void HiScoreTable::update()
// Comprueba los eventos // Comprueba los eventos
checkEventHandler(); checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza las variables // Actualiza las variables
if (SDL_GetTicks() - ticks > ticksSpeed) if (SDL_GetTicks() - ticks > ticksSpeed)
{ {
@@ -178,21 +182,45 @@ void HiScoreTable::checkEventHandler()
section.name = PROG_SECTION_QUIT; section.name = PROG_SECTION_QUIT;
break; break;
} }
}
}
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP)) // Comprueba las entradas
void HiScoreTable::checkInput()
{
if (input->checkInput(input_exit, REPEAT_FALSE))
{
section.name = PROG_SECTION_QUIT;
}
else if (input->checkInput(input_window_fullscreen, REPEAT_FALSE))
{
screen->switchVideoMode();
}
else if (input->checkInput(input_window_dec_size, REPEAT_FALSE))
{
screen->decWindowSize();
}
else if (input->checkInput(input_window_inc_size, REPEAT_FALSE))
{
screen->incWindowSize();
}
else if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE))
{
if (mode == mhst_auto)
{ {
if (mode == mhst_auto) JA_StopMusic();
section.name = PROG_SECTION_TITLE;
section.subsection = TITLE_SECTION_1;
}
else
{
if (counter > 30)
{ {
JA_StopMusic(); manualQuit = true;
section.name = PROG_SECTION_TITLE;
section.subsection = TITLE_SECTION_1;
}
else
{
if (counter > 30)
{
manualQuit = true;
}
} }
} }
} }

View File

@@ -2,6 +2,7 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "common/asset.h" #include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h" #include "common/jail_audio.h"
#include "common/screen.h" #include "common/screen.h"
#include "common/sprite.h" #include "common/sprite.h"
@@ -27,6 +28,7 @@ private:
SDL_Event *eventHandler; // Manejador de eventos SDL_Event *eventHandler; // Manejador de eventos
SDL_Texture *backbuffer; // Textura para usar como backbuffer SDL_Texture *backbuffer; // Textura para usar como backbuffer
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Objeto pata gestionar la entrada
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
Text *text; // Objeto para escribir texto Text *text; // Objeto para escribir texto
options_t *options; // Opciones y parametyros del programa options_t *options; // Opciones y parametyros del programa
@@ -49,12 +51,15 @@ private:
// Comprueba los eventos // Comprueba los eventos
void checkEventHandler(); void checkEventHandler();
// Comprueba las entradas
void checkInput();
// Transforma un valor numérico en una cadena de 6 cifras // Transforma un valor numérico en una cadena de 6 cifras
std::string scoreToString(Uint32 num); std::string scoreToString(Uint32 num);
public: public:
// Constructor // Constructor
HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *mAsset, Lang *lang, options_t *options); HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, options_t *options);
// Destructor // Destructor
~HiScoreTable(); ~HiScoreTable();

View File

@@ -975,7 +975,7 @@ section_t Title::runHiScoreTable(mode_hiScoreTable_e mode)
return section; return section;
} }
hiScoreTable = new HiScoreTable(renderer, screen, asset, lang, options); hiScoreTable = new HiScoreTable(renderer, screen, asset, input, lang, options);
section = hiScoreTable->run(mode); section = hiScoreTable->run(mode);
delete hiScoreTable; delete hiScoreTable;