From 35ef1e786d98f6030314523c8609e39bff78b109 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Wed, 30 Oct 2024 19:06:51 -0400 Subject: [PATCH] A bit more cleanup before I redesign the renderer. --- gui.cpp | 9 ++++----- render.hpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) 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; } + };