implement fullscreen toggle key F11
This commit is contained in:
parent
c8cfc9ac15
commit
17f44664e5
12
src/main.rs
12
src/main.rs
|
@ -77,11 +77,21 @@ fn setup(
|
|||
fn handle_input(
|
||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||
mut settings: ResMut<settings::Settings>,
|
||||
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>
|
||||
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
|
||||
mut windows: Query<&mut Window, With<PrimaryWindow>>,
|
||||
) {
|
||||
if keyboard_input.pressed(settings.key_exit) {
|
||||
app_exit_events.send(bevy::app::AppExit);
|
||||
}
|
||||
if keyboard_input.just_pressed(settings.key_fullscreen) {
|
||||
for mut window in &mut windows {
|
||||
window.mode = if window.mode == WindowMode::Windowed {
|
||||
WindowMode::BorderlessFullscreen
|
||||
} else {
|
||||
WindowMode::Windowed
|
||||
}
|
||||
}
|
||||
}
|
||||
if keyboard_input.just_pressed(settings.key_restart) {
|
||||
settings.reset();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue