afegits comandos y restriccions en la consola per al modo kiosko

This commit is contained in:
2026-03-28 00:26:29 +01:00
parent 7bad27d686
commit 8355c266a6
3 changed files with 79 additions and 12 deletions

View File

@@ -66,6 +66,7 @@ class Screen {
void setRendererSurface(const std::shared_ptr<Surface>& surface = nullptr); // Establece el renderizador para las surfaces void setRendererSurface(const std::shared_ptr<Surface>& surface = nullptr); // Establece el renderizador para las surfaces
void setNotificationsEnabled(bool value); // Establece la visibilidad de las notificaciones void setNotificationsEnabled(bool value); // Establece la visibilidad de las notificaciones
void toggleFPS(); // Activa o desactiva el contador de FPS void toggleFPS(); // Activa o desactiva el contador de FPS
[[nodiscard]] auto isFPSVisible() const -> bool { return show_fps_; } // Estado actual del overlay de debug
// Getters // Getters
auto getRenderer() -> SDL_Renderer*; auto getRenderer() -> SDL_Renderer*;

View File

@@ -242,7 +242,7 @@ void Logo::endSection() {
break; break;
default: default:
// Ninguna acción por defecto SceneManager::current = SceneManager::Scene::LOADING_SCREEN;
break; break;
} }
} }

View File

