merdes varies

This commit is contained in:
2025-11-08 13:21:59 +01:00
parent 85d34fb907
commit 1f01268dcf
8 changed files with 47 additions and 26 deletions

View File

@@ -12,6 +12,10 @@
#include "game/ui/notifier.hpp" // Para Notifier, NotificationText
#include "utils/utils.hpp" // Para stringInVector
#ifdef _DEBUG
#include "core/system/debug.hpp" // Para Debug
#endif
namespace GlobalInputs {
// Funciones internas
@@ -101,10 +105,17 @@ void handleToggleVSync() {
Notifier::get()->show({"V-SYNC " + std::string(Options::video.vertical_sync ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
}
#ifdef _DEBUG
void handleShowDebugInfo() {
Screen::get()->toggleDebugInfo();
}
void handleToggleDebug() {
Debug::get()->toggleEnabled();
Notifier::get()->show({"DEBUG " + std::string(Debug::get()->getEnabled() ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
}
#endif
// Detecta qué acción global ha sido presionada (si alguna)
auto getPressedAction() -> InputAction {
if (Input::get()->checkAction(InputAction::EXIT, Input::DO_NOT_ALLOW_REPEAT)) {
@@ -140,6 +151,9 @@ auto getPressedAction() -> InputAction {
if (Input::get()->checkAction(InputAction::TOGGLE_VSYNC, Input::DO_NOT_ALLOW_REPEAT)) {
return InputAction::TOGGLE_VSYNC;
}
if (Input::get()->checkAction(InputAction::TOGGLE_DEBUG, Input::DO_NOT_ALLOW_REPEAT)) {
return InputAction::TOGGLE_DEBUG;
}
if (Input::get()->checkAction(InputAction::SHOW_DEBUG_INFO, Input::DO_NOT_ALLOW_REPEAT)) {
return InputAction::SHOW_DEBUG_INFO;
}
@@ -201,6 +215,10 @@ void handle() {
handleToggleVSync();
break;
case InputAction::TOGGLE_DEBUG:
handleToggleDebug();
break;
case InputAction::SHOW_DEBUG_INFO:
handleShowDebugInfo();
break;

View File

@@ -78,8 +78,8 @@ class Input {
{Action::TOGGLE_MUSIC, KeyState(SDL_SCANCODE_F8)},
{Action::TOGGLE_BORDER, KeyState(SDL_SCANCODE_F9)},
{Action::TOGGLE_VSYNC, KeyState(SDL_SCANCODE_F10)},
{Action::PAUSE, KeyState(SDL_SCANCODE_F11)},
{Action::SHOW_DEBUG_INFO, KeyState(SDL_SCANCODE_F12)}} {}
{Action::TOGGLE_DEBUG, KeyState(SDL_SCANCODE_F12)},
{Action::SHOW_DEBUG_INFO, KeyState(SDL_SCANCODE_F11)}} {}
};
struct Gamepad {

View File

@@ -22,6 +22,7 @@ const std::unordered_map<InputAction, std::string> ACTION_TO_STRING = {
{InputAction::PREVIOUS_PALETTE, "PREVIOUS_PALETTE"},
{InputAction::TOGGLE_SHADERS, "TOGGLE_SHADERS"},
{InputAction::SHOW_DEBUG_INFO, "SHOW_DEBUG_INFO"},
{InputAction::TOGGLE_DEBUG, "TOGGLE_DEBUG"},
{InputAction::NONE, "NONE"}};
const std::unordered_map<std::string, InputAction> STRING_TO_ACTION = {
@@ -43,6 +44,7 @@ const std::unordered_map<std::string, InputAction> STRING_TO_ACTION = {
{"PREVIOUS_PALETTE", InputAction::PREVIOUS_PALETTE},
{"TOGGLE_SHADERS", InputAction::TOGGLE_SHADERS},
{"SHOW_DEBUG_INFO", InputAction::SHOW_DEBUG_INFO},
{"TOGGLE_DEBUG", InputAction::TOGGLE_DEBUG},
{"NONE", InputAction::NONE}};
const std::unordered_map<SDL_GamepadButton, std::string> BUTTON_TO_STRING = {

View File

@@ -30,6 +30,7 @@ enum class InputAction : int { // Acciones de entrada posibles en el juego
NEXT_PALETTE,
PREVIOUS_PALETTE,
SHOW_DEBUG_INFO,
TOGGLE_DEBUG,
// Input obligatorio
NONE,