From 2f23bc5ce10ef0759e5829e4412227217825082e Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 15 May 2022 14:41:23 -0400 Subject: [PATCH] add is_empty method to States this is intended to allow a game loop to determine if the state manager is actually doing anything or not, allowing the game loop to exit out when it determines if there are no states and no more pending states. --- libretrogd/src/states/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libretrogd/src/states/mod.rs b/libretrogd/src/states/mod.rs index 68b7958..97dc15e 100644 --- a/libretrogd/src/states/mod.rs +++ b/libretrogd/src/states/mod.rs @@ -164,6 +164,11 @@ impl States { } } + #[inline] + pub fn is_empty(&self) -> bool { + self.states.is_empty() && self.pending_state.is_none() && self.command.is_none() + } + fn can_push_or_pop(&self) -> bool { if let Some(state) = self.states.front() { if state.current_state != State::Active {