migrant input: ja funcionen coses, pero encara queda
This commit is contained in:
@@ -1250,14 +1250,14 @@ void Game::checkPauseInput() {
|
||||
// Comprueba los mandos
|
||||
auto gamepads = input_->getGamepads();
|
||||
for (auto gamepad : gamepads) {
|
||||
if (input_->checkAction(Input::Action::PAUSE, Input::DO_NOT_ALLOW_REPEAT, Input::Device::CONTROLLER, gamepad)) {
|
||||
if (input_->checkAction(Input::Action::PAUSE, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
pause(!paused_);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el teclado
|
||||
if (input_->checkAction(Input::Action::PAUSE, Input::DO_NOT_ALLOW_REPEAT, Input::Device::KEYBOARD)) {
|
||||
if (input_->checkAction(Input::Action::PAUSE, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
pause(!paused_);
|
||||
return;
|
||||
}
|
||||
@@ -1366,14 +1366,12 @@ void Game::handlePlayersInput() {
|
||||
|
||||
// Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
||||
void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
||||
const auto &controller = Options::controllers.at(0);
|
||||
|
||||
if (input_->checkAction(Input::Action::LEFT, Input::ALLOW_REPEAT, controller.type, controller.gamepad)) {
|
||||
if (input_->checkAction(Input::Action::LEFT, Input::ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setInput(Input::Action::LEFT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.left = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::RIGHT, Input::ALLOW_REPEAT, controller.type, controller.gamepad)) {
|
||||
} else if (input_->checkAction(Input::Action::RIGHT, Input::ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setInput(Input::Action::RIGHT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.right = 1;
|
||||
@@ -1391,18 +1389,17 @@ void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
||||
|
||||
// Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
||||
void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::FIRE_CENTER, autofire, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (input_->checkAction(Input::Action::FIRE_CENTER, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
handleFireInput(player, BulletType::UP);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::FIRE_LEFT, autofire, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
} else if (input_->checkAction(Input::Action::FIRE_LEFT, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
handleFireInput(player, BulletType::LEFT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire_left = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::FIRE_RIGHT, autofire, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
} else if (input_->checkAction(Input::Action::FIRE_RIGHT, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
handleFireInput(player, BulletType::RIGHT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire_right = 1;
|
||||
@@ -1412,17 +1409,16 @@ void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire
|
||||
|
||||
// Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio.
|
||||
void Game::handlePlayerContinueInput(const std::shared_ptr<Player> &player) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setPlayingState(Player::State::RESPAWNING);
|
||||
player->addCredit();
|
||||
sendPlayerToTheFront(player);
|
||||
}
|
||||
|
||||
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad) ||
|
||||
input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad()) ||
|
||||
input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad()) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
if (player->getContinueCounter() < param.scoreboard.skip_countdown_value) {
|
||||
player->decContinueCounter();
|
||||
}
|
||||
@@ -1431,8 +1427,7 @@ void Game::handlePlayerContinueInput(const std::shared_ptr<Player> &player) {
|
||||
|
||||
// Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio.
|
||||
void Game::handlePlayerWaitingInput(const std::shared_ptr<Player> &player) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setPlayingState(Player::State::ENTERING_SCREEN);
|
||||
player->addCredit();
|
||||
sendPlayerToTheFront(player);
|
||||
@@ -1441,8 +1436,7 @@ void Game::handlePlayerWaitingInput(const std::shared_ptr<Player> &player) {
|
||||
|
||||
// Procesa las entradas para la introducción del nombre del jugador.
|
||||
void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else if (player->getEnterNamePositionOverflow()) {
|
||||
@@ -1452,18 +1446,18 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
||||
} else {
|
||||
player->setInput(Input::Action::RIGHT);
|
||||
}
|
||||
} else if (input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
} else if (input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad()) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else {
|
||||
player->setInput(Input::Action::LEFT);
|
||||
}
|
||||
} else if (input_->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
} else if (input_->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setInput(Input::Action::UP);
|
||||
} else if (input_->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
} else if (input_->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setInput(Input::Action::DOWN);
|
||||
} else if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
} else if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else {
|
||||
@@ -1594,14 +1588,16 @@ void Game::initPlayers(int player_id) {
|
||||
players_.emplace_back(std::make_unique<Player>(1, param.game.play_area.first_quarter_x - (Player::WIDTH / 2), Y, demo_.enabled, param.game.play_area.rect, player_textures_.at(0), player_animations_));
|
||||
players_.back()->setScoreBoardPanel(Scoreboard::Id::LEFT);
|
||||
players_.back()->setName(Lang::getText("[SCOREBOARD] 1"));
|
||||
players_.back()->setController(getController(players_.back()->getId()));
|
||||
//players_.back()->setController(getController(players_.back()->getId()));
|
||||
players_.back()->setGamepad(Options::controllers.front().gamepad);
|
||||
players_.back()->setUsesKeyboard(true);
|
||||
players_.back()->setPlayingState(Player::State::WAITING);
|
||||
|
||||
// Crea al jugador dos y lo pone en modo espera
|
||||
players_.emplace_back(std::make_unique<Player>(2, param.game.play_area.third_quarter_x - (Player::WIDTH / 2), Y, demo_.enabled, param.game.play_area.rect, player_textures_.at(1), player_animations_));
|
||||
players_.back()->setScoreBoardPanel(Scoreboard::Id::RIGHT);
|
||||
players_.back()->setName(Lang::getText("[SCOREBOARD] 2"));
|
||||
players_.back()->setController(getController(players_.back()->getId()));
|
||||
//players_.back()->setController(getController(players_.back()->getId()));
|
||||
players_.back()->setPlayingState(Player::State::WAITING);
|
||||
|
||||
// Activa el jugador que coincide con el "player_id" o ambos si es "0"
|
||||
|
||||
Reference in New Issue
Block a user