From 31705586cd2f97eb7e9052980fd47b3e48a8bbde Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 14 May 2024 18:32:23 +0200 Subject: [PATCH] show key bindings in menu instead of with F1 key --- README.md | 3 +-- src/hud.rs | 7 ------- src/menu.rs | 36 ++++++++++++++++++++++++++++++++++++ src/var.rs | 4 ++++ 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 90dcaac..e191146 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Source code: https://codeberg.org/hut/outfly # Controls -- F1: Show key bindings +- ESC: Menu, show key bindings and achievements - Space: Slow down (or match velocity) - AWSD/Shift/Ctrl: Accelerate - R: Rotate (hold & move mouse) @@ -41,7 +41,6 @@ Source code: https://codeberg.org/hut/outfly - C: Camera - Y: Toggle rotation stabilizer - F11: Fullscreen -- ESC: Menu - JKULIO: Mouseless camera rotation - Augmented Reality: (toggle with Tab) - Left click: Target objects diff --git a/src/hud.rs b/src/hud.rs index d103b9d..1897b09 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -942,19 +942,12 @@ fn handle_input( keyboard_input: Res>, mouse_input: Res>, settings: Res, - mut log: ResMut, mut ew_sfx: EventWriter, mut ew_target: EventWriter, mut ew_game: EventWriter, q_objects: Query<(Entity, &Transform), (With, Without, Without, Without)>, q_camera: Query<&Transform, With>, ) { - if keyboard_input.just_pressed(settings.key_help) { - ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click)); - for line in include_str!("data/keybindings.in").trim().lines().rev() { - log.add(line.to_string(), "".to_string(), LogLevel::Always); - } - } if keyboard_input.just_pressed(settings.key_togglehud) { ew_game.send(GameEvent::SetAR(Turn::Toggle)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Switch)); diff --git a/src/menu.rs b/src/menu.rs index 950aca1..2bd153e 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -239,6 +239,42 @@ pub fn setup( }, )); }); + + let keybindings = include_str!("data/keybindings.in"); + let style_keybindings = TextStyle { + font: font_handle.clone(), + font_size: settings.font_size_keybindings, + color: settings.hud_color_keybindings, + ..default() + }; + + commands.spawn(( + MenuElement, + NodeBundle { + style: Style { + width: Val::Percent(96.0), + height: Val::Percent(96.0), + left: Val::Percent(2.0), + top: Val::Percent(2.0), + align_items: AlignItems::Start, + justify_content: JustifyContent::End, + ..default() + }, + visibility: Visibility::Hidden, + ..default() + }, + )).with_children(|builder| { + builder.spawn(( + TextBundle { + text: Text { + sections: vec![TextSection::new(keybindings, style_keybindings)], + justify: JustifyText::Right, + ..default() + }, + ..default() + }, + )); + }); } pub fn show_deathscreen( diff --git a/src/var.rs b/src/var.rs index 70efdd1..f5753ee 100644 --- a/src/var.rs +++ b/src/var.rs @@ -59,6 +59,7 @@ pub struct Settings { pub font_size_death_achievements: f32, pub font_size_achievement: f32, pub font_size_achievement_header: f32, + pub font_size_keybindings: f32, pub hud_color: Color, pub hud_color_fps: Color, pub hud_color_console: Color, @@ -75,6 +76,7 @@ pub struct Settings { pub hud_color_achievement_accomplished: Color, pub hud_color_death: Color, pub hud_color_death_achievements: Color, + pub hud_color_keybindings: Color, pub chat_speed: f32, pub flashlight_active: bool, pub hud_active: bool, @@ -181,6 +183,7 @@ impl Default for Settings { font_size_death_achievements: 24.0, font_size_achievement: 24.0, font_size_achievement_header: 32.0, + font_size_keybindings: 20.0, hud_color: Color::hex("#BE1251").unwrap(), hud_color_fps: Color::hex("#181818").unwrap(), hud_color_console: Color::hex("#BE1251").unwrap(), @@ -197,6 +200,7 @@ impl Default for Settings { hud_color_achievement_header: Color::hex("#BE1251").unwrap(), hud_color_death: Color::hex("#CCCCCC").unwrap(), hud_color_death_achievements: Color::hex("#CCCCCC").unwrap(), + hud_color_keybindings: Color::hex("#999999").unwrap(), chat_speed: DEFAULT_CHAT_SPEED * if dev_mode { 2.5 } else { 1.0 }, flashlight_active: false, hud_active: true,