mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Combat music toggle
This commit is contained in:
parent
96f77e9dd6
commit
32f3437fb0
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Recipe for twigs from wooden logs
|
- Recipe for twigs from wooden logs
|
||||||
- First version of multisalvage that allows to obtain more than one piece of material from salvage
|
- First version of multisalvage that allows to obtain more than one piece of material from salvage
|
||||||
- Axe
|
- Axe
|
||||||
|
- Combat music toggle
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ hud-settings-inactive_master_volume_perc = Inactive Window Volume
|
|||||||
hud-settings-music_volume = Music Volume
|
hud-settings-music_volume = Music Volume
|
||||||
hud-settings-sound_effect_volume = Sound Effects Volume
|
hud-settings-sound_effect_volume = Sound Effects Volume
|
||||||
hud-settings-ambience_volume = Ambience Volume
|
hud-settings-ambience_volume = Ambience Volume
|
||||||
|
hud-settings-combat_music = Combat Music
|
||||||
hud-settings-music_spacing = Music Spacing
|
hud-settings-music_spacing = Music Spacing
|
||||||
hud-settings-audio_device = Audio Device
|
hud-settings-audio_device = Audio Device
|
||||||
hud-settings-reset_sound = Reset to Defaults
|
hud-settings-reset_sound = Reset to Defaults
|
||||||
|
@ -58,6 +58,8 @@ pub struct AudioFrontend {
|
|||||||
pub subtitles_enabled: bool,
|
pub subtitles_enabled: bool,
|
||||||
pub subtitles: VecDeque<Subtitle>,
|
pub subtitles: VecDeque<Subtitle>,
|
||||||
|
|
||||||
|
pub combat_music_enabled: bool,
|
||||||
|
|
||||||
mtm: AssetHandle<MusicTransitionManifest>,
|
mtm: AssetHandle<MusicTransitionManifest>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +70,7 @@ impl AudioFrontend {
|
|||||||
num_sfx_channels: usize,
|
num_sfx_channels: usize,
|
||||||
num_ui_channels: usize,
|
num_ui_channels: usize,
|
||||||
subtitles: bool,
|
subtitles: bool,
|
||||||
|
combat_music_enabled: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Commented out until audio device switcher works
|
// Commented out until audio device switcher works
|
||||||
//let audio_device = get_device_raw(&dev);
|
//let audio_device = get_device_raw(&dev);
|
||||||
@ -118,6 +121,7 @@ impl AudioFrontend {
|
|||||||
mtm: AssetExt::load_expect("voxygen.audio.music_transition_manifest"),
|
mtm: AssetExt::load_expect("voxygen.audio.music_transition_manifest"),
|
||||||
subtitles: VecDeque::new(),
|
subtitles: VecDeque::new(),
|
||||||
subtitles_enabled: subtitles,
|
subtitles_enabled: subtitles,
|
||||||
|
combat_music_enabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +147,7 @@ impl AudioFrontend {
|
|||||||
mtm: AssetExt::load_expect("voxygen.audio.music_transition_manifest"),
|
mtm: AssetExt::load_expect("voxygen.audio.music_transition_manifest"),
|
||||||
subtitles: VecDeque::new(),
|
subtitles: VecDeque::new(),
|
||||||
subtitles_enabled: false,
|
subtitles_enabled: false,
|
||||||
|
combat_music_enabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,29 +255,31 @@ impl MusicMgr {
|
|||||||
let groups = ecs.read_component::<Group>();
|
let groups = ecs.read_component::<Group>();
|
||||||
let mtm = audio.mtm.read();
|
let mtm = audio.mtm.read();
|
||||||
|
|
||||||
if let Some(player_pos) = positions.get(player) {
|
if audio.combat_music_enabled {
|
||||||
// TODO: `group::ENEMY` will eventually be moved server-side with an
|
if let Some(player_pos) = positions.get(player) {
|
||||||
// alignment/faction rework, so this will need an alternative way to measure
|
// TODO: `group::ENEMY` will eventually be moved server-side with an
|
||||||
// "in-combat-ness"
|
// alignment/faction rework, so this will need an alternative way to measure
|
||||||
let num_nearby_entities: u32 = (&entities, &positions, &healths, &groups)
|
// "in-combat-ness"
|
||||||
.join()
|
let num_nearby_entities: u32 = (&entities, &positions, &healths, &groups)
|
||||||
.map(|(entity, pos, health, group)| {
|
.join()
|
||||||
if entity != player
|
.map(|(entity, pos, health, group)| {
|
||||||
&& group == &ENEMY
|
if entity != player
|
||||||
&& (player_pos.0 - pos.0).magnitude_squared()
|
&& group == &ENEMY
|
||||||
< mtm.combat_nearby_radius.powf(2.0)
|
&& (player_pos.0 - pos.0).magnitude_squared()
|
||||||
{
|
< mtm.combat_nearby_radius.powf(2.0)
|
||||||
(health.maximum() / mtm.combat_health_factor).ceil() as u32
|
{
|
||||||
} else {
|
(health.maximum() / mtm.combat_health_factor).ceil() as u32
|
||||||
0
|
} else {
|
||||||
}
|
0
|
||||||
})
|
}
|
||||||
.sum();
|
})
|
||||||
|
.sum();
|
||||||
|
|
||||||
if num_nearby_entities >= mtm.combat_nearby_high_thresh {
|
if num_nearby_entities >= mtm.combat_nearby_high_thresh {
|
||||||
activity_state = MusicActivity::Combat(CombatIntensity::High);
|
activity_state = MusicActivity::Combat(CombatIntensity::High);
|
||||||
} else if num_nearby_entities >= mtm.combat_nearby_low_thresh {
|
} else if num_nearby_entities >= mtm.combat_nearby_low_thresh {
|
||||||
activity_state = MusicActivity::Combat(CombatIntensity::Low);
|
activity_state = MusicActivity::Combat(CombatIntensity::Low);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ widget_ids! {
|
|||||||
//audio_device_list,
|
//audio_device_list,
|
||||||
//audio_device_text,
|
//audio_device_text,
|
||||||
reset_sound_button,
|
reset_sound_button,
|
||||||
|
combat_music_toggle_label,
|
||||||
|
combat_music_toggle_button,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,6 +433,30 @@ impl<'a> Widget for Sound<'a> {
|
|||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.music_spacing_number, ui);
|
.set(state.ids.music_spacing_number, ui);
|
||||||
|
|
||||||
|
// Combat music toggle
|
||||||
|
let audio = &self.global_state.audio;
|
||||||
|
|
||||||
|
Text::new(&self.localized_strings.get_msg("hud-settings-combat_music"))
|
||||||
|
.font_size(self.fonts.cyri.scale(14))
|
||||||
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
|
.down_from(state.ids.music_spacing_slider, 10.0)
|
||||||
|
.x_align_to(state.ids.music_spacing_text, Align::Start)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(state.ids.combat_music_toggle_label, ui);
|
||||||
|
|
||||||
|
let combat_music_enabled = ToggleButton::new(
|
||||||
|
audio.combat_music_enabled,
|
||||||
|
self.imgs.checkbox,
|
||||||
|
self.imgs.checkbox_checked,
|
||||||
|
)
|
||||||
|
.w_h(18.0, 18.0)
|
||||||
|
.right_from(state.ids.combat_music_toggle_label, 10.0)
|
||||||
|
.hover_images(self.imgs.checkbox_mo, self.imgs.checkbox_checked_mo)
|
||||||
|
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
|
||||||
|
.set(state.ids.combat_music_toggle_button, ui);
|
||||||
|
|
||||||
|
events.push(ToggleCombatMusic(combat_music_enabled));
|
||||||
|
|
||||||
// Audio Device Selector
|
// Audio Device Selector
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
// let device = &self.global_state.audio.device;
|
// let device = &self.global_state.audio.device;
|
||||||
@ -463,7 +489,7 @@ impl<'a> Widget for Sound<'a> {
|
|||||||
.w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
|
.w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
|
||||||
.hover_image(self.imgs.button_hover)
|
.hover_image(self.imgs.button_hover)
|
||||||
.press_image(self.imgs.button_press)
|
.press_image(self.imgs.button_press)
|
||||||
.down_from(state.ids.music_spacing_slider, 12.0)
|
.down_from(state.ids.combat_music_toggle_button, 12.0)
|
||||||
.x_align_to(state.ids.ambience_volume_text, Align::Start)
|
.x_align_to(state.ids.ambience_volume_text, Align::Start)
|
||||||
.label(&self.localized_strings.get_msg("hud-settings-reset_sound"))
|
.label(&self.localized_strings.get_msg("hud-settings-reset_sound"))
|
||||||
.label_font_size(self.fonts.cyri.scale(14))
|
.label_font_size(self.fonts.cyri.scale(14))
|
||||||
|
@ -140,6 +140,7 @@ fn main() {
|
|||||||
settings.audio.num_sfx_channels,
|
settings.audio.num_sfx_channels,
|
||||||
settings.audio.num_ui_channels,
|
settings.audio.num_ui_channels,
|
||||||
settings.audio.subtitles,
|
settings.audio.subtitles,
|
||||||
|
settings.audio.combat_music_enabled,
|
||||||
),
|
),
|
||||||
// AudioOutput::Device(ref dev) => Some(dev.clone()),
|
// AudioOutput::Device(ref dev) => Some(dev.clone()),
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ pub enum Audio {
|
|||||||
AdjustAmbienceVolume(f32),
|
AdjustAmbienceVolume(f32),
|
||||||
MuteAmbienceVolume(bool),
|
MuteAmbienceVolume(bool),
|
||||||
AdjustMusicSpacing(f32),
|
AdjustMusicSpacing(f32),
|
||||||
|
ToggleCombatMusic(bool),
|
||||||
//ChangeAudioDevice(String),
|
//ChangeAudioDevice(String),
|
||||||
ResetAudioSettings,
|
ResetAudioSettings,
|
||||||
}
|
}
|
||||||
@ -286,6 +287,9 @@ impl SettingsChange {
|
|||||||
|
|
||||||
settings.audio.music_spacing = multiplier;
|
settings.audio.music_spacing = multiplier;
|
||||||
},
|
},
|
||||||
|
Audio::ToggleCombatMusic(combat_music_enabled) => {
|
||||||
|
global_state.audio.combat_music_enabled = combat_music_enabled
|
||||||
|
},
|
||||||
//Audio::ChangeAudioDevice(name) => {
|
//Audio::ChangeAudioDevice(name) => {
|
||||||
// global_state.audio.set_device(name.clone());
|
// global_state.audio.set_device(name.clone());
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ pub struct AudioSettings {
|
|||||||
pub num_ui_channels: usize,
|
pub num_ui_channels: usize,
|
||||||
pub music_spacing: f32,
|
pub music_spacing: f32,
|
||||||
pub subtitles: bool,
|
pub subtitles: bool,
|
||||||
|
pub combat_music_enabled: bool,
|
||||||
|
|
||||||
/// Audio Device that Voxygen will use to play audio.
|
/// Audio Device that Voxygen will use to play audio.
|
||||||
pub output: AudioOutput,
|
pub output: AudioOutput,
|
||||||
@ -66,6 +67,7 @@ impl Default for AudioSettings {
|
|||||||
music_spacing: 1.0,
|
music_spacing: 1.0,
|
||||||
subtitles: false,
|
subtitles: false,
|
||||||
output: AudioOutput::Automatic,
|
output: AudioOutput::Automatic,
|
||||||
|
combat_music_enabled: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user