internal static void EnableFlowManager() { foreach (VRCFlowManager flowManager in Resources.FindObjectsOfTypeAll <VRCFlowManager>()) { flowManager.enabled = true; } _FlowManagerPaused = false; MVRCLogger.LogWarning("Enabled Flow Manager!"); }
public static void ShowQuickMenuPage(string page) { if (string.IsNullOrEmpty(page)) { return; } Transform tPage = VRCEUi.QuickMenu?.transform.Find(page); if (tPage == null) { MVRCLogger.LogError("Could not find QuickMenu page with name " + page); } ShowQuickMenuPage(tPage); }
public static void RunBeforeFlowManager(IEnumerator func) { if (_FlowManagerFinished) { MVRCLogger.LogError("Attmpted to run function, after before flow manager has finished!"); return; } TryHookFlowManager(); _PreFlowExectution.Enqueue(func); if (!_StartedUp) { GameObject obj = new GameObject(); obj.AddComponent <AnimateOnEnabled>().StartCoroutine(SetupUI()); GameObject.DontDestroyOnLoad(obj); _StartedUp = true; } }
private static IEnumerator SetupQuickMenu() { // Run UI checks while (VRCEUi.QuickMenu == null) { yield return(null); } // Get QuickMenu defaults Vector2 quickMenuButtonPos = VRCEUi.InternalQuickMenu.ReportWorldButton.GetComponent <RectTransform>().localPosition; // Load QuickMenu UI MVRCLogger.Log("Loading QuickMenu UI..."); _quickMenuMoreMenu = new VRCEUiQuickScrollMenu("MoreMenu", false); _quickMenuMoreButton = new VRCEUiQuickButton("MoreButton", new Vector2(quickMenuButtonPos.x, quickMenuButtonPos.y + 840f), "More", "Shows more Quick Menu buttons that mods have added.", VRCEUi.InternalQuickMenu.ShortcutMenu); _quickMenuMoreButton.Control.gameObject.SetActive(_quickMenuMoreMenu.HasButtons); _quickMenuMoreButton.OnClick += () => { if (VRCEUi.InternalQuickMenu.CurrentPage == null) { return; } ShowQuickMenuPage(_quickMenuMoreMenu.Control); }; _quickMenuLessButton = new VRCEUiQuickButton("LessButton", new Vector2(quickMenuButtonPos.x, quickMenuButtonPos.y + 420f), "Less", "Takes you back to the main Quick Menu screen.", _quickMenuMoreMenu.Control); _quickMenuLessButton.OnClick += () => { if (VRCEUi.QuickMenu == null) { return; } VRCEUi.QuickMenu.SetMenuIndex(0); }; MVRCLogger.Log("QuickMenu UI has been loaded!"); }
internal static void DisableFlowManager() // Thanks Slaynash for the code { _FlowManagerPaused = true; VRCFlowManager[] managers = Resources.FindObjectsOfTypeAll <VRCFlowManager>(); foreach (VRCFlowManager flowManager in managers) { flowManager.enabled = false; } if (GameObject.Find("UserInterface") == null) { IEnumerator loadUi() { yield return(null); SceneManager.LoadScene("ui", LoadSceneMode.Single); } MVRCLogger.Log("Loading UserInterface..."); managers[0].StartCoroutine(loadUi()); } MVRCLogger.LogWarning("Disabled Flow Manager!"); }
private static IEnumerator SetupUserInfo() { // Run UI checks while (VRCEUi.UserInfoScreen == null) { yield return(null); } // Get UserInfo defaults _userInfoDefaultButtons = new Transform[] { VRCEUi.InternalUserInfoScreen.PlaylistsButton, VRCEUi.InternalUserInfoScreen.FavoriteButton, VRCEUi.InternalUserInfoScreen.ReportButton, VRCEUi.InternalUserInfoScreen.OnlineVoteKickButton, VRCEUi.InternalUserInfoScreen.OnlineJoinButton, VRCEUi.InternalUserInfoScreen.OfflineJoinButton }; if (_userInfoDefaultButtons.Any(a => a == null)) { MVRCLogger.LogError("Failed to get UserInfo default buttons!"); yield break; } Vector3 userInfoButtonPos = _userInfoDefaultButtons[0].GetComponent <RectTransform>().localPosition; // Load UserInfo UI MVRCLogger.Log("Loading UserInfo UI..."); _userInfoScrollView = new VRCEUiPageScrollView("MoreScroll", new Vector2(userInfoButtonPos.x, userInfoButtonPos.y + 35f), new Vector2(200f, 75f * 5f), 75f, 3, 33f, VRCEUi.InternalUserInfoScreen.UserPanel); _userInfoScrollView.Control.gameObject.SetActive(false); _userInfoMoreButton = new VRCEUiButton("More", new Vector2(userInfoButtonPos.x, userInfoButtonPos.y + 75f), "More", VRCEUi.InternalUserInfoScreen.UserPanel); _userInfoMoreButton.Control.gameObject.SetActive(_userInfoScrollView.HasItems); _userInfoMoreButton.OnClick += () => SetUserInfoUIState(_userInfoMoreButton.Text == "More"); VRCEUi.UserInfoScreen.AddComponent <UserInfoActivityManager>(); MVRCLogger.Log("UserInfo UI has been loaded!"); }
private static IEnumerator CheckForUpdates() { string newVersion = null; bool hasPopup = true; MVRCLogger.Log("Checking for updates..."); using (UnityWebRequest request = UnityWebRequest.Get("https://api.github.com/repos/AtiLion/VRCMenuUtils/releases/latest")) { yield return(request.SendWebRequest()); if (request.isNetworkError) { MVRCLogger.LogError("Network error! Failed to check for updates!"); yield break; } if (request.isHttpError) { MVRCLogger.LogError("HTTP error! Failed to check for updates!"); yield break; } try { JObject data = JObject.Parse(request.downloadHandler.text); JToken version; if (!data.TryGetValue("tag_name", out version)) { MVRCLogger.LogError("No version data found!"); yield break; } if ((string)version == Version) { MVRCLogger.Log("No updates found!"); yield break; } newVersion = (string)version; } catch (Exception ex) { MVRCLogger.LogError("Version check failed! Invalid format!", ex); yield break; } } if (newVersion != null) { // Show update MVRCLogger.Log("New update has been found! Version: " + newVersion); VRCUiPopupManager.ShowStandardPopup( "VRCMenuUtils Update", "A new VRCMenuUtils update is now available! Please update as soon as you can.", "Close", () => { VRCUiPopupManager.HideCurrentPopup(); hasPopup = false; }, "Open", () => System.Diagnostics.Process.Start("https://github.com/AtiLion/VRCMenuUtils/releases") ); while (hasPopup) { yield return(null); } } }
private static IEnumerator SetupUI() { if (_miVRCUiManagerGetInstace != null && _UIInitialized) { yield break; } // Grab VRCUiManager _miVRCUiManagerGetInstace = typeof(VRCUiManager).GetMethod("get_Instance", BindingFlags.Public | BindingFlags.Static); if (_miVRCUiManagerGetInstace == null) { MVRCLogger.LogError("Failed to find get_Instance in VRCUiManager!"); yield break; } MVRCLogger.Log("Waiting for VRCUiManager to load..."); while (VRCUiManager == null) { yield return(null); } if (_miVRCUiPopupManagerGetInstance == null) { _miVRCUiPopupManagerGetInstance = typeof(VRCUiPopupManager).GetMethod("get_Instance", BindingFlags.Public | BindingFlags.Static); if (_miVRCUiPopupManagerGetInstance == null) { MVRCLogger.LogError("Failed to find get_Instance in VRCUiPopupManager!"); yield break; } while (VRCUiPopupManager == null) { yield return(null); } } MVRCLogger.Log("VRCUiManager has been loaded!"); // Check for updates RunBeforeFlowManager(CheckForUpdates()); // Setup UserInfo yield return(SetupUserInfo()); // Setup Quick Menu yield return(SetupQuickMenu()); // Run pre-flow manager functions while (!_FlowManagerPaused) { yield return(null); } while (_PreFlowExectution.Count > 0) { yield return(_PreFlowExectution.Dequeue()); } // Finish EnableFlowManager(); _FlowManagerFinished = true; OnUserInfoButtonAdd += _UserInfoButtonAdded; OnQuickMenuButtonAdd += _QuickMenuButtonAdded; _UIInitialized = true; }