diff --git a/source/game/ui/console.cpp b/source/game/ui/console.cpp index 1240e18..79853e8 100644 --- a/source/game/ui/console.cpp +++ b/source/game/ui/console.cpp @@ -202,11 +202,11 @@ static const std::vector COMMANDS = { } return "usage: ss [on|off|size|upscale [nearest|linear]|downscale [bilinear|lanczos2|lanczos3]]"; }, - .completions = { - {"SS", {"ON", "OFF", "SIZE", "UPSCALE", "DOWNSCALE"}}, - {"SS UPSCALE", {"NEAREST", "LINEAR"}}, - {"SS DOWNSCALE", {"BILINEAR", "LANCZOS2", "LANCZOS3"}}, - }}, + .completions = { + {"SS", {"ON", "OFF", "SIZE", "UPSCALE", "DOWNSCALE"}}, + {"SS UPSCALE", {"NEAREST", "LINEAR"}}, + {"SS DOWNSCALE", {"BILINEAR", "LANCZOS2", "LANCZOS3"}}, + }}, // SHADER [ON|OFF|NEXT [PRESET]|POSTFX|CRTPI] — Toggle/cicla/selecciona shader (F4 / Shift+F4) {.keyword = "SHADER", .execute = [](const std::vector& args) -> std::string { @@ -226,11 +226,11 @@ static const std::vector COMMANDS = { } if (args[0] == "POSTFX") { Screen::get()->setActiveShader(Rendering::ShaderType::POSTFX); - return "Shader: POSTFX"; + return "Shader: PostFX"; } if (args[0] == "CRTPI") { Screen::get()->setActiveShader(Rendering::ShaderType::CRTPI); - return "Shader: CRTPI"; + return "Shader: CrtPi"; } if (args[0] == "NEXT") { // SHADER NEXT PRESET → cicla presets del shader activo @@ -252,21 +252,20 @@ static const std::vector COMMANDS = { return "PostFX preset: " + Options::postfx_presets[static_cast(Options::current_postfx_preset)].name; } - // SHADER NEXT → cicla entre tipos de shader (POSTFX ↔ CRTPI) + // SHADER NEXT → cicla entre tipos de shader (PostFX ↔ CrtPi) Screen::get()->nextShader(); return std::string("Shader: ") + - (Options::current_shader == Rendering::ShaderType::CRTPI ? "CRTPI" : "POSTFX"); + (Options::current_shader == Rendering::ShaderType::CRTPI ? "CrtPi" : "PostFX"); } return "usage: shader [on|off|next [preset]|postfx|crtpi]"; }, - .completions = { - {"SHADER", {"ON", "OFF", "NEXT", "POSTFX", "CRTPI"}}, - {"SHADER NEXT", {"PRESET"}}, - }}, + .completions = { + {"SHADER", {"ON", "OFF", "NEXT", "POSTFX", "CRTPI"}}, + {"SHADER NEXT", {"PRESET"}}, + }}, // BORDER [ON|OFF] — Borde decorativo (B) - {.keyword = "BORDER", .execute = BOOL_TOGGLE_CMD("Border", Options::video.border.enabled, Screen::get()->toggleBorder()), - .completions = {{"BORDER", {"ON", "OFF"}}}}, + {.keyword = "BORDER", .execute = BOOL_TOGGLE_CMD("Border", Options::video.border.enabled, Screen::get()->toggleBorder()), .completions = {{"BORDER", {"ON", "OFF"}}}}, // FULLSCREEN [ON|OFF [PLEASE]] — Pantalla completa (F3); OFF bloqueado en kiosk sin PLEASE {.keyword = "FULLSCREEN", .execute = [](const std::vector& args) -> std::string { @@ -295,7 +294,7 @@ static const std::vector COMMANDS = { } return "usage: fullscreen [on|off]"; }, - .completions = {{"FULLSCREEN", {"ON", "OFF"}}}}, + .completions = {{"FULLSCREEN", {"ON", "OFF"}}}}, // ZOOM UP/DOWN — Zoom de ventana (F1/F2) {.keyword = "ZOOM", .execute = [](const std::vector& args) -> std::string { @@ -310,7 +309,7 @@ static const std::vector COMMANDS = { } return "usage: zoom [up|down]"; }, - .completions = {{"ZOOM", {"UP", "DOWN"}}}}, + .completions = {{"ZOOM", {"UP", "DOWN"}}}}, // INTSCALE [ON|OFF] — Escalado entero (F7) {.keyword = "INTSCALE", .execute = [](const std::vector& args) -> std::string { @@ -326,11 +325,10 @@ static const std::vector COMMANDS = { Screen::get()->setVideoMode(Options::video.fullscreen); return std::string("IntScale ") + (Options::video.integer_scale ? "ON" : "OFF"); }, - .completions = {{"INTSCALE", {"ON", "OFF"}}}}, + .completions = {{"INTSCALE", {"ON", "OFF"}}}}, // VSYNC [ON|OFF] — Sincronización vertical - {.keyword = "VSYNC", .execute = BOOL_TOGGLE_CMD("VSync", Options::video.vertical_sync, Screen::get()->toggleVSync()), - .completions = {{"VSYNC", {"ON", "OFF"}}}}, + {.keyword = "VSYNC", .execute = BOOL_TOGGLE_CMD("VSync", Options::video.vertical_sync, Screen::get()->toggleVSync()), .completions = {{"VSYNC", {"ON", "OFF"}}}}, // DRIVER [LIST|AUTO|] — Driver GPU (aplica en el próximo arranque) {.keyword = "DRIVER", .execute = [](const std::vector& args) -> std::string { @@ -387,23 +385,30 @@ static const std::vector COMMANDS = { Options::saveToFile(); return "Driver: " + driver_lower + " (restart)"; }, - .completions = {{"DRIVER", {"LIST", "AUTO", "NONE"}}}}, + .completions = {{"DRIVER", {"LIST", "AUTO", "NONE"}}}}, // PALETTE NEXT/PREV/ — Paleta de colores (F5/F6 o por nombre) {.keyword = "PALETTE", .execute = [](const std::vector& args) -> std::string { + const auto palName = []() -> std::string { + std::string name = Options::video.palette; + std::ranges::transform(name, name.begin(), ::tolower); + return name; + }; if (args.empty()) { return "usage: palette [next|prev|]"; } if (args[0] == "NEXT") { Screen::get()->nextPalette(); - return "Palette: " + Options::video.palette; + return "Palette: " + palName(); } if (args[0] == "PREV") { Screen::get()->previousPalette(); - return "Palette: " + Options::video.palette; + return "Palette: " + palName(); } if (!Screen::get()->setPaletteByName(args[0])) { - return "Unknown palette: " + args[0]; + std::string arg_lower = args[0]; + std::ranges::transform(arg_lower, arg_lower.begin(), ::tolower); + return "Unknown palette: " + arg_lower; } - return "Palette: " + Options::video.palette; + return "Palette: " + palName(); }}, #ifdef _DEBUG @@ -426,7 +431,7 @@ static const std::vector COMMANDS = { GameControl::toggle_debug_mode(); return std::string("Debug mode ") + (Debug::get()->isEnabled() ? "ON" : "OFF"); }, - .completions = {{"DEBUG", {"ON", "OFF"}}}}, + .completions = {{"DEBUG", {"ON", "OFF"}}}}, // ROOM |NEXT|PREV — Cambia a la habitación indicada (1-60); solo en escena GAME {.keyword = "ROOM", .execute = [](const std::vector& args) -> std::string { @@ -453,7 +458,7 @@ static const std::vector COMMANDS = { } return std::string("Room not found: ") + buf; }, - .completions = {{"ROOM", {"NEXT", "PREV"}}}}, + .completions = {{"ROOM", {"NEXT", "PREV"}}}}, #endif @@ -476,13 +481,13 @@ static const std::vector COMMANDS = { RenderInfo::get()->toggle(); return "Info overlay ON"; }, - .completions = { + .completions = { #ifdef _DEBUG - {"SHOW", {"INFO", "NOTIFICATION", "CHEEVO"}}, + {"SHOW", {"INFO", "NOTIFICATION", "CHEEVO"}}, #else - {"SHOW", {"INFO"}}, + {"SHOW", {"INFO"}}, #endif - }}, + }}, // HIDE INFO — disponible en Release {.keyword = "HIDE", .execute = [](const std::vector& args) -> std::string { @@ -491,7 +496,7 @@ static const std::vector COMMANDS = { RenderInfo::get()->toggle(); return "Info overlay OFF"; }, - .completions = {{"HIDE", {"INFO"}}}}, + .completions = {{"HIDE", {"INFO"}}}}, // CHEAT — Trucos de juego; solo en escena GAME; no aparece en ayuda en builds Release {.keyword = "CHEAT", .execute = [](const std::vector& args) -> std::string { @@ -558,14 +563,14 @@ static const std::vector COMMANDS = { }, .hidden = CHEAT_HIDDEN, .completions = { - {"CHEAT", {"INFINITE", "INVINCIBILITY", "OPEN", "CLOSE"}}, - {"CHEAT INFINITE", {"LIVES"}}, + {"CHEAT", {"INFINITE", "INVINCIBILITY", "OPEN", "CLOSE"}}, + {"CHEAT INFINITE", {"LIVES"}}, {"CHEAT INFINITE LIVES", {"ON", "OFF"}}, - {"CHEAT INVINCIBILITY", {"ON", "OFF"}}, - {"CHEAT OPEN", {"THE"}}, - {"CHEAT OPEN THE", {"JAIL"}}, - {"CHEAT CLOSE", {"THE"}}, - {"CHEAT CLOSE THE", {"JAIL"}}, + {"CHEAT INVINCIBILITY", {"ON", "OFF"}}, + {"CHEAT OPEN", {"THE"}}, + {"CHEAT OPEN THE", {"JAIL"}}, + {"CHEAT CLOSE", {"THE"}}, + {"CHEAT CLOSE THE", {"JAIL"}}, }}, // SET PLAYER SKIN <1|2> — Cambia la skin del jugador (disponible en todos los builds, GAME) @@ -592,27 +597,29 @@ static const std::vector COMMANDS = { if (args.size() >= 3) { if (args[2] == "GAME") { target = SceneManager::Scene::GAME; - name = "GAME"; + name = "game"; } else if (args[2] == "LOGO") { target = SceneManager::Scene::LOGO; - name = "LOGO"; + name = "logo"; } else if (args[2] == "LOADING") { target = SceneManager::Scene::LOADING_SCREEN; - name = "LOADING"; + name = "loading"; } else if (args[2] == "TITLE") { target = SceneManager::Scene::TITLE; - name = "TITLE"; + name = "title"; } else if (args[2] == "CREDITS") { target = SceneManager::Scene::CREDITS; - name = "CREDITS"; + name = "credits"; } else if (args[2] == "ENDING") { target = SceneManager::Scene::ENDING; - name = "ENDING"; + name = "ending"; } else if (args[2] == "ENDING2") { target = SceneManager::Scene::ENDING2; - name = "ENDING2"; + name = "ending2"; } else { - return "Unknown scene: " + args[2]; + std::string scene_lower = args[2]; + std::ranges::transform(scene_lower, scene_lower.begin(), ::tolower); + return "Unknown scene: " + scene_lower; } } Debug::get()->setInitialScene(target); @@ -654,17 +661,17 @@ static const std::vector COMMANDS = { return "usage: set player skin <1|2>"; #endif }, - .completions = { + .completions = { #ifdef _DEBUG - {"SET", {"PLAYER", "INITIAL", "ITEMS"}}, - {"SET PLAYER", {"SKIN"}}, - {"SET INITIAL", {"ROOM", "POS", "SCENE"}}, - {"SET INITIAL SCENE", {"LOGO", "LOADING", "TITLE", "CREDITS", "GAME", "ENDING", "ENDING2"}}, + {"SET", {"PLAYER", "INITIAL", "ITEMS"}}, + {"SET PLAYER", {"SKIN"}}, + {"SET INITIAL", {"ROOM", "POS", "SCENE"}}, + {"SET INITIAL SCENE", {"LOGO", "LOADING", "TITLE", "CREDITS", "GAME", "ENDING", "ENDING2"}}, #else - {"SET", {"PLAYER"}}, - {"SET PLAYER", {"SKIN"}}, + {"SET", {"PLAYER"}}, + {"SET PLAYER", {"SKIN"}}, #endif - }}, + }}, #ifdef _DEBUG // SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART] — Cambiar o reiniciar escena; solo en Debug @@ -699,7 +706,7 @@ static const std::vector COMMANDS = { if (args[0] == "ENDING2") { return GO_TO(SceneManager::Scene::ENDING2, "Ending 2"); } return "Unknown scene: " + args[0]; }, - .completions = {{"SCENE", {"LOGO", "LOADING", "TITLE", "CREDITS", "GAME", "ENDING", "ENDING2", "RESTART"}}}}, + .completions = {{"SCENE", {"LOGO", "LOADING", "TITLE", "CREDITS", "GAME", "ENDING", "ENDING2", "RESTART"}}}}, #endif // RESTART — Reiniciar desde el principio (equivale a SCENE LOGO) @@ -729,7 +736,7 @@ static const std::vector COMMANDS = { } return "usage: kiosk [on]"; }, - .completions = {{"KIOSK", {"ON"}}}}, + .completions = {{"KIOSK", {"ON"}}}}, // AUDIO [ON|OFF|VOL <0-100>] — Audio maestro (estado + volumen) {.keyword = "AUDIO", .execute = [](const std::vector& args) -> std::string { @@ -761,7 +768,7 @@ static const std::vector COMMANDS = { } return "usage: audio [on|off|vol n]"; }, - .completions = {{"AUDIO", {"ON", "OFF", "VOL"}}}}, + .completions = {{"AUDIO", {"ON", "OFF", "VOL"}}}}, // MUSIC [ON|OFF|VOL <0-100>] — Volumen e interruptor de música {.keyword = "MUSIC", .execute = [](const std::vector& args) -> std::string { @@ -797,7 +804,7 @@ static const std::vector COMMANDS = { } return "usage: music [on|off|vol n]"; }, - .completions = {{"MUSIC", {"ON", "OFF", "VOL"}}}}, + .completions = {{"MUSIC", {"ON", "OFF", "VOL"}}}}, // SOUND [ON|OFF|VOL <0-100>] — Volumen e interruptor de efectos de sonido {.keyword = "SOUND", .execute = [](const std::vector& args) -> std::string { @@ -833,7 +840,7 @@ static const std::vector COMMANDS = { } return "usage: sound [on|off|vol n]"; }, - .completions = {{"SOUND", {"ON", "OFF", "VOL"}}}}, + .completions = {{"SOUND", {"ON", "OFF", "VOL"}}}}, // EXIT / QUIT — Cerrar la aplicacion (bloqueado en kiosk) {.keyword = "EXIT", .execute = [](const std::vector& args) -> std::string { @@ -1215,7 +1222,7 @@ void Console::handleEvent(const SDL_Event& event) { } } } else { - const std::string base_cmd = upper.substr(0, space_pos); + const std::string base_cmd = upper.substr(0, space_pos); const std::string sub_prefix = upper.substr(space_pos + 1); if (base_cmd == "PALETTE" && Screen::get() != nullptr) { // NEXT/PREV primero, luego todos los nombres de paleta disponibles @@ -1281,7 +1288,11 @@ void Console::processCommand() { break; } } - if (!found) { result = "Unknown: " + cmd; } + if (!found) { + std::string cmd_lower = cmd; + std::ranges::transform(cmd_lower, cmd_lower.begin(), ::tolower); + result = "Unknown: " + cmd_lower; + } // Word-wrap automático según el ancho disponible en píxeles msg_lines_ = wrapText(result); diff --git a/source/game/ui/console.hpp b/source/game/ui/console.hpp index 8a88c29..6594719 100644 --- a/source/game/ui/console.hpp +++ b/source/game/ui/console.hpp @@ -100,7 +100,7 @@ class Console { std::string saved_input_; // guarda input_line_ al empezar a navegar // Estado de autocompletado (TAB) - std::vector tab_matches_; // Comandos que coinciden con el prefijo actual - int tab_index_{-1}; // Índice actual en tab_matches_ + std::vector tab_matches_; // Comandos que coinciden con el prefijo actual + int tab_index_{-1}; // Índice actual en tab_matches_ std::unordered_map> tab_completions_; // Mapa pre-calculado en constructor };