Added tooltips and SettingControl input listener to the settings menu. Minor cosmetic adjustments.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Barotrauma.LuaCs.Data;
|
using Barotrauma.LuaCs.Data;
|
||||||
using Microsoft.Toolkit.Diagnostics;
|
using Microsoft.Toolkit.Diagnostics;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using OneOf;
|
using OneOf;
|
||||||
|
|
||||||
@@ -148,4 +149,104 @@ public sealed class SettingControl : SettingBase, ISettingControl
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CLIENT
|
||||||
|
private static GUICustomComponent InputListener;
|
||||||
|
|
||||||
|
public override void AddDisplayComponent(GUILayoutGroup layoutGroup, Vector2 relativeSize, Action<string> onSerializedValue)
|
||||||
|
{
|
||||||
|
var inputButton = new GUIButton(new RectTransform(relativeSize, layoutGroup.RectTransform), Alignment.Center,
|
||||||
|
style: "GUITextBoxNoIcon")
|
||||||
|
{
|
||||||
|
Text = this.Value.ToString(),
|
||||||
|
OnClicked = (btn, obj) =>
|
||||||
|
{
|
||||||
|
if (InputListener is not null)
|
||||||
|
{
|
||||||
|
// Another button is active
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CoroutineManager.Invoke(() =>
|
||||||
|
{
|
||||||
|
CreateListener(btn);
|
||||||
|
}, 0f); // delay one frame for button inputs
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
inputButton.OutlineColor = Color.PeachPuff;
|
||||||
|
inputButton.TextColor = Color.White;
|
||||||
|
|
||||||
|
|
||||||
|
void ClearListener()
|
||||||
|
{
|
||||||
|
InputListener?.Parent.RemoveChild(InputListener);
|
||||||
|
InputListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateListener(GUIButton button)
|
||||||
|
{
|
||||||
|
ClearListener();
|
||||||
|
InputListener = new GUICustomComponent(new RectTransform(Vector2.Zero, layoutGroup.RectTransform),
|
||||||
|
onUpdate: (deltaTime, component) =>
|
||||||
|
{
|
||||||
|
var pressedKeys = PlayerInput.GetKeyboardState.GetPressedKeys();
|
||||||
|
if (pressedKeys?.Any() ?? false)
|
||||||
|
{
|
||||||
|
if (pressedKeys.Contains(Keys.Escape))
|
||||||
|
{
|
||||||
|
ClearListener();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplyValue(pressedKeys.First(), button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PlayerInput.PrimaryMouseButtonClicked() &&
|
||||||
|
(GUI.MouseOn == null || !(GUI.MouseOn is GUIButton) || GUI.MouseOn.IsChildOf(layoutGroup)))
|
||||||
|
{
|
||||||
|
ApplyValue(MouseButton.PrimaryMouse, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (PlayerInput.SecondaryMouseButtonClicked())
|
||||||
|
{
|
||||||
|
ApplyValue(MouseButton.SecondaryMouse, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (PlayerInput.MidButtonClicked())
|
||||||
|
{
|
||||||
|
ApplyValue(MouseButton.MiddleMouse, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (PlayerInput.Mouse4ButtonClicked())
|
||||||
|
{
|
||||||
|
ApplyValue(MouseButton.MouseButton4, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (PlayerInput.Mouse5ButtonClicked())
|
||||||
|
{
|
||||||
|
ApplyValue(MouseButton.MouseButton5, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (PlayerInput.MouseWheelUpClicked())
|
||||||
|
{
|
||||||
|
ApplyValue(MouseButton.MouseWheelUp, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (PlayerInput.MouseWheelDownClicked())
|
||||||
|
{
|
||||||
|
ApplyValue(MouseButton.MouseWheelDown, button);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyValue(KeyOrMouse input, GUIButton button)
|
||||||
|
{
|
||||||
|
button.Text = input.ToString();
|
||||||
|
onSerializedValue?.Invoke(input.ToString());
|
||||||
|
ClearListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -258,7 +258,8 @@ internal sealed class ModsGameplaySettingsMenu : ModsSettingsMenuBase
|
|||||||
GUIFrame entryFrame = new GUIFrame(new RectTransform(new Vector2(1f, settingHeight), parent));
|
GUIFrame entryFrame = new GUIFrame(new RectTransform(new Vector2(1f, settingHeight), parent));
|
||||||
GUILayoutGroup entryLayoutGroup = new GUILayoutGroup(new RectTransform(Vector2.One, entryFrame.RectTransform), isHorizontal: true);
|
GUILayoutGroup entryLayoutGroup = new GUILayoutGroup(new RectTransform(Vector2.One, entryFrame.RectTransform), isHorizontal: true);
|
||||||
|
|
||||||
new GUIFrame(new RectTransform(new Vector2(0.05f, 1f), entryLayoutGroup.RectTransform),
|
// padding
|
||||||
|
new GUIFrame(new RectTransform(new Vector2(0.02f, 1f), entryLayoutGroup.RectTransform),
|
||||||
color: Color.TransparentBlack);
|
color: Color.TransparentBlack);
|
||||||
|
|
||||||
new GUITextBlock(new RectTransform(labelSize - new Vector2(0.05f, 0f), entryLayoutGroup.RectTransform),
|
new GUITextBlock(new RectTransform(labelSize - new Vector2(0.05f, 0f), entryLayoutGroup.RectTransform),
|
||||||
@@ -267,7 +268,7 @@ internal sealed class ModsGameplaySettingsMenu : ModsSettingsMenuBase
|
|||||||
font: GUIStyle.SmallFont,
|
font: GUIStyle.SmallFont,
|
||||||
textAlignment: Alignment.Left)
|
textAlignment: Alignment.Left)
|
||||||
{
|
{
|
||||||
CanBeFocused = false
|
ToolTip = GetLocalizedString(setting.GetDisplayInfo().Tooltip, string.Empty)
|
||||||
};
|
};
|
||||||
|
|
||||||
setting.AddDisplayComponent(entryLayoutGroup, controlSize, newValue =>
|
setting.AddDisplayComponent(entryLayoutGroup, controlSize, newValue =>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<Settings>
|
<Settings>
|
||||||
<Setting Name="DisableErrorGUIOverlay" Type="bool" Value="true"/>
|
<Setting Name="DisableErrorGUIOverlay" Type="bool" Value="true"/>
|
||||||
<Setting Name="HideUserNamesInLogs" Type="bool" Value="true"/>
|
<Setting Name="HideUserNamesInLogs" Type="bool" Value="true"/>
|
||||||
<Setting Name="LocalDataSavePath" Type="string" Value="/Data/Mods" AllowChangesWhileExecuting="false"/>
|
<Setting Name="LocalDataSavePath" Type="string" Value="/Data/Mods" ShowInMenus="false" ReadOnly="true"/>
|
||||||
<Setting Name="LuaForBarotraumaSteamId" Type="ulong" Value="2559634234" ReadOnly="true"/>
|
<Setting Name="LuaForBarotraumaSteamId" Type="ulong" Value="2559634234" ReadOnly="true"/>
|
||||||
<Setting Name="IsCsEnabled" Type="bool" Value="false" AllowChangesWhileExecuting="false"/>
|
<Setting Name="IsCsEnabled" Type="bool" Value="false" AllowChangesWhileExecuting="false"/>
|
||||||
<Setting Name="RestrictMessageSize" Type="bool" Value="true"/>
|
<Setting Name="RestrictMessageSize" Type="bool" Value="true"/>
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
<LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayName>Suppress GUI Popup on Error</LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayName>
|
<LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayName>Suppress GUI Popup on Error</LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayName>
|
||||||
<LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayCategory>General</LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayCategory>
|
<LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayCategory>General</LuaCsForBarotrauma.DisableErrorGUIOverlay.DisplayCategory>
|
||||||
<LuaCsForBarotrauma.IsCsEnabled.DisplayName>Are C# Mods Allowed</LuaCsForBarotrauma.IsCsEnabled.DisplayName>
|
<LuaCsForBarotrauma.IsCsEnabled.DisplayName>Are C# Mods Allowed</LuaCsForBarotrauma.IsCsEnabled.DisplayName>
|
||||||
|
<LuaCsForBarotrauma.IsCsEnabled.Tooltip>Should unsandboxed scripts and dlls be allowed to run.</LuaCsForBarotrauma.IsCsEnabled.Tooltip>
|
||||||
<LuaCsForBarotrauma.IsCsEnabled.DisplayCategory>General</LuaCsForBarotrauma.IsCsEnabled.DisplayCategory>
|
<LuaCsForBarotrauma.IsCsEnabled.DisplayCategory>General</LuaCsForBarotrauma.IsCsEnabled.DisplayCategory>
|
||||||
<LuaCsForBarotrauma.HideUserNamesInLogs.DisplayName>Hide Local OS Account Name In Logs</LuaCsForBarotrauma.HideUserNamesInLogs.DisplayName>
|
<LuaCsForBarotrauma.HideUserNamesInLogs.DisplayName>Hide Local OS Account Name In Logs</LuaCsForBarotrauma.HideUserNamesInLogs.DisplayName>
|
||||||
<LuaCsForBarotrauma.HideUserNamesInLogs.DisplayCategory>General</LuaCsForBarotrauma.HideUserNamesInLogs.DisplayCategory>
|
<LuaCsForBarotrauma.HideUserNamesInLogs.DisplayCategory>General</LuaCsForBarotrauma.HideUserNamesInLogs.DisplayCategory>
|
||||||
<LuaCsForBarotrauma.LocalDataSavePath.DisplayName>Where to Save Local Data</LuaCsForBarotrauma.LocalDataSavePath.DisplayName>
|
|
||||||
<LuaCsForBarotrauma.LocalDataSavePath.DisplayCategory>General</LuaCsForBarotrauma.LocalDataSavePath.DisplayCategory>
|
|
||||||
<LuaCsForBarotrauma.RestrictMessageSize.DisplayName>Limit Network Message Size</LuaCsForBarotrauma.RestrictMessageSize.DisplayName>
|
<LuaCsForBarotrauma.RestrictMessageSize.DisplayName>Limit Network Message Size</LuaCsForBarotrauma.RestrictMessageSize.DisplayName>
|
||||||
|
<LuaCsForBarotrauma.RestrictMessageSize.Tooltip>Limits the maximum network message size to avoid buffer size issues.</LuaCsForBarotrauma.RestrictMessageSize.Tooltip>
|
||||||
<LuaCsForBarotrauma.RestrictMessageSize.DisplayCategory>Networking</LuaCsForBarotrauma.RestrictMessageSize.DisplayCategory>
|
<LuaCsForBarotrauma.RestrictMessageSize.DisplayCategory>Networking</LuaCsForBarotrauma.RestrictMessageSize.DisplayCategory>
|
||||||
</infotexts>
|
</infotexts>
|
||||||
|
|||||||
Reference in New Issue
Block a user