les tecles de funcio ja tornena a funcionar amb la consola oberta

This commit is contained in:
2026-03-28 14:03:41 +01:00
parent ed21a47f92
commit 854a5f04b2
4 changed files with 35 additions and 17 deletions

View File

@@ -190,15 +190,16 @@ namespace GlobalInputs {
// Comprueba los inputs que se pueden introducir en cualquier sección del juego // Comprueba los inputs que se pueden introducir en cualquier sección del juego
void handle() { void handle() {
// Si la consola está activa, bloquea el resto de inputs globales const bool CONSOLE_ACTIVE = Console::get() != nullptr && Console::get()->isActive();
if (Console::get() != nullptr && Console::get()->isActive()) {
if (CONSOLE_ACTIVE) {
// TAB/ESC cierran la consola en lugar de ejecutar sus acciones normales
if (Input::get()->checkAction(InputAction::TOGGLE_CONSOLE, Input::DO_NOT_ALLOW_REPEAT) || if (Input::get()->checkAction(InputAction::TOGGLE_CONSOLE, Input::DO_NOT_ALLOW_REPEAT) ||
Input::get()->checkAction(InputAction::EXIT, Input::DO_NOT_ALLOW_REPEAT)) { Input::get()->checkAction(InputAction::EXIT, Input::DO_NOT_ALLOW_REPEAT)) {
Console::get()->toggle(); Console::get()->toggle();
}
return; return;
} }
} else {
// Salida de administrador en modo kiosko (Ctrl+Shift+Alt+Q) // Salida de administrador en modo kiosko (Ctrl+Shift+Alt+Q)
if (Options::kiosk.enabled) { if (Options::kiosk.enabled) {
SDL_Keymod mod = SDL_GetModState(); SDL_Keymod mod = SDL_GetModState();
@@ -208,10 +209,16 @@ namespace GlobalInputs {
return; return;
} }
} }
}
// Detectar qué acción global está siendo presionada // Detectar qué acción global está siendo presionada
InputAction action = getPressedAction(); InputAction action = getPressedAction();
// Con consola activa, ACCEPT (saltar sección) y EXIT están bloqueados
if (CONSOLE_ACTIVE && (action == InputAction::ACCEPT || action == InputAction::EXIT)) {
return;
}
// Ejecutar el handler correspondiente usando switch statement // Ejecutar el handler correspondiente usando switch statement
switch (action) { switch (action) {
case InputAction::EXIT: case InputAction::EXIT:

View File

@@ -8,13 +8,13 @@
#include <vector> // Para vector #include <vector> // Para vector
#include "core/audio/audio.hpp" // Para Audio #include "core/audio/audio.hpp" // Para Audio
#include "core/locale/locale.hpp" // Para Locale
#include "core/rendering/render_info.hpp" // Para RenderInfo #include "core/rendering/render_info.hpp" // Para RenderInfo
#include "core/rendering/screen.hpp" // Para Screen #include "core/rendering/screen.hpp" // Para Screen
#include "core/rendering/sprite/sprite.hpp" // Para Sprite #include "core/rendering/sprite/sprite.hpp" // Para Sprite
#include "core/rendering/surface.hpp" // Para Surface #include "core/rendering/surface.hpp" // Para Surface
#include "core/rendering/text.hpp" // Para Text #include "core/rendering/text.hpp" // Para Text
#include "core/resources/resource_cache.hpp" // Para Resource #include "core/resources/resource_cache.hpp" // Para Resource
#include "core/locale/locale.hpp" // Para Locale
#include "game/options.hpp" // Para Options #include "game/options.hpp" // Para Options
#include "game/scene_manager.hpp" // Para SceneManager #include "game/scene_manager.hpp" // Para SceneManager
#include "game/ui/notifier.hpp" // Para Notifier #include "game/ui/notifier.hpp" // Para Notifier
@@ -97,6 +97,7 @@ static void printHelp() {
SDL_Log(" MUSIC [ON|OFF|VOL <0-100>] Music volume"); SDL_Log(" MUSIC [ON|OFF|VOL <0-100>] Music volume");
SDL_Log(" SOUND [ON|OFF|VOL <0-100>] Sound volume"); SDL_Log(" SOUND [ON|OFF|VOL <0-100>] Sound volume");
SDL_Log(" SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]"); SDL_Log(" SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]");
SDL_Log(" SIZE Window size in pixels");
SDL_Log(" KIOSK [ON] Enable kiosk mode"); SDL_Log(" KIOSK [ON] Enable kiosk mode");
SDL_Log(" EXIT / QUIT Quit application"); SDL_Log(" EXIT / QUIT Quit application");
SDL_Log(" SHOW [FPS|INFO|NOTIFICATION|CHEEVO] Show debug overlay or test notification"); SDL_Log(" SHOW [FPS|INFO|NOTIFICATION|CHEEVO] Show debug overlay or test notification");
@@ -355,7 +356,9 @@ static const std::vector<ConsoleCommand> COMMANDS = {
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; } if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
if (args.empty()) { return "Usage: ROOM <1-60>"; } if (args.empty()) { return "Usage: ROOM <1-60>"; }
int num = 0; int num = 0;
try { num = std::stoi(args[0]); } catch (...) { return "Usage: ROOM <1-60>"; } try {
num = std::stoi(args[0]);
} catch (...) { return "Usage: ROOM <1-60>"; }
if (num < 1 || num > 60) { return "Room must be between 1 and 60"; } if (num < 1 || num > 60) { return "Room must be between 1 and 60"; }
char buf[16]; char buf[16];
std::snprintf(buf, sizeof(buf), "%02d.yaml", num); std::snprintf(buf, sizeof(buf), "%02d.yaml", num);
@@ -602,6 +605,14 @@ static const std::vector<ConsoleCommand> COMMANDS = {
return "Quitting..."; return "Quitting...";
}}, }},
// SIZE — Devuelve el tamaño actual de la ventana en píxeles
{.keyword = "SIZE", .execute = [](const std::vector<std::string>&) -> std::string {
int w = 0;
int h = 0;
SDL_GetWindowSize(SDL_GetRenderWindow(Screen::get()->getRenderer()), &w, &h);
return std::to_string(w) + "x" + std::to_string(h);
}},
// HELP / ? — Muestra ayuda en la terminal del sistema // HELP / ? — Muestra ayuda en la terminal del sistema
{.keyword = "HELP", .execute = [](const std::vector<std::string>&) -> std::string { {.keyword = "HELP", .execute = [](const std::vector<std::string>&) -> std::string {
printHelp(); printHelp();