treballant en la consola

This commit is contained in:
2026-03-27 22:24:55 +01:00
parent 3712f0c8d9
commit f25ee18329
8 changed files with 218 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
#include "core/rendering/screen.hpp" // Para Screen
#include "game/options.hpp" // Para Options, options, OptionsVideo, Section
#include "game/scene_manager.hpp" // Para SceneManager
#include "game/ui/console.hpp" // Para Console
#include "game/ui/notifier.hpp" // Para Notifier, NotificationText
#include "utils/utils.hpp" // Para stringInVector
@@ -176,6 +177,9 @@ namespace GlobalInputs {
if (Input::get()->checkAction(InputAction::SHOW_DEBUG_INFO, Input::DO_NOT_ALLOW_REPEAT)) {
return InputAction::SHOW_DEBUG_INFO;
}
if (Input::get()->checkAction(InputAction::TOGGLE_CONSOLE, Input::DO_NOT_ALLOW_REPEAT)) {
return InputAction::TOGGLE_CONSOLE;
}
return InputAction::NONE;
}
@@ -185,6 +189,15 @@ namespace GlobalInputs {
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
void handle() {
// Si la consola está activa, bloquea el resto de inputs globales
if (Console::get() != nullptr && Console::get()->isActive()) {
if (Input::get()->checkAction(InputAction::TOGGLE_CONSOLE, Input::DO_NOT_ALLOW_REPEAT) ||
Input::get()->checkAction(InputAction::EXIT, Input::DO_NOT_ALLOW_REPEAT)) {
Console::get()->toggle();
}
return;
}
// Salida de administrador en modo kiosko (Ctrl+Shift+Alt+Q)
if (Options::kiosk.enabled) {
SDL_Keymod mod = SDL_GetModState();
@@ -252,6 +265,10 @@ namespace GlobalInputs {
handleToggleVSync();
break;
case InputAction::TOGGLE_CONSOLE:
if (Console::get() != nullptr) { Console::get()->toggle(); }
break;
#ifdef _DEBUG
case InputAction::TOGGLE_DEBUG:
Screen::get()->toggleFPS();

View File

@@ -51,7 +51,8 @@ Input::Input(std::string game_controller_db_path)
{Action::TOGGLE_BORDER, KeyState{.scancode = SDL_SCANCODE_F9}},
{Action::TOGGLE_VSYNC, KeyState{.scancode = SDL_SCANCODE_F10}},
{Action::PAUSE, KeyState{.scancode = SDL_SCANCODE_F11}},
{Action::TOGGLE_DEBUG, KeyState{.scancode = SDL_SCANCODE_F12}}};
{Action::TOGGLE_DEBUG, KeyState{.scancode = SDL_SCANCODE_F12}},
{Action::TOGGLE_CONSOLE, KeyState{.scancode = SDL_SCANCODE_TAB}}};
initSDLGamePad(); // Inicializa el subsistema SDL_INIT_GAMEPAD
}

View File

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

View File

@@ -18,6 +18,7 @@
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
#include "core/resources/resource_list.hpp" // Para Asset, AssetType
#include "game/options.hpp" // Para Options, options, OptionsVideo, Border
#include "game/ui/console.hpp" // Para Console
#include "game/ui/notifier.hpp" // Para Notifier
// [SINGLETON]
@@ -215,6 +216,9 @@ void Screen::renderNotifications() const {
if (notifications_enabled_) {
Notifier::get()->render();
}
if (Console::get() != nullptr) {
Console::get()->render();
}
}
// Cambia el estado del PostFX
@@ -247,6 +251,9 @@ void Screen::reloadPostFX() {
void Screen::update(float delta_time) {
fps_.calculate(SDL_GetTicks());
Notifier::get()->update(delta_time);
if (Console::get() != nullptr) {
Console::get()->update(delta_time);
}
Mouse::updateCursorVisibility();
}

View File

@@ -30,6 +30,7 @@
#include "game/scenes/loading_screen.hpp" // Para LoadingScreen
#include "game/scenes/logo.hpp" // Para Logo
#include "game/scenes/title.hpp" // Para Title
#include "game/ui/console.hpp" // Para Console
#include "game/ui/notifier.hpp" // Para Notifier
#include "utils/defines.hpp" // Para WINDOW_CAPTION
@@ -141,6 +142,7 @@ Director::Director(std::vector<std::string> const& args) {
// Initialize resources (works for both release and development)
Resource::Cache::init();
Notifier::init("", "8bithud");
Console::init("8bithud");
Screen::get()->setNotificationsEnabled(true);
// Special handling for gamecontrollerdb.txt - SDL needs filesystem path
@@ -191,6 +193,7 @@ Director::~Director() {
Debug::destroy();
#endif
Input::destroy();
Console::destroy();
Notifier::destroy();
Resource::Cache::destroy();
Resource::Helper::shutdownResourceSystem(); // Shutdown resource pack system