implement fullscreen toggle key F11

This commit is contained in:
yuni 2024-04-08 00:23:55 +02:00
parent c8cfc9ac15
commit 17f44664e5

View file

@ -77,11 +77,21 @@ fn setup(
fn handle_input( fn handle_input(
keyboard_input: Res<ButtonInput<KeyCode>>, keyboard_input: Res<ButtonInput<KeyCode>>,
mut settings: ResMut<settings::Settings>, 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) { if keyboard_input.pressed(settings.key_exit) {
app_exit_events.send(bevy::app::AppExit); 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) { if keyboard_input.just_pressed(settings.key_restart) {
settings.reset(); settings.reset();
} }