Optimize codes
This commit is contained in:
@@ -47,104 +47,69 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
|
|
||||||
public static IPAddressInfoPanel Create()
|
public static IPAddressInfoPanel Create()
|
||||||
{
|
{
|
||||||
var ipAddressInfoPanel = new IPAddressInfoPanel();
|
var ipAddressInfoPanel = new IPAddressInfoPanel { MouseFilter = MouseFilterEnum.Ignore };
|
||||||
|
|
||||||
ipAddressInfoPanel.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
ipAddressInfoPanel.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
ipAddressInfoPanel.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
||||||
|
|
||||||
var content = new VBoxContainer { Name = "Content" };
|
var content = new VBoxContainer { Name = "Content", MouseFilter = MouseFilterEnum.Stop };
|
||||||
ipAddressInfoPanel.AddChild(content);
|
ipAddressInfoPanel.AddChildSafely(content);
|
||||||
|
|
||||||
content.MouseFilter = MouseFilterEnum.Stop;
|
var menu = new Control
|
||||||
|
{ Name = "Menu", CustomMinimumSize = new Vector2(300, 24), MouseFilter = MouseFilterEnum.Pass };
|
||||||
|
content.AddChildSafely(menu);
|
||||||
|
|
||||||
var menu = new Control { Name = "Menu" };
|
var background = new NinePatchRect
|
||||||
content.AddChild(menu);
|
{
|
||||||
|
Name = "Background", MouseFilter = MouseFilterEnum.Ignore,
|
||||||
menu.CustomMinimumSize = new Vector2(300, 24);
|
Texture = GD.Load<CompressedTexture2D>("res://images/ui/tiny_nine_patch.png"), PatchMarginLeft = 12,
|
||||||
|
PatchMarginTop = 12, PatchMarginRight = 12, PatchMarginBottom = 12,
|
||||||
menu.MouseFilter = MouseFilterEnum.Pass;
|
Modulate = new Color(Colors.Black, 0.471f)
|
||||||
|
};
|
||||||
var background = new NinePatchRect { Name = "Background" };
|
|
||||||
menu.AddChild(background);
|
|
||||||
|
|
||||||
background.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
|
menu.AddChildSafely(background);
|
||||||
background.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
background.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
||||||
|
|
||||||
background.Texture = GD.Load<CompressedTexture2D>("res://images/ui/tiny_nine_patch.png");
|
var menuIcon = new TextureRect { Name = "Icon", MouseFilter = MouseFilterEnum.Ignore };
|
||||||
background.PatchMarginLeft = 12;
|
|
||||||
background.PatchMarginTop = 12;
|
|
||||||
background.PatchMarginRight = 12;
|
|
||||||
background.PatchMarginBottom = 12;
|
|
||||||
|
|
||||||
background.Modulate = new Color(Colors.Black, 0.471f);
|
var menuSvgImage = new Image();
|
||||||
|
menuSvgImage.LoadSvgFromString(
|
||||||
var menuIcon = new TextureRect { Name = "Icon" };
|
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#FFFFFF\"><path d=\"M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z\"/></svg>");
|
||||||
menu.AddChild(menuIcon);
|
menuIcon.Texture = ImageTexture.CreateFromImage(menuSvgImage);
|
||||||
|
|
||||||
menuIcon.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
|
menu.AddChildSafely(menuIcon);
|
||||||
menuIcon.SetAnchorsPreset(LayoutPreset.Center);
|
menuIcon.SetAnchorsPreset(LayoutPreset.Center);
|
||||||
menuIcon.OffsetLeft = -12;
|
menuIcon.OffsetLeft = -12;
|
||||||
menuIcon.OffsetTop = -12;
|
menuIcon.OffsetTop = -12;
|
||||||
menuIcon.OffsetRight = 12;
|
menuIcon.OffsetRight = 12;
|
||||||
menuIcon.OffsetBottom = 12;
|
menuIcon.OffsetBottom = 12;
|
||||||
|
|
||||||
var menuSvgImage = new Image();
|
var box = new PanelContainer
|
||||||
|
{ Name = "Box", MouseFilter = MouseFilterEnum.Ignore, Modulate = new Color(Colors.White, 0) };
|
||||||
|
|
||||||
menuSvgImage.LoadSvgFromString(
|
var styleBox = new StyleBoxTexture
|
||||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#FFFFFF\"><path d=\"M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z\"/></svg>");
|
{
|
||||||
|
Texture = GD.Load<CompressedTexture2D>("res://images/ui/tiny_nine_patch.png"), TextureMarginLeft = 12,
|
||||||
menuIcon.Texture = ImageTexture.CreateFromImage(menuSvgImage);
|
TextureMarginTop = 12, TextureMarginRight = 12, TextureMarginBottom = 12, ContentMarginLeft = 12,
|
||||||
|
ContentMarginTop = 12, ContentMarginRight = 12, ContentMarginBottom = 12,
|
||||||
var box = new PanelContainer { Name = "Box" };
|
ModulateColor = new Color(Colors.Black, 0.471f)
|
||||||
content.AddChild(box);
|
};
|
||||||
|
|
||||||
box.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
box.Modulate = new Color(Colors.White, 0);
|
|
||||||
|
|
||||||
var styleBox = new StyleBoxTexture();
|
|
||||||
|
|
||||||
styleBox.Texture = GD.Load<CompressedTexture2D>("res://images/ui/tiny_nine_patch.png");
|
|
||||||
styleBox.TextureMarginLeft = 12;
|
|
||||||
styleBox.TextureMarginTop = 12;
|
|
||||||
styleBox.TextureMarginRight = 12;
|
|
||||||
styleBox.TextureMarginBottom = 12;
|
|
||||||
|
|
||||||
styleBox.ContentMarginLeft = 12;
|
|
||||||
styleBox.ContentMarginTop = 12;
|
|
||||||
styleBox.ContentMarginRight = 12;
|
|
||||||
styleBox.ContentMarginBottom = 12;
|
|
||||||
|
|
||||||
styleBox.ModulateColor = new Color(Colors.Black, 0.471f);
|
|
||||||
|
|
||||||
box.AddThemeStyleboxOverride("panel", styleBox);
|
box.AddThemeStyleboxOverride("panel", styleBox);
|
||||||
|
content.AddChildSafely(box);
|
||||||
|
|
||||||
var container = new VBoxContainer { Name = "Container" };
|
var container = new VBoxContainer
|
||||||
box.AddChild(container);
|
{
|
||||||
|
Name = "Container", MouseFilter = MouseFilterEnum.Ignore, Alignment = BoxContainer.AlignmentMode.Center
|
||||||
container.MouseFilter = MouseFilterEnum.Ignore;
|
};
|
||||||
|
container.AddThemeConstantOverride("separation", 8);
|
||||||
|
box.AddChildSafely(container);
|
||||||
container.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
container.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
||||||
|
|
||||||
container.Alignment = BoxContainer.AlignmentMode.Center;
|
var loading = new Control
|
||||||
|
{ Name = "Loading", CustomMinimumSize = new Vector2(64, 64), MouseFilter = MouseFilterEnum.Ignore };
|
||||||
container.AddThemeConstantOverride("separation", 8);
|
container.AddChildSafely(loading);
|
||||||
|
|
||||||
var loading = new Control { Name = "Loading" };
|
|
||||||
container.AddChild(loading);
|
|
||||||
|
|
||||||
loading.CustomMinimumSize = new Vector2(64, 64);
|
|
||||||
|
|
||||||
loading.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
var loadingIcon = new LoadingIcon();
|
|
||||||
loading.AddChild(loadingIcon);
|
|
||||||
|
|
||||||
loadingIcon.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
|
var loadingIcon = new LoadingIcon { MouseFilter = MouseFilterEnum.Ignore };
|
||||||
|
loading.AddChildSafely(loadingIcon);
|
||||||
loadingIcon.SetAnchorsPreset(LayoutPreset.Center);
|
loadingIcon.SetAnchorsPreset(LayoutPreset.Center);
|
||||||
loadingIcon.OffsetLeft = -32;
|
loadingIcon.OffsetLeft = -32;
|
||||||
loadingIcon.OffsetTop = -32;
|
loadingIcon.OffsetTop = -32;
|
||||||
@@ -157,66 +122,52 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
|
|
||||||
content.SetAnchorsAndOffsetsPreset(LayoutPreset.CenterTop);
|
content.SetAnchorsAndOffsetsPreset(LayoutPreset.CenterTop);
|
||||||
|
|
||||||
var copiedLabel = new CopiedLabel { Name = "CopiedLabel" };
|
var copiedLabel = new CopiedLabel { Name = "CopiedLabel", MouseFilter = MouseFilterEnum.Ignore };
|
||||||
ipAddressInfoPanel.AddChild(copiedLabel);
|
ipAddressInfoPanel.AddChildSafely(copiedLabel);
|
||||||
|
|
||||||
copiedLabel.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
return ipAddressInfoPanel;
|
return ipAddressInfoPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddAddressElement(Node container, string name, string locKeyPrefix, bool isTrim)
|
private static void AddAddressElement(Node container, string name, string locKeyPrefix, bool isTrim)
|
||||||
{
|
{
|
||||||
var addressElement = new HBoxContainer { Name = name };
|
var addressElement = new HBoxContainer
|
||||||
container.AddChild(addressElement);
|
{ Name = name, CustomMinimumSize = new Vector2(0, 24), MouseFilter = MouseFilterEnum.Ignore };
|
||||||
|
|
||||||
addressElement.CustomMinimumSize = new Vector2(0, 24);
|
|
||||||
|
|
||||||
addressElement.Alignment = BoxContainer.AlignmentMode.Center;
|
|
||||||
|
|
||||||
addressElement.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
var ipAddressTitleLabel = new IPAddressLabel { Name = "TitleLabel" };
|
|
||||||
addressElement.AddChild(ipAddressTitleLabel);
|
|
||||||
|
|
||||||
ipAddressTitleLabel.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
|
var ipAddressTitleLabel = new IPAddressLabel { Name = "TitleLabel", MouseFilter = MouseFilterEnum.Ignore };
|
||||||
|
addressElement.AddChildSafely(ipAddressTitleLabel);
|
||||||
ipAddressTitleLabel.SetLocalization(locKeyPrefix);
|
ipAddressTitleLabel.SetLocalization(locKeyPrefix);
|
||||||
|
|
||||||
var ipAddressLabel = new IPAddressLabel { Name = "Label" };
|
var ipAddressLabel = new IPAddressLabel { Name = "Label", MouseFilter = MouseFilterEnum.Ignore };
|
||||||
addressElement.AddChild(ipAddressLabel);
|
|
||||||
|
|
||||||
ipAddressLabel.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
if (isTrim)
|
if (isTrim)
|
||||||
{
|
{
|
||||||
ipAddressLabel.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
ipAddressLabel.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||||
ipAddressLabel.TextOverrunBehavior = TextServer.OverrunBehavior.TrimEllipsis;
|
ipAddressLabel.TextOverrunBehavior = TextServer.OverrunBehavior.TrimEllipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addressElement.AddChildSafely(ipAddressLabel);
|
||||||
|
|
||||||
|
container.AddChildSafely(addressElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddAddressContainer(Node container, string name, string locKeyPrefix)
|
private static void AddAddressContainer(Node container, string name, string locKeyPrefix)
|
||||||
{
|
{
|
||||||
var addressElement = new VBoxContainer { Name = name };
|
var addressElement = new VBoxContainer
|
||||||
container.AddChild(addressElement);
|
{ Name = name, CustomMinimumSize = new Vector2(0, 24), MouseFilter = MouseFilterEnum.Ignore };
|
||||||
|
|
||||||
addressElement.CustomMinimumSize = new Vector2(0, 24);
|
|
||||||
|
|
||||||
addressElement.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
var ipAddressTitleLabel = new IPAddressLabel { Name = "TitleLabel" };
|
|
||||||
addressElement.AddChild(ipAddressTitleLabel);
|
|
||||||
|
|
||||||
ipAddressTitleLabel.HorizontalAlignment = HorizontalAlignment.Center;
|
|
||||||
|
|
||||||
|
var ipAddressTitleLabel = new IPAddressLabel
|
||||||
|
{ Name = "TitleLabel", HorizontalAlignment = HorizontalAlignment.Center };
|
||||||
|
addressElement.AddChildSafely(ipAddressTitleLabel);
|
||||||
ipAddressTitleLabel.SetLocalization(locKeyPrefix);
|
ipAddressTitleLabel.SetLocalization(locKeyPrefix);
|
||||||
|
|
||||||
var vBoxContainer = new VBoxContainer { Name = "Container" };
|
var vBoxContainer = new VBoxContainer
|
||||||
addressElement.AddChild(vBoxContainer);
|
{
|
||||||
|
Name = "Container", MouseFilter = MouseFilterEnum.Ignore, Alignment = BoxContainer.AlignmentMode.Center
|
||||||
|
};
|
||||||
|
|
||||||
vBoxContainer.MouseFilter = MouseFilterEnum.Ignore;
|
addressElement.AddChildSafely(vBoxContainer);
|
||||||
|
|
||||||
vBoxContainer.Alignment = BoxContainer.AlignmentMode.Center;
|
container.AddChildSafely(addressElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@@ -312,7 +263,7 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
|
|
||||||
foreach (var child in _localIPAddressContainer.GetChildren())
|
foreach (var child in _localIPAddressContainer.GetChildren())
|
||||||
{
|
{
|
||||||
child.QueueFree();
|
child.QueueFreeSafely();
|
||||||
}
|
}
|
||||||
|
|
||||||
_loading.Visible = true;
|
_loading.Visible = true;
|
||||||
@@ -344,20 +295,14 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
|
|
||||||
var hasLocalIPAddress = false;
|
var hasLocalIPAddress = false;
|
||||||
|
|
||||||
var localIPAddressList = GetLocalIPAddressList();
|
foreach (var localIPAddress in GetLocalIPAddress())
|
||||||
|
|
||||||
foreach (var localIPAddress in localIPAddressList)
|
|
||||||
{
|
{
|
||||||
if (localIPAddress != ipAddress)
|
if (localIPAddress != ipAddress)
|
||||||
{
|
{
|
||||||
var ipAddressLabel = new IPAddressLabel();
|
var ipAddressLabel = new IPAddressLabel
|
||||||
_localIPAddressContainer.AddChild(ipAddressLabel);
|
{ MouseFilter = MouseFilterEnum.Pass, HorizontalAlignment = HorizontalAlignment.Center };
|
||||||
|
|
||||||
ipAddressLabel.MouseFilter = MouseFilterEnum.Pass;
|
ipAddressLabel.SetTextAutoSize($"{localIPAddress}:{port}");
|
||||||
|
|
||||||
ipAddressLabel.HorizontalAlignment = HorizontalAlignment.Center;
|
|
||||||
|
|
||||||
ipAddressLabel.Text = $"{localIPAddress}:{port}";
|
|
||||||
|
|
||||||
ipAddressLabel.GuiInput += inputEvent =>
|
ipAddressLabel.GuiInput += inputEvent =>
|
||||||
{
|
{
|
||||||
@@ -372,6 +317,8 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_localIPAddressContainer.AddChildSafely(ipAddressLabel);
|
||||||
|
|
||||||
hasLocalIPAddress = true;
|
hasLocalIPAddress = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,10 +349,8 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
_content.SetAnchorsAndOffsetsPreset(LayoutPreset.CenterTop);
|
_content.SetAnchorsAndOffsetsPreset(LayoutPreset.CenterTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<string> GetLocalIPAddressList()
|
private static IEnumerable<string> GetLocalIPAddress()
|
||||||
{
|
{
|
||||||
var list = new List<string>();
|
|
||||||
|
|
||||||
foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces())
|
foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces())
|
||||||
{
|
{
|
||||||
if (networkInterface.OperationalStatus == OperationalStatus.Up &&
|
if (networkInterface.OperationalStatus == OperationalStatus.Up &&
|
||||||
@@ -417,14 +362,10 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
foreach (var ip in networkInterface.GetIPProperties().UnicastAddresses)
|
foreach (var ip in networkInterface.GetIPProperties().UnicastAddresses)
|
||||||
{
|
{
|
||||||
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
|
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||||
{
|
yield return ip.Address.ToString();
|
||||||
list.Add(ip.Address.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMouseEntered()
|
private void OnMouseEntered()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using MegaCrit.Sts2.addons.mega_text;
|
using MegaCrit.Sts2.addons.mega_text;
|
||||||
using MegaCrit.Sts2.Core.ControllerInput;
|
using MegaCrit.Sts2.Core.ControllerInput;
|
||||||
|
using MegaCrit.Sts2.Core.Helpers;
|
||||||
using MegaCrit.Sts2.Core.Localization;
|
using MegaCrit.Sts2.Core.Localization;
|
||||||
using MegaCrit.Sts2.Core.Nodes.Screens.MainMenu;
|
using MegaCrit.Sts2.Core.Nodes.Screens.MainMenu;
|
||||||
|
|
||||||
@@ -12,40 +13,33 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
|
|
||||||
public static JoinButton Create(NJoinFriendRefreshButton joinFriendRefreshButton)
|
public static JoinButton Create(NJoinFriendRefreshButton joinFriendRefreshButton)
|
||||||
{
|
{
|
||||||
var joinButton = new JoinButton();
|
var joinButton = new JoinButton
|
||||||
|
{
|
||||||
|
CustomMinimumSize = new Vector2(150, 50),
|
||||||
|
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
|
||||||
|
MouseFilter = MouseFilterEnum.Stop,
|
||||||
|
Material = (Material)joinFriendRefreshButton.Material.Duplicate()
|
||||||
|
};
|
||||||
|
|
||||||
joinButton.CustomMinimumSize = new Vector2(150, 50);
|
var background = new NinePatchRect
|
||||||
joinButton.SizeFlagsHorizontal = SizeFlags.ShrinkCenter;
|
{
|
||||||
|
Name = "Background", MouseFilter = MouseFilterEnum.Ignore,
|
||||||
joinButton.MouseFilter = MouseFilterEnum.Stop;
|
Texture = GD.Load<CompressedTexture2D>("res://images/ui/tiny_nine_patch.png"), PatchMarginLeft = 12,
|
||||||
|
PatchMarginTop = 12, PatchMarginRight = 12, PatchMarginBottom = 12,
|
||||||
joinButton.Material = joinFriendRefreshButton.Material.Duplicate() as Material;
|
Modulate = joinFriendRefreshButton.SelfModulate,
|
||||||
|
Material = joinButton.Material
|
||||||
var background = new NinePatchRect { Name = "Background" };
|
};
|
||||||
joinButton.AddChild(background);
|
|
||||||
|
|
||||||
background.MouseFilter = MouseFilterEnum.Ignore;
|
|
||||||
|
|
||||||
|
joinButton.AddChildSafely(background);
|
||||||
background.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
background.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
||||||
|
|
||||||
background.Texture = GD.Load<CompressedTexture2D>("res://images/ui/tiny_nine_patch.png");
|
|
||||||
background.PatchMarginLeft = 12;
|
|
||||||
background.PatchMarginTop = 12;
|
|
||||||
background.PatchMarginRight = 12;
|
|
||||||
background.PatchMarginBottom = 12;
|
|
||||||
|
|
||||||
background.Modulate = joinFriendRefreshButton.SelfModulate;
|
|
||||||
background.Material = joinButton.Material;
|
|
||||||
|
|
||||||
foreach (var child in joinFriendRefreshButton.GetChildren())
|
foreach (var child in joinFriendRefreshButton.GetChildren())
|
||||||
{
|
{
|
||||||
joinButton.AddChild(child.Duplicate());
|
joinButton.AddChildSafely(child.Duplicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
var controllerIcon = joinButton.GetNode<TextureRect>("ControllerIcon");
|
var controllerIcon = joinButton.GetNode<TextureRect>("ControllerIcon");
|
||||||
|
|
||||||
controllerIcon.Owner = joinButton;
|
controllerIcon.Owner = joinButton;
|
||||||
|
|
||||||
controllerIcon.Position = new Vector2(controllerIcon.Position.X - 12, controllerIcon.Position.Y);
|
controllerIcon.Position = new Vector2(controllerIcon.Position.X - 12, controllerIcon.Position.Y);
|
||||||
|
|
||||||
return joinButton;
|
return joinButton;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace SlayTheSpire2.LAN.Multiplayer.Components
|
|||||||
child.Reparent(lanMultiplayerHostSubmenu, false);
|
child.Reparent(lanMultiplayerHostSubmenu, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
multiplayerHostSubmenu.QueueFree();
|
multiplayerHostSubmenu.QueueFreeSafely();
|
||||||
|
|
||||||
return lanMultiplayerHostSubmenu;
|
return lanMultiplayerHostSubmenu;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,18 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
{
|
{
|
||||||
private static void Prefix(NJoinFriendScreen __instance)
|
private static void Prefix(NJoinFriendScreen __instance)
|
||||||
{
|
{
|
||||||
var lanPanel = new NinePatchRect { Name = "LANPanel" };
|
var panel = __instance.GetNode<NinePatchRect>("Panel");
|
||||||
__instance.AddChild(lanPanel);
|
|
||||||
|
|
||||||
lanPanel.PatchMarginTop = 12;
|
var lanPanel = new NinePatchRect
|
||||||
lanPanel.PatchMarginBottom = 12;
|
{
|
||||||
lanPanel.PatchMarginLeft = 12;
|
Name = "LANPanel",
|
||||||
lanPanel.PatchMarginRight = 12;
|
Texture = panel.Texture,
|
||||||
|
SelfModulate = panel.SelfModulate,
|
||||||
|
PatchMarginTop = 12,
|
||||||
|
PatchMarginBottom = 12,
|
||||||
|
PatchMarginLeft = 12,
|
||||||
|
PatchMarginRight = 12
|
||||||
|
};
|
||||||
|
|
||||||
lanPanel.SetAnchorsPreset(Control.LayoutPreset.Center);
|
lanPanel.SetAnchorsPreset(Control.LayoutPreset.Center);
|
||||||
lanPanel.OffsetLeft = 450;
|
lanPanel.OffsetLeft = 450;
|
||||||
@@ -32,43 +37,27 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
lanPanel.OffsetRight = 790;
|
lanPanel.OffsetRight = 790;
|
||||||
lanPanel.OffsetBottom = 338;
|
lanPanel.OffsetBottom = 338;
|
||||||
|
|
||||||
if (__instance.GetNode("Panel") is NinePatchRect panel)
|
var vBoxContainer = new VBoxContainer
|
||||||
{
|
{
|
||||||
lanPanel.Texture = panel.Texture;
|
Alignment = BoxContainer.AlignmentMode.Center
|
||||||
lanPanel.SelfModulate = panel.SelfModulate;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
var vBoxContainer = new VBoxContainer();
|
|
||||||
|
|
||||||
lanPanel.AddChild(vBoxContainer);
|
|
||||||
|
|
||||||
vBoxContainer.Alignment = BoxContainer.AlignmentMode.Center;
|
|
||||||
vBoxContainer.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.FullRect);
|
|
||||||
vBoxContainer.AddThemeConstantOverride("separation", 24);
|
vBoxContainer.AddThemeConstantOverride("separation", 24);
|
||||||
|
lanPanel.AddChildSafely(vBoxContainer);
|
||||||
|
vBoxContainer.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.FullRect);
|
||||||
|
|
||||||
if (__instance.GetNode("TitleLabel").Duplicate() is MegaLabel ipAddressLabel)
|
var addressLineEdit = new AddressLineEdit
|
||||||
{
|
{
|
||||||
lanPanel.AddChild(ipAddressLabel);
|
Name = "AddressInput", Text = SettingsService.Instance.SettingsModel.IPAddress,
|
||||||
|
Alignment = HorizontalAlignment.Center, CustomMinimumSize = new Vector2(300, 50),
|
||||||
|
SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter
|
||||||
|
};
|
||||||
|
|
||||||
ipAddressLabel.SetTextAutoSize("LAN IP:");
|
vBoxContainer.AddChildSafely(addressLineEdit);
|
||||||
ipAddressLabel.CustomMinimumSize = new Vector2(300, 0);
|
|
||||||
ipAddressLabel.SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
var addressLineEdit = new AddressLineEdit { Name = "AddressInput" };
|
|
||||||
|
|
||||||
vBoxContainer.AddChild(addressLineEdit);
|
|
||||||
|
|
||||||
addressLineEdit.Text = SettingsService.Instance.SettingsModel.IPAddress;
|
|
||||||
addressLineEdit.Alignment = HorizontalAlignment.Center;
|
|
||||||
addressLineEdit.CustomMinimumSize = new Vector2(300, 50);
|
|
||||||
addressLineEdit.SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter;
|
|
||||||
|
|
||||||
var joinButton = JoinButton.Create(__instance.GetNode<NJoinFriendRefreshButton>("RefreshButton"));
|
var joinButton = JoinButton.Create(__instance.GetNode<NJoinFriendRefreshButton>("RefreshButton"));
|
||||||
|
|
||||||
joinButton.Name = "JointButton";
|
joinButton.Name = "JointButton";
|
||||||
|
vBoxContainer.AddChildSafely(joinButton);
|
||||||
vBoxContainer.AddChild(joinButton);
|
|
||||||
|
|
||||||
joinButton.Connect(NClickableControl.SignalName.Released, Callable.From<NClickableControl>(_ =>
|
joinButton.Connect(NClickableControl.SignalName.Released, Callable.From<NClickableControl>(_ =>
|
||||||
{
|
{
|
||||||
@@ -95,6 +84,14 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
SettingsService.Instance.SettingsModel.NetId, addressInfo.Address, port)));
|
SettingsService.Instance.SettingsModel.NetId, addressInfo.Address, port)));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
var ipAddressLabel = (MegaLabel)__instance.GetNode("TitleLabel").Duplicate();
|
||||||
|
ipAddressLabel.CustomMinimumSize = new Vector2(300, 0);
|
||||||
|
ipAddressLabel.SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter;
|
||||||
|
lanPanel.AddChildSafely(ipAddressLabel);
|
||||||
|
ipAddressLabel.SetTextAutoSize("LAN IP:");
|
||||||
|
|
||||||
|
__instance.AddChildSafely(lanPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,10 +25,8 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
if (lanMultiplayerHostSubmenu != null)
|
if (lanMultiplayerHostSubmenu != null)
|
||||||
{
|
{
|
||||||
lanMultiplayerHostSubmenu.Name = "LANMultiplayerHostSubmenu";
|
lanMultiplayerHostSubmenu.Name = "LANMultiplayerHostSubmenu";
|
||||||
|
|
||||||
__instance.AddChildSafely(lanMultiplayerHostSubmenu);
|
|
||||||
|
|
||||||
lanMultiplayerHostSubmenu.Visible = false;
|
lanMultiplayerHostSubmenu.Visible = false;
|
||||||
|
__instance.AddChildSafely(lanMultiplayerHostSubmenu);
|
||||||
|
|
||||||
__result = lanMultiplayerHostSubmenu;
|
__result = lanMultiplayerHostSubmenu;
|
||||||
|
|
||||||
|
|||||||
+28
-36
@@ -32,62 +32,54 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
|
|
||||||
var disableDrawing = PreloadManager.Cache
|
var disableDrawing = PreloadManager.Cache
|
||||||
.GetScene(SceneHelper.GetScenePath("screens/card_library/card_library_tickbox"))
|
.GetScene(SceneHelper.GetScenePath("screens/card_library/card_library_tickbox"))
|
||||||
.Instantiate<Control>();
|
.Instantiate<NLibraryStatTickbox>();
|
||||||
|
|
||||||
if (disableDrawing is NLibraryStatTickbox cardLibraryTickBox &&
|
disableDrawing.Name = "DisableDrawing";
|
||||||
container.GetNode("MarginContainer") is MarginContainer marginContainer)
|
disableDrawing.SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter;
|
||||||
|
disableDrawing.SetLabel("Disable drawing");
|
||||||
|
|
||||||
|
var marginContainer = (MarginContainer)container.GetNode("MarginContainer");
|
||||||
|
marginContainer.RemoveThemeConstantOverride("margin_top");
|
||||||
|
|
||||||
|
var lanMapDrawingsService = LanMapDrawingsService.Instance;
|
||||||
|
|
||||||
|
container.AddChildSafely(disableDrawing);
|
||||||
|
container.MoveChild(disableDrawing, 0);
|
||||||
|
|
||||||
|
disableDrawing.IsTicked =
|
||||||
|
lanMapDrawingsService.DisableDrawingHashSet.Contains(____player.NetId);
|
||||||
|
|
||||||
|
disableDrawing.Toggled += tickBox =>
|
||||||
{
|
{
|
||||||
disableDrawing.Name = "DisableDrawing";
|
if (NMapScreen.Instance == null)
|
||||||
|
return;
|
||||||
|
|
||||||
container.AddChild(cardLibraryTickBox);
|
var drawingState = GetDrawingStateForPlayer(NMapScreen.Instance.Drawings, ____player.NetId);
|
||||||
container.MoveChild(cardLibraryTickBox, 0);
|
|
||||||
|
|
||||||
marginContainer.RemoveThemeConstantOverride("margin_top");
|
var drawViewport = Traverse.Create(drawingState).Field("drawViewport").GetValue<SubViewport>();
|
||||||
|
|
||||||
cardLibraryTickBox.SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter;
|
if (drawViewport != null)
|
||||||
|
|
||||||
cardLibraryTickBox.SetLabel("Disable drawing");
|
|
||||||
|
|
||||||
var lanMapDrawingsService = LanMapDrawingsService.Instance;
|
|
||||||
|
|
||||||
cardLibraryTickBox.IsTicked =
|
|
||||||
lanMapDrawingsService.DisableDrawingHashSet.Contains(____player.NetId);
|
|
||||||
|
|
||||||
cardLibraryTickBox.Toggled += tickBox =>
|
|
||||||
{
|
{
|
||||||
if (NMapScreen.Instance == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var drawingState = GetDrawingStateForPlayer(NMapScreen.Instance.Drawings, ____player.NetId);
|
|
||||||
|
|
||||||
var drawViewport = Traverse.Create(drawingState).Field("drawViewport").GetValue<SubViewport>();
|
|
||||||
|
|
||||||
if (tickBox.IsTicked)
|
if (tickBox.IsTicked)
|
||||||
{
|
{
|
||||||
if (drawViewport != null)
|
foreach (var line2D in drawViewport.GetChildren().OfType<Line2D>())
|
||||||
{
|
{
|
||||||
foreach (var line2D in drawViewport.GetChildren().OfType<Line2D>())
|
line2D.Visible = false;
|
||||||
{
|
|
||||||
line2D.Visible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lanMapDrawingsService.DisableDrawingHashSet.Add(____player.NetId);
|
lanMapDrawingsService.DisableDrawingHashSet.Add(____player.NetId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (drawViewport != null)
|
foreach (var line2D in drawViewport.GetChildren().OfType<Line2D>())
|
||||||
{
|
{
|
||||||
foreach (var line2D in drawViewport.GetChildren().OfType<Line2D>())
|
line2D.Visible = true;
|
||||||
{
|
|
||||||
line2D.Visible = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lanMapDrawingsService.DisableDrawingHashSet.Remove(____player.NetId);
|
lanMapDrawingsService.DisableDrawingHashSet.Remove(____player.NetId);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,90 +29,93 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
{
|
{
|
||||||
var buttonContainerNode = __instance.GetNode("ButtonContainer");
|
var buttonContainerNode = __instance.GetNode("ButtonContainer");
|
||||||
|
|
||||||
if (buttonContainerNode.GetNode("HostButton").Duplicate() is NSubmenuButton lanHostButton)
|
var lanHostButton = (NSubmenuButton)buttonContainerNode.GetNode("HostButton").Duplicate();
|
||||||
{
|
|
||||||
NSubmenuButtonDuplicateMaterial(lanHostButton);
|
|
||||||
|
|
||||||
buttonContainerNode.AddChild(lanHostButton);
|
NSubmenuButtonDuplicateMaterial(lanHostButton);
|
||||||
buttonContainerNode.MoveChild(lanHostButton, 1);
|
|
||||||
|
|
||||||
lanHostButton.Connect(NClickableControl.SignalName.Released,
|
buttonContainerNode.AddChildSafely(lanHostButton);
|
||||||
Callable.From<NButton>(_ =>
|
buttonContainerNode.MoveChild(lanHostButton, 1);
|
||||||
|
|
||||||
|
lanHostButton.SetIconAndLocalization("HOST");
|
||||||
|
|
||||||
|
var lanHostTitle = Traverse.Create(lanHostButton).Field("_title").GetValue<MegaLabel>();
|
||||||
|
lanHostTitle.SetTextAutoSize($"LAN {lanHostTitle.Text}");
|
||||||
|
|
||||||
|
lanHostButton.Connect(NClickableControl.SignalName.Released,
|
||||||
|
Callable.From<NButton>(_ =>
|
||||||
|
{
|
||||||
|
var traverse = Traverse.Create(__instance);
|
||||||
|
|
||||||
|
var settingsModel = SettingsService.Instance.SettingsModel;
|
||||||
|
|
||||||
|
var stack = traverse.Field("_stack").GetValue<NSubmenuStack>();
|
||||||
|
|
||||||
|
if (SaveManager.Instance.Progress.NumberOfRuns > 0)
|
||||||
{
|
{
|
||||||
var traverse = Traverse.Create(__instance);
|
stack.PushSubmenuType<LanMultiplayerHostSubmenu>();
|
||||||
|
}
|
||||||
var settingsModel = SettingsService.Instance.SettingsModel;
|
else
|
||||||
|
|
||||||
var stack = traverse.Field("_stack").GetValue<NSubmenuStack>();
|
|
||||||
|
|
||||||
if (SaveManager.Instance.Progress.NumberOfRuns > 0)
|
|
||||||
{
|
|
||||||
stack.PushSubmenuType<LanMultiplayerHostSubmenu>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LanHostHelper.StartHost(GameMode.Standard,
|
|
||||||
traverse.Field("_loadingOverlay").GetValue<Control>(), stack, settingsModel.HostPort,
|
|
||||||
settingsModel.HostMaxPlayers);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
lanHostButton.SetIconAndLocalization("HOST");
|
|
||||||
var lanHostTitle = Traverse.Create(lanHostButton).Field("_title").GetValue<MegaLabel>();
|
|
||||||
lanHostTitle.Text = $"LAN {lanHostTitle.Text}";
|
|
||||||
|
|
||||||
LanMultiplayerSubmenuButtonService.Instance.LanHostButton = lanHostButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buttonContainerNode.GetNode("LoadButton").Duplicate() is NSubmenuButton lanLoadButton)
|
|
||||||
{
|
|
||||||
NSubmenuButtonDuplicateMaterial(lanLoadButton);
|
|
||||||
|
|
||||||
buttonContainerNode.AddChild(lanLoadButton);
|
|
||||||
buttonContainerNode.MoveChild(lanLoadButton, 2);
|
|
||||||
|
|
||||||
lanLoadButton.Connect(NClickableControl.SignalName.Released,
|
|
||||||
Callable.From<NButton>(_ =>
|
|
||||||
{
|
{
|
||||||
var traverse = Traverse.Create(__instance);
|
LanHostHelper.StartHost(GameMode.Standard,
|
||||||
|
traverse.Field("_loadingOverlay").GetValue<Control>(), stack, settingsModel.HostPort,
|
||||||
|
settingsModel.HostMaxPlayers);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
var settingsModel = SettingsService.Instance.SettingsModel;
|
LanMultiplayerSubmenuButtonService.Instance.LanHostButton = lanHostButton;
|
||||||
|
|
||||||
LanHostHelper.StartLoad(lanLoadButton, traverse.Field("_loadingOverlay").GetValue<Control>(),
|
var lanLoadButton = (NSubmenuButton)buttonContainerNode.GetNode("LoadButton").Duplicate();
|
||||||
traverse.Field("_stack").GetValue<NSubmenuStack>(),
|
|
||||||
settingsModel.HostPort, settingsModel.HostMaxPlayers);
|
|
||||||
}));
|
|
||||||
lanLoadButton.SetIconAndLocalization("MP_LOAD");
|
|
||||||
var lanLoadButtonTitle = Traverse.Create(lanLoadButton).Field("_title").GetValue<MegaLabel>();
|
|
||||||
lanLoadButtonTitle.Text = $"LAN {lanLoadButtonTitle.Text}";
|
|
||||||
|
|
||||||
LanMultiplayerSubmenuButtonService.Instance.LanLoadButton = lanLoadButton;
|
NSubmenuButtonDuplicateMaterial(lanLoadButton);
|
||||||
}
|
|
||||||
|
|
||||||
if (buttonContainerNode.GetNode("AbandonButton").Duplicate() is NSubmenuButton lanAbandonButton)
|
buttonContainerNode.AddChildSafely(lanLoadButton);
|
||||||
{
|
buttonContainerNode.MoveChild(lanLoadButton, 2);
|
||||||
NSubmenuButtonDuplicateMaterial(lanAbandonButton);
|
|
||||||
|
|
||||||
buttonContainerNode.AddChild(lanAbandonButton);
|
lanLoadButton.SetIconAndLocalization("MP_LOAD");
|
||||||
buttonContainerNode.MoveChild(lanAbandonButton, 3);
|
|
||||||
|
|
||||||
lanAbandonButton.Connect(NClickableControl.SignalName.Released,
|
var lanLoadButtonTitle = Traverse.Create(lanLoadButton).Field("_title").GetValue<MegaLabel>();
|
||||||
Callable.From<NButton>(_ =>
|
lanLoadButtonTitle.SetTextAutoSize($"LAN {lanLoadButtonTitle.Text}");
|
||||||
{
|
|
||||||
TaskHelper.RunSafely(
|
|
||||||
LanHostHelper.TryAbandonMultiplayerRun(() => UpdateButtons(__instance)));
|
|
||||||
}));
|
|
||||||
lanAbandonButton.SetIconAndLocalization("MP_ABANDON");
|
|
||||||
var lanAbandonButtonTitle = Traverse.Create(lanAbandonButton).Field("_title").GetValue<MegaLabel>();
|
|
||||||
lanAbandonButtonTitle.Text = $"LAN {lanAbandonButtonTitle.Text}";
|
|
||||||
|
|
||||||
LanMultiplayerSubmenuButtonService.Instance.LanAbandonButton = lanAbandonButton;
|
lanLoadButton.Connect(NClickableControl.SignalName.Released,
|
||||||
}
|
Callable.From<NButton>(_ =>
|
||||||
|
{
|
||||||
|
var traverse = Traverse.Create(__instance);
|
||||||
|
|
||||||
|
var settingsModel = SettingsService.Instance.SettingsModel;
|
||||||
|
|
||||||
|
LanHostHelper.StartLoad(lanLoadButton, traverse.Field("_loadingOverlay").GetValue<Control>(),
|
||||||
|
traverse.Field("_stack").GetValue<NSubmenuStack>(),
|
||||||
|
settingsModel.HostPort, settingsModel.HostMaxPlayers);
|
||||||
|
}));
|
||||||
|
|
||||||
|
LanMultiplayerSubmenuButtonService.Instance.LanLoadButton = lanLoadButton;
|
||||||
|
|
||||||
|
var lanAbandonButton = (NSubmenuButton)buttonContainerNode.GetNode("AbandonButton").Duplicate();
|
||||||
|
|
||||||
|
NSubmenuButtonDuplicateMaterial(lanAbandonButton);
|
||||||
|
|
||||||
|
buttonContainerNode.AddChildSafely(lanAbandonButton);
|
||||||
|
buttonContainerNode.MoveChild(lanAbandonButton, 3);
|
||||||
|
|
||||||
|
lanAbandonButton.SetIconAndLocalization("MP_ABANDON");
|
||||||
|
|
||||||
|
var lanAbandonButtonTitle = Traverse.Create(lanAbandonButton).Field("_title").GetValue<MegaLabel>();
|
||||||
|
lanAbandonButtonTitle.SetTextAutoSize($"LAN {lanAbandonButtonTitle.Text}");
|
||||||
|
|
||||||
|
lanAbandonButton.Connect(NClickableControl.SignalName.Released,
|
||||||
|
Callable.From<NButton>(_ =>
|
||||||
|
{
|
||||||
|
TaskHelper.RunSafely(
|
||||||
|
LanHostHelper.TryAbandonMultiplayerRun(() => UpdateButtons(__instance)));
|
||||||
|
}));
|
||||||
|
|
||||||
|
LanMultiplayerSubmenuButtonService.Instance.LanAbandonButton = lanAbandonButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void NSubmenuButtonDuplicateMaterial(NSubmenuButton nSubmenuButton)
|
private static void NSubmenuButtonDuplicateMaterial(NSubmenuButton nSubmenuButton)
|
||||||
{
|
{
|
||||||
var bgPanel = nSubmenuButton.GetNode<Control>("BgPanel");
|
var bgPanel = nSubmenuButton.GetNode<Control>("BgPanel");
|
||||||
bgPanel.Material = bgPanel.Material.Duplicate() as Material;
|
bgPanel.Material = (Material)bgPanel.Material.Duplicate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using MegaCrit.Sts2.Core.Helpers;
|
||||||
using MegaCrit.Sts2.Core.Nodes.Rooms;
|
using MegaCrit.Sts2.Core.Nodes.Rooms;
|
||||||
using MegaCrit.Sts2.Core.Runs;
|
using MegaCrit.Sts2.Core.Runs;
|
||||||
|
using Control = Godot.Control;
|
||||||
|
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable UnusedType.Global
|
// ReSharper disable UnusedType.Global
|
||||||
@@ -18,11 +20,11 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
{
|
{
|
||||||
var bgContainer = __instance.GetNode("BgContainer");
|
var bgContainer = __instance.GetNode("BgContainer");
|
||||||
|
|
||||||
var lastLeftCharacterUp = bgContainer.GetNode("Character_3");
|
var lastLeftCharacterUp = (Control)bgContainer.GetNode("Character_3");
|
||||||
var lastLeftCharacterDown = bgContainer.GetNode("Character_1");
|
var lastLeftCharacterDown = (Control)bgContainer.GetNode("Character_1");
|
||||||
|
|
||||||
var lastRightCharacterUp = bgContainer.GetNode("Character_4");
|
var lastRightCharacterUp = (Control)bgContainer.GetNode("Character_4");
|
||||||
var lastRightCharacterDown = bgContainer.GetNode("Character_2");
|
var lastRightCharacterDown = (Control)bgContainer.GetNode("Character_2");
|
||||||
|
|
||||||
for (var i = 4; i < ____runState.Players.Count; i++)
|
for (var i = 4; i < ____runState.Players.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -59,8 +61,8 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
var bgContainer = __instance.GetNode("BgContainer");
|
var bgContainer = __instance.GetNode("BgContainer");
|
||||||
var restSiteBackground = bgContainer.GetChild(0);
|
var restSiteBackground = bgContainer.GetChild(0);
|
||||||
|
|
||||||
var lastLeftRestSite = restSiteBackground.GetNode("RestSiteLLog");
|
var lastLeftRestSite = (Control)restSiteBackground.GetNode("RestSiteLLog");
|
||||||
var lastRightRestSite = restSiteBackground.GetNode("RestSiteRLog");
|
var lastRightRestSite = (Control)restSiteBackground.GetNode("RestSiteRLog");
|
||||||
|
|
||||||
for (var i = 4; i < ____runState.Players.Count; i++)
|
for (var i = 4; i < ____runState.Players.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -76,36 +78,32 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddRestSite(Node restSiteBackground, ref Node restSite, bool isLeft)
|
private static void AddRestSite(Node restSiteBackground, ref Control restSite, bool isLeft)
|
||||||
{
|
{
|
||||||
var nextRestSiteIndex = restSite.GetIndex() + 1;
|
var nextRestSiteIndex = restSite.GetIndex() + 1;
|
||||||
restSite = restSite.Duplicate();
|
|
||||||
restSiteBackground.AddChild(restSite);
|
|
||||||
restSite.MoveChild(restSite, nextRestSiteIndex);
|
|
||||||
|
|
||||||
if (restSite is Control control)
|
restSite = (Control)restSite.Duplicate();
|
||||||
{
|
|
||||||
control.Position = new Vector2(isLeft ? control.Position.X - 200 : control.Position.X + 200,
|
restSite.Position = new Vector2(isLeft ? restSite.Position.X - 200 : restSite.Position.X + 200,
|
||||||
control.Position.Y - 50);
|
restSite.Position.Y - 50);
|
||||||
}
|
|
||||||
|
restSiteBackground.AddChildSafely(restSite);
|
||||||
|
restSite.MoveChild(restSite, nextRestSiteIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddCharacter(Node bgContainer, ref Node character, List<Control> characterContainers,
|
private static void AddCharacter(Node bgContainer, ref Control character, List<Control> characterContainers,
|
||||||
int index, bool isLeft)
|
int index, bool isLeft)
|
||||||
{
|
{
|
||||||
var nextCharacterIndex = character.GetIndex() + 1;
|
var nextCharacterIndex = character.GetIndex() + 1;
|
||||||
character = character.Duplicate();
|
|
||||||
bgContainer.AddChild(character);
|
character = (Control)character.Duplicate();
|
||||||
|
character.Name = $"Character_{index + 1}";
|
||||||
|
bgContainer.AddChildSafely(character);
|
||||||
bgContainer.MoveChild(character, nextCharacterIndex);
|
bgContainer.MoveChild(character, nextCharacterIndex);
|
||||||
|
character.Position = new Vector2(isLeft ? character.Position.X - 200 : character.Position.X + 200,
|
||||||
|
character.Position.Y - 50);
|
||||||
|
|
||||||
if (character is Control control)
|
characterContainers.Add(character);
|
||||||
{
|
|
||||||
control.Name = $"Character_{index + 1}";
|
|
||||||
control.Position = new Vector2(isLeft ? control.Position.X - 200 : control.Position.X + 200,
|
|
||||||
control.Position.Y - 50);
|
|
||||||
|
|
||||||
characterContainers.Add(control);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using MegaCrit.Sts2.addons.mega_text;
|
using MegaCrit.Sts2.addons.mega_text;
|
||||||
|
using MegaCrit.Sts2.Core.Helpers;
|
||||||
using MegaCrit.Sts2.Core.Localization;
|
using MegaCrit.Sts2.Core.Localization;
|
||||||
using MegaCrit.Sts2.Core.Nodes.Screens.Settings;
|
using MegaCrit.Sts2.Core.Nodes.Screens.Settings;
|
||||||
using SlayTheSpire2.LAN.Multiplayer.Components;
|
using SlayTheSpire2.LAN.Multiplayer.Components;
|
||||||
@@ -26,178 +27,150 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
var moddingNode = __instance.GetNode("%Modding");
|
var moddingNode = __instance.GetNode("%Modding");
|
||||||
|
|
||||||
var vBoxContainerNode = moddingNode.GetParent();
|
var vBoxContainerNode = moddingNode.GetParent();
|
||||||
var generalSettings = vBoxContainerNode.GetParent();
|
|
||||||
|
|
||||||
if (__instance.GetNode("%ModdingDivider").Duplicate() is ColorRect hostPortDivider &&
|
var hostPortDivider = (ColorRect)__instance.GetNode("%ModdingDivider").Duplicate();
|
||||||
moddingNode.Duplicate() is MarginContainer hostPort &&
|
hostPortDivider.Name = "HostPortDivider";
|
||||||
hostPort.GetNode("Label") is MegaRichTextLabel hostPortLabel)
|
hostPortDivider.Visible = true;
|
||||||
|
vBoxContainerNode.AddChildSafely(hostPortDivider);
|
||||||
|
vBoxContainerNode.MoveChild(hostPortDivider, moddingNode.GetIndex() + 1);
|
||||||
|
|
||||||
|
var hostPort = (MarginContainer)moddingNode.Duplicate();
|
||||||
|
hostPort.Name = "HostPort";
|
||||||
|
hostPort.RemoveChildSafely(hostPort.GetNode("ModdingButton"));
|
||||||
|
hostPort.Visible = true;
|
||||||
|
|
||||||
|
var hostPortLineEdit = new SpinBox
|
||||||
{
|
{
|
||||||
hostPortDivider.Name = "HostPortDivider";
|
Name = "HostPortInput", CustomMinimumSize = new Vector2(324, 64),
|
||||||
|
SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd, Step = 1, MinValue = 0, MaxValue = 65535
|
||||||
|
};
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(hostPortDivider);
|
hostPortLineEdit.GetLineEdit().Alignment = HorizontalAlignment.Center;
|
||||||
vBoxContainerNode.MoveChild(hostPortDivider, moddingNode.GetIndex() + 1);
|
hostPort.AddChildSafely(hostPortLineEdit);
|
||||||
|
|
||||||
hostPortDivider.Show();
|
hostPortLineEdit.Value = SettingsService.Instance.SettingsModel.HostPort;
|
||||||
|
hostPortLineEdit.ValueChanged += value =>
|
||||||
|
{
|
||||||
|
SettingsService.Instance.SettingsModel.HostPort = (ushort)value;
|
||||||
|
SettingsService.Instance.WriteSettings();
|
||||||
|
};
|
||||||
|
|
||||||
hostPort.Name = "HostPort";
|
vBoxContainerNode.AddChildSafely(hostPort);
|
||||||
|
vBoxContainerNode.MoveChild(hostPort, hostPortDivider.GetIndex() + 1);
|
||||||
|
|
||||||
hostPort.RemoveChild(hostPort.GetNode("ModdingButton"));
|
var hostPortLabel = (MegaRichTextLabel)hostPort.GetNode("Label");
|
||||||
|
hostPortLabel.SetTextAutoSize("Host Port");
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(hostPort);
|
var hostMaxPlayersDivider = (ColorRect)__instance.GetNode("%ModdingDivider").Duplicate();
|
||||||
vBoxContainerNode.MoveChild(hostPort, hostPortDivider.GetIndex() + 1);
|
hostMaxPlayersDivider.Name = "HostMaxPlayersDivider";
|
||||||
|
hostMaxPlayersDivider.Visible = true;
|
||||||
|
vBoxContainerNode.AddChildSafely(hostMaxPlayersDivider);
|
||||||
|
vBoxContainerNode.MoveChild(hostMaxPlayersDivider, moddingNode.GetIndex() + 1);
|
||||||
|
|
||||||
hostPort.Show();
|
var hostMaxPlayers = (MarginContainer)moddingNode.Duplicate();
|
||||||
|
hostMaxPlayers.Name = "HostMaxPlayers";
|
||||||
|
hostMaxPlayers.RemoveChildSafely(hostMaxPlayers.GetNode("ModdingButton"));
|
||||||
|
hostMaxPlayers.Visible = true;
|
||||||
|
|
||||||
var hostPortLineEdit = new SpinBox { Name = "HostPortInput" };
|
var hostMaxPlayersInput = new SpinBox
|
||||||
hostPort.AddChild(hostPortLineEdit);
|
{
|
||||||
|
Name = "HostMaxPlayersInput", CustomMinimumSize = new Vector2(324, 64),
|
||||||
|
SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd, Step = 1, MinValue = 2,
|
||||||
|
};
|
||||||
|
|
||||||
hostPortLineEdit.CustomMinimumSize = new Vector2(324, 64);
|
hostMaxPlayersInput.GetLineEdit().Alignment = HorizontalAlignment.Center;
|
||||||
hostPortLineEdit.SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd;
|
hostMaxPlayers.AddChildSafely(hostMaxPlayersInput);
|
||||||
hostPortLineEdit.GetLineEdit().Alignment = HorizontalAlignment.Center;
|
|
||||||
|
|
||||||
hostPortLineEdit.Step = 1;
|
hostMaxPlayersInput.Value = SettingsService.Instance.SettingsModel.HostMaxPlayers;
|
||||||
hostPortLineEdit.MinValue = 0;
|
hostMaxPlayersInput.ValueChanged += value =>
|
||||||
hostPortLineEdit.MaxValue = 65535;
|
{
|
||||||
hostPortLineEdit.Value = SettingsService.Instance.SettingsModel.HostPort;
|
SettingsService.Instance.SettingsModel.HostMaxPlayers = (int)value;
|
||||||
hostPortLineEdit.ValueChanged += value =>
|
SettingsService.Instance.WriteSettings();
|
||||||
|
};
|
||||||
|
|
||||||
|
vBoxContainerNode.AddChildSafely(hostMaxPlayers);
|
||||||
|
vBoxContainerNode.MoveChild(hostMaxPlayers, hostMaxPlayersDivider.GetIndex() + 1);
|
||||||
|
|
||||||
|
var hostMaxPlayersLabel = (MegaRichTextLabel)hostMaxPlayers.GetNode("Label");
|
||||||
|
hostMaxPlayersLabel.SetTextAutoSize("Host Max Players");
|
||||||
|
|
||||||
|
var playerNameDivider = (ColorRect)__instance.GetNode("%ModdingDivider").Duplicate();
|
||||||
|
playerNameDivider.Name = "PlayerNameDivider";
|
||||||
|
playerNameDivider.Visible = true;
|
||||||
|
vBoxContainerNode.AddChildSafely(playerNameDivider);
|
||||||
|
vBoxContainerNode.MoveChild(playerNameDivider, moddingNode.GetIndex() + 1);
|
||||||
|
|
||||||
|
var playerName = (MarginContainer)moddingNode.Duplicate();
|
||||||
|
playerName.Name = "PlayerName";
|
||||||
|
playerName.RemoveChildSafely(playerName.GetNode("ModdingButton"));
|
||||||
|
playerName.Visible = true;
|
||||||
|
|
||||||
|
var marginContainer = new MarginContainer();
|
||||||
|
playerName.AddChildSafely(marginContainer);
|
||||||
|
|
||||||
|
marginContainer.AddThemeConstantOverride("margin_right", 18);
|
||||||
|
|
||||||
|
var playerNameInput = new PlayerNameLineEdit
|
||||||
|
{
|
||||||
|
Name = "PlayerNameInput", CustomMinimumSize = new Vector2(308, 64),
|
||||||
|
SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd, Alignment = HorizontalAlignment.Center,
|
||||||
|
MaxLength = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
marginContainer.AddChildSafely(playerNameInput);
|
||||||
|
|
||||||
|
playerNameInput.Text = SettingsService.Instance.SettingsModel.PlayerName;
|
||||||
|
playerNameInput.TextChanged += value =>
|
||||||
|
{
|
||||||
|
if (playerNameInput.IsEmpty || !playerNameInput.IsInvalid)
|
||||||
{
|
{
|
||||||
SettingsService.Instance.SettingsModel.HostPort = (ushort)value;
|
SettingsService.Instance.SettingsModel.PlayerName = value;
|
||||||
|
LanPlayerNameService.Instance.SetHostPlayerName();
|
||||||
SettingsService.Instance.WriteSettings();
|
SettingsService.Instance.WriteSettings();
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
hostPortLabel.Text = "Host Port";
|
vBoxContainerNode.AddChildSafely(playerName);
|
||||||
}
|
vBoxContainerNode.MoveChild(playerName, playerNameDivider.GetIndex() + 1);
|
||||||
|
|
||||||
if (__instance.GetNode("%ModdingDivider").Duplicate() is ColorRect hostMaxPlayersDivider &&
|
var playerNameLabel = (MegaRichTextLabel)playerName.GetNode("Label");
|
||||||
moddingNode.Duplicate() is MarginContainer hostMaxPlayers &&
|
playerNameLabel.SetTextAutoSize("Player Name");
|
||||||
hostMaxPlayers.GetNode("Label") is MegaRichTextLabel hostMaxPlayersLabel)
|
|
||||||
|
var netIdDivider = (ColorRect)__instance.GetNode("%ModdingDivider").Duplicate();
|
||||||
|
netIdDivider.Name = "NetIDDivider";
|
||||||
|
netIdDivider.Visible = true;
|
||||||
|
vBoxContainerNode.AddChildSafely(netIdDivider);
|
||||||
|
vBoxContainerNode.MoveChild(netIdDivider, moddingNode.GetIndex() + 1);
|
||||||
|
|
||||||
|
var netId = (MarginContainer)moddingNode.Duplicate();
|
||||||
|
netId.Name = "NetID";
|
||||||
|
netId.RemoveChildSafely(netId.GetNode("ModdingButton"));
|
||||||
|
netId.Visible = true;
|
||||||
|
|
||||||
|
var netIdInput = new SpinBox
|
||||||
{
|
{
|
||||||
hostMaxPlayersDivider.Name = "HostMaxPlayersDivider";
|
Name = "NetIDInput", CustomMinimumSize = new Vector2(324, 64),
|
||||||
|
SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd, Step = 1, MinValue = 2, MaxValue = ulong.MaxValue
|
||||||
|
};
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(hostMaxPlayersDivider);
|
netIdInput.GetLineEdit().Alignment = HorizontalAlignment.Center;
|
||||||
vBoxContainerNode.MoveChild(hostMaxPlayersDivider, moddingNode.GetIndex() + 1);
|
netId.AddChildSafely(netIdInput);
|
||||||
|
|
||||||
hostMaxPlayersDivider.Show();
|
netIdInput.Value = SettingsService.Instance.SettingsModel.NetId;
|
||||||
|
netIdInput.ValueChanged += value =>
|
||||||
hostMaxPlayers.Name = "HostMaxPlayers";
|
|
||||||
|
|
||||||
hostMaxPlayers.RemoveChild(hostMaxPlayers.GetNode("ModdingButton"));
|
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(hostMaxPlayers);
|
|
||||||
vBoxContainerNode.MoveChild(hostMaxPlayers, hostMaxPlayersDivider.GetIndex() + 1);
|
|
||||||
|
|
||||||
hostMaxPlayers.Show();
|
|
||||||
|
|
||||||
var hostMaxPlayersInput = new SpinBox { Name = "HostMaxPlayersInput" };
|
|
||||||
hostMaxPlayers.AddChild(hostMaxPlayersInput);
|
|
||||||
|
|
||||||
hostMaxPlayersInput.CustomMinimumSize = new Vector2(324, 64);
|
|
||||||
hostMaxPlayersInput.SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd;
|
|
||||||
hostMaxPlayersInput.GetLineEdit().Alignment = HorizontalAlignment.Center;
|
|
||||||
|
|
||||||
hostMaxPlayersInput.Step = 1;
|
|
||||||
hostMaxPlayersInput.MinValue = 2;
|
|
||||||
hostMaxPlayersInput.Value = SettingsService.Instance.SettingsModel.HostMaxPlayers;
|
|
||||||
hostMaxPlayersInput.ValueChanged += value =>
|
|
||||||
{
|
|
||||||
SettingsService.Instance.SettingsModel.HostMaxPlayers = (int)value;
|
|
||||||
SettingsService.Instance.WriteSettings();
|
|
||||||
};
|
|
||||||
|
|
||||||
hostMaxPlayersLabel.Text = "Host Max Players";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__instance.GetNode("%ModdingDivider").Duplicate() is ColorRect playerNameDivider &&
|
|
||||||
moddingNode.Duplicate() is MarginContainer playerName &&
|
|
||||||
playerName.GetNode("Label") is MegaRichTextLabel playerNameLabel)
|
|
||||||
{
|
{
|
||||||
playerNameDivider.Name = "PlayerNameDivider";
|
SettingsService.Instance.SettingsModel.NetId = (ulong)value;
|
||||||
|
SettingsService.Instance.WriteSettings();
|
||||||
|
};
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(playerNameDivider);
|
var netIdLabel = (MegaRichTextLabel)netId.GetNode("Label");
|
||||||
vBoxContainerNode.MoveChild(playerNameDivider, moddingNode.GetIndex() + 1);
|
netIdLabel.SetTextAutoSize("NetID");
|
||||||
|
|
||||||
playerNameDivider.Show();
|
vBoxContainerNode.AddChildSafely(netId);
|
||||||
|
vBoxContainerNode.MoveChild(netId, netIdDivider.GetIndex() + 1);
|
||||||
|
|
||||||
playerName.Name = "PlayerName";
|
var generalSettings = (NSettingsPanel)vBoxContainerNode.GetParent();
|
||||||
|
RefreshSize(generalSettings);
|
||||||
playerName.RemoveChild(playerName.GetNode("ModdingButton"));
|
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(playerName);
|
|
||||||
vBoxContainerNode.MoveChild(playerName, playerNameDivider.GetIndex() + 1);
|
|
||||||
|
|
||||||
playerName.Show();
|
|
||||||
|
|
||||||
var marginContainer = new MarginContainer();
|
|
||||||
playerName.AddChild(marginContainer);
|
|
||||||
|
|
||||||
marginContainer.AddThemeConstantOverride("margin_right", 18);
|
|
||||||
|
|
||||||
var playerNameInput = new PlayerNameLineEdit { Name = "PlayerNameInput" };
|
|
||||||
marginContainer.AddChild(playerNameInput);
|
|
||||||
|
|
||||||
playerNameInput.CustomMinimumSize = new Vector2(308, 64);
|
|
||||||
playerNameInput.SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd;
|
|
||||||
playerNameInput.Alignment = HorizontalAlignment.Center;
|
|
||||||
|
|
||||||
playerNameInput.MaxLength = 16;
|
|
||||||
playerNameInput.Text = SettingsService.Instance.SettingsModel.PlayerName;
|
|
||||||
playerNameInput.TextChanged += value =>
|
|
||||||
{
|
|
||||||
if (playerNameInput.IsEmpty || !playerNameInput.IsInvalid)
|
|
||||||
{
|
|
||||||
SettingsService.Instance.SettingsModel.PlayerName = value;
|
|
||||||
LanPlayerNameService.Instance.SetHostPlayerName();
|
|
||||||
SettingsService.Instance.WriteSettings();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
playerNameLabel.Text = "Player Name";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__instance.GetNode("%ModdingDivider").Duplicate() is ColorRect netIdDivider &&
|
|
||||||
moddingNode.Duplicate() is MarginContainer netId &&
|
|
||||||
netId.GetNode("Label") is MegaRichTextLabel netIdLabel)
|
|
||||||
{
|
|
||||||
netIdDivider.Name = "NetIDDivider";
|
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(netIdDivider);
|
|
||||||
vBoxContainerNode.MoveChild(netIdDivider, moddingNode.GetIndex() + 1);
|
|
||||||
|
|
||||||
netIdDivider.Show();
|
|
||||||
|
|
||||||
netId.Name = "NetID";
|
|
||||||
|
|
||||||
netId.RemoveChild(netId.GetNode("ModdingButton"));
|
|
||||||
|
|
||||||
vBoxContainerNode.AddChild(netId);
|
|
||||||
vBoxContainerNode.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 = ulong.MaxValue;
|
|
||||||
netIdInput.Value = SettingsService.Instance.SettingsModel.NetId;
|
|
||||||
netIdInput.ValueChanged += value =>
|
|
||||||
{
|
|
||||||
SettingsService.Instance.SettingsModel.NetId = (ulong)value;
|
|
||||||
SettingsService.Instance.WriteSettings();
|
|
||||||
};
|
|
||||||
|
|
||||||
netIdLabel.Text = "NetID";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (generalSettings is NSettingsPanel nSettingsPanel)
|
|
||||||
{
|
|
||||||
RefreshSize(nSettingsPanel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,9 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
|
|
||||||
for (var i = 4; i < runState.Players.Count; i++)
|
for (var i = 4; i < runState.Players.Count; i++)
|
||||||
{
|
{
|
||||||
var newMultiplayerRelicHolder = multiplayerRelicHolder.Duplicate();
|
var nTreasureRoomRelicHolder = (NTreasureRoomRelicHolder)multiplayerRelicHolder.Duplicate();
|
||||||
container.AddChild(newMultiplayerRelicHolder);
|
nTreasureRoomRelicHolder.Name = $"MultiplayerRelicHolder{i + 1}";
|
||||||
|
container.AddChildSafely(nTreasureRoomRelicHolder);
|
||||||
if (newMultiplayerRelicHolder is NTreasureRoomRelicHolder nTreasureRoomRelicHolder)
|
|
||||||
{
|
|
||||||
nTreasureRoomRelicHolder.Name = $"MultiplayerRelicHolder{i + 1}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,45 +37,31 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
{
|
{
|
||||||
if (____multiplayerHolders.Count > 4)
|
if (____multiplayerHolders.Count > 4)
|
||||||
{
|
{
|
||||||
var container = __instance.GetNode("Container");
|
var gridContainer = new GridContainer
|
||||||
|
{ Name = "RelicContainer", Columns = 4, CustomMinimumSize = new Vector2(0, 469) };
|
||||||
|
|
||||||
var scrollContainer = new NScrollableContainer { Name = "ScrollableContainer" };
|
gridContainer.AddThemeConstantOverride("h_separation", 42);
|
||||||
|
gridContainer.AddThemeConstantOverride("v_separation", 42);
|
||||||
var mask = new TextureRect { Name = "Mask" };
|
gridContainer.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.TopWide);
|
||||||
scrollContainer.AddChild(mask);
|
|
||||||
|
|
||||||
mask.ClipContents = true;
|
|
||||||
|
|
||||||
var viewport = new Control { Name = "Viewport" };
|
var viewport = new Control { Name = "Viewport" };
|
||||||
mask.AddChild(viewport);
|
viewport.AddChildSafely(gridContainer);
|
||||||
|
|
||||||
var gridContainer = new GridContainer { Name = "RelicContainer" };
|
|
||||||
viewport.AddChild(gridContainer);
|
|
||||||
|
|
||||||
var scrollbar = PreloadManager.Cache.GetScene(SceneHelper.GetScenePath("ui/scrollbar"))
|
|
||||||
.Instantiate<NScrollbar>();
|
|
||||||
scrollContainer.AddChild(scrollbar);
|
|
||||||
|
|
||||||
container.AddChild(scrollContainer);
|
|
||||||
|
|
||||||
scrollContainer.SetAnchorsPreset(Control.LayoutPreset.FullRect);
|
|
||||||
scrollContainer.OffsetLeft = -510;
|
|
||||||
scrollContainer.OffsetTop = -250;
|
|
||||||
scrollContainer.OffsetRight = 510;
|
|
||||||
scrollContainer.OffsetBottom = 250;
|
|
||||||
|
|
||||||
mask.SetAnchorsPreset(Control.LayoutPreset.CenterTop);
|
|
||||||
mask.OffsetLeft = -450;
|
|
||||||
mask.OffsetTop = 250;
|
|
||||||
mask.OffsetRight = 450;
|
|
||||||
mask.OffsetBottom = 830;
|
|
||||||
|
|
||||||
viewport.SetAnchorsPreset(Control.LayoutPreset.TopWide);
|
viewport.SetAnchorsPreset(Control.LayoutPreset.TopWide);
|
||||||
viewport.OffsetLeft = 110;
|
viewport.OffsetLeft = 110;
|
||||||
viewport.OffsetTop = 110;
|
viewport.OffsetTop = 110;
|
||||||
viewport.OffsetRight = -120;
|
viewport.OffsetRight = -120;
|
||||||
viewport.OffsetBottom = 580;
|
viewport.OffsetBottom = 580;
|
||||||
|
|
||||||
|
var mask = new TextureRect { Name = "Mask", ClipContents = true };
|
||||||
|
mask.AddChildSafely(viewport);
|
||||||
|
mask.SetAnchorsPreset(Control.LayoutPreset.CenterTop);
|
||||||
|
mask.OffsetLeft = -450;
|
||||||
|
mask.OffsetTop = 250;
|
||||||
|
mask.OffsetRight = 450;
|
||||||
|
mask.OffsetBottom = 830;
|
||||||
|
|
||||||
|
var scrollbar = PreloadManager.Cache.GetScene(SceneHelper.GetScenePath("ui/scrollbar"))
|
||||||
|
.Instantiate<NScrollbar>();
|
||||||
scrollbar.AnchorLeft = 0.794f;
|
scrollbar.AnchorLeft = 0.794f;
|
||||||
scrollbar.AnchorTop = 0.187f;
|
scrollbar.AnchorTop = 0.187f;
|
||||||
scrollbar.AnchorRight = 0.818f;
|
scrollbar.AnchorRight = 0.818f;
|
||||||
@@ -89,13 +71,18 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
scrollbar.OffsetRight = -199;
|
scrollbar.OffsetRight = -199;
|
||||||
scrollbar.OffsetBottom = -163;
|
scrollbar.OffsetBottom = -163;
|
||||||
|
|
||||||
gridContainer.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.TopWide);
|
var scrollContainer = new NScrollableContainer { Name = "ScrollableContainer" };
|
||||||
|
scrollContainer.AddChildSafely(mask);
|
||||||
|
scrollContainer.AddChildSafely(scrollbar);
|
||||||
|
|
||||||
gridContainer.Columns = 4;
|
scrollContainer.SetAnchorsPreset(Control.LayoutPreset.FullRect);
|
||||||
gridContainer.CustomMinimumSize = new Vector2(0, 469);
|
scrollContainer.OffsetLeft = -510;
|
||||||
|
scrollContainer.OffsetTop = -250;
|
||||||
|
scrollContainer.OffsetRight = 510;
|
||||||
|
scrollContainer.OffsetBottom = 250;
|
||||||
|
|
||||||
gridContainer.AddThemeConstantOverride("h_separation", 42);
|
var container = __instance.GetNode("Container");
|
||||||
gridContainer.AddThemeConstantOverride("v_separation", 42);
|
container.AddChildSafely(scrollContainer);
|
||||||
|
|
||||||
scrollContainer.SetContent(gridContainer, 20, 30);
|
scrollContainer.SetContent(gridContainer, 20, 30);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using MegaCrit.Sts2.Core.Helpers;
|
||||||
using MegaCrit.Sts2.Core.Multiplayer.Game;
|
using MegaCrit.Sts2.Core.Multiplayer.Game;
|
||||||
using MegaCrit.Sts2.Core.Nodes.Screens.CharacterSelect;
|
using MegaCrit.Sts2.Core.Nodes.Screens.CharacterSelect;
|
||||||
using MegaCrit.Sts2.Core.Nodes.Screens.CustomRun;
|
using MegaCrit.Sts2.Core.Nodes.Screens.CustomRun;
|
||||||
@@ -30,10 +31,8 @@ namespace SlayTheSpire2.LAN.Multiplayer.Patchs.Screens
|
|||||||
{
|
{
|
||||||
var ipAddressInfoPanel = IPAddressInfoPanel.Create();
|
var ipAddressInfoPanel = IPAddressInfoPanel.Create();
|
||||||
ipAddressInfoPanel.Name = "IPAddressPanel";
|
ipAddressInfoPanel.Name = "IPAddressPanel";
|
||||||
|
|
||||||
__instance.AddChild(ipAddressInfoPanel);
|
|
||||||
|
|
||||||
ipAddressInfoPanel.Visible = false;
|
ipAddressInfoPanel.Visible = false;
|
||||||
|
__instance.AddChildSafely(ipAddressInfoPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,15 +46,13 @@ namespace SlayTheSpire2.LAN.Multiplayer.Services
|
|||||||
NModalContainer.Instance?.Add(nGenericPopup);
|
NModalContainer.Instance?.Add(nGenericPopup);
|
||||||
|
|
||||||
var nVerticalPopup = Traverse.Create(nGenericPopup).Field("_verticalPopup").GetValue<NVerticalPopup>();
|
var nVerticalPopup = Traverse.Create(nGenericPopup).Field("_verticalPopup").GetValue<NVerticalPopup>();
|
||||||
|
nVerticalPopup.YesButton.Visible = false;
|
||||||
nVerticalPopup.NoButton.SetAnchorsPreset(Control.LayoutPreset.CenterBottom);
|
nVerticalPopup.NoButton.SetAnchorsPreset(Control.LayoutPreset.CenterBottom);
|
||||||
nVerticalPopup.NoButton.OffsetLeft = -90;
|
nVerticalPopup.NoButton.OffsetLeft = -90;
|
||||||
nVerticalPopup.NoButton.OffsetTop = -152;
|
nVerticalPopup.NoButton.OffsetTop = -152;
|
||||||
nVerticalPopup.NoButton.OffsetRight = 90;
|
nVerticalPopup.NoButton.OffsetRight = 90;
|
||||||
nVerticalPopup.NoButton.OffsetBottom = -80;
|
nVerticalPopup.NoButton.OffsetBottom = -80;
|
||||||
|
|
||||||
nVerticalPopup.YesButton.Visible = false;
|
|
||||||
|
|
||||||
await nGenericPopup.WaitForConfirmation(locString,
|
await nGenericPopup.WaitForConfirmation(locString,
|
||||||
new LocString("gameplay_ui", "CONFIRM_LOAD_SAVE.header"),
|
new LocString("gameplay_ui", "CONFIRM_LOAD_SAVE.header"),
|
||||||
new LocString("gameplay_ui", "CONFIRM_LOAD_SAVE.cancel"),
|
new LocString("gameplay_ui", "CONFIRM_LOAD_SAVE.cancel"),
|
||||||
|
|||||||
Reference in New Issue
Block a user