Implemented an initial cut at the event router. Its job is to take the random events from SFML and translate them into nice clean orderly events to the Gui::FSM.

This commit is contained in:
Zed A. Shaw 2025-06-04 12:19:24 -04:00
parent 5c47a0151c
commit 0674908e49
8 changed files with 184 additions and 6 deletions

View file

@ -280,7 +280,7 @@ namespace gui {
dbc::log(fmt::format("END: received event after done: {}", int(ev)));
}
void FSM::keyboard_mouse() {
void FSM::handle_keyboard_mouse() {
while(const auto ev = $window.pollEvent()) {
if(ev->is<sf::Event::Closed>()) {
@ -290,6 +290,7 @@ namespace gui {
if(const auto* mouse = ev->getIf<sf::Event::MouseButtonPressed>()) {
if(mouse->button == sf::Mouse::Button::Left) {
sf::Vector2f pos = $window.mapPixelToCoords(mouse->position);
if(in_state(State::NEXT_LEVEL)) {
$boss_fight_ui->mouse(pos.x, pos.y, false);

View file

@ -85,7 +85,7 @@ namespace gui {
void END(Event ev);
void try_move(int dir, bool strafe);
void keyboard_mouse();
void handle_keyboard_mouse();
void draw_gui();
void render();
bool active();