2022-02-05 18:52:31 -08:00
|
|
|
|
using EpicTransport;
|
|
|
|
|
using Mirror;
|
2022-06-29 15:00:44 -07:00
|
|
|
|
using QSB.Localization;
|
2022-01-17 21:04:02 +00:00
|
|
|
|
using QSB.Messaging;
|
2021-12-05 14:06:43 +00:00
|
|
|
|
using QSB.Player.TransformSync;
|
2022-07-22 13:39:00 +01:00
|
|
|
|
using QSB.SaveSync;
|
2021-12-23 17:07:29 -08:00
|
|
|
|
using QSB.SaveSync.Messages;
|
2021-12-04 23:24:26 +00:00
|
|
|
|
using QSB.Utility;
|
2022-06-04 16:19:55 +01:00
|
|
|
|
using QSB.WorldSync;
|
2022-01-17 21:04:02 +00:00
|
|
|
|
using System;
|
2022-05-11 10:54:29 +01:00
|
|
|
|
using System.Linq;
|
2022-04-05 16:45:26 -07:00
|
|
|
|
using System.Text;
|
2021-08-26 08:51:33 +01:00
|
|
|
|
using UnityEngine;
|
2021-08-24 21:08:55 +01:00
|
|
|
|
using UnityEngine.UI;
|
2021-06-04 11:31:09 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.Menus;
|
|
|
|
|
|
|
|
|
|
internal class MenuManager : MonoBehaviour, IAddComponentOnStart
|
2021-06-04 11:31:09 +01:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public static MenuManager Instance;
|
|
|
|
|
|
|
|
|
|
private PopupMenu OneButtonInfoPopup;
|
|
|
|
|
private PopupMenu TwoButtonInfoPopup;
|
|
|
|
|
private bool _addedPauseLock;
|
2021-12-08 10:48:11 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
// Pause menu only
|
|
|
|
|
private GameObject QuitButton;
|
|
|
|
|
private GameObject DisconnectButton;
|
|
|
|
|
private PopupMenu DisconnectPopup;
|
2021-12-04 23:24:26 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
// title screen only
|
|
|
|
|
private GameObject ResumeGameButton;
|
|
|
|
|
private GameObject NewGameButton;
|
2022-04-05 17:26:30 -07:00
|
|
|
|
private Button HostButton;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private GameObject ConnectButton;
|
2022-04-05 13:52:28 -07:00
|
|
|
|
private PopupInputMenu ConnectPopup;
|
2022-07-22 13:39:00 +01:00
|
|
|
|
private FourChoicePopupMenu HostGameTypePopup;
|
2022-04-05 16:45:26 -07:00
|
|
|
|
private Text _loadingText;
|
|
|
|
|
private StringBuilder _nowLoadingSB;
|
2022-04-05 17:26:30 -07:00
|
|
|
|
private const int _titleButtonIndex = 2;
|
2022-04-22 15:27:17 -07:00
|
|
|
|
private float _connectPopupOpenTime;
|
2021-12-04 23:24:26 +00:00
|
|
|
|
|
2022-07-21 10:00:22 +01:00
|
|
|
|
private const string UpdateChangelog = $"QSB Version 0.20.2\r\nFixed issues with the Little Scout and attaching/detaching from the ship.";
|
2022-04-30 15:33:55 +01:00
|
|
|
|
|
2022-04-05 21:13:25 -07:00
|
|
|
|
private Action<bool> PopupClose;
|
2022-01-16 22:15:29 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private bool _intentionalDisconnect;
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-05-11 10:54:29 +01:00
|
|
|
|
private GameObject _threeChoicePopupBase;
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
2022-05-11 10:54:29 +01:00
|
|
|
|
|
|
|
|
|
_threeChoicePopupBase = Instantiate(Resources.FindObjectsOfTypeAll<PopupMenu>().First(x => x.name == "TwoButton-Popup" && x.transform.parent.name == "PopupCanvas" && x.transform.parent.parent.name == "TitleMenu").gameObject);
|
|
|
|
|
DontDestroyOnLoad(_threeChoicePopupBase);
|
|
|
|
|
_threeChoicePopupBase.SetActive(false);
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
MakeTitleMenus();
|
|
|
|
|
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
|
|
|
|
QSBNetworkManager.singleton.OnClientConnected += OnConnected;
|
|
|
|
|
QSBNetworkManager.singleton.OnClientDisconnected += OnDisconnected;
|
2022-04-30 15:33:55 +01:00
|
|
|
|
|
|
|
|
|
if (QSBCore.Storage.LastUsedVersion != QSBCore.QSBVersion)
|
|
|
|
|
{
|
|
|
|
|
// recently updated!
|
|
|
|
|
QSBCore.Storage.LastUsedVersion = QSBCore.QSBVersion;
|
|
|
|
|
QSBCore.Helper.Storage.Save(QSBCore.Storage, "storage.json");
|
|
|
|
|
QSBCore.MenuApi.RegisterStartupPopup(UpdateChangelog);
|
|
|
|
|
}
|
2022-06-04 16:19:55 +01:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
QSBLocalization.LanguageChanged += OnLanguageChanged;
|
2022-06-08 21:16:35 +01:00
|
|
|
|
|
2022-06-06 23:35:13 -07:00
|
|
|
|
if (QSBCore.DebugSettings.AutoStart)
|
|
|
|
|
{
|
|
|
|
|
// auto host/connect
|
|
|
|
|
Delay.RunWhen(PlayerData.IsLoaded, () =>
|
|
|
|
|
{
|
|
|
|
|
if (DebugLog.ProcessInstanceId == 0)
|
|
|
|
|
{
|
|
|
|
|
Host(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QSBCore.DefaultServerIP = "localhost";
|
|
|
|
|
Connect();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-01-24 11:08:05 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isUniverse)
|
|
|
|
|
{
|
|
|
|
|
if (isUniverse)
|
2021-12-05 14:06:43 +00:00
|
|
|
|
{
|
2022-04-05 19:05:09 -07:00
|
|
|
|
// wait a frame or else the changes won't actually happen
|
|
|
|
|
Delay.RunNextFrame(InitPauseMenus);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
return;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (newScene == OWScene.TitleScreen)
|
2021-08-26 14:56:42 +01:00
|
|
|
|
{
|
2022-04-05 19:05:09 -07:00
|
|
|
|
// wait a frame or else the changes won't actually happen
|
|
|
|
|
Delay.RunNextFrame(MakeTitleMenus);
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-08-26 14:56:42 +01:00
|
|
|
|
|
2022-04-05 16:45:26 -07:00
|
|
|
|
private void ResetStringBuilder()
|
|
|
|
|
{
|
|
|
|
|
if (_nowLoadingSB == null)
|
|
|
|
|
{
|
|
|
|
|
_nowLoadingSB = new StringBuilder();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_nowLoadingSB.Length = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-04 16:19:55 +01:00
|
|
|
|
private void OnLanguageChanged()
|
|
|
|
|
{
|
|
|
|
|
if (QSBSceneManager.CurrentScene != OWScene.TitleScreen)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Error - Language changed while not in title screen?! Should be impossible!", OWML.Common.MessageType.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
HostButton.transform.GetChild(0).GetChild(1).GetComponent<Text>().text = QSBLocalization.Current.MainMenuHost;
|
|
|
|
|
ConnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>().text = QSBLocalization.Current.MainMenuConnect;
|
|
|
|
|
var text = QSBCore.DebugSettings.UseKcpTransport ? QSBLocalization.Current.PublicIPAddress : QSBLocalization.Current.ProductUserID;
|
|
|
|
|
ConnectPopup.SetUpPopup(text, InputLibrary.menuConfirm, InputLibrary.cancel, new ScreenPrompt(QSBLocalization.Current.Connect), new ScreenPrompt(QSBLocalization.Current.Cancel), false);
|
2022-06-04 16:19:55 +01:00
|
|
|
|
ConnectPopup.SetInputFieldPlaceholderText(text);
|
2022-06-08 14:00:37 -07:00
|
|
|
|
HostGameTypePopup.SetUpPopup(QSBLocalization.Current.HostExistingOrNew,
|
2022-06-04 16:19:55 +01:00
|
|
|
|
InputLibrary.menuConfirm,
|
|
|
|
|
InputLibrary.confirm2,
|
2022-07-22 13:39:00 +01:00
|
|
|
|
InputLibrary.signalscope,
|
2022-06-04 16:19:55 +01:00
|
|
|
|
InputLibrary.cancel,
|
2022-06-08 14:00:37 -07:00
|
|
|
|
new ScreenPrompt(QSBLocalization.Current.ExistingSave),
|
|
|
|
|
new ScreenPrompt(QSBLocalization.Current.NewSave),
|
2022-07-22 13:39:00 +01:00
|
|
|
|
new ScreenPrompt(QSBLocalization.Current.CopySave),
|
2022-06-08 14:00:37 -07:00
|
|
|
|
new ScreenPrompt(QSBLocalization.Current.Cancel));
|
2022-06-04 16:19:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void Update()
|
|
|
|
|
{
|
2022-04-05 18:51:14 -07:00
|
|
|
|
if ((LoadManager.GetLoadingScene() == OWScene.SolarSystem || LoadManager.GetLoadingScene() == OWScene.EyeOfTheUniverse)
|
2022-04-05 16:45:26 -07:00
|
|
|
|
&& _loadingText != null)
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var num = LoadManager.GetAsyncLoadProgress();
|
|
|
|
|
num = num < 0.1f
|
|
|
|
|
? Mathf.InverseLerp(0f, 0.1f, num) * 0.9f
|
2022-04-05 11:20:06 -07:00
|
|
|
|
: 0.9f + Mathf.InverseLerp(0.1f, 1f, num) * 0.1f;
|
2022-04-05 16:45:26 -07:00
|
|
|
|
ResetStringBuilder();
|
|
|
|
|
_nowLoadingSB.Append(UITextLibrary.GetString(UITextType.LoadingMessage));
|
|
|
|
|
_nowLoadingSB.Append(num.ToString("P0"));
|
|
|
|
|
_loadingText.text = _nowLoadingSB.ToString();
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-26 14:56:42 +01:00
|
|
|
|
|
2022-05-11 10:54:29 +01:00
|
|
|
|
public ThreeChoicePopupMenu CreateThreeChoicePopup(string message, string confirm1Text, string confirm2Text, string cancelText)
|
|
|
|
|
{
|
|
|
|
|
var newPopup = Instantiate(_threeChoicePopupBase);
|
|
|
|
|
|
|
|
|
|
switch (LoadManager.GetCurrentScene())
|
|
|
|
|
{
|
|
|
|
|
case OWScene.TitleScreen:
|
|
|
|
|
newPopup.transform.parent = GameObject.Find("/TitleMenu/PopupCanvas").transform;
|
|
|
|
|
break;
|
|
|
|
|
case OWScene.SolarSystem:
|
|
|
|
|
case OWScene.EyeOfTheUniverse:
|
|
|
|
|
newPopup.transform.parent = GameObject.Find("/PauseMenu/PopupCanvas").transform;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newPopup.transform.localPosition = Vector3.zero;
|
|
|
|
|
newPopup.transform.localScale = Vector3.one;
|
|
|
|
|
newPopup.GetComponentsInChildren<LocalizedText>().ToList().ForEach(x => Destroy(x));
|
|
|
|
|
|
|
|
|
|
var originalPopup = newPopup.GetComponent<PopupMenu>();
|
|
|
|
|
|
|
|
|
|
var ok1Button = originalPopup._confirmButton.gameObject;
|
|
|
|
|
|
|
|
|
|
var ok2Button = Instantiate(ok1Button, ok1Button.transform.parent);
|
|
|
|
|
ok2Button.transform.SetSiblingIndex(1);
|
|
|
|
|
|
|
|
|
|
var popup = newPopup.AddComponent<ThreeChoicePopupMenu>();
|
|
|
|
|
popup._labelText = originalPopup._labelText;
|
|
|
|
|
popup._cancelAction = originalPopup._cancelAction;
|
|
|
|
|
popup._ok1Action = originalPopup._okAction;
|
|
|
|
|
popup._ok2Action = ok2Button.GetComponent<SubmitAction>();
|
|
|
|
|
popup._cancelButton = originalPopup._cancelButton;
|
|
|
|
|
popup._confirmButton1 = originalPopup._confirmButton;
|
|
|
|
|
popup._confirmButton2 = ok2Button.GetComponent<ButtonWithHotkeyImageElement>();
|
|
|
|
|
popup._rootCanvas = originalPopup._rootCanvas;
|
|
|
|
|
popup._menuActivationRoot = originalPopup._menuActivationRoot;
|
|
|
|
|
popup._startEnabled = originalPopup._startEnabled;
|
|
|
|
|
popup._selectOnActivate = originalPopup._selectOnActivate;
|
|
|
|
|
popup._selectableItemsRoot = originalPopup._selectableItemsRoot;
|
|
|
|
|
popup._subMenus = originalPopup._subMenus;
|
|
|
|
|
popup._menuOptions = originalPopup._menuOptions;
|
|
|
|
|
popup.SetUpPopup(
|
|
|
|
|
message,
|
|
|
|
|
InputLibrary.menuConfirm,
|
|
|
|
|
InputLibrary.confirm2,
|
|
|
|
|
InputLibrary.cancel,
|
|
|
|
|
new ScreenPrompt(confirm1Text),
|
|
|
|
|
new ScreenPrompt(confirm2Text),
|
|
|
|
|
new ScreenPrompt(cancelText),
|
|
|
|
|
true,
|
|
|
|
|
true);
|
|
|
|
|
return popup;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-22 13:39:00 +01:00
|
|
|
|
public FourChoicePopupMenu CreateFourChoicePopup(string message, string confirm1Text, string confirm2Text, string confirm3Text, string cancelText)
|
|
|
|
|
{
|
|
|
|
|
var newPopup = Instantiate(_threeChoicePopupBase);
|
|
|
|
|
|
|
|
|
|
switch (LoadManager.GetCurrentScene())
|
|
|
|
|
{
|
|
|
|
|
case OWScene.TitleScreen:
|
|
|
|
|
newPopup.transform.parent = GameObject.Find("/TitleMenu/PopupCanvas").transform;
|
|
|
|
|
break;
|
|
|
|
|
case OWScene.SolarSystem:
|
|
|
|
|
case OWScene.EyeOfTheUniverse:
|
|
|
|
|
newPopup.transform.parent = GameObject.Find("/PauseMenu/PopupCanvas").transform;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newPopup.transform.localPosition = Vector3.zero;
|
|
|
|
|
newPopup.transform.localScale = Vector3.one;
|
|
|
|
|
newPopup.GetComponentsInChildren<LocalizedText>().ToList().ForEach(x => Destroy(x));
|
|
|
|
|
|
|
|
|
|
var originalPopup = newPopup.GetComponent<PopupMenu>();
|
|
|
|
|
|
|
|
|
|
var ok1Button = originalPopup._confirmButton.gameObject;
|
|
|
|
|
|
|
|
|
|
var ok2Button = Instantiate(ok1Button, ok1Button.transform.parent);
|
|
|
|
|
ok2Button.transform.SetSiblingIndex(1);
|
|
|
|
|
|
|
|
|
|
var ok3Button = Instantiate(ok1Button, ok1Button.transform.parent);
|
|
|
|
|
ok3Button.transform.SetSiblingIndex(2);
|
|
|
|
|
|
|
|
|
|
var popup = newPopup.AddComponent<FourChoicePopupMenu>();
|
|
|
|
|
popup._labelText = originalPopup._labelText;
|
|
|
|
|
popup._cancelAction = originalPopup._cancelAction;
|
|
|
|
|
popup._ok1Action = originalPopup._okAction;
|
|
|
|
|
popup._ok2Action = ok2Button.GetComponent<SubmitAction>();
|
|
|
|
|
popup._ok3Action = ok3Button.GetComponent<SubmitAction>();
|
|
|
|
|
popup._cancelButton = originalPopup._cancelButton;
|
|
|
|
|
popup._confirmButton1 = originalPopup._confirmButton;
|
|
|
|
|
popup._confirmButton2 = ok2Button.GetComponent<ButtonWithHotkeyImageElement>();
|
|
|
|
|
popup._confirmButton3 = ok3Button.GetComponent<ButtonWithHotkeyImageElement>();
|
|
|
|
|
popup._rootCanvas = originalPopup._rootCanvas;
|
|
|
|
|
popup._menuActivationRoot = originalPopup._menuActivationRoot;
|
|
|
|
|
popup._startEnabled = originalPopup._startEnabled;
|
|
|
|
|
popup._selectOnActivate = originalPopup._selectOnActivate;
|
|
|
|
|
popup._selectableItemsRoot = originalPopup._selectableItemsRoot;
|
|
|
|
|
popup._subMenus = originalPopup._subMenus;
|
|
|
|
|
popup._menuOptions = originalPopup._menuOptions;
|
|
|
|
|
popup.SetUpPopup(
|
|
|
|
|
message,
|
|
|
|
|
InputLibrary.menuConfirm,
|
|
|
|
|
InputLibrary.confirm2,
|
|
|
|
|
InputLibrary.signalscope,
|
|
|
|
|
InputLibrary.cancel,
|
|
|
|
|
new ScreenPrompt(confirm1Text),
|
|
|
|
|
new ScreenPrompt(confirm2Text),
|
|
|
|
|
new ScreenPrompt(confirm3Text),
|
|
|
|
|
new ScreenPrompt(cancelText),
|
|
|
|
|
true,
|
|
|
|
|
true);
|
|
|
|
|
return popup;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 16:45:26 -07:00
|
|
|
|
public void LoadGame(bool inEye)
|
2022-03-02 19:46:33 -08:00
|
|
|
|
{
|
2022-04-05 16:49:45 -07:00
|
|
|
|
var sceneToLoad = inEye ? OWScene.EyeOfTheUniverse : OWScene.SolarSystem;
|
|
|
|
|
LoadManager.LoadSceneAsync(sceneToLoad, true, LoadManager.FadeType.ToBlack, 1f, false);
|
|
|
|
|
Locator.GetMenuInputModule().DisableInputs();
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-08-26 14:56:42 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void OpenInfoPopup(string message, string okButtonText)
|
|
|
|
|
{
|
|
|
|
|
OneButtonInfoPopup.SetUpPopup(message, InputLibrary.menuConfirm, InputLibrary.cancel, new ScreenPrompt(okButtonText), null, true, false);
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
OWTime.Pause(OWTime.PauseType.Menu);
|
|
|
|
|
OWInput.ChangeInputMode(InputMode.Menu);
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var pauseCommandListener = Locator.GetPauseCommandListener();
|
|
|
|
|
if (pauseCommandListener != null)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
pauseCommandListener.AddPauseCommandLock();
|
|
|
|
|
_addedPauseLock = true;
|
|
|
|
|
}
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
OneButtonInfoPopup.EnableMenu(true);
|
|
|
|
|
}
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void OpenInfoPopup(string message, string okButtonText, string cancelButtonText)
|
|
|
|
|
{
|
|
|
|
|
TwoButtonInfoPopup.SetUpPopup(message, InputLibrary.menuConfirm, InputLibrary.cancel, new ScreenPrompt(okButtonText), new ScreenPrompt(cancelButtonText));
|
2021-08-26 14:56:42 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
OWTime.Pause(OWTime.PauseType.Menu);
|
|
|
|
|
OWInput.ChangeInputMode(InputMode.Menu);
|
2021-11-25 15:38:05 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var pauseCommandListener = Locator.GetPauseCommandListener();
|
|
|
|
|
if (pauseCommandListener != null)
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
pauseCommandListener.AddPauseCommandLock();
|
|
|
|
|
_addedPauseLock = true;
|
|
|
|
|
}
|
2021-08-26 14:56:42 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
TwoButtonInfoPopup.EnableMenu(true);
|
|
|
|
|
}
|
2021-08-26 08:51:33 +01:00
|
|
|
|
|
2022-04-05 21:13:25 -07:00
|
|
|
|
private void OnCloseInfoPopup(bool confirm)
|
2022-03-02 19:46:33 -08:00
|
|
|
|
{
|
|
|
|
|
var pauseCommandListener = Locator.GetPauseCommandListener();
|
|
|
|
|
if (pauseCommandListener != null && _addedPauseLock)
|
|
|
|
|
{
|
|
|
|
|
pauseCommandListener.RemovePauseCommandLock();
|
|
|
|
|
_addedPauseLock = false;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
OWTime.Unpause(OWTime.PauseType.Menu);
|
|
|
|
|
OWInput.RestorePreviousInputs();
|
2021-08-26 14:56:42 +01:00
|
|
|
|
|
2022-04-05 21:13:25 -07:00
|
|
|
|
PopupClose?.SafeInvoke(confirm);
|
2022-04-05 17:46:24 -07:00
|
|
|
|
PopupClose = null;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-12-04 23:24:26 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void CreateCommonPopups()
|
|
|
|
|
{
|
2022-06-08 14:00:37 -07:00
|
|
|
|
var text = QSBCore.DebugSettings.UseKcpTransport ? QSBLocalization.Current.PublicIPAddress : QSBLocalization.Current.ProductUserID;
|
|
|
|
|
ConnectPopup = QSBCore.MenuApi.MakeInputFieldPopup(text, text, QSBLocalization.Current.Connect, QSBLocalization.Current.Cancel);
|
2022-04-22 15:27:17 -07:00
|
|
|
|
ConnectPopup.CloseMenuOnOk(false);
|
|
|
|
|
ConnectPopup.OnPopupConfirm += () =>
|
|
|
|
|
{
|
|
|
|
|
// fixes dumb thing with using keyboard to open popup
|
|
|
|
|
if (OWMath.ApproxEquals(Time.time, _connectPopupOpenTime))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConnectPopup.EnableMenu(false);
|
|
|
|
|
Connect();
|
|
|
|
|
};
|
|
|
|
|
ConnectPopup.OnActivateMenu += () => _connectPopupOpenTime = Time.time;
|
2021-12-05 11:00:18 +00:00
|
|
|
|
|
2022-04-05 11:20:06 -07:00
|
|
|
|
OneButtonInfoPopup = QSBCore.MenuApi.MakeInfoPopup("", "");
|
2022-04-05 21:13:25 -07:00
|
|
|
|
OneButtonInfoPopup.OnPopupConfirm += () => OnCloseInfoPopup(true);
|
2021-12-04 23:24:26 +00:00
|
|
|
|
|
2022-04-05 11:20:06 -07:00
|
|
|
|
TwoButtonInfoPopup = QSBCore.MenuApi.MakeTwoChoicePopup("", "", "");
|
2022-04-05 21:13:25 -07:00
|
|
|
|
TwoButtonInfoPopup.OnPopupConfirm += () => OnCloseInfoPopup(true);
|
|
|
|
|
TwoButtonInfoPopup.OnPopupCancel += () => OnCloseInfoPopup(false);
|
2022-05-11 10:54:29 +01:00
|
|
|
|
|
2022-07-22 13:39:00 +01:00
|
|
|
|
HostGameTypePopup = CreateFourChoicePopup(QSBLocalization.Current.HostExistingOrNew, QSBLocalization.Current.ExistingSave, QSBLocalization.Current.NewSave, QSBLocalization.Current.CopySave, QSBLocalization.Current.Cancel);
|
2022-05-11 10:54:29 +01:00
|
|
|
|
HostGameTypePopup.OnPopupConfirm1 += () => Host(false);
|
|
|
|
|
HostGameTypePopup.OnPopupConfirm2 += () => Host(true);
|
2022-07-22 13:39:00 +01:00
|
|
|
|
HostGameTypePopup.OnPopupConfirm3 += () =>
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"Replacing multiplayer save with singleplayer save");
|
|
|
|
|
QSBCore.IsInMultiplayer = true;
|
|
|
|
|
StandaloneProfileManager.SharedInstance.SaveGame(QSBProfileManager._currentProfile.gameSave, null, null, null);
|
|
|
|
|
Host(false);
|
|
|
|
|
};
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-08-26 08:51:33 +01:00
|
|
|
|
|
2022-04-05 11:20:06 -07:00
|
|
|
|
private static void SetButtonActive(Button button, bool active)
|
|
|
|
|
=> SetButtonActive(button ? button.gameObject : null, active);
|
2021-08-26 08:51:33 +01:00
|
|
|
|
|
2022-04-05 11:20:06 -07:00
|
|
|
|
private static void SetButtonActive(GameObject button, bool active)
|
2022-03-02 19:46:33 -08:00
|
|
|
|
{
|
|
|
|
|
if (button == null)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DebugLog.DebugWrite($"Warning - Tried to set button to {active}, but it was null.", OWML.Common.MessageType.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-12-08 10:48:11 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
button.SetActive(active);
|
|
|
|
|
button.GetComponent<CanvasGroup>().alpha = active ? 1 : 0;
|
|
|
|
|
}
|
2021-12-08 10:48:11 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void InitPauseMenus()
|
|
|
|
|
{
|
|
|
|
|
CreateCommonPopups();
|
2021-10-15 21:08:17 +01:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
DisconnectPopup = QSBCore.MenuApi.MakeTwoChoicePopup(QSBLocalization.Current.DisconnectAreYouSure, QSBLocalization.Current.Yes, QSBLocalization.Current.No);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DisconnectPopup.OnPopupConfirm += Disconnect;
|
2021-12-08 10:48:11 +00:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
DisconnectButton = QSBCore.MenuApi.PauseMenu_MakeMenuOpenButton(QSBLocalization.Current.PauseMenuDisconnect, DisconnectPopup);
|
2021-12-30 15:53:10 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
QuitButton = FindObjectOfType<PauseMenuManager>()._exitToMainMenuAction.gameObject;
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (QSBCore.IsInMultiplayer)
|
|
|
|
|
{
|
|
|
|
|
SetButtonActive(DisconnectButton, true);
|
|
|
|
|
SetButtonActive(QuitButton, false);
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
else
|
2021-06-04 11:31:09 +01:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
SetButtonActive(DisconnectButton, false);
|
|
|
|
|
SetButtonActive(QuitButton, true);
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|
2021-08-26 08:51:33 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var text = QSBCore.IsHost
|
2022-06-08 14:00:37 -07:00
|
|
|
|
? QSBLocalization.Current.PauseMenuStopHosting
|
|
|
|
|
: QSBLocalization.Current.PauseMenuDisconnect;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DisconnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>().text = text;
|
|
|
|
|
|
|
|
|
|
var popupText = QSBCore.IsHost
|
2022-06-09 16:42:03 +01:00
|
|
|
|
? QSBLocalization.Current.StopHostingAreYouSure
|
|
|
|
|
: QSBLocalization.Current.DisconnectAreYouSure;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DisconnectPopup._labelText.text = popupText;
|
2022-06-04 16:19:55 +01:00
|
|
|
|
|
|
|
|
|
var langController = QSBWorldSync.GetUnityObject<PauseMenuManager>().transform.GetChild(0).GetComponent<FontAndLanguageController>();
|
|
|
|
|
langController.AddTextElement(DisconnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>(), true, true, false);
|
|
|
|
|
langController.AddTextElement(DisconnectPopup._labelText, false, true, false);
|
|
|
|
|
langController.AddTextElement(DisconnectPopup._confirmButton._buttonText, false, true, false);
|
|
|
|
|
langController.AddTextElement(DisconnectPopup._cancelButton._buttonText, false, true, false);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MakeTitleMenus()
|
|
|
|
|
{
|
|
|
|
|
CreateCommonPopups();
|
2021-12-04 23:24:26 +00:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
HostButton = QSBCore.MenuApi.TitleScreen_MakeSimpleButton(QSBLocalization.Current.MainMenuHost, _titleButtonIndex);
|
2022-05-11 10:54:29 +01:00
|
|
|
|
HostButton.onClick.AddListener(PreHost);
|
2022-04-05 17:26:30 -07:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
ConnectButton = QSBCore.MenuApi.TitleScreen_MakeMenuOpenButton(QSBLocalization.Current.MainMenuConnect, _titleButtonIndex + 1, ConnectPopup);
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
ResumeGameButton = GameObject.Find("MainMenuLayoutGroup/Button-ResumeGame");
|
|
|
|
|
NewGameButton = GameObject.Find("MainMenuLayoutGroup/Button-NewGame");
|
|
|
|
|
|
2022-04-05 16:49:45 -07:00
|
|
|
|
SetButtonActive(ConnectButton, true);
|
|
|
|
|
Delay.RunWhen(PlayerData.IsLoaded, () => SetButtonActive(ResumeGameButton, PlayerData.LoadLoopCount() > 1));
|
|
|
|
|
SetButtonActive(NewGameButton, true);
|
2021-06-04 11:31:09 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (QSBCore.DebugSettings.SkipTitleScreen)
|
|
|
|
|
{
|
|
|
|
|
Application.runInBackground = true;
|
|
|
|
|
var titleScreenManager = FindObjectOfType<TitleScreenManager>();
|
|
|
|
|
var titleScreenAnimation = titleScreenManager._cameraController;
|
|
|
|
|
const float small = 1 / 1000f;
|
|
|
|
|
titleScreenAnimation._gamepadSplash = false;
|
|
|
|
|
titleScreenAnimation._introPan = false;
|
|
|
|
|
titleScreenAnimation._fadeDuration = small;
|
|
|
|
|
titleScreenAnimation.Start();
|
|
|
|
|
var titleAnimationController = titleScreenManager._gfxController;
|
|
|
|
|
titleAnimationController._logoFadeDelay = small;
|
|
|
|
|
titleAnimationController._logoFadeDuration = small;
|
|
|
|
|
titleAnimationController._echoesFadeDelay = small;
|
|
|
|
|
titleAnimationController._optionsFadeDelay = small;
|
|
|
|
|
titleAnimationController._optionsFadeDuration = small;
|
|
|
|
|
titleAnimationController._optionsFadeSpacing = small;
|
|
|
|
|
}
|
2022-06-04 16:19:55 +01:00
|
|
|
|
|
|
|
|
|
var mainMenuFontController = GameObject.Find("MainMenu").GetComponent<FontAndLanguageController>();
|
|
|
|
|
mainMenuFontController.AddTextElement(HostButton.transform.GetChild(0).GetChild(1).GetComponent<Text>(), true, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(ConnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>(), true, true, false);
|
|
|
|
|
|
|
|
|
|
mainMenuFontController.AddTextElement(OneButtonInfoPopup._labelText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(OneButtonInfoPopup._confirmButton._buttonText, false, true, false);
|
|
|
|
|
|
|
|
|
|
mainMenuFontController.AddTextElement(TwoButtonInfoPopup._labelText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(TwoButtonInfoPopup._confirmButton._buttonText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(TwoButtonInfoPopup._cancelButton._buttonText, false, true, false);
|
|
|
|
|
|
|
|
|
|
mainMenuFontController.AddTextElement(ConnectPopup._labelText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(ConnectPopup._confirmButton._buttonText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(ConnectPopup._cancelButton._buttonText, false, true, false);
|
|
|
|
|
|
|
|
|
|
mainMenuFontController.AddTextElement(HostGameTypePopup._labelText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(HostGameTypePopup._confirmButton1._buttonText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(HostGameTypePopup._confirmButton2._buttonText, false, true, false);
|
|
|
|
|
mainMenuFontController.AddTextElement(HostGameTypePopup._cancelButton._buttonText, false, true, false);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-02-05 23:01:02 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void Disconnect()
|
|
|
|
|
{
|
|
|
|
|
_intentionalDisconnect = true;
|
2021-12-08 10:48:11 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
QSBNetworkManager.singleton.StopHost();
|
2022-04-05 16:49:45 -07:00
|
|
|
|
|
|
|
|
|
SetButtonActive(DisconnectButton, false);
|
2022-01-24 15:52:05 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
Locator.GetSceneMenuManager().pauseMenu._pauseMenu.EnableMenu(false);
|
|
|
|
|
Locator.GetSceneMenuManager().pauseMenu._isPaused = false;
|
|
|
|
|
OWInput.RestorePreviousInputs();
|
2022-01-21 22:38:41 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
LoadManager.LoadScene(OWScene.TitleScreen, LoadManager.FadeType.ToBlack, 2f);
|
|
|
|
|
}
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-05-11 10:54:29 +01:00
|
|
|
|
private void PreHost()
|
2022-03-02 19:46:33 -08:00
|
|
|
|
{
|
2022-07-22 13:39:00 +01:00
|
|
|
|
var profile = QSBProfileManager._currentProfile;
|
|
|
|
|
var doesSingleplayerSaveExist = profile.gameSave.loopCount > 1;
|
|
|
|
|
var doesMultiplayerSaveExist = profile.multiplayerGameSave.loopCount > 1;
|
2022-05-11 10:54:29 +01:00
|
|
|
|
|
2022-07-22 13:39:00 +01:00
|
|
|
|
if (!doesSingleplayerSaveExist)
|
2022-05-11 10:54:29 +01:00
|
|
|
|
{
|
2022-07-22 13:39:00 +01:00
|
|
|
|
DebugLog.DebugWrite($"No singleplayer save exists.");
|
|
|
|
|
if (!doesMultiplayerSaveExist)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"No saves exist.");
|
|
|
|
|
Host(true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"Multiplayer save exists.");
|
|
|
|
|
Host(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-05-11 10:54:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-22 13:39:00 +01:00
|
|
|
|
DebugLog.DebugWrite($"A singleplayer save exists.");
|
2022-05-11 10:54:29 +01:00
|
|
|
|
HostGameTypePopup.EnableMenu(true);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-22 13:39:00 +01:00
|
|
|
|
private void Host(bool newMultiplayerSave)
|
2022-05-11 10:54:29 +01:00
|
|
|
|
{
|
2022-07-22 13:39:00 +01:00
|
|
|
|
QSBCore.IsInMultiplayer = true;
|
|
|
|
|
|
|
|
|
|
if (newMultiplayerSave)
|
2022-05-11 10:54:29 +01:00
|
|
|
|
{
|
2022-07-22 13:39:00 +01:00
|
|
|
|
DebugLog.DebugWrite($"Resetting game...");
|
2022-05-11 10:54:29 +01:00
|
|
|
|
PlayerData.ResetGame();
|
|
|
|
|
}
|
2022-07-22 13:39:00 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"Loading multiplayer game...");
|
|
|
|
|
var profile = QSBProfileManager._currentProfile;
|
|
|
|
|
PlayerData.Init(profile.multiplayerGameSave, profile.settingsSave, profile.graphicsSettings, profile.inputJSON);
|
|
|
|
|
}
|
2022-05-11 10:54:29 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_intentionalDisconnect = false;
|
2022-01-17 21:04:02 +00:00
|
|
|
|
|
2022-04-05 17:26:30 -07:00
|
|
|
|
SetButtonActive(ConnectButton, false);
|
|
|
|
|
SetButtonActive(ResumeGameButton, false);
|
|
|
|
|
SetButtonActive(NewGameButton, false);
|
|
|
|
|
_loadingText = HostButton.transform.GetChild(0).GetChild(1).GetComponent<Text>();
|
2022-01-14 19:26:58 +00:00
|
|
|
|
|
2022-04-05 17:46:24 -07:00
|
|
|
|
if (!QSBCore.DebugSettings.UseKcpTransport)
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var productUserId = EOSSDKComponent.LocalUserProductIdString;
|
2021-08-26 08:51:33 +01:00
|
|
|
|
|
2022-04-05 21:13:25 -07:00
|
|
|
|
PopupClose += confirm =>
|
2022-04-05 17:46:24 -07:00
|
|
|
|
{
|
2022-04-05 21:13:25 -07:00
|
|
|
|
if (confirm)
|
|
|
|
|
{
|
|
|
|
|
GUIUtility.systemCopyBuffer = productUserId;
|
|
|
|
|
}
|
2022-04-05 18:51:14 -07:00
|
|
|
|
|
2022-04-05 17:46:24 -07:00
|
|
|
|
LoadGame(PlayerData.GetWarpedToTheEye());
|
2022-04-05 18:51:14 -07:00
|
|
|
|
Delay.RunWhen(() => TimeLoop._initialized, QSBNetworkManager.singleton.StartHost);
|
2022-04-05 17:46:24 -07:00
|
|
|
|
};
|
2021-12-05 14:06:43 +00:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
OpenInfoPopup(string.Format(QSBLocalization.Current.CopyProductUserIDToClipboard, productUserId)
|
|
|
|
|
, QSBLocalization.Current.Yes
|
|
|
|
|
, QSBLocalization.Current.No);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-04-05 18:51:14 -07:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LoadGame(PlayerData.GetWarpedToTheEye());
|
|
|
|
|
Delay.RunWhen(() => TimeLoop._initialized, QSBNetworkManager.singleton.StartHost);
|
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-08-27 13:02:05 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void Connect()
|
|
|
|
|
{
|
2022-07-22 13:39:00 +01:00
|
|
|
|
QSBCore.IsInMultiplayer = true;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_intentionalDisconnect = false;
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-07-22 13:39:00 +01:00
|
|
|
|
var profile = QSBProfileManager._currentProfile;
|
|
|
|
|
PlayerData.Init(profile.multiplayerGameSave, profile.settingsSave, profile.graphicsSettings, profile.inputJSON);
|
|
|
|
|
|
2022-04-05 13:52:28 -07:00
|
|
|
|
var address = ConnectPopup.GetInputText();
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (address == string.Empty)
|
|
|
|
|
{
|
|
|
|
|
address = QSBCore.DefaultServerIP;
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|
2022-02-19 04:16:57 -08:00
|
|
|
|
|
2022-04-05 17:26:30 -07:00
|
|
|
|
SetButtonActive(HostButton, false);
|
2022-04-05 16:49:45 -07:00
|
|
|
|
SetButtonActive(ResumeGameButton, false);
|
|
|
|
|
SetButtonActive(NewGameButton, false);
|
2022-04-05 17:26:30 -07:00
|
|
|
|
_loadingText = ConnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>();
|
2022-06-08 14:00:37 -07:00
|
|
|
|
_loadingText.text = QSBLocalization.Current.Connecting;
|
2022-04-05 16:49:45 -07:00
|
|
|
|
Locator.GetMenuInputModule().DisableInputs();
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
QSBNetworkManager.singleton.networkAddress = address;
|
|
|
|
|
// hack to get disconnect call if start client fails immediately
|
2022-04-05 11:20:06 -07:00
|
|
|
|
typeof(NetworkClient).GetProperty(nameof(NetworkClient.connection))!.SetValue(null, new NetworkConnectionToServer());
|
2022-03-02 19:46:33 -08:00
|
|
|
|
QSBNetworkManager.singleton.StartClient();
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 11:20:06 -07:00
|
|
|
|
private static void OnConnected()
|
2022-03-02 19:46:33 -08:00
|
|
|
|
{
|
2022-04-05 16:49:45 -07:00
|
|
|
|
if (!QSBCore.IsHost)
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-04-05 16:49:45 -07:00
|
|
|
|
Delay.RunWhen(() => PlayerTransformSync.LocalInstance,
|
|
|
|
|
() => new RequestGameStateMessage().Send());
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 02:58:01 -07:00
|
|
|
|
public void OnKicked(string reason)
|
2022-03-02 19:46:33 -08:00
|
|
|
|
{
|
2022-07-22 13:39:00 +01:00
|
|
|
|
QSBCore.IsInMultiplayer = false;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_intentionalDisconnect = true;
|
|
|
|
|
|
2022-04-05 21:13:25 -07:00
|
|
|
|
PopupClose += _ =>
|
2022-03-02 19:46:33 -08:00
|
|
|
|
{
|
|
|
|
|
if (QSBSceneManager.IsInUniverse)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
LoadManager.LoadScene(OWScene.TitleScreen, LoadManager.FadeType.ToBlack, 2f);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
OpenInfoPopup(string.Format(QSBLocalization.Current.ServerRefusedConnection, reason), QSBLocalization.Current.OK);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisconnected(string error)
|
|
|
|
|
{
|
2022-07-22 13:39:00 +01:00
|
|
|
|
QSBCore.IsInMultiplayer = false;
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (_intentionalDisconnect)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite("intentional disconnect. dont show popup");
|
|
|
|
|
_intentionalDisconnect = false;
|
2021-08-26 08:51:33 +01:00
|
|
|
|
}
|
2022-03-18 02:36:29 -07:00
|
|
|
|
else
|
2021-08-26 08:51:33 +01:00
|
|
|
|
{
|
2022-04-05 21:13:25 -07:00
|
|
|
|
PopupClose += _ =>
|
2021-08-26 08:51:33 +01:00
|
|
|
|
{
|
2022-03-18 02:36:29 -07:00
|
|
|
|
if (QSBSceneManager.IsInUniverse)
|
|
|
|
|
{
|
|
|
|
|
LoadManager.LoadScene(OWScene.TitleScreen, LoadManager.FadeType.ToBlack, 2f);
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-08-26 08:51:33 +01:00
|
|
|
|
|
2022-06-08 14:00:37 -07:00
|
|
|
|
OpenInfoPopup(string.Format(QSBLocalization.Current.ClientDisconnectWithError, error), QSBLocalization.Current.OK);
|
2022-03-18 02:36:29 -07:00
|
|
|
|
}
|
2021-08-26 08:51:33 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
SetButtonActive(DisconnectButton, false);
|
|
|
|
|
SetButtonActive(ConnectButton, true);
|
|
|
|
|
SetButtonActive(QuitButton, true);
|
|
|
|
|
SetButtonActive(HostButton, true);
|
2022-04-05 16:49:45 -07:00
|
|
|
|
SetButtonActive(ResumeGameButton, PlayerData.LoadLoopCount() > 1);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
SetButtonActive(NewGameButton, true);
|
2022-04-06 11:43:09 -07:00
|
|
|
|
if (ConnectButton)
|
|
|
|
|
{
|
2022-06-08 14:00:37 -07:00
|
|
|
|
ConnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>().text = QSBLocalization.Current.MainMenuConnect;
|
2022-04-06 11:43:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HostButton)
|
|
|
|
|
{
|
2022-06-08 14:00:37 -07:00
|
|
|
|
HostButton.transform.GetChild(0).GetChild(1).GetComponent<Text>().text = QSBLocalization.Current.MainMenuHost;
|
2022-04-06 11:43:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 18:51:14 -07:00
|
|
|
|
_loadingText = null;
|
2022-04-05 14:36:32 -07:00
|
|
|
|
Locator.GetMenuInputModule().EnableInputs();
|
2021-06-04 11:31:09 +01:00
|
|
|
|
}
|
2022-04-05 11:20:06 -07:00
|
|
|
|
}
|