Ja es pot gastar el teclat com a control independent del primer mando
Ja pot jugar un jugador amb teclat i altre amb mando Es pot asignar el teclat a qualsevol dels dos jugadors Continua podentse gastar mando i teclat a l'hora per al mateix jugador
This commit is contained in:
@@ -171,6 +171,9 @@ void Title::render()
|
||||
// Comprueba los eventos
|
||||
void Title::checkEvents()
|
||||
{
|
||||
// Comprueba el input para el resto de objetos
|
||||
define_buttons_->checkEvents();
|
||||
|
||||
// Si define_buttons_ está habilitado, es él quien gestiona los eventos
|
||||
if (!define_buttons_->isEnabled())
|
||||
{
|
||||
@@ -195,32 +198,33 @@ void Title::checkEvents()
|
||||
{
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_1:
|
||||
case SDLK_1: // Redefine los botones del mando #0
|
||||
{
|
||||
if (define_buttons_->enable(0))
|
||||
resetCounter();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDLK_2:
|
||||
case SDLK_2: // Redefine los botones del mando #1
|
||||
{
|
||||
if (define_buttons_->enable(1))
|
||||
resetCounter();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDLK_3:
|
||||
case SDLK_3: // Intercambia los mandos entre los dos jugadores
|
||||
{
|
||||
swapControllers();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDLK_4:
|
||||
case SDLK_4: // Muestra la asignacion de mandos
|
||||
{
|
||||
showControllers();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDLK_5: // Intercambia la asignación del teclado
|
||||
{
|
||||
swapKeyboard();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -235,55 +239,38 @@ void Title::checkInput()
|
||||
// Comprueba los controladores solo si no se estan definiendo los botones
|
||||
if (!define_buttons_->isEnabled())
|
||||
{
|
||||
// Comprueba el teclado para empezar a jugar
|
||||
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
|
||||
// Comprueba los métodos de control
|
||||
for (const auto &controller : options.controllers)
|
||||
{
|
||||
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||
!Input::get()->checkInput(InputType::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
{
|
||||
fade_->activate();
|
||||
post_fade_ = options.controller[0].player_id;
|
||||
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{
|
||||
fade_->activate();
|
||||
post_fade_ = controller.player_id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba los mandos
|
||||
for (int i = 0; i < Input::get()->getNumControllers(); ++i)
|
||||
{
|
||||
// Comprueba si se va a intercambiar la asignación de mandos a jugadores
|
||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i) &&
|
||||
Input::get()->checkInput(InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||
Input::get()->checkInput(InputType::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
{
|
||||
swapControllers();
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba si algun mando quiere ser configurado
|
||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i) &&
|
||||
Input::get()->checkInput(InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, controller.type, controller.index) &&
|
||||
Input::get()->checkInput(InputType::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, controller.type, controller.index))
|
||||
{
|
||||
define_buttons_->enable(i);
|
||||
define_buttons_->enable(controller.index);
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba el botón de START de los mandos
|
||||
if (Input::get()->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
// Si no está el botón de servicio activo
|
||||
if (!Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, INPUT_USE_GAMECONTROLLER, i))
|
||||
{
|
||||
if (section::options == section::Options::TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||
{
|
||||
fade_->activate();
|
||||
post_fade_ = options.controller[i].player_id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input para el resto de objetos
|
||||
define_buttons_->checkEvents();
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
globalInputs::check();
|
||||
}
|
||||
@@ -316,10 +303,17 @@ void Title::swapControllers()
|
||||
if (Input::get()->getNumControllers() == 0)
|
||||
return;
|
||||
|
||||
define_buttons_->swapControllers();
|
||||
swapOptionsControllers();
|
||||
showControllers();
|
||||
}
|
||||
|
||||
// Intercambia el teclado de jugador
|
||||
void Title::swapKeyboard()
|
||||
{
|
||||
swapOptionsKeyboard();
|
||||
Notifier::get()->showText("Teclat per al jugador " + std::to_string(getPlayerWhoUsesKeyboard()));
|
||||
}
|
||||
|
||||
// Muestra información sobre los controles y los jugadores
|
||||
void Title::showControllers()
|
||||
{
|
||||
@@ -332,16 +326,16 @@ void Title::showControllers()
|
||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
||||
{
|
||||
// Ejemplo: el jugador 1 tiene el mando 2
|
||||
playerControllerIndex.at(options.controller.at(i).player_id - 1) = i;
|
||||
playerControllerIndex.at(options.controllers.at(i).player_id - 1) = i;
|
||||
}
|
||||
|
||||
// Genera el texto correspondiente
|
||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i)
|
||||
{
|
||||
const size_t index = playerControllerIndex.at(i);
|
||||
if (options.controller.at(index).plugged)
|
||||
if (options.controllers.at(index).plugged)
|
||||
{
|
||||
text.at(i) = lang::getText(100) + std::to_string(i + 1) + ": " + options.controller.at(index).name;
|
||||
text.at(i) = lang::getText(100) + std::to_string(i + 1) + ": " + options.controllers.at(index).name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user