Service Menu: afegides opcions per als mandos

This commit is contained in:
2025-08-05 13:12:48 +02:00
parent 12e3226f17
commit 3bb5e5d604
7 changed files with 89 additions and 4 deletions

View File

@@ -57,7 +57,7 @@ class MenuRenderer {
bool resizing_ = false;
// --- Anchos precalculados ---
std::array<int, 5> group_menu_widths_ = {};
std::array<int, ServiceMenu::SETTINGS_GROUP_SIZE> group_menu_widths_ = {};
// --- Métodos privados de la vista ---
void setAnchors(const ServiceMenu *menu_state);

View File

@@ -176,6 +176,9 @@ void ServiceMenu::updateMenu() {
}
void ServiceMenu::applySettings() {
if (current_settings_group_ == SettingsGroup::CONTROLS) {
applyControlsSettings();
}
if (current_settings_group_ == SettingsGroup::VIDEO) {
applyVideoSettings();
}
@@ -190,6 +193,8 @@ void ServiceMenu::applySettings() {
updateOptionPairs();
}
void ServiceMenu::applyControlsSettings() {}
void ServiceMenu::applyVideoSettings() {
Screen::get()->applySettings();
setHiddenOptions();
@@ -216,6 +221,7 @@ auto ServiceMenu::getOptionByCaption(const std::string &caption) const -> MenuOp
auto ServiceMenu::getCurrentGroupAlignment() const -> ServiceMenu::GroupAlignment {
switch (current_settings_group_) {
case SettingsGroup::CONTROLS:
case SettingsGroup::VIDEO:
case SettingsGroup::AUDIO:
case SettingsGroup::SETTINGS:
@@ -239,6 +245,43 @@ auto ServiceMenu::countOptionsInGroup(SettingsGroup group) const -> size_t {
void ServiceMenu::initializeOptions() {
options_.clear();
// CONTROLS
options_.push_back(std::make_unique<ListOption>(
"Mando Jugador 1",
SettingsGroup::CONTROLS,
Input::get()->getControllerNames(),
[]() {
return Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).name;
},
[](const std::string &val) {
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER1, Input::get()->getGamepadByName(val), val);
}));
options_.push_back(std::make_unique<ListOption>(
"Mando Jugador 2",
SettingsGroup::CONTROLS,
Input::get()->getControllerNames(),
[]() {
return Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).name;
},
[](const std::string &val) {
Options::gamepad_manager.assignGamepadToPlayer(Player::Id::PLAYER2, Input::get()->getGamepadByName(val), val);
}));
options_.push_back(std::make_unique<ListOption>(
"Teclat",
SettingsGroup::CONTROLS,
std::vector<std::string>{
"Jugador 1",
"Jugador 2"},
[]() {
return Lang::getNameFromCode(Options::pending_changes.new_language);
},
[](const std::string &val) {
Options::pending_changes.new_language = Lang::getCodeFromName(val);
Options::checkPendingChanges();
}));
// VIDEO
options_.push_back(std::make_unique<BoolOption>(
Lang::getText("[SERVICE_MENU] FULLSCREEN"),
@@ -366,6 +409,11 @@ void ServiceMenu::initializeOptions() {
!Options::settings.shutdown_enabled));
// MAIN MENU
options_.push_back(std::make_unique<FolderOption>(
"Controls",
SettingsGroup::MAIN,
SettingsGroup::CONTROLS));
options_.push_back(std::make_unique<FolderOption>(
Lang::getText("[SERVICE_MENU] VIDEO"),
SettingsGroup::MAIN,
@@ -410,8 +458,10 @@ auto ServiceMenu::settingsGroupToString(SettingsGroup group) -> std::string {
switch (group) {
case SettingsGroup::MAIN:
return Lang::getText("[SERVICE_MENU] TITLE");
case SettingsGroup::CONTROLS:
return Lang::getText("[SERVICE_MENU] TITLE");
case SettingsGroup::VIDEO:
return Lang::getText("[SERVICE_MENU] VIDEO");
return "Controls";
case SettingsGroup::AUDIO:
return Lang::getText("[SERVICE_MENU] AUDIO");
case SettingsGroup::SETTINGS:

View File

@@ -9,11 +9,12 @@
#include "ui_message.h" // Para UIMessage
class MenuOption;
class MenuRenderer; // <-- Nuevo
class MenuRenderer;
class ServiceMenu {
public:
enum class SettingsGroup {
CONTROLS,
VIDEO,
AUDIO,
SETTINGS,
@@ -30,6 +31,7 @@ class ServiceMenu {
static constexpr size_t OPTIONS_HORIZONTAL_PADDING = 20;
static constexpr size_t MIN_WIDTH = 240;
static constexpr size_t MIN_GAP_OPTION_VALUE = 30;
static constexpr size_t SETTINGS_GROUP_SIZE = 6;
// --- Métodos de singleton ---
static void init();
@@ -88,6 +90,7 @@ class ServiceMenu {
void initializeOptions();
void updateMenu();
void applySettings();
void applyControlsSettings();
void applyVideoSettings();
static void applyAudioSettings();
void applySettingsSettings();