2 Commits

5 changed files with 73 additions and 67 deletions

View File

@@ -3012,6 +3012,22 @@ void Game::checkGameInput()
demo.keys.fireLeft = 0;
demo.keys.fireRight = 0;
// Comprueba las teclas de cambiar el tamaño de la centana y el modo de video
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();
}
// Modo Demo activo
if (demo.enabled)
{
@@ -3849,40 +3865,6 @@ void Game::checkEventHandler()
section.subsection = GAME_SECTION_PAUSE;
}
}
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
{
switch (eventHandler->key.keysym.scancode)
{
case SDL_SCANCODE_F:
screen->switchVideoMode();
reloadTextures();
break;
case SDL_SCANCODE_F1:
screen->setWindowSize(1);
reloadTextures();
break;
case SDL_SCANCODE_F2:
screen->setWindowSize(2);
reloadTextures();
break;
case SDL_SCANCODE_F3:
screen->setWindowSize(3);
reloadTextures();
break;
case SDL_SCANCODE_F4:
screen->setWindowSize(4);
reloadTextures();
break;
default:
break;
}
}
}
}

View File

@@ -418,9 +418,6 @@ private:
// Acciones a realizar cuando el jugador muere
void killPlayer(Player *player);
// Obtiene el valor de la variable
Uint8 getSubsection();
// Calcula y establece el valor de amenaza en funcion de los globos activos
void evaluateAndSetMenace();

View File

@@ -4,12 +4,13 @@
const Uint8 SELF = 0;
// Constructor
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang)
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang)
{
// Copia los punteros
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->input = input;
this->lang = lang;
// Reserva memoria para los punteros
@@ -75,6 +76,9 @@ void Instructions::update()
// Comprueba los eventos
checkEventHandler();
// Comprueba las entradas
checkInput();
// Actualiza las variables
if (SDL_GetTicks() - ticks > ticksSpeed)
{
@@ -216,8 +220,33 @@ void Instructions::checkEventHandler()
section.name = PROG_SECTION_QUIT;
break;
}
}
}
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP))
// Comprueba las entradas
void Instructions::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 == m_auto)
{
@@ -234,7 +263,6 @@ void Instructions::checkEventHandler()
}
}
}
}
// Bucle para la pantalla de instrucciones
section_t Instructions::run(mode_e mode)

View File

@@ -2,6 +2,7 @@
#include <SDL2/SDL.h>
#include "common/asset.h"
#include "common/input.h"
#include "common/jail_audio.h"
#include "common/screen.h"
#include "common/sprite.h"
@@ -30,6 +31,7 @@ private:
SDL_Texture *backbuffer; // Textura para usar como backbuffer
Sprite *sprite; // Sprite con la textura de las instrucciones
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
Text *text; // Objeto para escribir texto
@@ -51,9 +53,12 @@ private:
// Comprueba los eventos
void checkEventHandler();
// Comprueba las entradas
void checkInput();
public:
// Constructor
Instructions(SDL_Renderer *renderer, Screen *screen, Asset *mAsset, Lang *lang);
Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang);
// Destructor
~Instructions();

View File

@@ -710,12 +710,6 @@ void Title::checkInput()
{
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))
{
section.name = PROG_SECTION_TITLE;
section.subsection = TITLE_SECTION_1;
}
}
// Actualiza el tileado de fondo
@@ -963,7 +957,7 @@ section_t Title::run()
// Ejecuta la parte donde se muestran las instrucciones
section_t Title::runInstructions(mode_e mode)
{
instructions = new Instructions(renderer, screen, asset, lang);
instructions = new Instructions(renderer, screen, asset, input, lang);
section = instructions->run(mode);
delete instructions;