GamepadManager::swapPlayers() ja notifica als jugadors
This commit is contained in:
@@ -156,6 +156,21 @@ class GamepadManager {
|
||||
std::swap(gamepads_[0].instance, gamepads_[1].instance);
|
||||
std::swap(gamepads_[0].name, gamepads_[1].name);
|
||||
std::swap(gamepads_[0].path, gamepads_[1].path);
|
||||
|
||||
for (auto player: players)
|
||||
{
|
||||
switch (player->getId())
|
||||
{
|
||||
case Player::Id::PLAYER1:
|
||||
player->setGamepad(gamepads_[0].instance);
|
||||
break;
|
||||
case Player::Id::PLAYER2:
|
||||
player->setGamepad(gamepads_[1].instance);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void saveToFile(std::ofstream& file) const {
|
||||
@@ -209,6 +224,14 @@ class GamepadManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
void addPlayer(std::shared_ptr<Player> player) { players.push_back(player); } // Añade un jugador a la lista
|
||||
void clearPlayers() { players.clear(); } // Limpia la lista de jugadores
|
||||
|
||||
// Asigna el mando a un jugador
|
||||
void assignTo(Input::Gamepad gamepad, Player::Id player_id) {
|
||||
|
||||
}
|
||||
|
||||
// Asigna los mandos físicos basándose en la configuración actual de nombres.
|
||||
void assignAndLinkGamepads();
|
||||
|
||||
@@ -223,7 +246,8 @@ class GamepadManager {
|
||||
private:
|
||||
static constexpr std::string_view UNASSIGNED_TEXT = "---";
|
||||
static constexpr size_t MAX_PLAYERS = 2;
|
||||
std::array<Gamepad, MAX_PLAYERS> gamepads_;
|
||||
std::array<Gamepad, MAX_PLAYERS> gamepads_; // Punteros a las estructuras de mandos de Options
|
||||
std::vector<std::shared_ptr<Player>> players; // Punteros a los jugadores
|
||||
|
||||
// Convierte Player::Id a índice del array
|
||||
[[nodiscard]] static auto playerIdToIndex(Player::Id player_id) -> size_t {
|
||||
|
||||
Reference in New Issue
Block a user