diff --git a/OpenRA.Game/GameRules/UserSettings.cs b/OpenRA.Game/GameRules/UserSettings.cs index d9fad57127..d1df8679cf 100644 --- a/OpenRA.Game/GameRules/UserSettings.cs +++ b/OpenRA.Game/GameRules/UserSettings.cs @@ -38,6 +38,7 @@ namespace OpenRA.GameRules //Sound Settings public float SoundVolume = 0.5f; public float MusicVolume = 0.5f; + public float VideoVolume = 0.5f; public bool MusicPlayer = false; // Internal game settings diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index 2ed68e0039..6833e17558 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -145,7 +145,7 @@ namespace OpenRA set { Game.Settings.SoundVolume = value; - soundEngine.SetSoundVolume(value, music); + soundEngine.SetSoundVolume(value, music, video); } } @@ -160,6 +160,17 @@ namespace OpenRA } } + public static float VideoVolume + { + get { return Game.Settings.VideoVolume; } + set + { + Game.Settings.VideoVolume = value; + if (video != null) + video.Volume = value; + } + } + public static float MusicSeekPosition { get { return (music != null)? music.SeekPosition : 0; } @@ -213,7 +224,7 @@ namespace OpenRA void SetAllSoundsPaused(bool paused); void StopAllSounds(); void SetListenerPosition(float2 position); - void SetSoundVolume(float volume, ISound music); + void SetSoundVolume(float volume, ISound music, ISound video); } interface ISoundSource {} @@ -327,14 +338,15 @@ namespace OpenRA } } - public void SetSoundVolume(float volume, ISound music) + public void SetSoundVolume(float volume, ISound music, ISound video) { var sounds = sourcePool.Select(s => s.Key).Where( b => { int state; Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state); return ((state == Al.AL_PLAYING || state == Al.AL_PAUSED) && - ((music != null)? b != ((OpenAlSound) music).source : true)); + ((music != null)? b != ((OpenAlSound) music).source : true) && + ((video != null)? b != ((OpenAlSound) video).source : true)); }).ToList(); foreach (var s in sounds) { @@ -410,7 +422,6 @@ namespace OpenRA Al.alSourcef(source, Al.AL_REFERENCE_DISTANCE, 200); Al.alSourcef(source, Al.AL_MAX_DISTANCE, 1500); Volume = volume; - Al.alSourcePlay(source); }