Input: afegits dos inputs per a ServiceMenu (accept i back)

Style: renombrats alguns metodes de windowZoom a windowSize
This commit is contained in:
2025-06-10 11:01:17 +02:00
parent 813f994500
commit 32d3f96a3d
5 changed files with 53 additions and 17 deletions

View File

@@ -176,8 +176,12 @@ void Director::bindInputs()
Input::get()->bindKey(InputAction::START, SDL_SCANCODE_RETURN); Input::get()->bindKey(InputAction::START, SDL_SCANCODE_RETURN);
// Teclado - Control del programa // Teclado - Menu de servicio
Input::get()->bindKey(InputAction::SERVICE, SDL_SCANCODE_0); Input::get()->bindKey(InputAction::SERVICE, SDL_SCANCODE_0);
Input::get()->bindKey(InputAction::SM_SELECT, SDL_SCANCODE_RETURN);
Input::get()->bindKey(InputAction::SM_BACK, SDL_SCANCODE_BACKSPACE);
// Teclado - Control del programa
Input::get()->bindKey(InputAction::EXIT, SDL_SCANCODE_ESCAPE); Input::get()->bindKey(InputAction::EXIT, SDL_SCANCODE_ESCAPE);
Input::get()->bindKey(InputAction::PAUSE, SDL_SCANCODE_P); Input::get()->bindKey(InputAction::PAUSE, SDL_SCANCODE_P);
Input::get()->bindKey(InputAction::BACK, SDL_SCANCODE_BACKSPACE); Input::get()->bindKey(InputAction::BACK, SDL_SCANCODE_BACKSPACE);
@@ -213,8 +217,10 @@ void Director::bindInputs()
Input::get()->bindGameControllerButton(i, InputAction::START, SDL_GAMEPAD_BUTTON_START); Input::get()->bindGameControllerButton(i, InputAction::START, SDL_GAMEPAD_BUTTON_START);
// Mando - Control del programa // Teclado - Menu de servicio
Input::get()->bindGameControllerButton(i, InputAction::SERVICE, SDL_GAMEPAD_BUTTON_BACK); Input::get()->bindGameControllerButton(i, InputAction::SERVICE, SDL_GAMEPAD_BUTTON_BACK);
Input::get()->bindGameControllerButton(i, InputAction::SM_SELECT, SDL_GAMEPAD_BUTTON_WEST);
Input::get()->bindGameControllerButton(i, InputAction::SM_BACK, SDL_GAMEPAD_BUTTON_NORTH);
} }
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso // Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso

View File

