Update MenuManager.cs

This commit is contained in:
Mister_Nebula 2021-08-24 22:30:53 +01:00
parent 3e5422af02
commit a5259cb237

View File

@ -7,7 +7,8 @@ namespace QSB.Menus
{
private IMenuAPI MenuApi => QSBCore.MenuApi;
private PopupMenu PopupMenu;
private GameObject MultiplayerButton;
private Button HostButton;
private GameObject ClientButton;
private Button DisconnectButton;
public void Start()
@ -17,28 +18,36 @@ namespace QSB.Menus
private void MakeTitleMenus()
{
PopupMenu = MenuApi.MakeInputFieldPopup("IP Address", "IP Address", "Host a server", "Connect to server");
PopupMenu.OnPopupConfirm += Host;
PopupMenu.OnPopupCancel += Connect;
PopupMenu = MenuApi.MakeInputFieldPopup("IP Address", "IP Address", "Connect", "Cancel");
PopupMenu.OnPopupConfirm += Connect;
HostButton = MenuApi.TitleScreen_MakeSimpleButton("MULTIPLAYER (HOST)");
HostButton.onClick.AddListener(Host);
ClientButton = MenuApi.TitleScreen_MakeMenuOpenButton("MULTIPLAYER (CONNECT)", PopupMenu);
MultiplayerButton = MenuApi.TitleScreen_MakeMenuOpenButton("MULTIPLAYER", PopupMenu);
DisconnectButton = MenuApi.TitleScreen_MakeSimpleButton("DISCONNECT");
DisconnectButton.gameObject.SetActive(false);
DisconnectButton.onClick.AddListener(Disconnect);
DisconnectButton.gameObject.SetActive(false);
DisconnectButton.GetComponent<CanvasGroup>().alpha = 1f;
}
private void Disconnect()
{
QSBNetworkManager.Instance.StopHost();
DisconnectButton.gameObject.SetActive(false);
MultiplayerButton.SetActive(true);
ClientButton.SetActive(true);
HostButton.gameObject.SetActive(true);
}
private void Host()
{
QSBNetworkManager.Instance.StartHost();
DisconnectButton.gameObject.SetActive(true);
MultiplayerButton.SetActive(false);
DisconnectButton.GetComponent<CanvasGroup>().alpha = 1f;
ClientButton.SetActive(false);
HostButton.gameObject.SetActive(false);
}
private void Connect()
@ -46,7 +55,9 @@ namespace QSB.Menus
QSBNetworkManager.Instance.networkAddress = (PopupMenu as PopupInputMenu).GetInputText();
QSBNetworkManager.Instance.StartClient();
DisconnectButton.gameObject.SetActive(true);
MultiplayerButton.SetActive(false);
DisconnectButton.GetComponent<CanvasGroup>().alpha = 1f;
ClientButton.SetActive(false);
HostButton.gameObject.SetActive(false);
}
}
}