#include "global_events.h" #include // Para SDL_LogInfo, SDL_LogCategory #include "input.h" // Para Input #include "lang.h" // Para Lang #include "mouse.h" // Para handleEvent #include "options.h" // Para Options #include "screen.h" // Para Screen #include "section.hpp" // Para Name, Options, name, options #include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu namespace GlobalEvents { // Comprueba los eventos de Input y muestra notificaciones void handleInputEvents(const SDL_Event &event) { static auto *input_ = Input::get(); auto message = input_->handleEvent(event); if (message.empty()) return; // Reemplazo de palabras clave por texto localizado size_t pos; while ((pos = message.find(" CONNECTED")) != std::string::npos) { message.replace(pos, std::string(" CONNECTED").length(), " " + Lang::getText("[NOTIFICATIONS] CONNECTED")); } while ((pos = message.find(" DISCONNECTED")) != std::string::npos) { message.replace(pos, std::string(" DISCONNECTED").length(), " " + Lang::getText("[NOTIFICATIONS] DISCONNECTED")); } Options::gamepad_manager.assignAndLinkGamepads(); Options::gamepad_manager.resyncGamepadsWithPlayers(); Notifier::get()->show({message}); ServiceMenu::get()->refresh(); } // Comprueba los eventos que se pueden producir en cualquier sección del juego void check(const SDL_Event &event) { switch (event.type) { case SDL_EVENT_QUIT: // Evento de salida de la aplicación Section::name = Section::Name::QUIT; Section::options = Section::Options::NONE; return; case SDL_EVENT_RENDER_DEVICE_RESET: case SDL_EVENT_RENDER_TARGETS_RESET: SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL_RENDER_TARGETS_RESET"); break; case SDL_EVENT_WINDOW_RESIZED: Screen::get()->initShaders(); break; default: break; } ServiceMenu::get()->handleEvent(event); Mouse::handleEvent(event); handleInputEvents(event); } } // namespace GlobalEvents