Ja es por canviar el jugador que maneja el teclat "en calent" desde el service menu
This commit is contained in:
@@ -72,6 +72,9 @@ Title::~Title() {
|
||||
if (Section::name == Section::Name::LOGO) {
|
||||
Audio::get()->fadeOutMusic(300);
|
||||
}
|
||||
|
||||
// Desregistra los jugadores de Options
|
||||
Options::keyboard.clearPlayers();
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
@@ -208,11 +211,36 @@ void Title::checkInput() {
|
||||
|
||||
if (!ServiceMenu::get()->isEnabled()) {
|
||||
processControllerInputs();
|
||||
processKeyboardStart();
|
||||
}
|
||||
|
||||
GlobalInputs::check();
|
||||
}
|
||||
|
||||
void Title::processKeyboardStart() {
|
||||
if (!canProcessStartButton()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool START_PRESSED = Input::get()->checkAction(
|
||||
Input::Action::START,
|
||||
Input::DO_NOT_ALLOW_REPEAT,
|
||||
Input::CHECK_KEYBOARD);
|
||||
|
||||
if (START_PRESSED) {
|
||||
switch (Options::keyboard.player_id) {
|
||||
case Player::Id::PLAYER1:
|
||||
processPlayer1Start();
|
||||
break;
|
||||
case Player::Id::PLAYER2:
|
||||
processPlayer2Start();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Title::processControllerInputs() {
|
||||
for (const auto& controller : Options::gamepad_manager) {
|
||||
if (isStartButtonPressed(&controller)) {
|
||||
@@ -225,7 +253,7 @@ auto Title::isStartButtonPressed(const Options::Gamepad* controller) -> bool {
|
||||
return Input::get()->checkAction(
|
||||
Input::Action::START,
|
||||
Input::DO_NOT_ALLOW_REPEAT,
|
||||
Input::CHECK_KEYBOARD,
|
||||
Input::DO_NOT_CHECK_KEYBOARD,
|
||||
controller->instance);
|
||||
}
|
||||
|
||||
@@ -458,36 +486,28 @@ void Title::initPlayers() {
|
||||
std::vector<std::vector<std::string>> player_animations; // Vector con las animaciones del jugador
|
||||
|
||||
// Texturas - Player1
|
||||
{
|
||||
std::vector<std::shared_ptr<Texture>> player_texture;
|
||||
player_texture.emplace_back(Resource::get()->getTexture("player1.gif"));
|
||||
player_texture.emplace_back(Resource::get()->getTexture("player1_power.png"));
|
||||
player_textures.push_back(player_texture);
|
||||
}
|
||||
std::vector<std::shared_ptr<Texture>> player1_textures;
|
||||
player1_textures.emplace_back(Resource::get()->getTexture("player1.gif"));
|
||||
player1_textures.emplace_back(Resource::get()->getTexture("player1_power.png"));
|
||||
player_textures.push_back(player1_textures);
|
||||
|
||||
// Texturas - Player2
|
||||
{
|
||||
std::vector<std::shared_ptr<Texture>> player_texture;
|
||||
player_texture.emplace_back(Resource::get()->getTexture("player2.gif"));
|
||||
player_texture.emplace_back(Resource::get()->getTexture("player2_power.png"));
|
||||
player_textures.push_back(player_texture);
|
||||
}
|
||||
std::vector<std::shared_ptr<Texture>> player2_textures;
|
||||
player2_textures.emplace_back(Resource::get()->getTexture("player2.gif"));
|
||||
player2_textures.emplace_back(Resource::get()->getTexture("player2_power.png"));
|
||||
player_textures.push_back(player2_textures);
|
||||
|
||||
// Animaciones -- Jugador
|
||||
{
|
||||
player_animations.emplace_back(Resource::get()->getAnimation("player.ani"));
|
||||
player_animations.emplace_back(Resource::get()->getAnimation("player_power.ani"));
|
||||
}
|
||||
player_animations.emplace_back(Resource::get()->getAnimation("player.ani"));
|
||||
player_animations.emplace_back(Resource::get()->getAnimation("player_power.ani"));
|
||||
|
||||
// Crea los dos jugadores
|
||||
constexpr int PLAYER_WIDTH = 32;
|
||||
constexpr int PLAYER_HEIGHT = 32;
|
||||
const int Y = param.title.press_start_position - (PLAYER_HEIGHT / 2);
|
||||
const int Y = param.title.press_start_position - (Player::HEIGHT / 2);
|
||||
constexpr bool DEMO = false;
|
||||
|
||||
Player::Config config_player1;
|
||||
config_player1.id = Player::Id::PLAYER1;
|
||||
config_player1.x = param.game.game_area.center_x - (PLAYER_WIDTH / 2);
|
||||
config_player1.x = param.game.game_area.center_x - (Player::WIDTH / 2);
|
||||
config_player1.y = Y;
|
||||
config_player1.demo = DEMO;
|
||||
config_player1.play_area = ¶m.game.play_area.rect;
|
||||
@@ -500,7 +520,7 @@ void Title::initPlayers() {
|
||||
|
||||
Player::Config config_player2;
|
||||
config_player2.id = Player::Id::PLAYER2;
|
||||
config_player2.x = param.game.game_area.center_x - (PLAYER_WIDTH / 2);
|
||||
config_player2.x = param.game.game_area.center_x - (Player::WIDTH / 2);
|
||||
config_player2.y = Y;
|
||||
config_player2.demo = DEMO;
|
||||
config_player2.play_area = ¶m.game.play_area.rect;
|
||||
@@ -510,6 +530,10 @@ void Title::initPlayers() {
|
||||
config_player2.glowing_entry = &Options::settings.glowing_entries.at(static_cast<int>(Player::Id::PLAYER2) - 1);
|
||||
players_.emplace_back(std::make_unique<Player>(config_player2));
|
||||
players_.back()->setPlayingState(Player::State::TITLE_HIDDEN);
|
||||
|
||||
// Registra los jugadores en Options
|
||||
Options::keyboard.addPlayer(players_.at(0));
|
||||
Options::keyboard.addPlayer(players_.at(1));
|
||||
}
|
||||
|
||||
// Actualza los jugadores
|
||||
|
||||
Reference in New Issue
Block a user