@@ -75,6 +75,7 @@ static void printHelp() {
SDL_Log(" DEBUG Toggle debug overlay (F12)"); SDL_Log(" DEBUG Toggle debug overlay (F12)");
#endif #endif
SDL_Log(" SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]"); SDL_Log(" SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]");
SDL_Log(" KIOSK [ON] Enable kiosk mode");
SDL_Log(" EXIT / QUIT Quit application"); SDL_Log(" EXIT / QUIT Quit application");
SDL_Log(" HELP/? Show this help in terminal"); SDL_Log(" HELP/? Show this help in terminal");
} }
@@ -117,10 +118,31 @@ static const std::vector<ConsoleCommand> COMMANDS = {
Options::video.border.enabled, Options::video.border.enabled,
Screen::get()->toggleBorder())}, Screen::get()->toggleBorder())},
// FULLSCREEN [ON|OFF] — Pantalla completa (F3) // FULLSCREEN [ON|OFF [PLEASE]] — Pantalla completa (F3); OFF bloqueado en kiosk sin PLEASE
{.keyword = "FULLSCREEN", .execute = BOOL_TOGGLE_CMD("Fullscreen", {.keyword = "FULLSCREEN", .execute = [](const std::vector<std::string>& args) -> std::string {
Options::video.fullscreen, const bool EXPLICIT_ON = !args.empty() && args[0] == "ON";
Screen::get()->toggleVideoMode())}, const bool EXPLICIT_OFF = !args.empty() && args[0] == "OFF";
const bool WITH_PLEASE = !args.empty() && args.back() == "PLEASE";
const bool IS_TOGGLE = args.empty();
const bool TURNING_OFF = EXPLICIT_OFF || (IS_TOGGLE && Options::video.fullscreen);
if (TURNING_OFF && Options::kiosk.enabled && !WITH_PLEASE) {
return "Not allowed in kiosk mode";
}
if (EXPLICIT_ON) {
if (Options::video.fullscreen) { return "Fullscreen already ON"; }
Screen::get()->toggleVideoMode(); return "Fullscreen ON";
}
if (EXPLICIT_OFF) {
if (!Options::video.fullscreen) { return "Fullscreen already OFF"; }
Screen::get()->toggleVideoMode(); return "Fullscreen OFF";
}
if (IS_TOGGLE) {
Screen::get()->toggleVideoMode();
return std::string("Fullscreen ") + (Options::video.fullscreen ? "ON" : "OFF");
}
return "Usage: FULLSCREEN [ON|OFF]";
}},
// ZOOM UP/DOWN — Zoom de ventana (F1/F2) // ZOOM UP/DOWN — Zoom de ventana (F1/F2)
{.keyword = "ZOOM", .execute = [](const std::vector<std::string>& args) -> std::string { {.keyword = "ZOOM", .execute = [](const std::vector<std::string>& args) -> std::string {
@@ -171,15 +193,27 @@ static const std::vector<ConsoleCommand> COMMANDS = {
}}, }},
#ifdef _DEBUG #ifdef _DEBUG
// DEBUG — Toggle overlay de debug (F12, solo en builds debug) // DEBUG [ON|OFF] — Overlay de debug (F12, solo en builds debug)
{.keyword = "DEBUG", .execute = [](const std::vector<std::string>&) -> std::string { {.keyword = "DEBUG", .execute = BOOL_TOGGLE_CMD("Debug overlay",
Screen::get()->toggleFPS(); Screen::get()->isFPSVisible(),
return "Debug overlay toggled"; Screen::get()->toggleFPS())},
// SHOW FPS / HIDE FPS — Aliases de DEBUG ON / DEBUG OFF
{.keyword = "SHOW", .execute = [](const std::vector<std::string>& args) -> std::string {
if (args.empty() || args[0] != "FPS") { return "Usage: SHOW FPS"; }
if (Screen::get()->isFPSVisible()) { return "Debug overlay already ON"; }
Screen::get()->toggleFPS(); return "Debug overlay ON";
}},
{.keyword = "HIDE", .execute = [](const std::vector<std::string>& args) -> std::string {
if (args.empty() || args[0] != "FPS") { return "Usage: HIDE FPS"; }
if (!Screen::get()->isFPSVisible()) { return "Debug overlay already OFF"; }
Screen::get()->toggleFPS(); return "Debug overlay OFF";
}}, }},
#endif #endif
// SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART] — Cambiar o reiniciar escena // SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART] — Cambiar o reiniciar escena
{.keyword = "SCENE", .execute = [](const std::vector<std::string>& args) -> std::string { {.keyword = "SCENE", .execute = [](const std::vector<std::string>& args) -> std::string {
if (Options::kiosk.enabled) { return "Not allowed in kiosk mode"; }
if (args.empty()) { return "Usage: SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]"; } if (args.empty()) { return "Usage: SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]"; }
// RESTART: reinicia la escena actual (funciona desde cualquier escena) // RESTART: reinicia la escena actual (funciona desde cualquier escena)
@@ -210,12 +244,44 @@ static const std::vector<ConsoleCommand> COMMANDS = {
return "Unknown scene: " + args[0]; return "Unknown scene: " + args[0];
}}, }},
// EXIT / QUIT — Cerrar la aplicacion // RESTART — Reiniciar desde el principio (equivale a SCENE LOGO)
{.keyword = "EXIT", .execute = [](const std::vector<std::string>&) -> std::string { {.keyword = "RESTART", .execute = [](const std::vector<std::string>&) -> std::string {
SceneManager::current = SceneManager::Scene::LOGO;
return "Restarting...";
}},
// KIOSK [ON|OFF PLEASE|PLEASE] — Modo kiosko
{.keyword = "KIOSK", .execute = [](const std::vector<std::string>& args) -> std::string {
const bool DISABLE = (!args.empty() && args[0] == "PLEASE") ||
(args.size() >= 2 && args[0] == "OFF" && args[1] == "PLEASE");
if (DISABLE) {
Options::kiosk.enabled = false;
return "Kiosk mode OFF";
}
if (!args.empty() && args[0] == "OFF") {
return "Not allowed in kiosk mode";
}
if (args.empty() || args[0] == "ON") {
if (Options::kiosk.enabled) { return "Kiosk mode already ON"; }
Options::kiosk.enabled = true;
if (!Options::video.fullscreen) { Screen::get()->toggleVideoMode(); }
return "Kiosk mode ON";
}
return "Usage: KIOSK [ON]";
}},
// EXIT / QUIT — Cerrar la aplicacion (bloqueado en kiosk)
{.keyword = "EXIT", .execute = [](const std::vector<std::string>& args) -> std::string {
if (Options::kiosk.enabled && (args.empty() || args[0] != "PLEASE")) {
return "Not allowed in kiosk mode";
}
SceneManager::current = SceneManager::Scene::QUIT; SceneManager::current = SceneManager::Scene::QUIT;
return "Quitting..."; return "Quitting...";
}}, }},
{.keyword = "QUIT", .execute = [](const std::vector<std::string>&) -> std::string { {.keyword = "QUIT", .execute = [](const std::vector<std::string>& args) -> std::string {
if (Options::kiosk.enabled && (args.empty() || args[0] != "PLEASE")) {
return "Not allowed in kiosk mode";
}
SceneManager::current = SceneManager::Scene::QUIT; SceneManager::current = SceneManager::Scene::QUIT;
return "Quitting..."; return "Quitting...";
}}, }},