mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Ambience slider; fix to utterances
This commit is contained in:
parent
365f45397b
commit
83ee54001e
@ -116,6 +116,7 @@
|
||||
"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.ambience_volume": "Ambience Volume",
|
||||
"hud.settings.audio_device": "Audio Device",
|
||||
"hud.settings.reset_sound": "Reset to Defaults",
|
||||
|
||||
|
@ -91,7 +91,7 @@ pub fn handle_health_change(server: &Server, entity: EcsEntity, change: HealthCh
|
||||
// This if statement filters out anything under 5 damage, for DOT ticks
|
||||
// TODO: Find a better way to separate direct damage from DOT here
|
||||
let damage = -change.amount;
|
||||
if damage > -5.0 {
|
||||
if damage > 5.0 {
|
||||
if let Some(agent) = ecs.write_storage::<Agent>().get_mut(entity) {
|
||||
agent.inbox.push_front(AgentEvent::Hurt);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ impl AmbientMgr {
|
||||
client: &Client,
|
||||
camera: &Camera,
|
||||
) {
|
||||
let sfx_volume = audio.get_sfx_volume();
|
||||
let ambience_volume = audio.get_ambience_volume();
|
||||
// iterate through each tag
|
||||
for tag in AmbientChannelTag::iter() {
|
||||
// check if current conditions necessitate the current tag at all
|
||||
@ -72,7 +72,7 @@ impl AmbientMgr {
|
||||
} else if audio.get_ambient_channel(tag).is_some() {
|
||||
for index in 0..AmbientChannelTag::iter().len() {
|
||||
// update with sfx volume
|
||||
audio.ambient_channels[index].set_volume(sfx_volume);
|
||||
audio.ambient_channels[index].set_volume(ambience_volume);
|
||||
// if current channel's tag is not the current tag, move on to next channel
|
||||
if audio.ambient_channels[index].get_tag() == tag {
|
||||
// maintain: get the correct multiplier of whatever the tag of the current
|
||||
@ -157,7 +157,7 @@ impl AmbientMgr {
|
||||
}
|
||||
|
||||
fn check_rain_necessity(&mut self, client: &Client) -> bool {
|
||||
client.current_weather().rain * 500.0 > 0.0
|
||||
client.current_weather().rain > 0.001
|
||||
}
|
||||
|
||||
fn check_thunder_necessity(&mut self, client: &Client) -> bool {
|
||||
@ -173,12 +173,9 @@ impl AmbientMgr {
|
||||
} else {
|
||||
(0.0, 0.0)
|
||||
};
|
||||
|
||||
// Tree density factors into wind volume. The more trees,
|
||||
// the lower wind volume. The trees make more of an impact
|
||||
// the closer the camera is to the ground.
|
||||
let tree_multiplier =
|
||||
1.0 - (((1.0 - tree_density) + ((cam_pos.z - terrain_alt + 20.0).abs() / 150.0).powi(2)).min(1.0));
|
||||
let tree_multiplier = 1.0
|
||||
- (((1.0 - tree_density) + ((cam_pos.z - terrain_alt + 20.0).abs() / 150.0).powi(2))
|
||||
.min(1.0));
|
||||
|
||||
return tree_multiplier > 0.1;
|
||||
}
|
||||
@ -202,7 +199,6 @@ impl AmbientChannel {
|
||||
AmbientChannelTag::Leaves => self.get_leaves_volume(client, camera),
|
||||
};
|
||||
|
||||
// TODO: make rain diminish with distance above terrain
|
||||
target_volume = self.check_camera(state, client, cam_pos, target_volume);
|
||||
|
||||
return target_volume;
|
||||
@ -271,9 +267,10 @@ impl AmbientChannel {
|
||||
fn get_rain_volume(&mut self, client: &Client) -> f32 {
|
||||
// multipler at end will have to change depending on how intense rain normally
|
||||
// is
|
||||
// TODO: make rain diminish with distance above terrain
|
||||
let rain_intensity = client.current_weather().rain * 500.0;
|
||||
|
||||
return rain_intensity;
|
||||
return rain_intensity.min(0.9);
|
||||
}
|
||||
|
||||
fn get_thunder_volume(&mut self, client: &Client) -> f32 {
|
||||
@ -296,11 +293,12 @@ impl AmbientChannel {
|
||||
(0.0, 0.0)
|
||||
};
|
||||
|
||||
// Tree density factors into wind volume. The more trees,
|
||||
// the lower wind volume. The trees make more of an impact
|
||||
// the closer the camera is to the ground.
|
||||
let tree_multiplier =
|
||||
1.0 - (((1.0 - tree_density) + ((cam_pos.z - terrain_alt + 20.0).abs() / 150.0).powi(2)).min(1.0));
|
||||
// Tree density factors into leaves volume. The more trees,
|
||||
// the higher volume. The trees make more of an impact
|
||||
// the closer the camera is to the ground
|
||||
let tree_multiplier = 1.0
|
||||
- (((1.0 - tree_density) + ((cam_pos.z - terrain_alt + 20.0).abs() / 150.0).powi(2))
|
||||
.min(1.0));
|
||||
|
||||
if tree_multiplier > 0.1 {
|
||||
tree_multiplier
|
||||
|
@ -47,6 +47,7 @@ pub struct AudioFrontend {
|
||||
pub sfx_channels: Vec<SfxChannel>,
|
||||
pub ui_channels: Vec<UIChannel>,
|
||||
pub sfx_volume: f32,
|
||||
pub ambience_volume: f32,
|
||||
pub music_volume: f32,
|
||||
pub master_volume: f32,
|
||||
pub listener: Listener,
|
||||
@ -101,6 +102,7 @@ impl AudioFrontend {
|
||||
ui_channels,
|
||||
ambient_channels: Vec::new(),
|
||||
sfx_volume: 1.0,
|
||||
ambience_volume: 1.0,
|
||||
music_volume: 1.0,
|
||||
master_volume: 1.0,
|
||||
listener: Listener::default(),
|
||||
@ -131,6 +133,7 @@ impl AudioFrontend {
|
||||
ui_channels: Vec::new(),
|
||||
ambient_channels: Vec::new(),
|
||||
sfx_volume: 1.0,
|
||||
ambience_volume: 1.0,
|
||||
music_volume: 1.0,
|
||||
master_volume: 1.0,
|
||||
listener: Listener::default(),
|
||||
@ -462,11 +465,16 @@ impl AudioFrontend {
|
||||
// this retrieves the current setting for sfx volume
|
||||
pub fn get_sfx_volume(&self) -> f32 { self.sfx_volume * self.master_volume }
|
||||
|
||||
// this retrieves the current setting for ambience volume
|
||||
pub fn get_ambience_volume(&self) -> f32 { self.ambience_volume * self.master_volume }
|
||||
|
||||
// this retrieves the current setting for music volume
|
||||
pub fn get_music_volume(&self) -> f32 { self.music_volume * self.master_volume }
|
||||
|
||||
pub fn sfx_enabled(&self) -> bool { self.get_sfx_volume() > 0.0 }
|
||||
|
||||
pub fn ambience_enabled(&self) -> bool { self.get_ambience_volume() > 0.0 }
|
||||
|
||||
pub fn music_enabled(&self) -> bool { self.get_music_volume() > 0.0 }
|
||||
|
||||
pub fn set_sfx_volume(&mut self, sfx_volume: f32) {
|
||||
@ -475,6 +483,14 @@ impl AudioFrontend {
|
||||
self.update_sfx_volumes();
|
||||
}
|
||||
|
||||
pub fn set_ambience_volume(&mut self, ambience_volume: f32) {
|
||||
self.ambience_volume = ambience_volume;
|
||||
|
||||
for channel in self.ambient_channels.iter_mut() {
|
||||
channel.set_volume(ambience_volume)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_music_volume(&mut self, music_volume: f32) {
|
||||
self.music_volume = music_volume;
|
||||
|
||||
@ -500,10 +516,6 @@ impl AudioFrontend {
|
||||
for channel in self.sfx_channels.iter_mut() {
|
||||
channel.set_volume(sfx_volume);
|
||||
}
|
||||
|
||||
for channel in self.ambient_channels.iter_mut() {
|
||||
channel.set_volume(sfx_volume);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stop_ambient_sounds(&mut self) {
|
||||
|
@ -31,6 +31,9 @@ widget_ids! {
|
||||
sfx_volume_text,
|
||||
sfx_volume_slider,
|
||||
sfx_volume_number,
|
||||
ambience_volume_text,
|
||||
ambience_volume_slider,
|
||||
ambience_volume_number,
|
||||
//audio_device_list,
|
||||
//audio_device_text,
|
||||
reset_sound_button,
|
||||
@ -246,6 +249,40 @@ impl<'a> Widget for Sound<'a> {
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.sfx_volume_number, ui);
|
||||
// Ambience Volume
|
||||
Text::new(self.localized_strings.get("hud.settings.ambience_volume"))
|
||||
.down_from(state.ids.sfx_volume_slider, 10.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.ambience_volume_text, ui);
|
||||
// Ambience Volume Slider
|
||||
if let Some(new_val) = ImageSlider::continuous(
|
||||
self.global_state.settings.audio.ambience_volume,
|
||||
0.0,
|
||||
1.0,
|
||||
self.imgs.slider_indicator,
|
||||
self.imgs.slider,
|
||||
)
|
||||
.w_h(104.0, 22.0)
|
||||
.down_from(state.ids.ambience_volume_text, 10.0)
|
||||
.track_breadth(12.0)
|
||||
.slider_length(10.0)
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.ambience_volume_slider, ui)
|
||||
{
|
||||
events.push(AdjustAmbienceVolume(new_val));
|
||||
}
|
||||
// Ambience Volume Number
|
||||
Text::new(&format!(
|
||||
"{:2.0}%",
|
||||
self.global_state.settings.audio.ambience_volume * 100.0
|
||||
))
|
||||
.right_from(state.ids.ambience_volume_slider, 8.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.ambience_volume_number, ui);
|
||||
|
||||
// Audio Device Selector
|
||||
// --------------------------------------------
|
||||
@ -279,7 +316,7 @@ impl<'a> Widget for Sound<'a> {
|
||||
.w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
|
||||
.hover_image(self.imgs.button_hover)
|
||||
.press_image(self.imgs.button_press)
|
||||
.down_from(state.ids.sfx_volume_slider, 12.0)
|
||||
.down_from(state.ids.ambience_volume_slider, 12.0)
|
||||
.label(self.localized_strings.get("hud.settings.reset_sound"))
|
||||
.label_font_size(self.fonts.cyri.scale(14))
|
||||
.label_color(TEXT_COLOR)
|
||||
|
@ -233,6 +233,7 @@ fn main() {
|
||||
audio.set_master_volume(settings.audio.master_volume);
|
||||
audio.set_music_volume(settings.audio.music_volume);
|
||||
audio.set_sfx_volume(settings.audio.sfx_volume);
|
||||
audio.set_ambience_volume(settings.audio.ambience_volume);
|
||||
|
||||
// Load the profile.
|
||||
let profile = Profile::load(&config_dir);
|
||||
|
@ -1103,6 +1103,9 @@ impl Scene {
|
||||
&self.terrain,
|
||||
client,
|
||||
);
|
||||
}
|
||||
|
||||
if audio.ambience_enabled() {
|
||||
self.ambient_mgr
|
||||
.maintain(audio, scene_data.state, client, &self.camera);
|
||||
}
|
||||
@ -1110,11 +1113,6 @@ impl Scene {
|
||||
if audio.music_enabled() {
|
||||
self.music_mgr.maintain(audio, scene_data.state, client);
|
||||
}
|
||||
|
||||
// self.ambient_wind_mgr
|
||||
// .maintain(audio, scene_data.state, client, &self.camera);
|
||||
// self.ambient_rain_mgr
|
||||
// .maintain(audio, scene_data.state, client, &self.camera);
|
||||
}
|
||||
|
||||
pub fn global_bind_group(&self) -> &GlobalsBindGroup { &self.globals_bind_group }
|
||||
|
@ -175,16 +175,16 @@ impl SessionState {
|
||||
self.scene
|
||||
.maintain_debug_hitboxes(&client, &global_state.settings, &mut self.hitboxes);
|
||||
|
||||
// All this camera code is just to determine if it's underwater for the sfx filter
|
||||
// All this camera code is just to determine if it's underwater for the sfx
|
||||
// filter
|
||||
let camera = self.scene.camera_mut();
|
||||
camera.compute_dependents(&*client.state().terrain());
|
||||
let camera::Dependents {
|
||||
cam_pos, ..
|
||||
} = self.scene.camera().dependents();
|
||||
let camera::Dependents { cam_pos, .. } = self.scene.camera().dependents();
|
||||
let focus_pos = self.scene.camera().get_focus_pos();
|
||||
let focus_off = focus_pos.map(|e| e.trunc());
|
||||
let cam_pos = cam_pos + focus_off;
|
||||
let underwater = client.state()
|
||||
let underwater = client
|
||||
.state()
|
||||
.terrain()
|
||||
.get(cam_pos.map(|e| e.floor() as i32))
|
||||
.map(|b| b.is_liquid())
|
||||
@ -262,7 +262,7 @@ impl SessionState {
|
||||
let sfx_trigger_item = sfx_triggers.get_key_value(&SfxEvent::from(&inv_event));
|
||||
|
||||
match inv_event {
|
||||
InventoryUpdateEvent::Dropped
|
||||
InventoryUpdateEvent::Dropped
|
||||
| InventoryUpdateEvent::Swapped
|
||||
| InventoryUpdateEvent::Given
|
||||
| InventoryUpdateEvent::Collected(_)
|
||||
@ -272,14 +272,15 @@ impl SessionState {
|
||||
global_state
|
||||
.audio
|
||||
.emit_sfx_item(sfx_trigger_item, Some(1.0));
|
||||
|
||||
}
|
||||
_ => global_state
|
||||
.audio
|
||||
.emit_sfx(sfx_trigger_item, client.position().unwrap_or_default(), Some(1.0), underwater)
|
||||
},
|
||||
_ => global_state.audio.emit_sfx(
|
||||
sfx_trigger_item,
|
||||
client.position().unwrap_or_default(),
|
||||
Some(1.0),
|
||||
underwater,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
match inv_event {
|
||||
InventoryUpdateEvent::BlockCollectFailed { pos, reason } => {
|
||||
self.hud.add_failed_block_pickup(
|
||||
|
@ -22,6 +22,7 @@ pub enum Audio {
|
||||
AdjustInactiveMasterVolume(f32),
|
||||
AdjustMusicVolume(f32),
|
||||
AdjustSfxVolume(f32),
|
||||
AdjustAmbienceVolume(f32),
|
||||
//ChangeAudioDevice(String),
|
||||
ResetAudioSettings,
|
||||
}
|
||||
@ -202,6 +203,11 @@ impl SettingsChange {
|
||||
|
||||
settings.audio.sfx_volume = sfx_volume;
|
||||
},
|
||||
Audio::AdjustAmbienceVolume(ambience_volume) => {
|
||||
global_state.audio.set_ambience_volume(ambience_volume);
|
||||
|
||||
settings.audio.ambience_volume = ambience_volume;
|
||||
},
|
||||
//Audio::ChangeAudioDevice(name) => {
|
||||
// global_state.audio.set_device(name.clone());
|
||||
|
||||
|
@ -25,6 +25,7 @@ pub struct AudioSettings {
|
||||
pub inactive_master_volume_perc: f32,
|
||||
pub music_volume: f32,
|
||||
pub sfx_volume: f32,
|
||||
pub ambience_volume: f32,
|
||||
pub num_sfx_channels: usize,
|
||||
pub num_ui_channels: usize,
|
||||
|
||||
@ -39,6 +40,7 @@ impl Default for AudioSettings {
|
||||
inactive_master_volume_perc: 0.5,
|
||||
music_volume: 0.3,
|
||||
sfx_volume: 0.6,
|
||||
ambience_volume: 0.6,
|
||||
num_sfx_channels: 60,
|
||||
num_ui_channels: 10,
|
||||
output: AudioOutput::Automatic,
|
||||
|
Loading…
Reference in New Issue
Block a user