示例#1
0
        public static void OpenPage(string page, bool setCurrentTab = true)
        {
            GameObject pageGameObject = GameObject.Find(page);

            if (pageGameObject == null)
            {
                MelonLoader.MelonLogger.Error($"Page with path {page} could not be found");
                return;
            }

            CurrentMenu.SetActive(false);

            if (page.Split('/').Last() == "ShortcutMenu")
            {
                SetMenuIndex(0);
            }
            else
            {
                QuickMenu.prop_QuickMenu_0.field_Private_Int32_0 = -1;
                CurrentMenu = pageGameObject;
            }

            CurrentTabMenu.SetActive(false);
            if (setCurrentTab)
            {
                CurrentTabMenu = pageGameObject;
            }

            QuickMenuContextualDisplay quickMenuContextualDisplay = QuickMenu.prop_QuickMenu_0.field_Private_QuickMenuContextualDisplay_0;

            QuickMenuContexualDisplayMethod.Invoke(quickMenuContextualDisplay, new object[] { QuickMenuContextualDisplayEnum.GetEnumValues().GetValue(Array.IndexOf(QuickMenuContextualDisplayEnum.GetEnumNames(), "NoSelection")) });

            pageGameObject.SetActive(true);
        }
示例#2
0
        public static void OnSceneWasLoaded()
        {
            if (currentMenuField != null)
            {
                return;
            }

            // Check which fields return null
            List <PropertyInfo> possibleProps = new List <PropertyInfo>();

            foreach (PropertyInfo prop in typeof(QuickMenu).GetProperties().Where(pi => pi.Name.StartsWith("field_Private_GameObject_")))
            {
                GameObject value = (GameObject)prop.GetValue(QuickMenu.prop_QuickMenu_0);
                if (value == null)
                {
                    possibleProps.Add(prop);
                }
            }

            // Open QuickMenu to set current menu
            try
            {
                setMenuIndex.Invoke(QuickMenu.prop_QuickMenu_0, new object[] { 8 });
            }
            catch { } // Ignore error cuz it still sets the menu

            // Find out which menu actually got set
            foreach (PropertyInfo prop in possibleProps)
            {
                if (prop.GetValue(QuickMenu.prop_QuickMenu_0) != null)
                {
                    currentMenuField = prop;
                }
            }

            CurrentMenu.SetActive(false);

            MonoBehaviour tabManager = GameObject.Find("UserInterface/QuickMenu/QuickModeTabs").GetComponents <MonoBehaviour>().First(monoBehaviour => monoBehaviour.GetIl2CppType().GetMethods().Any(mb => mb.Name.StartsWith("ShowTabContent")));

            Il2CppSystem.Reflection.PropertyInfo tabManagerSingleton = tabManager.GetIl2CppType().GetProperties().First(pi => pi.PropertyType == tabManager.GetIl2CppType());
            tabManagerSingleton.SetValue(null, tabManager, null);                                                               // Singleton is null until QM is opened. Set it to a value so that the next line won't error

            GameObject.Find("UserInterface/QuickMenu/QuickModeTabs/NotificationsTab").GetComponent <Button>().onClick.Invoke(); // Force a button click to set notifs menu as current tab menu

            tabManagerSingleton.SetValue(null, null, null);                                                                     // Set singleton back to null as to not change values willy nilly xD

            foreach (PropertyInfo prop in possibleProps)
            {
                if (prop.Name != currentMenuField.Name && prop.GetValue(QuickMenu.prop_QuickMenu_0) != null)
                {
                    currentTabMenuField = prop;
                }
            }

            CurrentTabMenu.SetActive(false);

            // Set to null as to not change values unexpectedly
            foreach (PropertyInfo prop in possibleProps)
            {
                prop.SetValue(QuickMenu.prop_QuickMenu_0, null);
            }
            QuickMenu.prop_QuickMenu_0.field_Private_Int32_0 = -1;
        }