claude: treballant en el nou define_buttons
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#include "section.hpp" // Para Name, name, Options, options
|
||||
#include "ui/ui_message.h" // Para UIMessage
|
||||
#include "utils.h" // Para Zone
|
||||
#include "action_list_option.h" // Para ActionListOption
|
||||
#include "define_buttons.h" // Para DefineButtons
|
||||
|
||||
// Singleton
|
||||
ServiceMenu *ServiceMenu::instance = nullptr;
|
||||
@@ -32,6 +34,7 @@ ServiceMenu::ServiceMenu()
|
||||
|
||||
renderer_ = std::make_unique<MenuRenderer>(this, element_text, title_text);
|
||||
restart_message_ui_ = std::make_unique<UIMessage>(element_text, Lang::getText("[SERVICE_MENU] NEED_RESTART_MESSAGE"), param.service_menu.title_color);
|
||||
define_buttons_ = std::make_unique<DefineButtons>();
|
||||
|
||||
reset();
|
||||
}
|
||||
@@ -55,6 +58,11 @@ void ServiceMenu::render() {
|
||||
const float MSG_Y = renderer_->getRect().y + 39.0F;
|
||||
restart_message_ui_->setPosition(MSG_X, MSG_Y);
|
||||
restart_message_ui_->render();
|
||||
|
||||
// Renderizar DefineButtons si está activo (se dibuja por encima de todo)
|
||||
if (define_buttons_ && define_buttons_->isEnabled()) {
|
||||
define_buttons_->render();
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceMenu::update() {
|
||||
@@ -70,6 +78,22 @@ void ServiceMenu::update() {
|
||||
last_pending_changes_ = now_pending;
|
||||
}
|
||||
restart_message_ui_->update();
|
||||
|
||||
// Actualizar DefineButtons
|
||||
if (define_buttons_) {
|
||||
define_buttons_->update();
|
||||
|
||||
// Si DefineButtons ha terminado, deshabilitarlo
|
||||
if (define_buttons_->isEnabled() && define_buttons_->isFinished()) {
|
||||
// Pequeño delay antes de cerrar
|
||||
static int finish_delay = 0;
|
||||
finish_delay++;
|
||||
if (finish_delay > 60) { // 1 segundo a 60 FPS
|
||||
define_buttons_->disable();
|
||||
finish_delay = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceMenu::reset() {
|
||||
@@ -247,8 +271,8 @@ auto ServiceMenu::countOptionsInGroup(SettingsGroup group) const -> size_t {
|
||||
void ServiceMenu::initializeOptions() {
|
||||
options_.clear();
|
||||
|
||||
// CONTROLS
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
// CONTROLS - Usando ActionListOption para mandos
|
||||
options_.push_back(std::make_unique<ActionListOption>(
|
||||
Lang::getText("[SERVICE_MENU] CONTROLLER1"),
|
||||
SettingsGroup::CONTROLS,
|
||||
Input::get()->getControllerNames(),
|
||||
@@ -257,9 +281,16 @@ void ServiceMenu::initializeOptions() {
|
||||
},
|
||||
[](const std::string &val) {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER1, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() {
|
||||
// Acción: configurar botones del mando del jugador 1
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER1);
|
||||
if (gamepad && gamepad->instance) {
|
||||
define_buttons_->enable(gamepad);
|
||||
}
|
||||
}));
|
||||
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
options_.push_back(std::make_unique<ActionListOption>(
|
||||
Lang::getText("[SERVICE_MENU] CONTROLLER2"),
|
||||
SettingsGroup::CONTROLS,
|
||||
Input::get()->getControllerNames(),
|
||||
@@ -268,8 +299,16 @@ void ServiceMenu::initializeOptions() {
|
||||
},
|
||||
[](const std::string &val) {
|
||||
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER2, Input::get()->getGamepadByName(val), val);
|
||||
},
|
||||
[this]() {
|
||||
// Acción: configurar botones del mando del jugador 2
|
||||
auto* gamepad = &Options::gamepad_manager.getGamepad(Player::Id::PLAYER2);
|
||||
if (gamepad && gamepad->instance) {
|
||||
define_buttons_->enable(gamepad);
|
||||
}
|
||||
}));
|
||||
|
||||
// CONTROLS - Opción para teclado (solo lista, sin acción)
|
||||
options_.push_back(std::make_unique<ListOption>(
|
||||
Lang::getText("[SERVICE_MENU] KEYBOARD"),
|
||||
SettingsGroup::CONTROLS,
|
||||
@@ -277,13 +316,16 @@ void ServiceMenu::initializeOptions() {
|
||||
Lang::getText("[SERVICE_MENU] PLAYER1"),
|
||||
Lang::getText("[SERVICE_MENU] PLAYER2")},
|
||||
[]() {
|
||||
return Lang::getNameFromCode(Options::pending_changes.new_language);
|
||||
// Aquí deberías devolver el jugador actual asignado al teclado
|
||||
// Por ahora devuelvo "Jugador 1" como ejemplo
|
||||
return Lang::getText("[SERVICE_MENU] PLAYER1");
|
||||
},
|
||||
[](const std::string &val) {
|
||||
Options::pending_changes.new_language = Lang::getCodeFromName(val);
|
||||
Options::checkPendingChanges();
|
||||
// Aquí asignarías el teclado al jugador seleccionado
|
||||
// Implementación pendiente según tu sistema de input
|
||||
}));
|
||||
|
||||
// CONTROLS - Acción para intercambiar mandos
|
||||
options_.push_back(std::make_unique<ActionOption>(
|
||||
Lang::getText("[SERVICE_MENU] SWAP_CONTROLLERS"),
|
||||
SettingsGroup::CONTROLS,
|
||||
|
||||
Reference in New Issue
Block a user