Add VideoVolume

This commit is contained in:
alzeih
2010-08-14 16:10:27 +12:00
parent ae703d50b2
commit db16ab4cdc
2 changed files with 17 additions and 5 deletions

View File

@@ -38,6 +38,7 @@ namespace OpenRA.GameRules
//Sound Settings //Sound Settings
public float SoundVolume = 0.5f; public float SoundVolume = 0.5f;
public float MusicVolume = 0.5f; public float MusicVolume = 0.5f;
public float VideoVolume = 0.5f;
public bool MusicPlayer = false; public bool MusicPlayer = false;
// Internal game settings // Internal game settings

View File

@@ -145,7 +145,7 @@ namespace OpenRA
set set
{ {
Game.Settings.SoundVolume = value; 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 public static float MusicSeekPosition
{ {
get { return (music != null)? music.SeekPosition : 0; } get { return (music != null)? music.SeekPosition : 0; }
@@ -213,7 +224,7 @@ namespace OpenRA
void SetAllSoundsPaused(bool paused); void SetAllSoundsPaused(bool paused);
void StopAllSounds(); void StopAllSounds();
void SetListenerPosition(float2 position); void SetListenerPosition(float2 position);
void SetSoundVolume(float volume, ISound music); void SetSoundVolume(float volume, ISound music, ISound video);
} }
interface ISoundSource {} 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 => var sounds = sourcePool.Select(s => s.Key).Where( b =>
{ {
int state; int state;
Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state); Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state);
return ((state == Al.AL_PLAYING || state == Al.AL_PAUSED) && 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(); }).ToList();
foreach (var s in sounds) foreach (var s in sounds)
{ {
@@ -410,7 +422,6 @@ namespace OpenRA
Al.alSourcef(source, Al.AL_REFERENCE_DISTANCE, 200); Al.alSourcef(source, Al.AL_REFERENCE_DISTANCE, 200);
Al.alSourcef(source, Al.AL_MAX_DISTANCE, 1500); Al.alSourcef(source, Al.AL_MAX_DISTANCE, 1500);
Volume = volume; Volume = volume;
Al.alSourcePlay(source); Al.alSourcePlay(source);
} }