public IEnumerator OnLoad() { Logger.Msg("Adding QM listener...."); //From https://github.com/tetra-fox/QMFreeze/blob/master/QMFreeze/Mod.cs while (GameObject.Find("/UserInterface")?.transform.Find("Canvas_QuickMenu(Clone)/Container/Window/MicButton") == null) { yield return(new WaitForSeconds(1f)); } EnableDisableListener listener = GameObject.Find("/UserInterface")?.transform.Find("Canvas_QuickMenu(Clone)/Container/Window/MicButton").gameObject .AddComponent <EnableDisableListener>(); listener.OnEnabled += delegate { QMopen(); }; listener.OnDisabled += delegate { QMclosed(); }; string vrCamPath = "_Application/TrackingVolume/TrackingSteam(Clone)/SteamCamera/[CameraRig]/Neck/Camera (eye)/StackedCamera : Cam_InternalUI"; string desktopCamPath = "_Application/TrackingVolume/TrackingSteam(Clone)/SteamCamera/[CameraRig]/Neck/Camera (head)/Camera (eye)/StackedCamera : Cam_InternalUI"; try { if (GameObject.Find(vrCamPath) != null) { UIcamera = GameObject.Find(vrCamPath).GetComponent <Camera>(); } else { UIcamera = GameObject.Find(desktopCamPath).GetComponent <Camera>(); } } catch (System.Exception ex) { Logger.Error($"Error finding UI Camera\n" + ex.ToString()); } Logger.Msg("Initialized QM listener + UICam Found!"); }
public static void AddMenuListeners() { // Add listeners EnableDisableListener shortcutMenuListener = Constants.shortcutMenu.AddComponent <EnableDisableListener>(); shortcutMenuListener.OnEnableEvent += new Action(() => { PlayerListMod.playerList.SetActive(!shouldStayHidden); UIManager.CurrentMenu = Constants.shortcutMenu; }); shortcutMenuListener.OnDisableEvent += new Action(() => PlayerListMod.playerList.SetActive(false)); // TODO: add listeners to tab buttons to close my menu or to make it so tabs are inaccesible when menu is open GameObject newElements = GameObject.Find("UserInterface/QuickMenu/QuickMenu_NewElements"); GameObject Tabs = GameObject.Find("UserInterface/QuickMenu/QuickModeTabs"); UIManager.OnQuickMenuCloseEvent += new Action(EntryManager.SaveEntries); EnableDisableListener playerListMenuListener = playerListMenus[0].gameObject.AddComponent <EnableDisableListener>(); playerListMenuListener.OnEnableEvent += new Action(() => { PlayerListMod.playerList.SetActive(!shouldStayHidden); PlayerListMod.playerListRect.anchoredPosition = Converters.ConvertToUnityUnits(new Vector3(2.5f, 3.5f)); Tabs.SetActive(false); newElements.SetActive(false); }); playerListMenuListener.OnDisableEvent += new Action(() => { PlayerListMod.playerList.SetActive(false); PlayerListMod.playerListRect.anchoredPosition = Config.PlayerListPosition; PlayerListMod.playerListRect.localPosition = new Vector3(PlayerListMod.playerListRect.localPosition.x, PlayerListMod.playerListRect.localPosition.y, 25); Tabs.SetActive(true); newElements.SetActive(true); }); }
public static void AdjustSubMenus() { for (int i = 0; i < playerListMenus.Count; i++) { int k = i; // dum reference stuff if (i > 0) { new SingleButton(playerListMenus[i].path, "UserInterface/QuickMenu/EmojiMenu/PageUp", new Vector3(4, 0), $"Page {i}", new Action(() => UIManager.OpenPage($"UserInterface/QuickMenu/PlayerListMenuPage{k}")), $"Go back to page {i}", "BackPageButton"); new SingleButton(playerListMenus[i].path, new Vector3(4, 1), $"Save", new Action(EntryManager.SaveEntries), $"Saves all settings if you have made changes, this is also done automatically when you close the menu", "SaveEntriesButton"); } if (i + 1 < playerListMenus.Count) { new SingleButton(playerListMenus[i].path, "UserInterface/QuickMenu/EmojiMenu/PageDown", new Vector3(4, 2), $"Page {i + 2}", new Action(() => UIManager.OpenPage($"UserInterface/QuickMenu/PlayerListMenuPage{k + 2}")), $"Go to page {i + 2}", "ForwardPageButton"); } if (i == 0) { continue; // Skip main config menu } EnableDisableListener subMenuListener = playerListMenus[i].gameObject.AddComponent <EnableDisableListener>(); subMenuListener.OnEnableEvent += new Action(() => { PlayerListMod.playerList.SetActive(!shouldStayHidden); PlayerListMod.playerListRect.anchoredPosition = Converters.ConvertToUnityUnits(new Vector3(6.5f, 3.5f)); }); subMenuListener.OnDisableEvent += new Action(() => { PlayerListMod.playerList.SetActive(false); PlayerListMod.playerListRect.anchoredPosition = Config.PlayerListPosition; PlayerListMod.playerListRect.localPosition = new Vector3(PlayerListMod.playerListRect.localPosition.x, PlayerListMod.playerListRect.localPosition.y, 25); }); } }
public static void CreateSortPages() { sortMenu = new SubMenu("UserInterface/QuickMenu", "PlayerListSortMenu"); // Shush its fine sortTypeButtonTable.Add(EntrySortManager.SortType.None, new SingleButton(sortMenu.gameObject, new Vector3(1, 0), "None", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.None)), "Set sort type to none", "NoneSortButton")); sortTypeButtonTable.Add(EntrySortManager.SortType.Default, new SingleButton(sortMenu.gameObject, new Vector3(2, 0), "Default", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.Default)), "Set sort type to default", "DefaultSortButton")); sortTypeButtonTable.Add(EntrySortManager.SortType.Alphabetical, new SingleButton(sortMenu.gameObject, new Vector3(3, 0), "Alphabetical", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.Alphabetical)), "Set sort type to alphabetical", "AlphabeticalSortButton")); sortTypeButtonTable.Add(EntrySortManager.SortType.AvatarPerf, new SingleButton(sortMenu.gameObject, new Vector3(4, 0), "Avatar Perf", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.AvatarPerf)), "Set sort type to avatar perf", "AvatarPerfSortButton")); sortTypeButtonTable.Add(EntrySortManager.SortType.Distance, new SingleButton(sortMenu.gameObject, new Vector3(1, 1), "Distance", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.Distance)), "Set sort type to distance\nWARNING: This may cause noticable frame drops", "DistanceSortButton")); sortTypeButtonTable.Add(EntrySortManager.SortType.Friends, new SingleButton(sortMenu.gameObject, new Vector3(2, 1), "Friends", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.Friends)), "Set sort type to friends", "FriendsSortButton")); sortTypeButtonTable.Add(EntrySortManager.SortType.NameColor, new SingleButton(sortMenu.gameObject, new Vector3(3, 1), "Name Color", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.NameColor)), "Set sort type to displayname color", "NameColorSortButton")); sortTypeButtonTable.Add(EntrySortManager.SortType.Ping, new SingleButton(sortMenu.gameObject, new Vector3(4, 1), "Ping", new Action(() => entryWrapperValue.SetValue(EntrySortManager.currentComparisonProperty.GetValue(null), EntrySortManager.SortType.Ping)), "Set sort type to ping\nWARNING: This may cause noticable frame drops", "PingSortButton")); new SingleButton(sortMenu.gameObject, new Vector3(5, 2), "Back", new Action(() => playerListMenus[2].OpenSubMenu()), "Press to go back", "BackButton", textColor: Color.yellow); AddPlayerListToSubMenu(sortMenu); for (int i = 0; i < sortTypeButtonTable.Count; i++) { SingleButton button = sortTypeButtonTable.ElementAt(i).Value; button.ButtonComponent.onClick.AddListener(new Action(() => { currentHighlightedSortType.sprite = UiManager.RegularButtonSprite; currentHighlightedSortType = button.gameObject.GetComponent <Image>(); currentHighlightedSortType.sprite = UiManager.FullOnButtonSprite; })); } EnableDisableListener listener = sortMenu.gameObject.GetComponent <EnableDisableListener>(); listener.OnEnableEvent += new Action(() => { EntrySortManager.SortType currentSortType = EntrySortManager.SortType.None; if (EntrySortManager.currentComparisonProperty.Name.Contains("Base")) { currentSortType = PlayerListConfig.currentBaseSort.Value; } else if (EntrySortManager.currentComparisonProperty.Name.Contains("Upper")) { currentSortType = PlayerListConfig.currentUpperSort.Value; } else if (EntrySortManager.currentComparisonProperty.Name.Contains("Highest")) { currentSortType = PlayerListConfig.currentHighestSort.Value; } if (currentHighlightedSortType != null) { currentHighlightedSortType.sprite = UiManager.RegularButtonSprite; } currentHighlightedSortType = sortTypeButtonTable[currentSortType].gameObject.GetComponent <Image>(); currentHighlightedSortType.sprite = UiManager.FullOnButtonSprite; }); }
public static void AddListenerToShortcutMenu(Action onEnable, Action onDisable) { EnableDisableListener shortcutMenuListener = Constants.shortcutMenu.GetComponent <EnableDisableListener>(); if (shortcutMenuListener == null) { shortcutMenuListener = Constants.shortcutMenu.AddComponent <EnableDisableListener>(); } shortcutMenuListener.OnEnabled += onEnable; shortcutMenuListener.OnDisabled += onDisable; }
public override void VRChat_OnUiManagerInit() { MelonLogger.Msg("Adding QM listener..."); // MicControls is enabled no matter the QM page that's open, so let's use that to determine whether or not the QM is open // Unless you have some other mod that removes this button then idk lol EnableDisableListener listener = GameObject.Find("/UserInterface/QuickMenu/MicControls").AddComponent <EnableDisableListener>(); listener.OnEnabled += delegate { Freeze(); }; listener.OnDisabled += delegate { Unfreeze(); }; MelonLogger.Msg("Initialized!"); }
public static void LoadAssetBundle() { // Stolen from UIExpansionKit (https://github.com/knah/VRCMods/blob/master/UIExpansionKit) #Imnotaskidiswear MelonLogger.Msg("Loading List UI..."); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PlayerList.playerlistmod.assetbundle")) { using (var memoryStream = new MemoryStream((int)stream.Length)) { stream.CopyTo(memoryStream); AssetBundle assetBundle = AssetBundle.LoadFromMemory_Internal(memoryStream.ToArray(), 0); assetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset; playerList = UnityEngine.Object.Instantiate(assetBundle.LoadAsset_Internal("Assets/Prefabs/PlayerListMod.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), Constants.quickMenu.transform); menuButton = UnityEngine.Object.Instantiate(assetBundle.LoadAsset_Internal("Assets/Prefabs/PlayerListMenuButton.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), Constants.shortcutMenu.transform); } } menuButton.SetLayerRecursive(12); menuButton.transform.localPosition = Converters.ConvertToUnityUnits(new Vector3(4, -1)); menuButton.GetComponent <RectTransform>().pivot = new Vector2(0, 0); UiTooltip tooltip = menuButton.AddComponent <UiTooltip>(); tooltip.field_Public_String_0 = "Open PlayerList menu"; tooltip.field_Public_String_1 = "Open PlayerList menu"; playerList.SetLayerRecursive(12); playerListRect = playerList.GetComponent <RectTransform>(); playerListRect.anchoredPosition = Config.PlayerListPosition; playerListRect.localPosition = new Vector3(playerListRect.localPosition.x, playerListRect.localPosition.y, 25); // Do this or else it looks off for whatever reason playerList.SetActive(false); MenuManager.shouldStayHidden = !Config.enabledOnStart.Value; _fontSize = Config.fontSize.Value; MenuButtonPosition = Config.MenuButtonPosition; Constants.playerListLayout = playerList.transform.Find("PlayerList Viewport/PlayerList").GetComponent <VerticalLayoutGroup>(); Constants.generalInfoLayout = playerList.transform.Find("GeneralInfo Viewport/GeneralInfo").GetComponent <VerticalLayoutGroup>(); EnableDisableListener playerListListener = playerList.AddComponent <EnableDisableListener>(); playerListListener.OnEnableEvent += EntryManager.RefreshAllEntries; }
public static void AddMenuListeners() { // Add listeners if (PlayerListMod.HasUIX) { typeof(UIXManager).GetMethod("AddListenerToShortcutMenu").Invoke(null, new object[2] { new Action(() => playerList.SetActive(!shouldStayHidden && !PlayerListConfig.onlyEnabledInConfig.Value)), new Action(() => playerList.SetActive(false)) }); } else { EnableDisableListener shortcutMenuListener = Constants.shortcutMenu.AddComponent <EnableDisableListener>(); shortcutMenuListener.OnEnableEvent += new Action(() => playerList.SetActive(!shouldStayHidden && !PlayerListConfig.onlyEnabledInConfig.Value)); shortcutMenuListener.OnDisableEvent += new Action(() => playerList.SetActive(false)); } GameObject newElements = GameObject.Find("UserInterface/QuickMenu/QuickMenu_NewElements"); GameObject Tabs = GameObject.Find("UserInterface/QuickMenu/QuickModeTabs"); UiManager.OnQuickMenuClosed += new Action(PlayerListConfig.SaveEntries); EnableDisableListener playerListMenuListener = playerListMenus[0].gameObject.AddComponent <EnableDisableListener>(); playerListMenuListener.OnEnableEvent += new Action(() => { playerList.SetActive(!shouldStayHidden); playerListRect.anchoredPosition = Converters.ConvertToUnityUnits(new Vector3(2.5f, 3.5f)); newElements.SetActive(false); }); playerListMenuListener.OnDisableEvent += new Action(() => { playerList.SetActive(false); playerListRect.anchoredPosition = PlayerListConfig.playerListPosition.Value; playerListRect.localPosition = playerListRect.localPosition.SetZ(25); newElements.SetActive(true); }); }