cargo fmt

main
Elijah C. Voigt 2 years ago
parent 716c94a5f3
commit 59755d2bdd

@ -92,7 +92,7 @@ impl Plugin for Display3dPlugin {
gizmo_system, gizmo_system,
selected_gizmo, selected_gizmo,
moves_gizmo, moves_gizmo,
debug_selected.run_if(any_with_component::<game::Selected>()) debug_selected.run_if(any_with_component::<game::Selected>()),
) )
.run_if(resource_exists::<debug::DebugEnabled>()) .run_if(resource_exists::<debug::DebugEnabled>())
.run_if(in_state(GameState::Play)) .run_if(in_state(GameState::Play))
@ -392,7 +392,13 @@ fn fix_skybox(
/// Set the model for each piece based on the game::Piece::* marker /// Set the model for each piece based on the game::Piece::* marker
fn set_piece_model( fn set_piece_model(
mut events: Query<(&mut Handle<Scene>, &Piece), (Or<(Added<game::Piece>, Changed<game::Piece>)>, With<Display3d>)>, mut events: Query<
(&mut Handle<Scene>, &Piece),
(
Or<(Added<game::Piece>, Changed<game::Piece>)>,
With<Display3d>,
),
>,
gltfs: Res<Assets<Gltf>>, gltfs: Res<Assets<Gltf>>,
tweaks: Res<Assets<Tweaks>>, tweaks: Res<Assets<Tweaks>>,
tweaks_file: Res<tweak::GameTweaks>, tweaks_file: Res<tweak::GameTweaks>,
@ -1526,6 +1532,12 @@ fn debug_selected(
mut debug_info: ResMut<debug::DebugInfo>, mut debug_info: ResMut<debug::DebugInfo>,
) { ) {
query.iter().for_each(|(e, bi, p, s)| { query.iter().for_each(|(e, bi, p, s)| {
debug_info.set("Active".into(), format!("\n>>ID: {:?}\n>>Piece: {:?}\n>>Side: {:?}\n>>Index: {:?}", e, p, s, bi)); debug_info.set(
"Active".into(),
format!(
"\n>>ID: {:?}\n>>Piece: {:?}\n>>Side: {:?}\n>>Index: {:?}",
e, p, s, bi
),
);
}); });
} }

@ -30,8 +30,9 @@ impl Plugin for GamePlugin {
hide_valid_moves.run_if(any_component_removed::<Selected>()), hide_valid_moves.run_if(any_component_removed::<Selected>()),
manage_score.run_if(any_component_added::<Captured>), manage_score.run_if(any_component_added::<Captured>),
check_endgame.run_if(resource_changed::<Board>()), check_endgame.run_if(resource_changed::<Board>()),
reset_game reset_game.run_if(|keys: Res<Input<KeyCode>>| -> bool {
.run_if(|keys: Res<Input<KeyCode>>| -> bool { keys.just_pressed(KeyCode::R) }), keys.just_pressed(KeyCode::R)
}),
), ),
) )
.add_systems(OnEnter(GameState::Endgame), set_endgame) .add_systems(OnEnter(GameState::Endgame), set_endgame)
@ -663,7 +664,9 @@ fn manage_score(
}); });
} }
pub(crate) fn set_side(mut events: Query<(&mut Side, &BoardIndex), Or<(Changed<BoardIndex>, Added<BoardIndex>)>>) { pub(crate) fn set_side(
mut events: Query<(&mut Side, &BoardIndex), Or<(Changed<BoardIndex>, Added<BoardIndex>)>>,
) {
events events
.iter_mut() .iter_mut()
.for_each(|(mut side, idx)| match Board::side(*idx) { .for_each(|(mut side, idx)| match Board::side(*idx) {
@ -831,7 +834,13 @@ fn reset_game(
*score = Score { ..default() }; *score = Score { ..default() };
// Move all pieces to their correct spots // Move all pieces to their correct spots
pieces.iter().zip(board.pieces().iter()).for_each(|(e, (i, p))| { pieces
commands.entity(e).insert((i.clone(), p.clone())).remove::<Captured>(); .iter()
}); .zip(board.pieces().iter())
} .for_each(|(e, (i, p))| {
commands
.entity(e)
.insert((i.clone(), p.clone()))
.remove::<Captured>();
});
}

@ -66,7 +66,6 @@ fn interactive_button(
}); });
} }
fn scale_ui( fn scale_ui(
mut windows: Query<&mut Window, Changed<Window>>, mut windows: Query<&mut Window, Changed<Window>>,
mut ui_scale: ResMut<UiScale>, mut ui_scale: ResMut<UiScale>,
@ -78,7 +77,7 @@ fn scale_ui(
assert_eq!(windows.iter().count(), 1); assert_eq!(windows.iter().count(), 1);
if !tweaks.contains(tweakfile.handle.clone()) { if !tweaks.contains(tweakfile.handle.clone()) {
return return;
} }
let tweak = tweaks.get(tweakfile.handle.clone()).unwrap(); let tweak = tweaks.get(tweakfile.handle.clone()).unwrap();
let width = tweak.get::<f32>("resolution_x").unwrap(); let width = tweak.get::<f32>("resolution_x").unwrap();
@ -93,10 +92,10 @@ fn scale_ui(
// Setting UI Scale based on ratio of expected to current ratio // Setting UI Scale based on ratio of expected to current ratio
let width_ratio = w.resolution.width() / width; let width_ratio = w.resolution.width() / width;
let height_ratio = w.resolution.height() / height; let height_ratio = w.resolution.height() / height;
let new_scale = (width_ratio).min(height_ratio) as f64; let new_scale = (width_ratio).min(height_ratio) as f64;
if ui_scale.0 != new_scale { if ui_scale.0 != new_scale {
ui_scale.0 = new_scale; ui_scale.0 = new_scale;
} }
}); });
} }

Loading…
Cancel
Save