El responsable de comprobar si se ha pulsado alguna tecla para cambiar el tamaño de la venta, el modo de pantalla completa o la activación de los shaders pasa a ser la clase screen

This commit is contained in:
2024-07-05 14:09:38 +02:00
parent 5e7212dfaa
commit 62f3c42e7b
14 changed files with 209 additions and 187 deletions

View File

@@ -58,12 +58,6 @@ HiScoreTable::~HiScoreTable()
// Actualiza las variables
void HiScoreTable::update()
{
// Comprueba los eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza las variables
if (SDL_GetTicks() - ticks > ticksSpeed)
{
@@ -144,8 +138,15 @@ void HiScoreTable::render()
screen->blit();
}
// Recarga todas las texturas
void HiScoreTable::reloadTextures()
{
text->reLoadTexture();
fillTexture();
}
// Comprueba los eventos
void HiScoreTable::checkEventHandler()
void HiScoreTable::checkEvents()
{
// Comprueba los eventos que hay en la cola
while (SDL_PollEvent(eventHandler) != 0)
@@ -156,6 +157,15 @@ void HiScoreTable::checkEventHandler()
section->name = SECTION_PROG_QUIT;
break;
}
// Comprueba si se ha cambiado el tamaño de la ventana
else if (eventHandler->type == SDL_WINDOWEVENT)
{
if (eventHandler->window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{
reloadTextures();
}
}
}
}
@@ -167,27 +177,15 @@ void HiScoreTable::checkInput()
section->name = SECTION_PROG_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))
{
JA_StopMusic();
section->name = SECTION_PROG_TITLE;
section->subsection = SUBSECTION_TITLE_1;
}
// Comprueba el input para el resto de objetos
screen->checkInput();
}
// Bucle para la pantalla de instrucciones
@@ -195,7 +193,9 @@ void HiScoreTable::run()
{
while (section->name == SECTION_PROG_HI_SCORE_TABLE)
{
checkInput();
update();
checkEvents(); // Tiene que ir antes del render
render();
}
}