From 71d4507cb1ff853d21f2b2df95b3f5b0ff1c3079 Mon Sep 17 00:00:00 2001 From: milerius Date: Mon, 7 Oct 2019 20:49:49 +0200 Subject: [PATCH] feat(sfml): add window_resized event tag --- modules/sfml/antara/gaming/sfml/graphic.system.cpp | 8 +++++++- modules/sfml/antara/gaming/sfml/graphic.system.hpp | 3 +++ modules/sfml/antara/gaming/sfml/input.system.cpp | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/sfml/antara/gaming/sfml/graphic.system.cpp b/modules/sfml/antara/gaming/sfml/graphic.system.cpp index 8085c331..cf306841 100644 --- a/modules/sfml/antara/gaming/sfml/graphic.system.cpp +++ b/modules/sfml/antara/gaming/sfml/graphic.system.cpp @@ -14,7 +14,7 @@ * * ******************************************************************************/ -#include +#include #include "antara/gaming/ecs/component.position.hpp" #include "antara/gaming/ecs/component.layer.hpp" #include "antara/gaming/sfml/graphic.system.hpp" @@ -24,6 +24,7 @@ namespace antara::gaming::sfml { graphic_system::graphic_system(entt::registry ®istry) noexcept : system(registry) { + this->dispatcher_.sink>().connect<&graphic_system::on_window_resized_event>(*this); refresh_render_texture(); } @@ -138,4 +139,9 @@ namespace antara::gaming::sfml { draw_all_layers(std::make_index_sequence{}); } + + void graphic_system::on_window_resized_event(const entt::tag<"window_resized"_hs> &) noexcept + { + refresh_render_texture(); + } } diff --git a/modules/sfml/antara/gaming/sfml/graphic.system.hpp b/modules/sfml/antara/gaming/sfml/graphic.system.hpp index 3d060f8c..bc764c90 100644 --- a/modules/sfml/antara/gaming/sfml/graphic.system.hpp +++ b/modules/sfml/antara/gaming/sfml/graphic.system.hpp @@ -16,6 +16,7 @@ #pragma once +#include #include #include #include @@ -49,6 +50,8 @@ namespace antara::gaming::sfml //! Public getter sf::RenderWindow &get_window() noexcept; + void on_window_resized_event(const entt::tag<"window_resized"_hs> &evt) noexcept; + private: config::game_cfg &game_cfg_{entity_registry_.ctx()}; config::window_cfg &window_cfg_{game_cfg_.win_cfg}; diff --git a/modules/sfml/antara/gaming/sfml/input.system.cpp b/modules/sfml/antara/gaming/sfml/input.system.cpp index 11852a57..dec7aa25 100644 --- a/modules/sfml/antara/gaming/sfml/input.system.cpp +++ b/modules/sfml/antara/gaming/sfml/input.system.cpp @@ -15,6 +15,7 @@ ******************************************************************************/ #include +#include #include "antara/gaming/config/config.game.hpp" #include "antara/gaming/event/quit.game.hpp" #include "antara/gaming/event/mouse.button.pressed.hpp" @@ -44,7 +45,7 @@ namespace antara::gaming::sfml auto &window_component = this->entity_registry_.ctx().win_cfg; window_component.width = evt.size.width; window_component.height = evt.size.height; - this->dispatcher_.trigger(); + this->dispatcher_.trigger>(); } break; case sf::Event::LostFocus: