Settings menu with sound and music volume sliders, re-enabled deselecting connectionpanels with E in editmapscreen

This commit is contained in:
Regalis
2015-10-26 19:35:57 +02:00
parent ebe248a7cc
commit 9ed2963cd9
19 changed files with 223 additions and 72 deletions
@@ -49,10 +49,12 @@ namespace Barotrauma
}
}
static class AmbientSoundManager
static class SoundPlayer
{
public static Sound[] flowSounds = new Sound[3];
public static float MusicVolume = 1.0f;
private const float MusicLerpSpeed = 0.01f;
private static Sound[] waterAmbiences = new Sound[2];
@@ -63,7 +65,7 @@ namespace Barotrauma
private static BackgroundMusic currentMusic;
private static BackgroundMusic targetMusic;
private static BackgroundMusic[] musicClips;
private static float musicVolume;
private static float currMusicVolume;
private static Sound startDrone;
@@ -251,20 +253,20 @@ namespace Barotrauma
if (targetMusic == null || currentMusic == null || targetMusic.file != currentMusic.file)
{
musicVolume = MathHelper.Lerp(musicVolume, 0.0f, MusicLerpSpeed);
if (currentMusic != null) Sound.StreamVolume(musicVolume);
currMusicVolume = MathHelper.Lerp(currMusicVolume, 0.0f, MusicLerpSpeed);
if (currentMusic != null) Sound.StreamVolume(currMusicVolume);
if (musicVolume < 0.01f)
if (currMusicVolume < 0.01f)
{
Sound.StopStream();
if (targetMusic != null) Sound.StartStream(targetMusic.file, musicVolume);
if (targetMusic != null) Sound.StartStream(targetMusic.file, currMusicVolume);
currentMusic = targetMusic;
}
}
else
{
musicVolume = MathHelper.Lerp(musicVolume, 0.3f, MusicLerpSpeed);
Sound.StreamVolume(musicVolume);
currMusicVolume = MathHelper.Lerp(currMusicVolume, MusicVolume, MusicLerpSpeed);
Sound.StreamVolume(currMusicVolume);
}
}
+5 -3
View File
@@ -29,6 +29,8 @@ namespace Barotrauma.Sounds
public static OggStreamer oggStreamer;
public static OggStream oggStream;
public static float MasterVolume = 1.0f;
public static void Init()
{
AC = new AudioContext();
@@ -250,7 +252,7 @@ namespace Barotrauma.Sounds
public static void Volume(int sourceIndex, float volume)
{
AL.Source(alSources[sourceIndex], ALSourcef.Gain, volume);
AL.Source(alSources[sourceIndex], ALSourcef.Gain, volume * MasterVolume);
ALHelper.Check();
}
@@ -303,8 +305,8 @@ namespace Barotrauma.Sounds
//Resume(sourceIndex);
position/= 1000.0f;
OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSourcef.Gain, baseVolume);
OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSourcef.Gain, baseVolume * MasterVolume);
OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSource3f.Position, position.X, position.Y, 0.0f);
float lowPassGain = lowPassHfGain / Math.Max(position.Length() * 5.0f, 1.0f);