change connect text

This commit is contained in:
JohnCorby 2022-04-05 13:59:28 -07:00
parent 4af9bcbd26
commit 1644584ebf

View File

@ -5,7 +5,6 @@ using QSB.Player.TransformSync;
using QSB.SaveSync.Messages;
using QSB.Utility;
using System;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
@ -30,9 +29,8 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
private GameObject NewGameButton;
private GameObject ConnectButton;
private PopupInputMenu ConnectPopup;
private StringBuilder _nowLoadingSB;
private Text _loadingText;
private const int _titleButtonIndex = 2;
private Text _connectButtonText;
private const int _connectButtonIndex = 2;
private const string HostString = "OPEN TO MULTIPLAYER";
private const string ConnectString = "CONNECT TO MULTIPLAYER";
@ -75,31 +73,17 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
}
}
private void ResetStringBuilder()
{
if (_nowLoadingSB == null)
{
_nowLoadingSB = new StringBuilder();
return;
}
_nowLoadingSB.Length = 0;
}
private void Update()
{
if (QSBCore.IsInMultiplayer
&& LoadManager.GetLoadingScene() is OWScene.SolarSystem or OWScene.EyeOfTheUniverse
&& _loadingText != null)
&& _connectButtonText != null)
{
var num = LoadManager.GetAsyncLoadProgress();
num = num < 0.1f
? Mathf.InverseLerp(0f, 0.1f, num) * 0.9f
: 0.9f + Mathf.InverseLerp(0.1f, 1f, num) * 0.1f;
ResetStringBuilder();
_nowLoadingSB.Append(UITextLibrary.GetString(UITextType.LoadingMessage));
_nowLoadingSB.Append(num.ToString("P0"));
_loadingText.text = _nowLoadingSB.ToString();
_connectButtonText.text = $"{UITextLibrary.GetString(UITextType.LoadingMessage)}{num:P0}";
}
}
@ -245,8 +229,8 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
{
CreateCommonPopups();
ConnectButton = QSBCore.MenuApi.TitleScreen_MakeMenuOpenButton(ConnectString, _titleButtonIndex, ConnectPopup);
_loadingText = ConnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>();
ConnectButton = QSBCore.MenuApi.TitleScreen_MakeMenuOpenButton(ConnectString, _connectButtonIndex, ConnectPopup);
_connectButtonText = ConnectButton.transform.GetChild(0).GetChild(1).GetComponent<Text>();
ResumeGameButton = GameObject.Find("MainMenuLayoutGroup/Button-ResumeGame");
NewGameButton = GameObject.Find("MainMenuLayoutGroup/Button-NewGame");
@ -357,6 +341,7 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
SetButtonActive(ResumeGameButton, false);
SetButtonActive(NewGameButton, false);
_connectButtonText.text = "CONNECTING...";
ConnectButton.GetComponent<SubmitActionMenu>().enabled = false;
}
@ -424,6 +409,7 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
Delay.RunWhen(PlayerData.IsLoaded, () => SetButtonActive(ResumeGameButton, PlayerData.LoadLoopCount() > 1));
SetButtonActive(NewGameButton, true);
_connectButtonText.text = ConnectString;
ConnectButton.GetComponent<SubmitActionMenu>().enabled = true;
}
}