From 4efce51ded1da706f6ca6ac063285df5ede22fbb Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 4 Nov 2021 10:00:42 -0400 Subject: [PATCH] Fix rendering of menus by rendering before handling the RunState --- src/main.rs | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 36442cf..25b8879 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,6 +76,27 @@ impl State { impl GameState for State { fn tick(&mut self, ctx: &mut Rltk) { ctx.cls(); + + // Draw the UI + draw_map(&self.ecs, ctx); + { + let positions = self.ecs.read_storage::(); + let renderables = self.ecs.read_storage::(); + let map = self.ecs.fetch::(); + + let mut data = (&positions, &renderables).join().collect::>(); + data.sort_by(|&a, &b| b.1.render_order.cmp(&a.1.render_order)); + for (pos, render) in data.iter() { + let idx = map.xy_idx(pos.x, pos.y); + + if map.visible_tiles[idx] { + ctx.set(pos.x, pos.y, render.fg, render.bg, render.glyph) + } + } + + gui::draw_ui(&self.ecs, ctx); + } + let mut newrunstate; { let runstate = self.ecs.fetch::(); @@ -150,24 +171,6 @@ impl GameState for State { } damage_system::delete_the_dead(&mut self.ecs); - - draw_map(&self.ecs, ctx); - - let positions = self.ecs.read_storage::(); - let renderables = self.ecs.read_storage::(); - let map = self.ecs.fetch::(); - - let mut data = (&positions, &renderables).join().collect::>(); - data.sort_by(|&a, &b| b.1.render_order.cmp(&a.1.render_order)); - for (pos, render) in data.iter() { - let idx = map.xy_idx(pos.x, pos.y); - - if map.visible_tiles[idx] { - ctx.set(pos.x, pos.y, render.fg, render.bg, render.glyph) - } - } - - gui::draw_ui(&self.ecs, ctx); } }