(cb59734bd) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev

This commit is contained in:
Joonas Rikkonen
2019-06-04 16:41:00 +03:00
parent 440393d0cd
commit aadb0ffa80
2 changed files with 34 additions and 10 deletions
@@ -16,6 +16,19 @@ namespace Barotrauma
radioButtons = new Dictionary<Enum, GUITickBox>(); 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) public void AddRadioButton(Enum key, GUITickBox radioButton)
{ {
if (selected == key) radioButton.Selected = true; if (selected == key) radioButton.Selected = true;
@@ -473,10 +473,14 @@ namespace Barotrauma
return true; return true;
}; };
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice)) if (string.IsNullOrWhiteSpace(VoiceCaptureDevice) || !(deviceNames?.Contains(VoiceCaptureDevice) ?? false))
{ {
VoiceCaptureDevice = deviceNames?.Count > 0 ? deviceNames[0] : null; VoiceCaptureDevice = deviceNames?.Count > 0 ? deviceNames[0] : null;
} }
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice))
{
VoiceSetting = VoiceMode.Disabled;
}
#if (!OSX) #if (!OSX)
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TrimAudioDeviceName(VoiceCaptureDevice), deviceNames.Count); var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TrimAudioDeviceName(VoiceCaptureDevice), deviceNames.Count);
if (deviceNames?.Count > 0) if (deviceNames?.Count > 0)
@@ -498,19 +502,20 @@ namespace Barotrauma
{ {
deviceList.AddItem(TextManager.Get("VoipNoDevices") ?? "N/A", null); deviceList.AddItem(TextManager.Get("VoipNoDevices") ?? "N/A", null);
deviceList.ButtonEnabled = false; deviceList.ButtonEnabled = false;
deviceList.Select(0);
} }
#else #else
var defaultDeviceGroup = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.1f), audioSliders.RectTransform), true, Anchor.CenterLeft); 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), var currentDeviceTextBlock = new GUITextBlock(new RectTransform(new Vector2(.7f, 0.75f), null),
TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TextManager.EnsureUTF8(VoiceCaptureDevice))) TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TrimAudioDeviceName(VoiceCaptureDevice)))
{ {
ToolTip = TextManager.Get("CurrentDeviceToolTip.OSX"), ToolTip = TextManager.Get("CurrentDeviceToolTip.OSX"),
TextAlignment = Alignment.CenterLeft TextAlignment = Alignment.CenterLeft
}; };
string refreshText = ToolBox.WrapText(TextManager.Get("RefreshDefaultDevice"), defaultDeviceGroup.RectTransform.Rect.Width * 0.3f, GUI.Font); 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"), ToolTip = TextManager.Get("RefreshDefaultDeviceToolTip"),
OnClicked = (bt, userdata) => OnClicked = (bt, userdata) =>
@@ -521,20 +526,21 @@ namespace Barotrauma
if (VoiceCaptureDevice == deviceNames[0]) return true; if (VoiceCaptureDevice == deviceNames[0]) return true;
VoipCapture.ChangeCaptureDevice(deviceNames[0]); VoipCapture.ChangeCaptureDevice(deviceNames[0]);
currentDeviceButton.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TrimAudioDeviceName(VoiceCaptureDevice)); currentDeviceTextBlock.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TrimAudioDeviceName(VoiceCaptureDevice));
currentDeviceButton.Flash(Color.Blue); currentDeviceTextBlock.Flash(Color.Blue);
} }
else else
{ {
currentDeviceButton.Text = TextManager.Get("VoipNoDevices"); currentDeviceTextBlock.Text = TextManager.Get("VoipNoDevices") ?? "N/A";
currentDeviceButton.Flash(Color.Red); currentDeviceTextBlock.Flash(Color.Red);
} }
return true; return true;
} }
}; };
currentDeviceButton.OnClicked(currentDeviceButton, null);
currentDeviceButton.RectTransform.Parent = defaultDeviceGroup.RectTransform; currentDeviceTextBlock.RectTransform.Parent = defaultDeviceGroup.RectTransform;
#endif #endif
//var radioButtonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.12f), audioSliders.RectTransform)); //var radioButtonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.12f), audioSliders.RectTransform));
@@ -650,6 +656,10 @@ namespace Barotrauma
} }
}; };
voiceMode.Selected = VoiceSetting; voiceMode.Selected = VoiceSetting;
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice))
{
voiceMode.Enabled = false;
}
/// Controls tab ------------------------------------------------------------- /// Controls tab -------------------------------------------------------------
var controlsLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), tabs[(int)Tab.Controls].RectTransform, Anchor.TopCenter) 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) private string TrimAudioDeviceName(string name)
{ {
if (string.IsNullOrWhiteSpace(name)) { return string.Empty; }
string[] prefixes = { "OpenAL Soft on " }; string[] prefixes = { "OpenAL Soft on " };
foreach (string prefix in prefixes) foreach (string prefix in prefixes)
{ {