(dfb859379) Additional fixes to audio device capture list
This commit is contained in:
@@ -63,17 +63,11 @@ namespace Barotrauma
|
|||||||
frame = new GUIFrame(new RectTransform(new Vector2(0.5f, 0.45f), GUI.Canvas) { MinSize = new Point(400, 300), AbsoluteOffset = new Point(10, 10) },
|
frame = new GUIFrame(new RectTransform(new Vector2(0.5f, 0.45f), GUI.Canvas) { MinSize = new Point(400, 300), AbsoluteOffset = new Point(10, 10) },
|
||||||
color: new Color(0.4f, 0.4f, 0.4f, 0.8f));
|
color: new Color(0.4f, 0.4f, 0.4f, 0.8f));
|
||||||
|
|
||||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), frame.RectTransform, Anchor.Center)) { RelativeSpacing = 0.01f };
|
var paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), frame.RectTransform, Anchor.Center), style: null);
|
||||||
|
|
||||||
var toggleText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paddedFrame.RectTransform, Anchor.TopLeft), TextManager.Get("DebugConsoleHelpText"), Color.GreenYellow, GUI.SmallFont, Alignment.CenterLeft, style: null);
|
var toggleText = new GUITextBlock(new RectTransform(new Point(paddedFrame.Rect.Width-30, 20), paddedFrame.RectTransform, Anchor.TopLeft), TextManager.Get("DebugConsoleHelpText"), new Color(150,150,200,255), GUI.SmallFont, Alignment.CenterLeft, style: null);
|
||||||
|
|
||||||
var closeButton = new GUIButton(new RectTransform(new Vector2(0.025f, 1.0f), toggleText.RectTransform, Anchor.TopRight), "X", style: null)
|
var closeButton = new GUIButton(new RectTransform(new Point(20, 20), paddedFrame.RectTransform, Anchor.TopRight), "X", color: Color.Red);
|
||||||
{
|
|
||||||
Color = Color.DarkRed,
|
|
||||||
HoverColor = Color.Red,
|
|
||||||
TextColor = Color.White,
|
|
||||||
OutlineColor = Color.Red
|
|
||||||
};
|
|
||||||
closeButton.OnClicked += (btn, userdata) =>
|
closeButton.OnClicked += (btn, userdata) =>
|
||||||
{
|
{
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
@@ -82,12 +76,12 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
listBox = new GUIListBox(new RectTransform(new Point(paddedFrame.Rect.Width, paddedFrame.Rect.Height - 60), paddedFrame.RectTransform, Anchor.Center)
|
listBox = new GUIListBox(new RectTransform(new Point(paddedFrame.Rect.Width, paddedFrame.Rect.Height - 50), paddedFrame.RectTransform, Anchor.Center)
|
||||||
{
|
{
|
||||||
IsFixedSize = false
|
IsFixedSize = false
|
||||||
}, color: Color.Black * 0.9f) { ScrollBarVisible = true };
|
}, color: Color.Black * 0.9f);
|
||||||
|
|
||||||
textBox = new GUITextBox(new RectTransform(new Point(paddedFrame.Rect.Width, 30), paddedFrame.RectTransform, Anchor.BottomLeft)
|
textBox = new GUITextBox(new RectTransform(new Point(paddedFrame.Rect.Width, 20), paddedFrame.RectTransform, Anchor.BottomLeft)
|
||||||
{
|
{
|
||||||
IsFixedSize = false
|
IsFixedSize = false
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,20 @@ 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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user