コード例 #1
0
        public static void ShowQuickmenuPage(string pagename)
        {
            QuickMenu quickmenu     = GetQuickMenuInstance();
            Transform pageTransform = quickmenu?.transform.Find(pagename);

            if (currentPageGetter == null)
            {
                GameObject shortcutMenu = quickmenu.transform.Find("ShortcutMenu").gameObject;
                if (!shortcutMenu.activeInHierarchy)
                {
                    shortcutMenu = quickmenu.transform.Find("UserInteractMenu").gameObject;
                }


                FieldInfo[] fis   = Il2CppType.Of <QuickMenu>().GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where((fi) => fi.FieldType == Il2CppType.Of <GameObject>()).ToArray();
                int         count = 0;
                foreach (FieldInfo fi in fis)
                {
                    GameObject value = fi.GetValue(quickmenu)?.TryCast <GameObject>();
                    if (value == shortcutMenu && ++count == 2)
                    {
                        currentPageGetter = fi;
                        break;
                    }
                }
                if (currentPageGetter == null)
                {
                    Console.WriteLine("[QMStuff] Unable to find field currentPage in QuickMenu");
                    return;
                }
            }

            currentPageGetter.GetValue(quickmenu)?.Cast <GameObject>().SetActive(false);

            GameObject infoBar = GetQuickMenuInstance().transform.Find("QuickMenu_NewElements/_InfoBar").gameObject;

            infoBar.SetActive(pagename == "ShortcutMenu");

            QuickMenuContextualDisplay quickmenuContextualDisplay = GetQuickMenuInstance().field_Private_QuickMenuContextualDisplay_0;

            quickmenuContextualDisplay.Method_Public_Void_EnumNPublicSealedvaUnNoToUs7vUsNoUnique_0(QuickMenuContextualDisplay.EnumNPublicSealedvaUnNoToUs7vUsNoUnique.NoSelection);
            //quickmenuContextualDisplay.Method_Public_Nested0_0(QuickMenuContextualDisplay.Nested0.NoSelection);

            pageTransform.gameObject.SetActive(true);

            currentPageGetter.SetValue(quickmenu, pageTransform.gameObject);
            if (pagename == "ShortcutMenu")
            {
                SetIndex(0);
            }
            else if (pagename == "UserInteractMenu")
            {
                SetIndex(3);
            }
            else
            {
                SetIndex(-1);
            }
        }
コード例 #2
0
ファイル: RubyButtonAPI.cs プロジェクト: VRCMG/PostProcessing
        // Show a Quick Menu page via the Page Name. Hope to god this works!
        public static void ShowQuickmenuPage(string pagename)
        {
            var quickmenu     = GetQuickMenuInstance();
            var pageTransform = quickmenu.transform.Find(pagename);

            if (pageTransform == null)
            {
                Console.WriteLine("[QMStuff] pageTransform is null !");
            }

            if (currentPageGetter == null)
            {
                var shortcutMenu = quickmenu.transform.Find("ShortcutMenu").gameObject;
                if (shortcutMenu != null && !shortcutMenu.activeInHierarchy)
                {
                    shortcutMenu = quickmenu.transform.Find("UserInteractMenu").gameObject;
                }


                var fis = Il2CppType.Of <QuickMenu>().GetFields(BindingFlags.NonPublic | BindingFlags.Instance).Where((fi) => fi.FieldType == Il2CppType.Of <GameObject>()).ToArray();
                //MelonLoader.MelonLogger.Log("[QMStuff] GameObject Fields in QuickMenu:");
                int count = 0;
                foreach (var fi in fis)
                {
                    var value = fi.GetValue(quickmenu)?.TryCast <GameObject>();
                    if (value != shortcutMenu || ++count != 2)
                    {
                        continue;
                    }
                    //MelonLoader.MelonLogger.Log("[QMStuff] currentPage field: " + fi.Name);
                    currentPageGetter = fi;
                    break;
                }
                if (currentPageGetter == null)
                {
                    Console.WriteLine("[QMStuff] Unable to find field currentPage in QuickMenu");
                    return;
                }
            }

            currentPageGetter.GetValue(quickmenu)?.Cast <GameObject>().SetActive(false);

            var infoBar = GetQuickMenuInstance().transform.Find("QuickMenu_NewElements/_InfoBar").gameObject;

            infoBar.SetActive(pagename == "ShortcutMenu");

            QuickMenuContextualDisplay quickmenuContextualDisplay = GetQuickMenuInstance().field_Private_QuickMenuContextualDisplay_0;

            quickmenuContextualDisplay.Method_Public_Void_EnumNPublicSealedvaUnNoToUs7vUsNoUnique_0(QuickMenuContextualDisplay.EnumNPublicSealedvaUnNoToUs7vUsNoUnique.NoSelection);
            //quickmenuContextualDisplay.Method_Public_Nested0_0(QuickMenuContextualDisplay.Nested0.NoSelection);

            pageTransform.gameObject.SetActive(true);

            currentPageGetter.SetValue(quickmenu, pageTransform.gameObject);
            switch (pagename)
            {
            case "ShortcutMenu":
                SetIndex(0);
                break;

            case "UserInteractMenu":
                SetIndex(3);
                break;

            default:
                SetIndex(-1);
                break;
            }
        }