v0.18.15.0
This commit is contained in:
@@ -46,21 +46,7 @@ namespace Barotrauma
|
||||
return Instance;
|
||||
}
|
||||
|
||||
public void Recreate()
|
||||
{
|
||||
if (GUI.SettingsMenuOpen)
|
||||
{
|
||||
GUI.SettingsMenuOpen = false;
|
||||
GUI.SettingsMenuOpen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Create(mainFrame.Parent.RectTransform);
|
||||
Instance?.SelectTab(Tab.Controls);
|
||||
}
|
||||
}
|
||||
|
||||
private SettingsMenu(RectTransform mainParent)
|
||||
private SettingsMenu(RectTransform mainParent, GameSettings.Config setConfig = default)
|
||||
{
|
||||
unsavedConfig = GameSettings.CurrentConfig;
|
||||
|
||||
@@ -476,8 +462,9 @@ namespace Barotrauma
|
||||
Slider(voiceChat, (0, 500), 26, (v) => $"{Round(v)} ms", unsavedConfig.Audio.VoiceChatCutoffPrevention, (v) => unsavedConfig.Audio.VoiceChatCutoffPrevention = Round(v), TextManager.Get("CutoffPreventionTooltip"));
|
||||
}
|
||||
|
||||
|
||||
private readonly Dictionary<GUIButton, Func<LocalizedString>> inputButtonValueNameGetters = new Dictionary<GUIButton, Func<LocalizedString>>();
|
||||
private bool inputBoxSelectedThisFrame = false;
|
||||
|
||||
private void CreateControlsTab()
|
||||
{
|
||||
GUIFrame content = CreateNewContentFrame(Tab.Controls);
|
||||
@@ -501,7 +488,7 @@ namespace Barotrauma
|
||||
GUILayoutGroup createInputRowLayout()
|
||||
=> new GUILayoutGroup(new RectTransform((1.0f, 0.1f), keyMapList.Content.RectTransform), isHorizontal: true);
|
||||
|
||||
HashSet<GUIButton> inputButtons = new HashSet<GUIButton>();
|
||||
inputButtonValueNameGetters.Clear();
|
||||
Action<KeyOrMouse>? currentSetter = null;
|
||||
void addInputToRow(GUILayoutGroup currRow, LocalizedString labelText, Func<LocalizedString> valueNameGetter, Action<KeyOrMouse> valueSetter, bool isLegacyBind = false)
|
||||
{
|
||||
@@ -519,7 +506,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
inputButtons.ForEach(b =>
|
||||
inputButtonValueNameGetters.Keys.ForEach(b =>
|
||||
{
|
||||
if (b != btn) { b.Selected = false; }
|
||||
});
|
||||
@@ -544,7 +531,7 @@ namespace Barotrauma
|
||||
inputBox.Color = Color.Lerp(inputBox.Color, inputBox.DisabledColor, 0.5f);
|
||||
inputBox.TextColor = Color.Lerp(inputBox.TextColor, label.DisabledTextColor, 0.5f);
|
||||
}
|
||||
inputButtons.Add(inputBox);
|
||||
inputButtonValueNameGetters.Add(inputBox, valueNameGetter);
|
||||
}
|
||||
|
||||
var inputListener = new GUICustomComponent(new RectTransform(Vector2.Zero, layout.RectTransform), onUpdate: (deltaTime, component) =>
|
||||
@@ -560,7 +547,7 @@ namespace Barotrauma
|
||||
void clearSetter()
|
||||
{
|
||||
currentSetter = null;
|
||||
inputButtons.ForEach(b => b.Selected = false);
|
||||
inputButtonValueNameGetters.Keys.ForEach(b => b.Selected = false);
|
||||
}
|
||||
|
||||
void callSetter(KeyOrMouse v)
|
||||
@@ -663,11 +650,14 @@ namespace Barotrauma
|
||||
TextManager.Get("Reset"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("SetDefaultBindingsTooltip"),
|
||||
OnClicked = (btn, userdata) =>
|
||||
OnClicked = (_, userdata) =>
|
||||
{
|
||||
unsavedConfig.InventoryKeyMap = GameSettings.Config.InventoryKeyMapping.GetDefault();
|
||||
unsavedConfig.KeyMap = GameSettings.Config.KeyMapping.GetDefault();
|
||||
Recreate();
|
||||
foreach (var btn in inputButtonValueNameGetters.Keys)
|
||||
{
|
||||
btn.Text = inputButtonValueNameGetters[btn]();
|
||||
}
|
||||
Instance?.SelectTab(Tab.Controls);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user