Make clippy happy

main
Elijah Voigt 3 months ago
parent c24dabde16
commit 145008a52d

@ -774,26 +774,26 @@ fn drag_tree(
camera: Single<(&Camera, &GlobalTransform), With<Camera>>, camera: Single<(&Camera, &GlobalTransform), With<Camera>>,
window: Single<&Window>, window: Single<&Window>,
) { ) {
if *state.get() == DebuggingState::On { if *state.get() == DebuggingState::On
if let Ok(mut t) = query.get_mut(trigger.target()) { && let Ok(mut t) = query.get_mut(trigger.target())
let world_position = window {
.cursor_position() let world_position = window
.and_then(|cursor| camera.0.viewport_to_world(camera.1, cursor).ok()) .cursor_position()
.map(|ray| { .and_then(|cursor| camera.0.viewport_to_world(camera.1, cursor).ok())
// Compute ray's distance to entity .map(|ray| {
let distance = ray // Compute ray's distance to entity
.intersect_plane(t.translation, InfinitePlane3d::new(t.up())) let distance = ray
.unwrap(); .intersect_plane(t.translation, InfinitePlane3d::new(t.up()))
ray.get_point(distance) .unwrap();
}); ray.get_point(distance)
t.translation = world_position.unwrap(); });
} t.translation = world_position.unwrap();
} }
} }
// When you pointer over the '+' make the entire menu visible // When you pointer over the '+' make the entire menu visible
fn hide_menu(mut nodes: Query<(Entity, &mut Visibility, &NavState), Changed<NavState>>) { fn hide_menu(mut nodes: Query<(&mut Visibility, &NavState), Changed<NavState>>) {
nodes.iter_mut().for_each(|(e, mut v, n)| { nodes.iter_mut().for_each(|(mut v, n)| {
*v = match n { *v = match n {
NavState::Open => Visibility::Inherited, NavState::Open => Visibility::Inherited,
NavState::Closed => Visibility::Hidden, NavState::Closed => Visibility::Hidden,

@ -46,9 +46,9 @@ impl From<String> for MonologueLine {
} }
} }
impl Into<String> for MonologueLine { impl From<MonologueLine> for String {
fn into(self) -> String { fn from(val: MonologueLine) -> Self {
self.value val.value
} }
} }

@ -72,9 +72,7 @@ fn init_debug_ui(mut commands: Commands) {
DebuggingState::On, DebuggingState::On,
Name::new("Debug Indicator"), Name::new("Debug Indicator"),
GlobalZIndex(i32::MAX - 1), GlobalZIndex(i32::MAX - 1),
children![ children![Text(" Debug: ON ".into()),],
Text(" Debug: ON ".into()),
],
Node { Node {
align_self: AlignSelf::Center, align_self: AlignSelf::Center,
justify_self: JustifySelf::End, justify_self: JustifySelf::End,
@ -86,9 +84,7 @@ fn init_debug_ui(mut commands: Commands) {
commands.spawn(( commands.spawn((
DebuggingState::On, DebuggingState::On,
Name::new("Version #"), Name::new("Version #"),
children![ children![Text::new(VERSION),],
Text::new(VERSION),
],
GlobalZIndex(i32::MAX - 1), GlobalZIndex(i32::MAX - 1),
Node { Node {
width: Val::Auto, width: Val::Auto,
@ -99,62 +95,65 @@ fn init_debug_ui(mut commands: Commands) {
)); ));
// Version string for troubleshooting // Version string for troubleshooting
commands.spawn(( commands
DebuggingState::On, .spawn((
Name::new("FPS"), DebuggingState::On,
GlobalZIndex(i32::MAX - 1), Name::new("FPS"),
Node { GlobalZIndex(i32::MAX - 1),
width: Val::Auto, Node {
align_self: AlignSelf::Start, width: Val::Auto,
justify_self: JustifySelf::End, align_self: AlignSelf::Start,
..default() justify_self: JustifySelf::End,
}, ..default()
)).with_children(|parent| { },
parent.spawn(( ))
Text::new("FPS: ##.#"), .with_children(|parent| {
SyncResource::<Fps>::default(), parent.spawn((Text::new("FPS: ##.#"), SyncResource::<Fps>::default()));
)); });
});
commands.spawn(( commands
DebuggingState::On, .spawn((
Name::new("Entity Count"), DebuggingState::On,
GlobalZIndex(i32::MAX - 1), Name::new("Entity Count"),
Node { GlobalZIndex(i32::MAX - 1),
width: Val::Auto, Node {
align_self: AlignSelf::Start, width: Val::Auto,
justify_self: JustifySelf::Center, align_self: AlignSelf::Start,
..default() justify_self: JustifySelf::Center,
}, ..default()
)).with_children(|parent| { },
parent.spawn(( ))
Text::new("Entities: ###"), .with_children(|parent| {
SyncResource::<EntityCount>::default(), parent.spawn((
)); Text::new("Entities: ###"),
}); SyncResource::<EntityCount>::default(),
));
});
// Tooltip // Tooltip
commands.spawn(( commands
DebuggingState::On, .spawn((
SyncResource::<ToolTip>::default(), DebuggingState::On,
Pickable::IGNORE, SyncResource::<ToolTip>::default(),
GlobalZIndex(i32::MAX), Pickable::IGNORE,
Node { GlobalZIndex(i32::MAX),
position_type: PositionType::Absolute, Node {
margin: UiRect { position_type: PositionType::Absolute,
left: Val::Px(20.0), margin: UiRect {
left: Val::Px(20.0),
..default()
},
align_content: AlignContent::Center,
justify_content: JustifyContent::Center,
..default() ..default()
}, },
align_content: AlignContent::Center, ))
justify_content: JustifyContent::Center, .with_children(|parent| {
..default() parent.spawn((
}, Text("Tooltip Placeholder".into()),
)).with_children(|parent| { SyncResource::<ToolTip>::default(),
parent.spawn(( ));
Text("Tooltip Placeholder".into()), });
SyncResource::<ToolTip>::default(),
));
});
} }
/// Toggles the debug state from off -> on // off -> on when triggered /// Toggles the debug state from off -> on // off -> on when triggered

@ -14,7 +14,7 @@ impl Plugin for BaseUiPlugin {
add_ui_text add_ui_text
.run_if(any_component_added::<Text>) .run_if(any_component_added::<Text>)
.after(add_ui_node), .after(add_ui_node),
navs_on_top.run_if(any_component_changed::<NavState>) navs_on_top.run_if(any_component_changed::<NavState>),
), ),
); );
} }
@ -208,18 +208,13 @@ pub enum NavState {
Closed, Closed,
} }
fn navs_on_top( fn navs_on_top(changed: Query<(Entity, &NavState), Changed<NavState>>, mut commands: Commands) {
changed: Query<(Entity, &NavState), Changed<NavState>>, changed.iter().for_each(|(e, ns)| match ns {
mut commands: Commands, NavState::Open => {
) { commands.entity(e).insert(GlobalZIndex(i32::MAX / 2));
changed.iter().for_each(|(e, ns)| { }
match ns { NavState::Closed => {
NavState::Open => { commands.entity(e).remove::<GlobalZIndex>();
commands.entity(e).insert(GlobalZIndex(i32::MAX/ 2));
}
NavState::Closed => {
commands.entity(e).remove::<GlobalZIndex>();
}
} }
}) })
} }

Loading…
Cancel
Save