From eba809e04b941f1045a330fee74fbca865f160a1 Mon Sep 17 00:00:00 2001 From: Ben Frankel Date: Thu, 15 Aug 2024 14:31:56 -0700 Subject: [PATCH] Clean up imports --- README.md | 20 ++++++++++---------- src/asset_tracking.rs | 3 +-- src/demo/animation.rs | 5 +++-- src/demo/level.rs | 2 +- src/screens/credits.rs | 3 +-- src/screens/loading.rs | 3 +-- src/screens/playing.rs | 2 +- src/screens/splash.rs | 3 +-- src/screens/title.rs | 3 +-- src/theme/interaction.rs | 7 ++----- src/theme/mod.rs | 5 +++-- src/theme/widgets.rs | 11 ++--------- 12 files changed, 27 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 8251ff73..5d415b0e 100644 --- a/README.md +++ b/README.md @@ -46,19 +46,19 @@ The best way to get started is to play around with what you find in [`src/demo/` This template comes with a basic project structure that you may find useful: -| Path | Description | -| -------------------------------------------------- | -------------------------------------------------------------------------- | -| [`src/lib.rs`](./src/lib.rs) | App setup | -| [`src/asset_tracking.rs`](./src/asset_tracking.rs) | A simple, high-level way to load collections of asset handles as resources | -| [`src/audio/`](./src/audio) | Commands for playing SFX and music | -| [`src/demo/`](./src/demo) | Example game mechanics & content (replace with your own code) | -| [`src/dev_tools.rs`](./src/dev_tools.rs) | Dev tools for dev builds (press \` aka backtick to toggle) | -| [`src/screens/`](./src/screens) | Splash screen, title screen, playing screen, etc. | -| [`src/theme/`](./src/theme) | Reusable UI widgets & theming +| Path | Description | +| -------------------------------------------------- | ------------------------------------------------------------------ | +| [`src/lib.rs`](./src/lib.rs) | App setup | +| [`src/asset_tracking.rs`](./src/asset_tracking.rs) | A high-level way to load collections of asset handles as resources | +| [`src/audio/`](./src/audio) | Commands for playing SFX and music | +| [`src/demo/`](./src/demo) | Example game mechanics & content (replace with your own code) | +| [`src/dev_tools.rs`](./src/dev_tools.rs) | Dev tools for dev builds (press \` aka backtick to toggle) | +| [`src/screens/`](./src/screens) | Splash screen, title screen, playing screen, etc. | +| [`src/theme/`](./src/theme) | Reusable UI widgets & theming | Feel free to move things around however you want, though. -If you are new to Bevy, the patterns used in this template may look a bit weird at first glance. +If you're new to Bevy, the patterns used in this template may look a bit weird at first glance. See our [Design Document](./docs/design.md) for more information on how we structured the code and why. > [!Tip] diff --git a/src/asset_tracking.rs b/src/asset_tracking.rs index a8c17bb2..b71076bc 100644 --- a/src/asset_tracking.rs +++ b/src/asset_tracking.rs @@ -1,4 +1,4 @@ -//! A simple, high-level way to load collections of asset handles as resources +//! A high-level way to load collections of asset handles as resources. use bevy::prelude::*; @@ -38,7 +38,6 @@ type InsertLoadedResource = fn(&mut World, &UntypedHandle); #[derive(Resource, Default)] struct ResourceHandles { waiting: Vec<(UntypedHandle, InsertLoadedResource)>, - #[allow(unused)] finished: Vec, } diff --git a/src/demo/animation.rs b/src/demo/animation.rs index 7894474c..e6a9caad 100644 --- a/src/demo/animation.rs +++ b/src/demo/animation.rs @@ -8,8 +8,9 @@ use bevy::prelude::*; use rand::prelude::*; use std::time::Duration; -use super::movement::MovementController; -use crate::{audio::SoundEffect, demo::player::PlayerAssets, AppSet}; +use crate::{ + audio::SoundEffect, demo::movement::MovementController, demo::player::PlayerAssets, AppSet, +}; pub(super) fn plugin(app: &mut App) { // Animate and play sound effects based on controls. diff --git a/src/demo/level.rs b/src/demo/level.rs index 6bf1b88c..0e06efa4 100644 --- a/src/demo/level.rs +++ b/src/demo/level.rs @@ -2,7 +2,7 @@ use bevy::{ecs::world::Command, prelude::*}; -use super::player::SpawnPlayer; +use crate::demo::player::SpawnPlayer; pub(super) fn plugin(_app: &mut App) { // No setup required for this plugin. diff --git a/src/screens/credits.rs b/src/screens/credits.rs index 3ed2e955..f5b1ae52 100644 --- a/src/screens/credits.rs +++ b/src/screens/credits.rs @@ -2,8 +2,7 @@ use bevy::prelude::*; -use super::Screen; -use crate::{asset_tracking::LoadResource, audio::Music, theme::prelude::*}; +use crate::{asset_tracking::LoadResource, audio::Music, screens::Screen, theme::prelude::*}; pub(super) fn plugin(app: &mut App) { app.load_resource::(); diff --git a/src/screens/loading.rs b/src/screens/loading.rs index 29bc45be..d3433d13 100644 --- a/src/screens/loading.rs +++ b/src/screens/loading.rs @@ -3,10 +3,9 @@ use bevy::prelude::*; -use super::Screen; use crate::{ demo::player::PlayerAssets, - screens::{credits::CreditsMusic, playing::GameplayMusic}, + screens::{credits::CreditsMusic, playing::GameplayMusic, Screen}, theme::{interaction::InteractionAssets, prelude::*}, }; diff --git a/src/screens/playing.rs b/src/screens/playing.rs index c6d322b5..b6bd4ab1 100644 --- a/src/screens/playing.rs +++ b/src/screens/playing.rs @@ -2,9 +2,9 @@ use bevy::{input::common_conditions::input_just_pressed, prelude::*}; -use super::Screen; use crate::{ asset_tracking::LoadResource, audio::Music, demo::level::spawn_level as spawn_level_command, + screens::Screen, }; pub(super) fn plugin(app: &mut App) { diff --git a/src/screens/splash.rs b/src/screens/splash.rs index 1a22c34c..0a982065 100644 --- a/src/screens/splash.rs +++ b/src/screens/splash.rs @@ -6,8 +6,7 @@ use bevy::{ render::texture::{ImageLoaderSettings, ImageSampler}, }; -use super::Screen; -use crate::{theme::prelude::*, AppSet}; +use crate::{screens::Screen, theme::prelude::*, AppSet}; pub(super) fn plugin(app: &mut App) { // Spawn splash screen. diff --git a/src/screens/title.rs b/src/screens/title.rs index 599f766b..29d4f1c2 100644 --- a/src/screens/title.rs +++ b/src/screens/title.rs @@ -2,8 +2,7 @@ use bevy::prelude::*; -use super::Screen; -use crate::theme::prelude::*; +use crate::{screens::Screen, theme::prelude::*}; pub(super) fn plugin(app: &mut App) { app.add_systems(OnEnter(Screen::Title), show_title_screen); diff --git a/src/theme/interaction.rs b/src/theme/interaction.rs index a51890a8..aef211be 100644 --- a/src/theme/interaction.rs +++ b/src/theme/interaction.rs @@ -1,9 +1,6 @@ +use bevy::prelude::*; + use crate::{asset_tracking::LoadResource, audio::SoundEffect}; -use bevy::{ - ecs::{system::SystemId, world::Command}, - prelude::*, -}; -use std::{collections::VecDeque, marker::PhantomData}; pub(super) fn plugin(app: &mut App) { app.register_type::(); diff --git a/src/theme/mod.rs b/src/theme/mod.rs index 9ded2ee0..135fcd20 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -1,12 +1,13 @@ //! Reusable UI widgets & theming. -// Unused utilities and re-exports may trigger these lints undesirably. -#![allow(dead_code, unused_imports)] +// Unused utilities may trigger this lints undesirably. +#![allow(dead_code)] pub mod interaction; pub mod palette; mod widgets; +#[allow(unused_imports)] pub mod prelude { pub use super::{ interaction::{InteractionPalette, OnPress}, diff --git a/src/theme/widgets.rs b/src/theme/widgets.rs index 490277eb..21395774 100644 --- a/src/theme/widgets.rs +++ b/src/theme/widgets.rs @@ -1,15 +1,8 @@ //! Helper traits for creating common widgets. -use bevy::{ - ecs::system::{EntityCommands, SystemId}, - prelude::*, - ui::Val::*, -}; +use bevy::{ecs::system::EntityCommands, prelude::*, ui::Val::*}; -use super::{ - interaction::{InteractionPalette, OnPress}, - palette::*, -}; +use crate::theme::{interaction::InteractionPalette, palette::*}; /// An extension trait for spawning UI widgets. pub trait Widgets {