Skip to content

Commit

Permalink
Example cleanup (#6131)
Browse files Browse the repository at this point in the history
Co-authored-by: devil-ira <justthecooldude@gmail.com>
  • Loading branch information
tim-blackbird and tim-blackbird committed Sep 30, 2022
1 parent 6929d95 commit 3aaf746
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/2d/mesh2d_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ impl Plugin for ColoredMesh2dPlugin {
);

// Register our custom draw function and pipeline, and add our render systems
let render_app = app.get_sub_app_mut(RenderApp).unwrap();
render_app
app.get_sub_app_mut(RenderApp)
.unwrap()
.add_render_command::<Transparent2d, DrawColoredMesh2d>()
.init_resource::<ColoredMesh2dPipeline>()
.init_resource::<SpecializedRenderPipelines<ColoredMesh2dPipeline>>()
Expand Down
2 changes: 1 addition & 1 deletion examples/input/mouse_grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn grab_mouse(
mouse: Res<Input<MouseButton>>,
key: Res<Input<KeyCode>>,
) {
let window = windows.get_primary_mut().unwrap();
let window = windows.primary_mut();
if mouse.just_pressed(MouseButton::Left) {
window.set_cursor_visibility(false);
window.set_cursor_lock_mode(true);
Expand Down
1 change: 0 additions & 1 deletion examples/shader/compute_shader_game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use bevy::{
renderer::{RenderContext, RenderDevice},
RenderApp, RenderStage,
},
window::WindowDescriptor,
};
use std::borrow::Cow;

Expand Down
2 changes: 1 addition & 1 deletion examples/stress_tests/many_buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct UiFont(Handle<Font>);

impl FromWorld for UiFont {
fn from_world(world: &mut World) -> Self {
let asset_server = world.get_resource::<AssetServer>().unwrap();
let asset_server = world.resource::<AssetServer>();
UiFont(asset_server.load("fonts/FiraSans-Bold.ttf"))
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/window/transparent_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! [documentation](https://docs.rs/bevy/latest/bevy/prelude/struct.WindowDescriptor.html#structfield.transparent)
//! for more details.

use bevy::{prelude::*, window::WindowDescriptor};
use bevy::prelude::*;

fn main() {
App::new()
Expand Down
4 changes: 2 additions & 2 deletions examples/window/window_resizing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn toggle_resolution(
mut windows: ResMut<Windows>,
resolution: Res<ResolutionSettings>,
) {
let window = windows.get_primary_mut().unwrap();
let window = windows.primary_mut();

if keys.just_pressed(KeyCode::Key1) {
let res = resolution.small;
Expand All @@ -87,7 +87,7 @@ fn on_resize_system(
mut q: Query<&mut Text, With<ResolutionText>>,
mut resize_reader: EventReader<WindowResized>,
) {
let mut text = q.get_single_mut().unwrap();
let mut text = q.single_mut();
for e in resize_reader.iter() {
// When resolution is being changed
text.sections[0].value = format!("{:.1} x {:.1}", e.width, e.height);
Expand Down
7 changes: 5 additions & 2 deletions examples/window/window_settings.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//! Illustrates how to change window settings and shows how to affect
//! the mouse pointer in various ways.

use bevy::{prelude::*, window::PresentMode};
use bevy_internal::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
window::PresentMode,
};

fn main() {
App::new()
Expand Down
2 changes: 1 addition & 1 deletion tests/window/minimising.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {

fn minimise_automatically(mut windows: ResMut<Windows>, mut frames: Local<u32>) {
if *frames == 60 {
windows.get_primary_mut().unwrap().set_minimized(true);
windows.primary_mut().set_minimized(true);
} else {
*frames += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/window/resizing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn change_window_size(

fn sync_dimensions(dim: Res<Dimensions>, mut windows: ResMut<Windows>) {
if dim.is_changed() {
windows.get_primary_mut().unwrap().set_resolution(
windows.primary_mut().set_resolution(
dim.width.try_into().unwrap(),
dim.height.try_into().unwrap(),
);
Expand Down

0 comments on commit 3aaf746

Please sign in to comment.