diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dcf72121d..5da070ed06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Players can now opt-in to server-authoritiative physics in gameplay settings. - Added `/server_physics` admin command. - Sort inventory button +- Option to change the master volume when window is unfocused ### Changed @@ -77,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Combat rating no longer takes buffs into account - Minimap icons are now displayed in both map modes - Server now denies any running trades when a user exits to the character selection screen. +- Sfx volume changes now also change the ambient sounds volume ## [0.9.0] - 2021-03-20 diff --git a/assets/voxygen/i18n/en/hud/hud_settings.ron b/assets/voxygen/i18n/en/hud/hud_settings.ron index b1db273017..7706b81b24 100644 --- a/assets/voxygen/i18n/en/hud/hud_settings.ron +++ b/assets/voxygen/i18n/en/hud/hud_settings.ron @@ -94,6 +94,8 @@ "hud.settings.reset_graphics": "Reset to Defaults", + "hud.settings.master_volume": "Master Volume", + "hud.settings.inactive_master_volume": "Master Volume (inactive window)", "hud.settings.music_volume": "Music Volume", "hud.settings.sound_effect_volume": "Sound Effects Volume", "hud.settings.audio_device": "Audio Device", diff --git a/voxygen/src/hud/settings_window/sound.rs b/voxygen/src/hud/settings_window/sound.rs index ffda2e6e40..1fb08e5b87 100644 --- a/voxygen/src/hud/settings_window/sound.rs +++ b/voxygen/src/hud/settings_window/sound.rs @@ -24,6 +24,10 @@ widget_ids! { audio_volume_text, sfx_volume_slider, sfx_volume_text, + master_volume_slider, + master_volume_text, + inactive_master_volume_slider, + inactive_master_volume_text, audio_device_list, audio_device_text, } @@ -93,9 +97,63 @@ impl<'a> Widget for Sound<'a> { .rgba(0.33, 0.33, 0.33, 1.0) .set(state.ids.window_scrollbar, ui); + // Master Volume ---------------------------------------------------- + Text::new(&self.localized_strings.get("hud.settings.master_volume")) + .top_left_with_margins_on(state.ids.window, 10.0, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.master_volume_text, ui); + + if let Some(new_val) = ImageSlider::continuous( + self.global_state.settings.audio.master_volume, + 0.0, + 1.0, + self.imgs.slider_indicator, + self.imgs.slider, + ) + .w_h(104.0, 22.0) + .down_from(state.ids.master_volume_text, 10.0) + .track_breadth(12.0) + .slider_length(10.0) + .pad_track((5.0, 5.0)) + .set(state.ids.master_volume_slider, ui) + { + events.push(AdjustMasterVolume(new_val)); + } + + // Master Volume (inactive window) ---------------------------------- + Text::new( + &self + .localized_strings + .get("hud.settings.inactive_master_volume"), + ) + .down_from(state.ids.master_volume_slider, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.inactive_master_volume_text, ui); + + if let Some(new_val) = ImageSlider::continuous( + self.global_state.settings.audio.inactive_master_volume, + 0.0, + 1.0, + self.imgs.slider_indicator, + self.imgs.slider, + ) + .w_h(104.0, 22.0) + .down_from(state.ids.inactive_master_volume_text, 10.0) + .track_breadth(12.0) + .slider_length(10.0) + .pad_track((5.0, 5.0)) + .set(state.ids.inactive_master_volume_slider, ui) + { + events.push(AdjustInactiveMasterVolume(new_val)); + } + // Music Volume ----------------------------------------------------- Text::new(&self.localized_strings.get("hud.settings.music_volume")) - .top_left_with_margins_on(state.ids.window, 10.0, 10.0) + .down_from(state.ids.inactive_master_volume_slider, 10.0) .font_size(self.fonts.cyri.scale(14)) .font_id(self.fonts.cyri.conrod_id) .color(TEXT_COLOR) diff --git a/voxygen/src/session/settings_change.rs b/voxygen/src/session/settings_change.rs index d72fc26c35..cc7217b97e 100644 --- a/voxygen/src/session/settings_change.rs +++ b/voxygen/src/session/settings_change.rs @@ -19,6 +19,8 @@ use vek::*; #[derive(Clone)] pub enum Audio { + AdjustMasterVolume(f32), + AdjustInactiveMasterVolume(f32), AdjustMusicVolume(f32), AdjustSfxVolume(f32), //ChangeAudioDevice(String), @@ -153,6 +155,14 @@ impl SettingsChange { match self { SettingsChange::Audio(audio_change) => { match audio_change { + Audio::AdjustMasterVolume(master_volume) => { + global_state.audio.set_master_volume(master_volume); + + settings.audio.master_volume = master_volume; + }, + Audio::AdjustInactiveMasterVolume(inactive_master_volume) => { + settings.audio.inactive_master_volume = inactive_master_volume; + }, Audio::AdjustMusicVolume(music_volume) => { global_state.audio.set_music_volume(music_volume);