desacoplament de Player i Options

Player: canviat id de int a enum
migrant input: eliminat Device, keyboard separat de la llista de mandos, llig i guarda configuracions de mandos
falta: definir botons, asignar mandos a jugadors i guardar la asignació
This commit is contained in:
2025-08-03 22:49:28 +02:00
parent de9fb5aa4b
commit 90c080f3e3
19 changed files with 433 additions and 353 deletions

View File

@@ -19,8 +19,9 @@ DefineButtons::DefineButtons()
clearButtons();
for (int i = 0; i < input_->getNumControllers(); ++i) {
// controller_names_.emplace_back(input_->getControllerName(i));
auto gamepads = input_->getGamepads();
for (auto gamepad : gamepads) {
controller_names_.emplace_back(input_->getControllerName(gamepad));
}
}
@@ -28,9 +29,9 @@ DefineButtons::DefineButtons()
void DefineButtons::render() {
static auto text = Resource::get()->getText("8bithud");
if (enabled_) {
// text->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(Options::controllers.at(index_controller_).player_id));
// text->writeCentered(x_, y_, controller_names_.at(index_controller_));
// text->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
text->writeCentered(x_, y_ - 10, Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(static_cast<int>(gamepad_options_->player_id)));
text->writeCentered(x_, y_, gamepad_options_->instance->name);
text->writeCentered(x_, y_ + 10, buttons_.at(index_button_).label);
}
}
@@ -76,15 +77,15 @@ void DefineButtons::checkEvents(const SDL_Event &event) {
}
// Habilita el objeto
auto DefineButtons::enable(int index) -> bool {
if (index < input_->getNumControllers()) {
auto DefineButtons::enable(std::shared_ptr<Options::Gamepad> gamepad_options) -> bool {
if (gamepad_options != nullptr) {
gamepad_options_ = gamepad_options;
enabled_ = true;
finished_ = false;
index_button_ = 0;
clearButtons();
return true;
}
return false;
}