Add some new settings

This commit is contained in:
Sofia 2026-07-28 20:02:01 +03:00
parent 5715fe4f39
commit a6846302fe
2 changed files with 28 additions and 0 deletions

View File

@ -25,6 +25,7 @@ pub const ANNOUNCER_BUS: &str = "Announcer";
pub struct GameSettings {
pub fov: f64,
pub default_name: String,
pub replay_fps: u8,
pub recent_servers: Vec<RecentServer>,
pub volume: VolumeSettings,
pub keybinds: KeybindSettings,
@ -49,6 +50,7 @@ pub struct KeybindSettings {
pub shoot: Keybind,
pub melee: Keybind,
pub jump: Keybind,
pub telegrenade: Keybind,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, PartialOrd)]
@ -122,6 +124,7 @@ impl Default for GameSettings {
Self {
fov: 90.,
default_name: "Default McGee".to_owned(),
replay_fps: 60,
recent_servers: Vec::new(),
volume: VolumeSettings {
master_volume: 100.,
@ -139,6 +142,7 @@ impl Default for GameSettings {
shoot: Keybind::MouseButton(MouseButton::LEFT.to_godot()),
melee: Keybind::Key(Key::F.to_godot()),
jump: Keybind::Key(Key::SPACE.to_godot()),
telegrenade: Keybind::Key(Key::Q.to_godot()),
},
}
}
@ -188,6 +192,7 @@ impl GameSettingsManager {
set_keybind("shoot", settings.keybinds.shoot);
set_keybind("punch", settings.keybinds.melee);
set_keybind("jump", settings.keybinds.jump);
set_keybind("throw_telegrenade", settings.keybinds.telegrenade);
self.settings = settings;
if let Some(mut file) = FileAccess::open("user://config.toml", ModeFlags::WRITE) {

View File

@ -19,6 +19,7 @@ pub enum Setting {
// General settings
FoV,
DefaultName,
ReplayFPS,
// Volume settings
MasterVolume,
@ -36,6 +37,7 @@ pub enum Setting {
Jump,
SelectRaygun,
SelectShotgun,
ThrowTelegrenade,
}
pub enum SettingsTab {
@ -49,6 +51,7 @@ impl ToString for Setting {
match self {
Setting::FoV => "Field of View",
Setting::DefaultName => "Default Name",
Setting::ReplayFPS => "Replay FPS",
Setting::MasterVolume => "Master volume",
Setting::SfxVolume => "Sfx Volume",
@ -64,6 +67,7 @@ impl ToString for Setting {
Setting::Shoot => "Shoot",
Setting::Melee => "Melee",
Setting::Jump => "Jump",
Setting::ThrowTelegrenade => "Throw Telegrenade",
}
.to_string()
}
@ -74,6 +78,7 @@ impl Setting {
match self {
Setting::FoV => SettingsTab::General,
Setting::DefaultName => SettingsTab::General,
Setting::ReplayFPS => SettingsTab::General,
Setting::MasterVolume => SettingsTab::Volume,
Setting::SfxVolume => SettingsTab::Volume,
@ -300,6 +305,9 @@ impl SettingsPanel {
(Setting::DefaultName, SettingValue::String(value)) => {
new_settings.default_name = value.clone()
}
(Setting::ReplayFPS, SettingValue::SliderNumber(value)) => {
new_settings.replay_fps = value.value as u8;
}
(Setting::MasterVolume, SettingValue::SliderNumber(value)) => {
new_settings.volume.master_volume = value.value;
@ -341,6 +349,9 @@ impl SettingsPanel {
(Setting::Jump, SettingValue::Keybind(keybind)) => {
new_settings.keybinds.jump = *keybind;
}
(Setting::ThrowTelegrenade, SettingValue::Keybind(keybind)) => {
new_settings.keybinds.telegrenade = *keybind;
}
_ => {}
}
}
@ -373,6 +384,14 @@ fn settings_from(map: &mut HashMap<Setting, SettingValue>, settings: &GameSettin
Setting::DefaultName,
SettingValue::String(settings.default_name.clone()),
);
map.insert(
Setting::ReplayFPS,
SettingValue::SliderNumber(SliderValue {
min: 1.,
max: 240.,
value: 60.,
}),
);
map.insert(
Setting::MasterVolume,
SettingValue::SliderNumber(SliderValue {
@ -439,4 +458,8 @@ fn settings_from(map: &mut HashMap<Setting, SettingValue>, settings: &GameSettin
SettingValue::Keybind(settings.keybinds.melee),
);
map.insert(Setting::Jump, SettingValue::Keybind(settings.keybinds.jump));
map.insert(
Setting::ThrowTelegrenade,
SettingValue::Keybind(settings.keybinds.telegrenade),
);
}