migrant input: ja funcionen coses, pero encara queda
This commit is contained in:
@@ -19,13 +19,13 @@
|
||||
|
||||
namespace Options {
|
||||
// --- Variables globales ---
|
||||
WindowOptions window; // Opciones de la ventana
|
||||
SettingsOptions settings; // Opciones del juego
|
||||
VideoOptions video; // Opciones de vídeo
|
||||
AudioOptions audio; // Opciones de audio
|
||||
std::vector<GamepadOptions> controllers; // Opciones de mando para cada jugador
|
||||
PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
||||
//std::vector<GamepadConfig> gamepad_configs; // Lista con las configuraciones registradas para cada mando
|
||||
WindowOptions window; // Opciones de la ventana
|
||||
SettingsOptions settings; // Opciones del juego
|
||||
VideoOptions video; // Opciones de vídeo
|
||||
AudioOptions audio; // Opciones de audio
|
||||
std::vector<GamepadOptions> controllers; // Opciones de mando para cada jugador
|
||||
PendingChanges pending_changes; // Opciones que se aplican al cerrar
|
||||
// std::vector<GamepadConfig> gamepad_configs; // Lista con las configuraciones registradas para cada mando
|
||||
|
||||
// Declaraciones
|
||||
auto set(const std::string& var, const std::string& value) -> bool;
|
||||
@@ -159,7 +159,6 @@ auto saveToFile() -> bool {
|
||||
file << "\n";
|
||||
file << "controller." << controller_index << ".name=" << controller.name << "\n";
|
||||
file << "controller." << controller_index << ".player=" << controller.player_id << "\n";
|
||||
file << "controller." << controller_index << ".type=" << static_cast<int>(controller.type) << "\n";
|
||||
|
||||
// Incrementa el índice
|
||||
++controller_index;
|
||||
@@ -186,8 +185,6 @@ void parseAndSetController(const std::string& var, const std::string& value) {
|
||||
controller.name = value;
|
||||
} else if (setting_key == "player") {
|
||||
controller.player_id = std::clamp(std::stoi(value), 1, 2);
|
||||
} else if (setting_key == "type") {
|
||||
controller.type = static_cast<Input::Device>(std::stoi(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,31 +257,31 @@ auto set(const std::string& var, const std::string& value) -> bool {
|
||||
void setKeyboardToPlayer(int player_id) {
|
||||
for (auto& controller : controllers) {
|
||||
if (controller.player_id == player_id) {
|
||||
controller.type = Input::Device::ANY;
|
||||
// controller.type = Input::Device::ANY;
|
||||
} else {
|
||||
controller.type = Input::Device::CONTROLLER;
|
||||
// controller.type = Input::Device::CONTROLLER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Intercambia el teclado de jugador
|
||||
void swapKeyboard() {
|
||||
std::swap(controllers.at(0).type, controllers.at(1).type);
|
||||
// std::swap(controllers.at(0).type, controllers.at(1).type);
|
||||
}
|
||||
|
||||
// Intercambia los jugadores asignados a los dos primeros mandos
|
||||
void swapControllers() {
|
||||
std::swap(controllers.at(0).player_id, controllers.at(1).player_id);
|
||||
std::swap(controllers.at(0).type, controllers.at(1).type);
|
||||
// std::swap(controllers.at(0).type, controllers.at(1).type);
|
||||
}
|
||||
|
||||
// Averigua quien está usando el teclado
|
||||
auto getPlayerWhoUsesKeyboard() -> int {
|
||||
for (const auto& controller : controllers) {
|
||||
if (controller.type == Input::Device::ANY) {
|
||||
return controller.player_id;
|
||||
}
|
||||
}
|
||||
// for (const auto& controller : controllers) {
|
||||
// if (controller.type == Input::Device::ANY) {
|
||||
// return controller.player_id;
|
||||
// }
|
||||
//}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user