diff --git a/gui.cpp b/gui.cpp index 4299156..0c69e39 100644 --- a/gui.cpp +++ b/gui.cpp @@ -126,12 +126,11 @@ bool GUI::handle_ui_events() { bool event_happened = false; sf::Event event; auto player = $world.get_the(); - auto& window = $renderer.$window; - int map_font_size = $renderer.$map_font_size; + int map_font_size = $renderer.font_size(); - while(window.pollEvent(event)) { + while($renderer.poll_event(event)) { if(event.type == sf::Event::Closed) { - window.close(); + $renderer.close(); } else if(event.type == sf::Event::KeyPressed) { auto& player_motion = $world.get(player.entity); @@ -179,7 +178,7 @@ int GUI::main() { create_renderer(); run_systems(); - while($renderer.$window.isOpen()) { + while($renderer.is_open()) { render_scene(); if(handle_ui_events()) { diff --git a/render.hpp b/render.hpp index 5b73d73..dac9171 100644 --- a/render.hpp +++ b/render.hpp @@ -50,4 +50,15 @@ struct SFMLRender { sf::Sprite &get_text_sprite(wchar_t tile); bool resize_map(int new_size); void draw_screen(bool clear=true, float map_off_x=0.0f, float map_off_y=0.0f); + + bool poll_event(sf::Event &event) { + return $window.pollEvent(event); + } + + void close() { return $window.close(); } + + bool is_open() { return $window.isOpen(); } + + int font_size() { return $map_font_size; } + };