Fixed inability to connect via port

Added Scrollbar to choose Relic with more than 4 players
Added custom player name feature, Now host will synchronize client names
This commit is contained in:
kmyuhkyuk
2026-03-15 08:06:26 +08:00
parent 24a06e3a00
commit 6ff7a9dc2b
25 changed files with 785 additions and 107 deletions
@@ -8,7 +8,7 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
{
public override void _Ready()
{
TextSubmitted += OnTextSubmitted;
TextChanged += OnTextChanged;
}
public struct AddressInfo(bool isValid, string? address, ushort? port)
@@ -50,13 +50,14 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
else if (IPEndPoint.TryParse(Text, out var ipEndPoint))
{
addressInfo.IsValid = true;
addressInfo.Address = ipEndPoint.Address.ToString();
addressInfo.Port = (ushort)ipEndPoint.Port;
}
return addressInfo;
}
private void OnTextSubmitted(string newText)
private void OnTextChanged(string newText)
{
Modulate = Colors.White;
@@ -0,0 +1,37 @@
using System.Text.RegularExpressions;
using Godot;
using MegaCrit.Sts2.Core.Nodes.GodotExtensions;
namespace SlayTheSpire2.LAN.Multiplayer.Components
{
internal partial class PlayerNameLineEdit : NMegaLineEdit
{
[GeneratedRegex(@"[\x00-\x1F\x7F<>:""/\\|?*\x0B\x0C\x0D&;`#$%^+={}]")]
private static partial Regex InvalidCharsRegex();
public bool IsInvalid => !GetPlayerNameIsInvalid(Text);
public bool IsEmpty => string.IsNullOrEmpty(Text);
public PlayerNameLineEdit()
{
TextChanged += OnTextChanged;
}
private void OnTextChanged(string newText)
{
Modulate = Colors.White;
if (string.IsNullOrEmpty(newText) || !GetPlayerNameIsInvalid(newText))
return;
Modulate = Colors.Red;
}
public static bool GetPlayerNameIsInvalid(string playerName)
{
return string.IsNullOrWhiteSpace(playerName) || playerName.StartsWith(' ') ||
InvalidCharsRegex().IsMatch(playerName);
}
}
}