-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Reactor.Utilities.UI; | ||
using UnityEngine; | ||
|
||
namespace Reactor.Networking; | ||
|
||
internal static class HandshakePopup | ||
{ | ||
public const string Message = | ||
""" | ||
This server doesn't support Reactor's modded handshake. | ||
The lobbies shown could be incompatible with your current mods. | ||
For more info see <link=https://reactor.gg/handshake>reactor.gg/handshake</link> | ||
"""; | ||
|
||
private static ReactorPopup? _popup; | ||
|
||
public static void Show() | ||
{ | ||
if (_popup == null) | ||
{ | ||
_popup = ReactorPopup.Create(nameof(HandshakePopup)); | ||
_popup.Background.transform.localPosition = new Vector3(0, 0.20f, 0); | ||
_popup.Background.size = new Vector2(6.5f, 1.7f); | ||
_popup.BackButton.transform.SetLocalY(-0.2f); | ||
} | ||
|
||
var message = ReactorConfig.HandshakePopupMessage.Value; | ||
if (string.IsNullOrEmpty(message)) | ||
{ | ||
message = Message; | ||
} | ||
|
||
_popup.Show(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Reactor.Utilities.UI; | ||
using UnityEngine; | ||
|
||
namespace Reactor.Networking; | ||
|
||
internal static class MakePublicDisallowedPopup | ||
{ | ||
public const string Message = | ||
""" | ||
You can't make public lobbies on servers that don't support modded handshake. | ||
For more info see <link=https://reactor.gg/handshake>reactor.gg/handshake</link> | ||
"""; | ||
|
||
private static ReactorPopup? _popup; | ||
|
||
public static void Show() | ||
{ | ||
if (_popup == null) | ||
{ | ||
_popup = ReactorPopup.Create(nameof(MakePublicDisallowedPopup)); | ||
_popup.Background.transform.localPosition = new Vector3(0, 0.25f, 0); | ||
_popup.Background.size = new Vector2(7.5f, 1.5f); | ||
_popup.BackButton.transform.SetLocalY(-0.1f); | ||
} | ||
|
||
var message = ReactorConfig.MakePublicDisallowedPopupMessage.Value; | ||
if (string.IsNullOrEmpty(message)) | ||
{ | ||
message = Message; | ||
} | ||
|
||
_popup.Show(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Il2CppInterop.Runtime.Attributes; | ||
using Reactor.Utilities.Attributes; | ||
using TMPro; | ||
using UnityEngine; | ||
|
||
namespace Reactor.Utilities.UI; | ||
|
||
/// <summary> | ||
/// Wrapper over <see cref="GenericPopup"/> that adds hyperlink and controller support. | ||
/// </summary> | ||
[RegisterInIl2Cpp] | ||
internal sealed class ReactorPopup : MonoBehaviour | ||
{ | ||
private readonly Il2CppSystem.Collections.Generic.List<SelectableHyperLink> _selectableHyperLinks = new(); | ||
|
||
public GenericPopup Popup { get; private set; } = null!; | ||
public TextMeshPro TextArea { get; private set; } = null!; | ||
public PassiveButton BackButton { get; private set; } = null!; | ||
public SpriteRenderer Background { get; private set; } = null!; | ||
|
||
[HideFromIl2Cpp] | ||
public void Show(string text) | ||
{ | ||
Popup.Show(text); | ||
|
||
ControllerManager.Instance.OpenOverlayMenu(name, BackButton); | ||
|
||
SelectableHyperLinkHelper.AddSelectableUiForHyperlinks(_selectableHyperLinks, name); | ||
TextArea.text = SelectableHyperLinkHelper.DecomposeAnnouncementText(TextArea, _selectableHyperLinks, name, TextArea.text); | ||
SelectableHyperLinkHelper.UpdateHyperlinkPositions(TextArea, _selectableHyperLinks, name); | ||
|
||
ControllerManager.Instance.AddSelectableUiElement(BackButton, true); | ||
} | ||
|
||
public void OnDisable() | ||
{ | ||
ControllerManager.Instance.CloseOverlayMenu(name); | ||
} | ||
|
||
[HideFromIl2Cpp] | ||
public static ReactorPopup Create(string name) | ||
{ | ||
var genericPopup = Instantiate(DiscordManager.Instance.discordPopup, Camera.main!.transform); | ||
var gameObject = genericPopup.gameObject; | ||
var reactorPopup = gameObject.AddComponent<ReactorPopup>(); | ||
|
||
reactorPopup.Popup = genericPopup; | ||
reactorPopup.TextArea = genericPopup.TextAreaTMP; | ||
reactorPopup.BackButton = gameObject.transform.Find("ExitGame").GetComponent<PassiveButton>(); | ||
reactorPopup.Background = gameObject.transform.Find("Background").GetComponent<SpriteRenderer>(); | ||
|
||
gameObject.name = name; | ||
genericPopup.destroyOnClose = true; | ||
reactorPopup.TextArea.fontSizeMin = 2; | ||
|
||
return reactorPopup; | ||
} | ||
} |