From 86436575e2a0bf7c1f89bdb7b6b6edc3d4559d77 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Fri, 12 Dec 2025 23:20:33 -0800 Subject: [PATCH] Simplify binary states --- tetris/src/blocks.rs | 2 +- tetris/src/debug.rs | 1 - tetris/src/main.rs | 12 +++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tetris/src/blocks.rs b/tetris/src/blocks.rs index b67d05f..9baffb9 100644 --- a/tetris/src/blocks.rs +++ b/tetris/src/blocks.rs @@ -12,7 +12,7 @@ impl Plugin for BlocksPlugin { fn build(&self, app: &mut App) { app.init_asset::() .init_asset_loader::() - .add_systems(OnEnter(Loading::Active), load_assets.run_if(run_once)) + .add_systems(OnEnter(Loading(true)), load_assets.run_if(run_once)) .add_systems(OnEnter(GameState::Setup), (setup_camera, setup_blocks)) .add_observer(add_shape); } diff --git a/tetris/src/debug.rs b/tetris/src/debug.rs index 66ff088..511cc56 100644 --- a/tetris/src/debug.rs +++ b/tetris/src/debug.rs @@ -65,7 +65,6 @@ fn setup_ui( column_gap: px(8), ..default() }, - TabGroup::default(), children![ (Text::new("debugger:"), ThemedText), (toggle_switch((),), observe(checkbox_self_update), observe(debug_toggle)), diff --git a/tetris/src/main.rs b/tetris/src/main.rs index 002f0f5..29647f2 100644 --- a/tetris/src/main.rs +++ b/tetris/src/main.rs @@ -47,12 +47,18 @@ fn main() { } /// Reports if the game is loading assets -#[derive(States, Default, Clone, Eq, Debug, PartialEq, Hash, Component)] +#[derive(States, Clone, Eq, Debug, PartialEq, Hash, Component)] struct Loading(bool); +impl Default for Loading { + fn default() -> Self { + Loading(true) + } +} + impl fmt::Display for Loading { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - rite!(f, "Loading {}", self.0) + write!(f, "Loading {}", self.0) } } @@ -97,7 +103,7 @@ impl SetupChecklist { fn loading_check(mut next: ResMut>, all_assets: Res) { debug_assert!(all_assets.is_changed()); - next.set(Loading::Active); + next.set(Loading(true)); } /// Waits in Loading::Active until all assets are loaded then move to Loading(false)