A bit more cleanup before I redesign the renderer.

main
Zed A. Shaw 3 weeks ago
parent 9397af2a11
commit 35ef1e786d
  1. 9
      gui.cpp
  2. 11
      render.hpp

@ -126,12 +126,11 @@ bool GUI::handle_ui_events() {
bool event_happened = false;
sf::Event event;
auto player = $world.get_the<Player>();
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<Motion>(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()) {

@ -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; }
};

Loading…
Cancel
Save