@@ -170,6 +170,32 @@ namespace globalInputs
ServiceMenu::get()->toggle(); ServiceMenu::get()->toggle();
} }
// Cambia el modo de pantalla completa
void toggleFullscreen()
{
Screen::get()->toggleFullscreen();
const std::string MODE = options.video.fullscreen ? lang::getText("[NOTIFICATIONS] 11") : lang::getText("[NOTIFICATIONS] 10");
Notifier::get()->show({MODE});
}
// Reduce el tamaño de la ventana
void decWindowSize()
{
if (Screen::get()->decWindowSize())
{
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
}
}
// Aumenta el tamaño de la ventana
void incWindowSize()
{
if (Screen::get()->incWindowSize())
{
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
}
}
// Comprueba el boton de servicio // Comprueba el boton de servicio
void checkServiceButton() void checkServiceButton()
{ {
@@ -184,7 +210,7 @@ namespace globalInputs
{ {
for (int i = 0; i < Input::get()->getNumControllers(); ++i) for (int i = 0; i < Input::get()->getNumControllers(); ++i)
{ {
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) if (Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
{ {
toggleServiceMenu(); toggleServiceMenu();
return; return;
@@ -230,14 +256,14 @@ namespace globalInputs
} }
// Aceptar // Aceptar
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) if (Input::get()->checkInput(InputAction::SM_SELECT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
{ {
ServiceMenu::get()->selectOption(); ServiceMenu::get()->selectOption();
return; return;
} }
// Atras // Atras
if (Input::get()->checkInput(InputAction::BACK, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) if (Input::get()->checkInput(InputAction::SM_BACK, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
{ {
ServiceMenu::get()->moveBack(); ServiceMenu::get()->moveBack();
return; return;
@@ -249,42 +275,42 @@ namespace globalInputs
for (int i = 0; i < Input::get()->getNumControllers(); ++i) for (int i = 0; i < Input::get()->getNumControllers(); ++i)
{ {
// Arriba // Arriba
if (Input::get()->checkInput(InputAction::UP, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) if (Input::get()->checkInput(InputAction::UP, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
{ {
ServiceMenu::get()->setSelectorUp(); ServiceMenu::get()->setSelectorUp();
return; return;
} }
// Abajo // Abajo
if (Input::get()->checkInput(InputAction::DOWN, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) if (Input::get()->checkInput(InputAction::DOWN, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
{ {
ServiceMenu::get()->setSelectorDown(); ServiceMenu::get()->setSelectorDown();
return; return;
} }
// Derecha // Derecha
if (Input::get()->checkInput(InputAction::RIGHT, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) if (Input::get()->checkInput(InputAction::RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
{ {
ServiceMenu::get()->adjustOption(true); ServiceMenu::get()->adjustOption(true);
return; return;
} }
// Izquierda // Izquierda
if (Input::get()->checkInput(InputAction::LEFT, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) if (Input::get()->checkInput(InputAction::LEFT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
{ {
ServiceMenu::get()->adjustOption(false); ServiceMenu::get()->adjustOption(false);
return; return;
} }
// Aceptar // Aceptar
if (Input::get()->checkInput(InputAction::FIRE_LEFT, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) if (Input::get()->checkInput(InputAction::SM_SELECT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
{ {
ServiceMenu::get()->selectOption(); ServiceMenu::get()->selectOption();
return; return;
} }
// Atras // Atras
if (Input::get()->checkInput(InputAction::FIRE_CENTER, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i)) if (Input::get()->checkInput(InputAction::SM_BACK, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
{ {
ServiceMenu::get()->moveBack(); ServiceMenu::get()->moveBack();
return; return;
@@ -310,7 +336,7 @@ namespace globalInputs
// Comprueba el teclado para decrementar el tamaño de la ventana // Comprueba el teclado para decrementar el tamaño de la ventana
if (Input::get()->checkInput(InputAction::WINDOW_DEC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) if (Input::get()->checkInput(InputAction::WINDOW_DEC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
{ {
if (Screen::get()->decWindowZoom()) if (Screen::get()->decWindowSize())
{ {
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)}); Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
} }
@@ -320,7 +346,7 @@ namespace globalInputs
// Comprueba el teclado para incrementar el tamaño de la ventana // Comprueba el teclado para incrementar el tamaño de la ventana
if (Input::get()->checkInput(InputAction::WINDOW_INC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD)) if (Input::get()->checkInput(InputAction::WINDOW_INC_SIZE, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
{ {
if (Screen::get()->incWindowZoom()) if (Screen::get()->incWindowSize())
{ {
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)}); Notifier::get()->show({lang::getText("[NOTIFICATIONS] 09") + " x" + std::to_string(options.window.size)});
} }

View File

@@ -31,6 +31,10 @@ enum class InputAction : int
FIRE_RIGHT, FIRE_RIGHT,
START, START,
// Service Menu
SM_SELECT,
SM_BACK,
// Inputs de control // Inputs de control
BACK, BACK,
EXIT, EXIT,

View File

@@ -130,7 +130,7 @@ void Screen::setWindowZoom(int zoom)
} }
// Reduce el tamaño de la ventana // Reduce el tamaño de la ventana
bool Screen::decWindowZoom() bool Screen::decWindowSize()
{ {
if (!options.video.fullscreen) if (!options.video.fullscreen)
{ {
@@ -149,7 +149,7 @@ bool Screen::decWindowZoom()
} }
// Aumenta el tamaño de la ventana // Aumenta el tamaño de la ventana
bool Screen::incWindowZoom() bool Screen::incWindowSize()
{ {
if (!options.video.fullscreen) if (!options.video.fullscreen)
{ {

View File

@@ -38,8 +38,8 @@ public:
void setFullscreenMode(bool mode = options.video.fullscreen); // Establece el modo de video void setFullscreenMode(bool mode = options.video.fullscreen); // Establece el modo de video
void toggleFullscreen(); // Cambia entre pantalla completa y ventana void toggleFullscreen(); // Cambia entre pantalla completa y ventana
void setWindowZoom(int size); // Cambia el tamaño de la ventana void setWindowZoom(int size); // Cambia el tamaño de la ventana
bool decWindowZoom(); // Reduce el tamaño de la ventana bool decWindowSize(); // Reduce el tamaño de la ventana
bool incWindowZoom(); // Aumenta el tamaño de la ventana bool incWindowSize(); // Aumenta el tamaño de la ventana
void applySettings(); // Aplica los valores de las opciones void applySettings(); // Aplica los valores de las opciones
// --- Efectos visuales --- // --- Efectos visuales ---