Unstable 0.17.0.0

This commit is contained in:
Markus Isberg
2022-02-26 02:43:01 +09:00
parent a83f375681
commit 3974067915
913 changed files with 32472 additions and 32364 deletions
@@ -3,6 +3,7 @@ using Concentus.Structs;
using Microsoft.Xna.Framework;
using OpenAL;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
@@ -18,6 +19,9 @@ namespace Barotrauma.Networking
private set;
}
public static IReadOnlyList<string> CaptureDeviceNames =>
Alc.GetStringList(IntPtr.Zero, OpenAL.Alc.CaptureDeviceSpecifier);
private IntPtr captureDevice;
private Thread captureThread;
@@ -40,7 +44,7 @@ namespace Barotrauma.Networking
public float Gain
{
get { return GameMain.Config?.MicrophoneVolume ?? 1.0f; }
get { return GameSettings.CurrentConfig.Audio.MicrophoneVolume; }
}
public DateTime LastEnqueueAudio;
@@ -106,16 +110,18 @@ namespace Barotrauma.Networking
string errorCode = Alc.GetError(IntPtr.Zero).ToString();
if (!GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "capturedevicenotfound"))
{
GUI.SettingsMenuOpen = false;
//GUI.SettingsMenuOpen = false;
new GUIMessageBox(TextManager.Get("Error"),
(TextManager.Get("VoipCaptureDeviceNotFound", returnNull: true) ?? "Could not start voice capture, suitable capture device not found.") + " (" + errorCode + ")")
(TextManager.Get("VoipCaptureDeviceNotFound").Fallback("Could not start voice capture, suitable capture device not found.")) + " (" + errorCode + ")")
{
UserData = "capturedevicenotfound"
};
}
GameAnalyticsManager.AddErrorEventOnce("Alc.CaptureDeviceOpenFailed", GameAnalyticsManager.ErrorSeverity.Error,
"Alc.CaptureDeviceOpen(" + deviceName + ") failed. Error code: " + errorCode);
GameMain.Config.VoiceSetting = GameSettings.VoiceMode.Disabled;
var config = GameSettings.CurrentConfig;
config.Audio.VoiceSetting = VoiceMode.Disabled;
GameSettings.SetCurrentConfig(config);
Instance?.Dispose();
Instance = null;
return;
@@ -157,13 +163,15 @@ namespace Barotrauma.Networking
public static void ChangeCaptureDevice(string deviceName)
{
GameMain.Config.VoiceCaptureDevice = deviceName;
var config = GameSettings.CurrentConfig;
config.Audio.VoiceCaptureDevice = deviceName;
GameSettings.SetCurrentConfig(config);
if (Instance != null)
{
UInt16 storedBufferID = Instance.LatestBufferID;
Instance.Dispose();
Create(GameMain.Config.VoiceCaptureDevice, storedBufferID);
Create(GameSettings.CurrentConfig.Audio.VoiceCaptureDevice, storedBufferID);
}
}
@@ -222,9 +230,9 @@ namespace Barotrauma.Networking
LastAmplitude = maxAmplitude;
bool allowEnqueue = overrideSound != null;
if (GameMain.WindowActive)
if (GameMain.WindowActive && SettingsMenu.Instance is null)
{
ForceLocal = captureTimer > 0 ? ForceLocal : GameMain.Config.UseLocalVoiceByDefault;
ForceLocal = captureTimer > 0 ? ForceLocal : GameSettings.CurrentConfig.Audio.UseLocalVoiceByDefault;
bool pttDown = false;
if ((PlayerInput.KeyDown(InputType.Voice) || PlayerInput.KeyDown(InputType.LocalVoice)) &&
GUI.KeyboardDispatcher.Subscriber == null)
@@ -239,14 +247,14 @@ namespace Barotrauma.Networking
ForceLocal = false;
}
}
if (GameMain.Config.VoiceSetting == GameSettings.VoiceMode.Activity)
if (GameSettings.CurrentConfig.Audio.VoiceSetting == VoiceMode.Activity)
{
if (dB > GameMain.Config.NoiseGateThreshold)
if (dB > GameSettings.CurrentConfig.Audio.NoiseGateThreshold)
{
allowEnqueue = true;
}
}
else if (GameMain.Config.VoiceSetting == GameSettings.VoiceMode.PushToTalk)
else if (GameSettings.CurrentConfig.Audio.VoiceSetting == VoiceMode.PushToTalk)
{
if (pttDown)
{
@@ -277,7 +285,7 @@ namespace Barotrauma.Networking
captureTimer -= (VoipConfig.BUFFER_SIZE * 1000) / VoipConfig.FREQUENCY;
if (allowEnqueue)
{
captureTimer = GameMain.Config.VoiceChatCutoffPrevention;
captureTimer = GameSettings.CurrentConfig.Audio.VoiceChatCutoffPrevention;
}
prevCaptured = true;
}
@@ -378,6 +386,7 @@ namespace Barotrauma.Networking
capturing = false;
captureThread?.Join();
captureThread = null;
if (captureDevice != IntPtr.Zero) { Alc.CaptureCloseDevice(captureDevice); }
}
}
}
@@ -43,7 +43,7 @@ namespace Barotrauma.Networking
public void SendToServer()
{
if (GameMain.Config.VoiceSetting == GameSettings.VoiceMode.Disabled)
if (GameSettings.CurrentConfig.Audio.VoiceSetting == VoiceMode.Disabled)
{
if (VoipCapture.Instance != null)
{
@@ -54,8 +54,8 @@ namespace Barotrauma.Networking
}
else
{
if (VoipCapture.Instance == null) VoipCapture.Create(GameMain.Config.VoiceCaptureDevice, storedBufferID);
if (VoipCapture.Instance == null || VoipCapture.Instance.EnqueuedTotalLength <= 0) return;
if (VoipCapture.Instance == null) { VoipCapture.Create(GameSettings.CurrentConfig.Audio.VoiceCaptureDevice, storedBufferID); }
if (VoipCapture.Instance == null || VoipCapture.Instance.EnqueuedTotalLength <= 0) { return; }
}
if (DateTime.Now >= lastSendTime + VoipConfig.SEND_INTERVAL)
@@ -80,7 +80,7 @@ namespace Barotrauma.Networking
if (queue == null)
{
#if DEBUG
DebugConsole.NewMessage("Couldn't find VoipQueue with id " + queueId.ToString() + "!", GUI.Style.Red);
DebugConsole.NewMessage("Couldn't find VoipQueue with id " + queueId.ToString() + "!", GUIStyle.Red);
#endif
return;
}
@@ -102,7 +102,7 @@ namespace Barotrauma.Networking
var messageType = !client.VoipQueue.ForceLocal && ChatMessage.CanUseRadio(client.Character, out radio) ? ChatMessageType.Radio : ChatMessageType.Default;
client.Character.ShowSpeechBubble(1.25f, ChatMessage.MessageColor[(int)messageType]);
client.VoipSound.UseRadioFilter = messageType == ChatMessageType.Radio && !GameMain.Config.DisableVoiceChatFilters;
client.VoipSound.UseRadioFilter = messageType == ChatMessageType.Radio && !GameSettings.CurrentConfig.Audio.DisableVoiceChatFilters;
if (messageType == ChatMessageType.Radio)
{
client.VoipSound.SetRange(radio.Range * 0.8f, radio.Range);
@@ -111,7 +111,7 @@ namespace Barotrauma.Networking
{
client.VoipSound.SetRange(ChatMessage.SpeakRange * 0.4f, ChatMessage.SpeakRange);
}
if (messageType != ChatMessageType.Radio && Character.Controlled != null && !GameMain.Config.DisableVoiceChatFilters)
if (messageType != ChatMessageType.Radio && Character.Controlled != null && !GameSettings.CurrentConfig.Audio.DisableVoiceChatFilters)
{
client.VoipSound.UseMuffleFilter = SoundPlayer.ShouldMuffleSound(Character.Controlled, client.Character.WorldPosition, ChatMessage.SpeakRange, client.Character.CurrentHull);
}
@@ -144,7 +144,7 @@ namespace Barotrauma.Networking
{
if (voiceIconSheetRects == null)
{
var soundIconStyle = GUI.Style.GetComponentStyle("GUISoundIcon");
var soundIconStyle = GUIStyle.GetComponentStyle("GUISoundIcon");
Rectangle sourceRect = soundIconStyle.Sprites.First().Value.First().Sprite.SourceRect;
var indexPieces = soundIconStyle.Element.Attribute("sheetindices").Value.Split(';');
voiceIconSheetRects = new Rectangle[indexPieces.Length];