diff --git a/godot/scenes/ui/settings.tscn b/godot/scenes/ui/settings.tscn index 280dd02..d228378 100644 --- a/godot/scenes/ui/settings.tscn +++ b/godot/scenes/ui/settings.tscn @@ -20,6 +20,7 @@ grow_horizontal = 2 grow_vertical = 2 [node name="v_box_container" type="VBoxContainer" parent="." unique_id=1384128810] +custom_minimum_size = Vector2(500, 500) layout_mode = 2 [node name="label" type="Label" parent="v_box_container" unique_id=2036746921] @@ -33,24 +34,18 @@ size_flags_vertical = 3 current_tab = 0 [node name="general" type="GridContainer" parent="v_box_container/tab_container" unique_id=833231169] -custom_minimum_size = Vector2(400, 0) -custom_maximum_size = Vector2(400, -1) layout_mode = 2 columns = 2 metadata/_tab_index = 0 [node name="volume" type="GridContainer" parent="v_box_container/tab_container" unique_id=1992916365] visible = false -custom_minimum_size = Vector2(400, 0) -custom_maximum_size = Vector2(400, -1) layout_mode = 2 columns = 2 metadata/_tab_index = 1 [node name="keybinds" type="GridContainer" parent="v_box_container/tab_container" unique_id=852698711] visible = false -custom_minimum_size = Vector2(400, 0) -custom_maximum_size = Vector2(400, -1) layout_mode = 2 columns = 2 metadata/_tab_index = 2 diff --git a/rust/src/game_settings.rs b/rust/src/game_settings.rs index 7209d83..aa7f68e 100644 --- a/rust/src/game_settings.rs +++ b/rust/src/game_settings.rs @@ -48,6 +48,7 @@ pub struct KeybindSettings { pub select_shotgun: Keybind, pub shoot: Keybind, pub melee: Keybind, + pub jump: Keybind, } #[derive(Clone, Copy, Debug, Serialize, Deserialize)] @@ -137,6 +138,7 @@ impl Default for GameSettings { select_shotgun: Keybind::Key(Key::KEY_2.to_godot()), shoot: Keybind::MouseButton(MouseButton::LEFT.to_godot()), melee: Keybind::Key(Key::F.to_godot()), + jump: Keybind::Key(Key::SPACE.to_godot()), }, } } @@ -185,6 +187,7 @@ impl GameSettingsManager { set_keybind("weapon_2", settings.keybinds.select_shotgun); set_keybind("shoot", settings.keybinds.shoot); set_keybind("punch", settings.keybinds.melee); + set_keybind("jump", settings.keybinds.jump); self.settings = settings; if let Some(mut file) = FileAccess::open("user://config.toml", ModeFlags::WRITE) { diff --git a/rust/src/ui/settings.rs b/rust/src/ui/settings.rs index 10aed6e..ae180bf 100644 --- a/rust/src/ui/settings.rs +++ b/rust/src/ui/settings.rs @@ -3,7 +3,8 @@ use std::collections::HashMap; use godot::{ classes::{ Button, Control, GridContainer, IPanelContainer, InputEvent, InputEventKey, - InputEventMouseButton, InputMap, Label, LineEdit, PanelContainer, control::SizeFlags, + InputEventMouseButton, InputMap, Label, LineEdit, PanelContainer, + control::{FocusBehaviorRecursive, FocusMode, SizeFlags}, }, prelude::*, }; @@ -32,6 +33,7 @@ pub enum Setting { MoveBackward, Shoot, Melee, + Jump, SelectRaygun, SelectShotgun, } @@ -61,6 +63,7 @@ impl ToString for Setting { Setting::SelectShotgun => "Select Shotgun", Setting::Shoot => "Shoot", Setting::Melee => "Melee", + Setting::Jump => "Jump", } .to_string() } @@ -197,6 +200,8 @@ impl IPanelContainer for SettingsPanel { Setting::Melee, SettingValue::Keybind(settings.keybinds.melee), ); + self.settings + .insert(Setting::Jump, SettingValue::Keybind(settings.keybinds.jump)); let mut keys = self.settings.keys().collect::>(); keys.sort(); @@ -274,6 +279,9 @@ impl IPanelContainer for SettingsPanel { if let Some((_, mut button)) = s.keybind_button.take() { button.set_pressed(false); } + s.base_mut().set_focus_behavior_recursive( + FocusBehaviorRecursive::DISABLED, + ); s.keybind_button = Some((setting_clone, button_clone.clone())) }); @@ -295,6 +303,8 @@ impl IPanelContainer for SettingsPanel { self.on_change(setting.clone(), SettingValue::Keybind(keybind)); button.set_text(&keybind.to_string()); button.set_pressed(false); + self.base_mut() + .set_focus_behavior_recursive(FocusBehaviorRecursive::INHERITED); } } } @@ -351,6 +361,9 @@ impl SettingsPanel { (Setting::Melee, SettingValue::Keybind(keybind)) => { new_settings.keybinds.melee = *keybind; } + (Setting::Jump, SettingValue::Keybind(keybind)) => { + new_settings.keybinds.jump = *keybind; + } _ => {} } }