Add NetID Setting

This commit is contained in:
kmyuhkyuk
2026-03-08 18:38:39 +08:00
parent 1ce04ee807
commit b4403b4d16
4 changed files with 45 additions and 7 deletions
@@ -11,6 +11,7 @@ namespace SlayTheSpire2.LAN.Multiplayer.Models
[JsonPropertyName("host_port")] public ushort HostPort { get; set; } = 33771;
[JsonPropertyName("host_max_players")] public int HostMaxPlayers { get; set; } = 4;
[JsonPropertyName("ip_address")] public string IPAddress { get; set; } = "127.0.0.1";
[JsonPropertyName("net_id")] public ulong NetId { get; set; } = 1000u;
public int SchemaVersion { get; set; }
}
@@ -97,11 +97,7 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs
port = ipAddressLineEdit.Port.Value;
}
var netId = 1000uL;
if (CommandLineHelper.TryGetValue("clientId", out var value) && value != null)
{
netId = ulong.Parse(value);
}
var netId = SettingsHelper.Instance.SettingsModel.NetId;
DisplayServer.WindowSetTitle("Slay The Spire 2 (Client)");
if (ipAddress != null)
@@ -97,6 +97,47 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs
hostMaxPlayersLabel.Text = "Host Max Players";
}
if (__instance.GetNode("%ModdingDivider").Duplicate() is ColorRect netIdDivider &&
moddingNode.Duplicate() is MarginContainer netId &&
netId.GetNode("Label") is RichTextLabel netIdLabel)
{
netIdDivider.Name = "NetIDDivider";
vBoxContainer.AddChild(netIdDivider);
vBoxContainer.MoveChild(netIdDivider, moddingNode.GetIndex() + 1);
netIdDivider.Show();
netId.Name = "NetID";
netId.RemoveChild(netId.GetNode("ModdingButton"));
vBoxContainer.AddChild(netId);
vBoxContainer.MoveChild(netId, netIdDivider.GetIndex() + 1);
netId.Show();
var netIdInput = new SpinBox { Name = "NetIDInput" };
netId.AddChild(netIdInput);
netIdInput.CustomMinimumSize = new Vector2(324, 64);
netIdInput.SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd;
netIdInput.GetLineEdit().Alignment = HorizontalAlignment.Center;
netIdInput.Step = 1;
netIdInput.MinValue = 2;
netIdInput.MaxValue = double.MaxValue;
netIdInput.Value = SettingsHelper.Instance.SettingsModel.NetId;
netIdInput.ValueChanged += value =>
{
SettingsHelper.Instance.SettingsModel.NetId = (ulong)value;
SettingsHelper.Instance.WriteSettings();
};
netIdLabel.Text = "NetID";
}
}
}
}
@@ -4,8 +4,8 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
</PropertyGroup>
<ItemGroup>