48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
#include "global_events.h"
|
|
|
|
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory
|
|
|
|
#include "input.h"
|
|
#include "mouse.h" // Para handleEvent
|
|
#include "screen.h"
|
|
#include "section.hpp" // Para Name, Options, name, options
|
|
#include "ui/service_menu.h" // Para ServiceMenu
|
|
|
|
namespace GlobalEvents {
|
|
// 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;
|
|
}
|
|
|
|
if (ServiceMenu::get()->isEnabled()) {
|
|
ServiceMenu::get()->handleEvent(event); // Método que vamos a crear
|
|
|
|
// Si DefineButtons está activo, no procesar más eventos
|
|
if (ServiceMenu::get()->isDefiningButtons()) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
Mouse::handleEvent(event);
|
|
|
|
static auto *input_ = Input::get();
|
|
input_->handleEvent(event);
|
|
}
|
|
} // namespace GlobalEvents
|