Modificat checkInput en varies seccions per a gastar global_inputs.cpp
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <string> // Para basic_string, string
|
||||
#include <vector> // Para vector
|
||||
#include <array> // Para vector
|
||||
#include "balloon_manager.h" // Para BalloonManager
|
||||
#include "fade.h" // Para Fade, FadeType, FadeMode
|
||||
#include "global_inputs.h" // Para check, update
|
||||
@@ -166,7 +167,7 @@ void Credits::fillTextTexture()
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 0);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
std::vector<std::string> texts = {
|
||||
const std::array<std::string, 10> TEXTS = {
|
||||
lang::getText(121),
|
||||
lang::getText(122),
|
||||
lang::getText(123),
|
||||
@@ -178,50 +179,50 @@ void Credits::fillTextTexture()
|
||||
"WWW.KENNEY.NL",
|
||||
"JAILDOCTOR"};
|
||||
|
||||
const int space_post_title = 3 + text->getCharacterSize();
|
||||
const int space_pre_title = text->getCharacterSize() * 4;
|
||||
const int texts_height = 1 * text->getCharacterSize() + 7 * space_post_title + 3 * space_pre_title;
|
||||
credits_rect_dst_.h = credits_rect_src_.h = texts_height;
|
||||
const int SPACE_POST_TITLE = 3 + text->getCharacterSize();
|
||||
const int SPACE_PRE_TITLE = text->getCharacterSize() * 4;
|
||||
const int TEXTS_HEIGHT = 1 * text->getCharacterSize() + 7 * SPACE_POST_TITLE + 3 * SPACE_PRE_TITLE;
|
||||
credits_rect_dst_.h = credits_rect_src_.h = TEXTS_HEIGHT;
|
||||
|
||||
int y = (param.game.height - texts_height) / 2;
|
||||
int y = (param.game.height - TEXTS_HEIGHT) / 2;
|
||||
y = 0;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(0), 1, no_color, 1, shdw_txt_color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(0), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
text->setPalette(0);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(4), 1, no_color, 1, shdw_txt_color);
|
||||
y += SPACE_POST_TITLE;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(4), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
y += space_pre_title;
|
||||
y += SPACE_PRE_TITLE;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(1), 1, no_color, 1, shdw_txt_color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(1), 1, no_color, 1, shdw_txt_color);
|
||||
text->setPalette(0);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(4), 1, no_color, 1, shdw_txt_color);
|
||||
y += SPACE_POST_TITLE;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(4), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
y += space_pre_title;
|
||||
y += SPACE_PRE_TITLE;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(2), 1, no_color, 1, shdw_txt_color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(2), 1, no_color, 1, shdw_txt_color);
|
||||
text->setPalette(0);
|
||||
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(5), 1, no_color, 1, shdw_txt_color);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(6), 1, no_color, 1, shdw_txt_color);
|
||||
y += SPACE_POST_TITLE;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(5), 1, no_color, 1, shdw_txt_color);
|
||||
y += SPACE_POST_TITLE;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(6), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
y += space_pre_title;
|
||||
y += SPACE_PRE_TITLE;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(3), 1, no_color, 1, shdw_txt_color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(3), 1, no_color, 1, shdw_txt_color);
|
||||
text->setPalette(0);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(7), 1, no_color, 1, shdw_txt_color);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(8), 1, no_color, 1, shdw_txt_color);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, texts.at(9), 1, no_color, 1, shdw_txt_color);
|
||||
y += SPACE_POST_TITLE;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(7), 1, no_color, 1, shdw_txt_color);
|
||||
y += SPACE_POST_TITLE;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(8), 1, no_color, 1, shdw_txt_color);
|
||||
y += SPACE_POST_TITLE;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(9), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
// Mini logo
|
||||
y += space_pre_title;
|
||||
y += SPACE_PRE_TITLE;
|
||||
mini_logo_rect_src_.y = y;
|
||||
auto mini_logo_sprite = std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"));
|
||||
mini_logo_sprite->setPosition(1 + param.game.game_area.center_x - mini_logo_sprite->getWidth() / 2, 1 + y);
|
||||
|
||||
@@ -55,6 +55,7 @@ Director::Director(int argc, const char *argv[])
|
||||
section::name = section::Name::LOGO;
|
||||
#else // NORMAL GAME
|
||||
section::name = section::Name::LOGO;
|
||||
section::options = section::Options::NONE;
|
||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||
#endif
|
||||
|
||||
@@ -97,11 +98,11 @@ void Director::init()
|
||||
|
||||
// Inicializa y crea el resto de objetos
|
||||
initSDL();
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
initJailAudio();
|
||||
dbg_init(renderer_);
|
||||
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language)));
|
||||
Screen::init(window_, renderer_);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
Resource::init();
|
||||
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
|
||||
bindInputs();
|
||||
|
||||
@@ -1357,12 +1357,14 @@ void Game::checkPauseInput()
|
||||
{
|
||||
// Comprueba los mandos
|
||||
for (int i = 0; i < input_->getNumControllers(); ++i)
|
||||
{
|
||||
if (input_->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i) &&
|
||||
input_->checkInput(InputType::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
|
||||
{
|
||||
pause(!paused_);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el teclado
|
||||
if (input_->checkInput(InputType::PAUSE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||
@@ -1379,7 +1381,8 @@ void Game::handleDemoMode()
|
||||
for (const auto &player : players_)
|
||||
{
|
||||
if (player->isPlaying())
|
||||
{ // Maneja el input específico del jugador en modo demo.
|
||||
{
|
||||
// Maneja el input específico del jugador en modo demo.
|
||||
handleDemoPlayerInput(player, index);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,28 @@ namespace globalInputs
|
||||
Notifier::get()->show({"Autofire " + boolToOnOff(options.game.autofire)});
|
||||
}
|
||||
|
||||
// Salta una sección del juego
|
||||
void skip_section()
|
||||
{
|
||||
switch (section::name)
|
||||
{
|
||||
case section::Name::INTRO:
|
||||
JA_StopMusic();
|
||||
// Continua en el case de abajo
|
||||
case section::Name::LOGO:
|
||||
case section::Name::HI_SCORE_TABLE:
|
||||
case section::Name::INSTRUCTIONS:
|
||||
{
|
||||
section::name = section::Name::TITLE;
|
||||
section::options = section::Options::TITLE_1;
|
||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
void check()
|
||||
{
|
||||
@@ -172,6 +194,13 @@ namespace globalInputs
|
||||
return;
|
||||
}
|
||||
|
||||
// Saltar sección
|
||||
if (Input::get()->checkAnyButtonPressed())
|
||||
{
|
||||
skip_section();
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset
|
||||
if (Input::get()->checkInput(InputType::RESET, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||
{
|
||||
|
||||
@@ -165,17 +165,6 @@ void HiScoreTable::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void HiScoreTable::checkInput()
|
||||
{
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (Input::get()->checkAnyButtonPressed())
|
||||
{
|
||||
// JA_StopMusic();
|
||||
section::name = section::Name::TITLE;
|
||||
section::options = section::Options::TITLE_1;
|
||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
|
||||
@@ -306,17 +306,6 @@ void Instructions::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Instructions::checkInput()
|
||||
{
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (Input::get()->checkAnyButtonPressed())
|
||||
{
|
||||
// JA_StopMusic();
|
||||
section::name = section::Name::TITLE;
|
||||
section::options = section::Options::TITLE_1;
|
||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
|
||||
@@ -163,16 +163,6 @@ void Intro::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Intro::checkInput()
|
||||
{
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (Input::get()->checkAnyButtonPressed())
|
||||
{
|
||||
JA_StopMusic();
|
||||
section::name = section::Name::TITLE;
|
||||
section::options = section::Options::TITLE_1;
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,22 +24,21 @@ Logo::Logo()
|
||||
{
|
||||
|
||||
// Inicializa variables
|
||||
counter_ = 0;
|
||||
section::name = section::Name::LOGO;
|
||||
dest_.x = param.game.game_area.center_x - jail_texture_->getWidth() / 2;
|
||||
dest_.y = param.game.game_area.center_y - jail_texture_->getHeight() / 2;
|
||||
since_sprite_->setPosition({(param.game.width - since_texture_->getWidth()) / 2, 83 + jail_texture_->getHeight() + 5, since_texture_->getWidth(), since_texture_->getHeight()});
|
||||
since_sprite_->setY(dest_.y + jail_texture_->getHeight() + 5);
|
||||
since_sprite_->setSpriteClip(0, 0, since_texture_->getWidth(), since_texture_->getHeight());
|
||||
since_texture_->setColor(0x00, 0x00, 0x00); // Esto en linux no hace nada ??
|
||||
since_texture_->setColor(0x00, 0x00, 0x00);
|
||||
|
||||
// Crea los sprites de cada linea
|
||||
for (int i = 0; i < jail_texture_->getHeight(); ++i)
|
||||
{
|
||||
auto temp = std::make_unique<Sprite>(jail_texture_, 0, i, jail_texture_->getWidth(), 1);
|
||||
temp->setSpriteClip(0, i, jail_texture_->getWidth(), 1);
|
||||
const int posX = (i % 2 == 0) ? param.game.width + (i * 3) : -jail_texture_->getWidth() - (i * 3);
|
||||
temp->setX(posX);
|
||||
const int POS_X = (i % 2 == 0) ? param.game.width + (i * 3) : -jail_texture_->getWidth() - (i * 3);
|
||||
temp->setX(POS_X);
|
||||
temp->setY(dest_.y + i);
|
||||
jail_sprite_.push_back(std::move(temp));
|
||||
}
|
||||
@@ -76,15 +75,6 @@ void Logo::checkEvents()
|
||||
// Comprueba las entradas
|
||||
void Logo::checkInput()
|
||||
{
|
||||
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
|
||||
if (Input::get()->checkAnyButtonPressed())
|
||||
{
|
||||
section::name = section::Name::TITLE;
|
||||
section::options = section::Options::TITLE_1;
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
// Variables
|
||||
std::vector<Color> color_; // Vector con los colores para el fade
|
||||
int counter_; // Contador
|
||||
int counter_ = 0; // Contador
|
||||
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
||||
SDL_Point dest_; // Posición X donde dibujar el logo
|
||||
LogoState state_ = LogoState::JAILGAMES; // El estado indica qué logo se está procesando
|
||||
|
||||
@@ -118,12 +118,6 @@ void Screen::renderScreen()
|
||||
// Establece el modo de video
|
||||
void Screen::setVideoMode(ScreenVideoMode videoMode)
|
||||
{
|
||||
#ifdef ARCADE
|
||||
options.video.mode = ScreenVideoMode::WINDOW;
|
||||
#else
|
||||
options.video.mode = videoMode;
|
||||
#endif
|
||||
|
||||
switch (options.video.mode)
|
||||
{
|
||||
case ScreenVideoMode::WINDOW:
|
||||
@@ -131,13 +125,6 @@ void Screen::setVideoMode(ScreenVideoMode videoMode)
|
||||
// Cambia a modo de ventana
|
||||
SDL_SetWindowFullscreen(window_, 0);
|
||||
|
||||
#ifdef ARCADE
|
||||
// Oculta el puntero
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
#else
|
||||
// Muestra el puntero
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
#endif
|
||||
// Modifica el tamaño de la ventana
|
||||
SDL_Point pos = getNewPosition();
|
||||
SDL_SetWindowSize(window_, param.game.width * options.video.window.size, param.game.height * options.video.window.size);
|
||||
|
||||
@@ -46,9 +46,9 @@ Title::Title()
|
||||
|
||||
// Asigna valores a otras variables
|
||||
section::options = section::Options::TITLE_1;
|
||||
const bool is_title_to_demo = (section::attract_mode == section::AttractMode::TITLE_TO_DEMO);
|
||||
next_section_ = is_title_to_demo ? section::Name::GAME_DEMO : section::Name::LOGO;
|
||||
section::attract_mode = is_title_to_demo ? section::AttractMode::TITLE_TO_LOGO : section::AttractMode::TITLE_TO_DEMO;
|
||||
const bool IS_TITLE_TO_DEMO = (section::attract_mode == section::AttractMode::TITLE_TO_DEMO);
|
||||
next_section_ = IS_TITLE_TO_DEMO ? section::Name::GAME_DEMO : section::Name::LOGO;
|
||||
section::attract_mode = IS_TITLE_TO_DEMO ? section::AttractMode::TITLE_TO_LOGO : section::AttractMode::TITLE_TO_DEMO;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
||||
Reference in New Issue
Block a user