From b4403b4d165838db85c44072594f8db64434db56 Mon Sep 17 00:00:00 2001 From: kmyuhkyuk <72241714+kmyuhkyuk@users.noreply.github.com> Date: Sun, 8 Mar 2026 18:38:39 +0800 Subject: [PATCH] Add NetID Setting --- .../Models/SettingsModel.cs | 1 + .../Patchs/NJoinFriendScreenPatch.cs | 6 +-- .../Patchs/NSettingsScreenPatch.cs | 41 +++++++++++++++++++ .../SlayTheSpire2.LAN.Multiplayer.csproj | 4 +- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/SlayTheSpire2.LAN.Multiplayer/Models/SettingsModel.cs b/SlayTheSpire2.LAN.Multiplayer/Models/SettingsModel.cs index 8a8e6e0..6fd8671 100644 --- a/SlayTheSpire2.LAN.Multiplayer/Models/SettingsModel.cs +++ b/SlayTheSpire2.LAN.Multiplayer/Models/SettingsModel.cs @@ -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; } } diff --git a/SlayTheSpire2.LAN.Multiplayer/Patchs/NJoinFriendScreenPatch.cs b/SlayTheSpire2.LAN.Multiplayer/Patchs/NJoinFriendScreenPatch.cs index 08414e3..b9216d6 100644 --- a/SlayTheSpire2.LAN.Multiplayer/Patchs/NJoinFriendScreenPatch.cs +++ b/SlayTheSpire2.LAN.Multiplayer/Patchs/NJoinFriendScreenPatch.cs @@ -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) diff --git a/SlayTheSpire2.LAN.Multiplayer/Patchs/NSettingsScreenPatch.cs b/SlayTheSpire2.LAN.Multiplayer/Patchs/NSettingsScreenPatch.cs index d07bb32..56d309e 100644 --- a/SlayTheSpire2.LAN.Multiplayer/Patchs/NSettingsScreenPatch.cs +++ b/SlayTheSpire2.LAN.Multiplayer/Patchs/NSettingsScreenPatch.cs @@ -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"; + } } } } \ No newline at end of file diff --git a/SlayTheSpire2.LAN.Multiplayer/SlayTheSpire2.LAN.Multiplayer.csproj b/SlayTheSpire2.LAN.Multiplayer/SlayTheSpire2.LAN.Multiplayer.csproj index 52e0a05..b8064fa 100644 --- a/SlayTheSpire2.LAN.Multiplayer/SlayTheSpire2.LAN.Multiplayer.csproj +++ b/SlayTheSpire2.LAN.Multiplayer/SlayTheSpire2.LAN.Multiplayer.csproj @@ -4,8 +4,8 @@ net9.0 enable enable - 1.1.0.0 - 1.1.0.0 + 1.2.0.0 + 1.2.0.0