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:
@@ -26,8 +26,6 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset,
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param->gameWidth, param->gameHeight);
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
|
||||
|
||||
|
||||
// Inicializa variables
|
||||
section->name = SECTION_PROG_INSTRUCTIONS;
|
||||
ticks = 0;
|
||||
@@ -35,7 +33,7 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset,
|
||||
counter = 0;
|
||||
counterEnd = 700;
|
||||
view = {0, 0, param->gameWidth, param->gameHeight};
|
||||
spritePos = {0,0};
|
||||
spritePos = {0, 0};
|
||||
|
||||
// Rellena la textura de texto
|
||||
fillTexture();
|
||||
@@ -153,17 +151,17 @@ void Instructions::fillTexture()
|
||||
|
||||
// Calcula cual es el texto más largo de las descripciones de los items
|
||||
int lenght = 0;
|
||||
for (int i= 17; i <=21;++i)
|
||||
for (int i = 17; i <= 21; ++i)
|
||||
{
|
||||
const int l = text->lenght(lang->getText(i));
|
||||
lenght = l > lenght? l : lenght;
|
||||
lenght = l > lenght ? l : lenght;
|
||||
}
|
||||
const int anchorItem = (param->gameWidth - (lenght + 24)) / 2;
|
||||
|
||||
// BORRAR ESTO
|
||||
//SDL_SetRenderDrawColor(renderer, 255, 255, 255, 32);
|
||||
//SDL_Rect rect = {10, firstLine, param->gameWidth - 20, size};
|
||||
//SDL_RenderFillRect(renderer, &rect);
|
||||
// SDL_SetRenderDrawColor(renderer, 255, 255, 255, 32);
|
||||
// SDL_Rect rect = {10, firstLine, param->gameWidth - 20, size};
|
||||
// SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
// Escribe el texto de las instrucciones
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, firstLine, lang->getText(11), 1, orangeColor, 1, shdwTxtColor);
|
||||
@@ -179,11 +177,11 @@ void Instructions::fillTexture()
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, anchor2, lang->getText(16), 1, orangeColor, 1, shdwTxtColor);
|
||||
|
||||
const int anchor3 = anchor2 + spacePostHeader;
|
||||
text->writeShadowed(anchorItem+24, anchor3 + spaceBetweenItemLines * 0, lang->getText(17), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem+24, anchor3 + spaceBetweenItemLines * 1, lang->getText(18), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem+24, anchor3 + spaceBetweenItemLines * 2, lang->getText(19), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem+24, anchor3 + spaceBetweenItemLines * 3, lang->getText(20), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem+24, anchor3 + spaceBetweenItemLines * 4, lang->getText(21), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem + 24, anchor3 + spaceBetweenItemLines * 0, lang->getText(17), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem + 24, anchor3 + spaceBetweenItemLines * 1, lang->getText(18), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem + 24, anchor3 + spaceBetweenItemLines * 2, lang->getText(19), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem + 24, anchor3 + spaceBetweenItemLines * 3, lang->getText(20), shdwTxtColor);
|
||||
text->writeShadowed(anchorItem + 24, anchor3 + spaceBetweenItemLines * 4, lang->getText(21), shdwTxtColor);
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
SDL_SetRenderTarget(renderer, temp);
|
||||
@@ -220,9 +218,6 @@ void Instructions::fillBackbuffer()
|
||||
// Actualiza las variables
|
||||
void Instructions::update()
|
||||
{
|
||||
// Comprueba las entradas
|
||||
checkInput();
|
||||
|
||||
// Actualiza las variables
|
||||
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||
{
|
||||
@@ -271,6 +266,17 @@ void Instructions::render()
|
||||
screen->blit();
|
||||
}
|
||||
|
||||
// Recarga todas las texturas
|
||||
void Instructions::reloadTextures()
|
||||
{
|
||||
for (auto tex : itemTextures)
|
||||
{
|
||||
tex->reLoad();
|
||||
}
|
||||
text->reLoadTexture();
|
||||
fillTexture();
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
void Instructions::checkEvents()
|
||||
{
|
||||
@@ -283,6 +289,15 @@ void Instructions::checkEvents()
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,27 +309,15 @@ void Instructions::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
|
||||
@@ -322,8 +325,9 @@ void Instructions::run()
|
||||
{
|
||||
while (section->name == SECTION_PROG_INSTRUCTIONS)
|
||||
{
|
||||
checkInput();
|
||||
update();
|
||||
checkEvents();
|
||||
checkEvents(); // Tiene que ir antes del render
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user