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