From b71c080285bc73eeeca11dafd1bf9a894f5d9c7e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 29 Jan 2019 19:15:28 +0000 Subject: [PATCH] Add VolumeModifier support to music. --- OpenRA.Game/GameRules/MusicInfo.cs | 4 ++++ OpenRA.Game/Sound/Sound.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/GameRules/MusicInfo.cs b/OpenRA.Game/GameRules/MusicInfo.cs index a0f10ea7c3..02e6384407 100644 --- a/OpenRA.Game/GameRules/MusicInfo.cs +++ b/OpenRA.Game/GameRules/MusicInfo.cs @@ -19,6 +19,7 @@ namespace OpenRA.GameRules public readonly string Filename; public readonly string Title; public readonly bool Hidden; + public readonly float VolumeModifier = 1f; public int Length { get; private set; } // seconds public bool Exists { get; private set; } @@ -31,6 +32,9 @@ namespace OpenRA.GameRules if (nd.ContainsKey("Hidden")) bool.TryParse(nd["Hidden"].Value, out Hidden); + if (nd.ContainsKey("VolumeModifier")) + VolumeModifier = FieldLoader.GetValue("VolumeModifier", nd["VolumeModifier"].Value); + var ext = nd.ContainsKey("Extension") ? nd["Extension"].Value : "aud"; Filename = (nd.ContainsKey("Filename") ? nd["Filename"].Value : key) + "." + ext; } diff --git a/OpenRA.Game/Sound/Sound.cs b/OpenRA.Game/Sound/Sound.cs index 917b3a5aed..1f1b523230 100644 --- a/OpenRA.Game/Sound/Sound.cs +++ b/OpenRA.Game/Sound/Sound.cs @@ -214,7 +214,7 @@ namespace OpenRA Func stream = soundFormat => soundEngine.Play2DStream( soundFormat.GetPCMInputStream(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate, - false, true, WPos.Zero, MusicVolume); + false, true, WPos.Zero, MusicVolume * m.VolumeModifier); music = LoadSound(m.Filename, stream); if (music == null)