From a17bb0ad733e0dbe2c649ebb31a94990db438b01 Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Sun, 9 May 2021 09:51:41 +0000 Subject: [PATCH] Better inactive/active audio slider logic --- CHANGELOG.md | 1 + assets/voxygen/i18n/PL/hud/hud_settings.ron | 2 +- assets/voxygen/i18n/de_DE/gameinput.ron | 2 +- assets/voxygen/i18n/de_DE/hud/misc.ron | 5 ++-- assets/voxygen/i18n/en/gameinput.ron | 2 +- assets/voxygen/i18n/en/hud/hud_settings.ron | 2 +- assets/voxygen/i18n/en/hud/misc.ron | 2 +- .../voxygen/i18n/pt_BR/hud/hud_settings.ron | 2 +- .../voxygen/i18n/uk_UA/hud/hud_settings.ron | 2 +- voxygen/src/hud/settings_window/sound.rs | 25 ++++++++++++++++--- voxygen/src/run.rs | 3 ++- voxygen/src/session/settings_change.rs | 4 +-- voxygen/src/settings/audio.rs | 5 ++-- 13 files changed, 38 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d30b13b302..7fa8b6d415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Cultist Kit gives cape, rings and necklace in addition to armour and weapons. - Reworked minotaur to have unique attacks. - Wiring is now turing complete +- Better active/inactive master sound slider logic ### Removed diff --git a/assets/voxygen/i18n/PL/hud/hud_settings.ron b/assets/voxygen/i18n/PL/hud/hud_settings.ron index a859f4cce9..f37f2a7957 100644 --- a/assets/voxygen/i18n/PL/hud/hud_settings.ron +++ b/assets/voxygen/i18n/PL/hud/hud_settings.ron @@ -91,7 +91,7 @@ "hud.settings.reset_graphics": "Zresetuj ustawienia", "hud.settings.master_volume": "Głośność ogólna", - "hud.settings.inactive_master_volume": "Głośność ogólna (nieaktywne okno)", + "hud.settings.inactive_master_volume_perc": "Głośność ogólna (nieaktywne okno)", "hud.settings.music_volume": "Głośność muzyki", "hud.settings.sound_effect_volume": "Głośność efektów dźwiękowych", "hud.settings.audio_device": "Urządzenie dźwiękowe", diff --git a/assets/voxygen/i18n/de_DE/gameinput.ron b/assets/voxygen/i18n/de_DE/gameinput.ron index 80558adf45..5503a9c358 100644 --- a/assets/voxygen/i18n/de_DE/gameinput.ron +++ b/assets/voxygen/i18n/de_DE/gameinput.ron @@ -50,7 +50,7 @@ "gameinput.togglewield": "Waffe ziehen/wegstecken", "gameinput.interact": "Interagieren", "gameinput.freelook": "Freie Sicht", - "gameinput.autowalk": "Automatisch Laufen/Gleiten", + "gameinput.autowalk": "Automatisch Laufen/Schwimmen", "gameinput.cameraclamp": "Kamera fixieren", "gameinput.dance": "Tanzen", "gameinput.select": "Einheit auswählen", diff --git a/assets/voxygen/i18n/de_DE/hud/misc.ron b/assets/voxygen/i18n/de_DE/hud/misc.ron index 5bf61369ca..254a383e8a 100644 --- a/assets/voxygen/i18n/de_DE/hud/misc.ron +++ b/assets/voxygen/i18n/de_DE/hud/misc.ron @@ -41,10 +41,9 @@ Sobald du dich bereit dafür fühlst, kannst du Versuchen, dich den zahlreichen "hud.spell": "Zaubersprüche", // Diary "hud.diary": "Tagebuch", - "hud.free_look_indicator": "Freie Sicht aktiv. Drücke {key} zum deaktivieren.", - "hud.camera_clamp_indicator": "Vertikale Kamerafixierung aktib. Drücke {key} zum deaktivieren.", - "hud.auto_walk_indicator": "Auto gehen/gleiten aktiv", + "hud.camera_clamp_indicator": "Vertikale Kamerafixierung aktiv. Drücke {key} zum deaktivieren.", + "hud.auto_walk_indicator": "Auto Laufen/Schwimmen aktiv", }, diff --git a/assets/voxygen/i18n/en/gameinput.ron b/assets/voxygen/i18n/en/gameinput.ron index 331da4aae6..5750f9d331 100644 --- a/assets/voxygen/i18n/en/gameinput.ron +++ b/assets/voxygen/i18n/en/gameinput.ron @@ -51,7 +51,7 @@ "gameinput.togglewield": "Toggle Wield", "gameinput.interact": "Interact", "gameinput.freelook": "Free Look", - "gameinput.autowalk": "Auto Walk/Glide", + "gameinput.autowalk": "Auto Walk/Swim", "gameinput.cameraclamp": "Camera Clamp", "gameinput.dance": "Dance", "gameinput.select": "Select Entity", diff --git a/assets/voxygen/i18n/en/hud/hud_settings.ron b/assets/voxygen/i18n/en/hud/hud_settings.ron index f543e8f2d2..731724c352 100644 --- a/assets/voxygen/i18n/en/hud/hud_settings.ron +++ b/assets/voxygen/i18n/en/hud/hud_settings.ron @@ -96,7 +96,7 @@ "hud.settings.master_volume": "Master Volume", - "hud.settings.inactive_master_volume": "Master Volume (inactive window)", + "hud.settings.inactive_master_volume_perc": "Inactive Window Volume", "hud.settings.music_volume": "Music Volume", "hud.settings.sound_effect_volume": "Sound Effects Volume", "hud.settings.audio_device": "Audio Device", diff --git a/assets/voxygen/i18n/en/hud/misc.ron b/assets/voxygen/i18n/en/hud/misc.ron index 8d9897d098..7f3f57c543 100644 --- a/assets/voxygen/i18n/en/hud/misc.ron +++ b/assets/voxygen/i18n/en/hud/misc.ron @@ -44,7 +44,7 @@ Whenever you feel ready, try to get even better equipment from the many challeng "hud.free_look_indicator": "Free look active. Press {key} to disable.", "hud.camera_clamp_indicator": "Camera vertical clamp active. Press {key} to disable.", - "hud.auto_walk_indicator": "Auto walk/glide active", + "hud.auto_walk_indicator": "Auto walk/swim active", }, diff --git a/assets/voxygen/i18n/pt_BR/hud/hud_settings.ron b/assets/voxygen/i18n/pt_BR/hud/hud_settings.ron index 20b59cb42b..c151be5793 100644 --- a/assets/voxygen/i18n/pt_BR/hud/hud_settings.ron +++ b/assets/voxygen/i18n/pt_BR/hud/hud_settings.ron @@ -96,7 +96,7 @@ "hud.settings.master_volume": "Volume Principal", - "hud.settings.inactive_master_volume": "Volume Principal (janela inativa)", + "hud.settings.inactive_master_volume_perc": "Volume Principal (janela inativa)", "hud.settings.music_volume": "Volume da Música", "hud.settings.sound_effect_volume": "Volume dos Efeitos", "hud.settings.audio_device": "Dispositivo de Áudio", diff --git a/assets/voxygen/i18n/uk_UA/hud/hud_settings.ron b/assets/voxygen/i18n/uk_UA/hud/hud_settings.ron index 1e0b4d12ba..c195020ff1 100644 --- a/assets/voxygen/i18n/uk_UA/hud/hud_settings.ron +++ b/assets/voxygen/i18n/uk_UA/hud/hud_settings.ron @@ -93,7 +93,7 @@ "hud.settings.save_window_size": "Зберегти розмір вікна", "hud.settings.master_volume": "Гучність", - "hud.settings.inactive_master_volume": "Гучність (якщо вікно неактивне)", + "hud.settings.inactive_master_volume_perc": "Гучність (якщо вікно неактивне)", "hud.settings.music_volume": "Гучність Музики", "hud.settings.sound_effect_volume": "Гучність Звукових Eфектів", "hud.settings.audio_device": "Звуковий пристрій", diff --git a/voxygen/src/hud/settings_window/sound.rs b/voxygen/src/hud/settings_window/sound.rs index 1fb08e5b87..eb3c4972e0 100644 --- a/voxygen/src/hud/settings_window/sound.rs +++ b/voxygen/src/hud/settings_window/sound.rs @@ -26,8 +26,10 @@ widget_ids! { sfx_volume_text, master_volume_slider, master_volume_text, + master_volume_number, inactive_master_volume_slider, inactive_master_volume_text, + inactive_master_volume_number, audio_device_list, audio_device_text, } @@ -98,6 +100,11 @@ impl<'a> Widget for Sound<'a> { .set(state.ids.window_scrollbar, ui); // Master Volume ---------------------------------------------------- + let master_volume = self.global_state.settings.audio.master_volume; + let master_val = format!("{:2.0}", master_volume * 100.0); + let inactive_master_volume_perc = + self.global_state.settings.audio.inactive_master_volume_perc; + let inactive_val = format!("{:2.0}%", inactive_master_volume_perc * 100.0); 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)) @@ -121,12 +128,17 @@ impl<'a> Widget for Sound<'a> { { events.push(AdjustMasterVolume(new_val)); } - + Text::new(&master_val) + .right_from(state.ids.master_volume_slider, 8.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.master_volume_number, ui); // Master Volume (inactive window) ---------------------------------- Text::new( &self .localized_strings - .get("hud.settings.inactive_master_volume"), + .get("hud.settings.inactive_master_volume_perc"), ) .down_from(state.ids.master_volume_slider, 10.0) .font_size(self.fonts.cyri.scale(14)) @@ -135,7 +147,7 @@ impl<'a> Widget for Sound<'a> { .set(state.ids.inactive_master_volume_text, ui); if let Some(new_val) = ImageSlider::continuous( - self.global_state.settings.audio.inactive_master_volume, + self.global_state.settings.audio.inactive_master_volume_perc, 0.0, 1.0, self.imgs.slider_indicator, @@ -150,7 +162,12 @@ impl<'a> Widget for Sound<'a> { { events.push(AdjustInactiveMasterVolume(new_val)); } - + Text::new(&inactive_val) + .right_from(state.ids.inactive_master_volume_slider, 8.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.inactive_master_volume_number, ui); // Music Volume ----------------------------------------------------- Text::new(&self.localized_strings.get("hud.settings.music_volume")) .down_from(state.ids.inactive_master_volume_slider, 10.0) diff --git a/voxygen/src/run.rs b/voxygen/src/run.rs index 774d7bf65d..b17e2ad236 100644 --- a/voxygen/src/run.rs +++ b/voxygen/src/run.rs @@ -66,7 +66,8 @@ pub fn run(mut global_state: GlobalState, event_loop: EventLoop) { global_state.audio.set_master_volume(if focused { global_state.settings.audio.master_volume } else { - global_state.settings.audio.inactive_master_volume + global_state.settings.audio.inactive_master_volume_perc + * global_state.settings.audio.master_volume }); } diff --git a/voxygen/src/session/settings_change.rs b/voxygen/src/session/settings_change.rs index 53c2d24c7b..c1e674bbcd 100644 --- a/voxygen/src/session/settings_change.rs +++ b/voxygen/src/session/settings_change.rs @@ -163,8 +163,8 @@ impl SettingsChange { settings.audio.master_volume = master_volume; }, - Audio::AdjustInactiveMasterVolume(inactive_master_volume) => { - settings.audio.inactive_master_volume = inactive_master_volume; + Audio::AdjustInactiveMasterVolume(inactive_master_volume_perc) => { + settings.audio.inactive_master_volume_perc = inactive_master_volume_perc; }, Audio::AdjustMusicVolume(music_volume) => { global_state.audio.set_music_volume(music_volume); diff --git a/voxygen/src/settings/audio.rs b/voxygen/src/settings/audio.rs index 70e5bc125b..4f907cad8d 100644 --- a/voxygen/src/settings/audio.rs +++ b/voxygen/src/settings/audio.rs @@ -21,7 +21,8 @@ impl AudioOutput { #[serde(default)] pub struct AudioSettings { pub master_volume: f32, - pub inactive_master_volume: f32, + #[serde(rename = "inactive_master_volume")] + pub inactive_master_volume_perc: f32, pub music_volume: f32, pub sfx_volume: f32, pub max_sfx_channels: usize, @@ -34,7 +35,7 @@ impl Default for AudioSettings { fn default() -> Self { Self { master_volume: 1.0, - inactive_master_volume: 0.5, + inactive_master_volume_perc: 0.5, music_volume: 0.4, sfx_volume: 0.6, max_sfx_channels: 30,