using System; using System.Collections; using Dissonance; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using Unity.Netcode.Transports.UTP; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; using UnityEngine.UI; public class MenuManager : MonoBehaviour { public GameObject menuButtons; public bool isInitScene; [Space(5f)] public GameObject menuNotification; public TextMeshProUGUI menuNotificationText; public TextMeshProUGUI menuNotificationButtonText; public TextMeshProUGUI versionNumberText; [Space(5f)] public TextMeshProUGUI loadingText; public GameObject loadingScreen; [Space(5f)] public GameObject lanButtonContainer; public GameObject lanWarningContainer; public GameObject joinCrewButtonContainer; public TextMeshProUGUI launchedInLanModeText; [Space(3f)] public GameObject serverListUIContainer; public AudioListener menuListener; public TextMeshProUGUI tipTextHostSettings; [Space(5f)] public TextMeshProUGUI logText; public GameObject inputFieldGameObject; [Space(5f)] public GameObject NewsPanel; [Space(5f)] public GameObject HostSettingsScreen; public TMP_InputField lobbyNameInputField; public bool hostSettings_LobbyPublic; public Animator setPublicButtonAnimator; public Animator setPrivateButtonAnimator; public TextMeshProUGUI privatePublicDescription; [SerializeField] private Button startHostButton; [SerializeField] private Button startClientButton; [SerializeField] private Button leaveButton; public GameObject HostSettingsOptionsLAN; public GameObject HostSettingsOptionsNormal; public Animator lanSetLocalButtonAnimator; public Animator lanSetAllowRemoteButtonAnimator; [SerializeField] private TMP_InputField joinCodeInput; private bool hasServerStarted; private bool startingAClient; private int currentMicrophoneDevice; public TextMeshProUGUI currentMicrophoneText; public DissonanceComms comms; public AudioSource MenuAudio; public AudioClip menuMusic; public AudioClip openMenuSound; public Animator menuAnimator; public TextMeshProUGUI changesNotAppliedText; public TextMeshProUGUI settingsBackButton; public GameObject PleaseConfirmChangesSettingsPanel; public Button PleaseConfirmChangesSettingsPanelBackButton; private bool selectingUIThisFrame; private GameObject lastSelectedGameObject; private bool playSelectAudioThisFrame; public bool[] filesCompatible; private void Update() { if (!(EventSystem.current == null) && lastSelectedGameObject != EventSystem.current.currentSelectedGameObject) { lastSelectedGameObject = EventSystem.current.currentSelectedGameObject; if (!playSelectAudioThisFrame) { playSelectAudioThisFrame = true; } else { MenuAudio.PlayOneShot(GameNetworkManager.Instance.buttonSelectSFX); } } } public void PlayConfirmSFX() { playSelectAudioThisFrame = false; MenuAudio.PlayOneShot(GameNetworkManager.Instance.buttonPressSFX); } public void PlayCancelSFX() { playSelectAudioThisFrame = false; MenuAudio.PlayOneShot(GameNetworkManager.Instance.buttonCancelSFX); } private void Awake() { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; if (GameNetworkManager.Instance != null) { GameNetworkManager.Instance.isDisconnecting = false; GameNetworkManager.Instance.isHostingGame = false; } if (GameNetworkManager.Instance != null && versionNumberText != null) { versionNumberText.text = $"v{GameNetworkManager.Instance.gameVersionNum}"; Debug.Log("Set version num"); } filesCompatible = new bool[3]; for (int i = 0; i < filesCompatible.Length; i++) { filesCompatible[i] = true; } } private IEnumerator PlayMenuMusicDelayed() { if (GameNetworkManager.Instance != null && GameNetworkManager.Instance.firstTimeInMenu) { GameNetworkManager.Instance.firstTimeInMenu = false; MenuAudio.PlayOneShot(openMenuSound, 1f); yield return new WaitForSeconds(0.3f); } else { menuAnimator.SetTrigger("skipOpening"); } yield return new WaitForSeconds(0.1f); MenuAudio.clip = menuMusic; MenuAudio.Play(); } private void Start() { if (isInitScene) { return; } bool flag = false; if (!string.IsNullOrEmpty(GameNetworkManager.Instance.disconnectionReasonMessage)) { SetLoadingScreen(isLoading: false); } else if (GameNetworkManager.Instance.disconnectReason != 0) { if (GameNetworkManager.Instance.disconnectReason == 1) { DisplayMenuNotification("The server host disconnected.", "[ Back ]"); flag = true; } else if (GameNetworkManager.Instance.disconnectReason == 2) { DisplayMenuNotification("Your connection timed out.", "[ Back ]"); flag = true; } else if (!string.IsNullOrEmpty(NetworkManager.Singleton.DisconnectReason)) { DisplayMenuNotification("Could not connect. Reason: " + NetworkManager.Singleton.DisconnectReason, "[ Back ]"); flag = true; } GameNetworkManager.Instance.disconnectReason = 0; } if (GameNetworkManager.Instance.disableSteam) { launchedInLanModeText.enabled = true; lanButtonContainer.SetActive(value: true); lanWarningContainer.SetActive(value: true); joinCrewButtonContainer.SetActive(value: false); } else { lanButtonContainer.SetActive(value: false); joinCrewButtonContainer.SetActive(value: true); } string defaultValue; if (GameNetworkManager.Instance.disableSteam) { defaultValue = "Unnamed"; } else if (!SteamClient.IsLoggedOn) { DisplayMenuNotification("Could not connect to Steam servers! (If you just want to play on your local network, choose LAN on launch.)", "Continue"); defaultValue = "Unnamed"; } else { defaultValue = SteamClient.Name.ToString() + "'s Crew"; } hostSettings_LobbyPublic = ES3.Load("HostSettings_Public", "LCGeneralSaveData", defaultValue: false); lobbyNameInputField.text = ES3.Load("HostSettings_Name", "LCGeneralSaveData", defaultValue); int num = ES3.Load("LastVerPlayed", "LCGeneralSaveData", -1); if (!flag) { if (GameNetworkManager.Instance.firstTimeInMenu && (GameNetworkManager.Instance.AlwaysDisplayNews || num != GameNetworkManager.Instance.gameVersionNum)) { NewsPanel.SetActive(value: true); EventSystem.current.SetSelectedGameObject(NewsPanel.gameObject.GetComponentInChildren