(cb59734bd) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev
This commit is contained in:
@@ -15,7 +15,20 @@ namespace Barotrauma
|
||||
{
|
||||
radioButtons = new Dictionary<Enum, GUITickBox>();
|
||||
}
|
||||
|
||||
|
||||
public override bool Enabled
|
||||
{
|
||||
get => base.Enabled;
|
||||
set
|
||||
{
|
||||
base.Enabled = value;
|
||||
foreach(KeyValuePair<Enum, GUITickBox> rbPair in radioButtons)
|
||||
{
|
||||
rbPair.Value.Enabled = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRadioButton(Enum key, GUITickBox radioButton)
|
||||
{
|
||||
if (selected == key) radioButton.Selected = true;
|
||||
|
||||
@@ -473,10 +473,14 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice))
|
||||
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice) || !(deviceNames?.Contains(VoiceCaptureDevice) ?? false))
|
||||
{
|
||||
VoiceCaptureDevice = deviceNames?.Count > 0 ? deviceNames[0] : null;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice))
|
||||
{
|
||||
VoiceSetting = VoiceMode.Disabled;
|
||||
}
|
||||
#if (!OSX)
|
||||
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TrimAudioDeviceName(VoiceCaptureDevice), deviceNames.Count);
|
||||
if (deviceNames?.Count > 0)
|
||||
@@ -498,19 +502,20 @@ namespace Barotrauma
|
||||
{
|
||||
deviceList.AddItem(TextManager.Get("VoipNoDevices") ?? "N/A", null);
|
||||
deviceList.ButtonEnabled = false;
|
||||
deviceList.Select(0);
|
||||
}
|
||||
|
||||
#else
|
||||
var defaultDeviceGroup = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.1f), audioSliders.RectTransform), true, Anchor.CenterLeft);
|
||||
var currentDeviceButton = new GUITextBlock(new RectTransform(new Vector2(.7f, 0.75f), null),
|
||||
TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TextManager.EnsureUTF8(VoiceCaptureDevice)))
|
||||
var currentDeviceTextBlock = new GUITextBlock(new RectTransform(new Vector2(.7f, 0.75f), null),
|
||||
TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TrimAudioDeviceName(VoiceCaptureDevice)))
|
||||
{
|
||||
ToolTip = TextManager.Get("CurrentDeviceToolTip.OSX"),
|
||||
TextAlignment = Alignment.CenterLeft
|
||||
};
|
||||
|
||||
string refreshText = ToolBox.WrapText(TextManager.Get("RefreshDefaultDevice"), defaultDeviceGroup.RectTransform.Rect.Width * 0.3f, GUI.Font);
|
||||
new GUIButton(new RectTransform(new Vector2(.3f, 0.75f), defaultDeviceGroup.RectTransform), refreshText)
|
||||
var currentDeviceButton = new GUIButton(new RectTransform(new Vector2(.3f, 0.75f), defaultDeviceGroup.RectTransform), refreshText)
|
||||
{
|
||||
ToolTip = TextManager.Get("RefreshDefaultDeviceToolTip"),
|
||||
OnClicked = (bt, userdata) =>
|
||||
@@ -521,20 +526,21 @@ namespace Barotrauma
|
||||
if (VoiceCaptureDevice == deviceNames[0]) return true;
|
||||
|
||||
VoipCapture.ChangeCaptureDevice(deviceNames[0]);
|
||||
currentDeviceButton.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TrimAudioDeviceName(VoiceCaptureDevice));
|
||||
currentDeviceButton.Flash(Color.Blue);
|
||||
currentDeviceTextBlock.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TrimAudioDeviceName(VoiceCaptureDevice));
|
||||
currentDeviceTextBlock.Flash(Color.Blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentDeviceButton.Text = TextManager.Get("VoipNoDevices");
|
||||
currentDeviceButton.Flash(Color.Red);
|
||||
currentDeviceTextBlock.Text = TextManager.Get("VoipNoDevices") ?? "N/A";
|
||||
currentDeviceTextBlock.Flash(Color.Red);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
currentDeviceButton.OnClicked(currentDeviceButton, null);
|
||||
|
||||
currentDeviceButton.RectTransform.Parent = defaultDeviceGroup.RectTransform;
|
||||
currentDeviceTextBlock.RectTransform.Parent = defaultDeviceGroup.RectTransform;
|
||||
#endif
|
||||
//var radioButtonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.12f), audioSliders.RectTransform));
|
||||
|
||||
@@ -650,6 +656,10 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
voiceMode.Selected = VoiceSetting;
|
||||
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice))
|
||||
{
|
||||
voiceMode.Enabled = false;
|
||||
}
|
||||
|
||||
/// Controls tab -------------------------------------------------------------
|
||||
var controlsLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), tabs[(int)Tab.Controls].RectTransform, Anchor.TopCenter)
|
||||
@@ -803,6 +813,7 @@ namespace Barotrauma
|
||||
|
||||
private string TrimAudioDeviceName(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) { return string.Empty; }
|
||||
string[] prefixes = { "OpenAL Soft on " };
|
||||
foreach (string prefix in prefixes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user