Exemplo n.º 1
0
        public static void Setup()
        {
            //Create mods config page

            GameObject screens      = GameObject.Find("UserInterface/MenuContent/Screens");
            GameObject avatarscreen = GameObject.Find("UserInterface/MenuContent/Screens/Avatar");

            if (avatarscreen != null)
            {
                GameObject go = new GameObject("ModConfig", typeof(RectTransform), typeof(VRCUiPage));
                go.transform.SetParent(screens.transform, false);
                go.GetComponent <VRCUiPage>().screenType  = avatarscreen.GetComponent <VRCUiPage>().screenType;
                go.GetComponent <VRCUiPage>().displayName = "Mod Conf";
                go.GetComponent <VRCUiPage>().AudioShow   = avatarscreen.GetComponent <VRCUiPage>().AudioShow;
                go.GetComponent <VRCUiPage>().AudioLoop   = avatarscreen.GetComponent <VRCUiPage>().AudioLoop;
                go.GetComponent <VRCUiPage>().AudioHide   = avatarscreen.GetComponent <VRCUiPage>().AudioHide;

                go.AddComponent <ModConfigPage>();

                //SCREEN CONTENT SIZE: 1500x1000


                //Create mods config quickmenu button
                Transform baseButtonTransform = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/CloseButton");
                if (baseButtonTransform != null)
                {
                    Transform modconf = UnityUiUtils.DuplicateButton(baseButtonTransform, "Mod\nConfigs", new Vector2(-420, 0));
                    modconf.name = "ModConfigsButton";
                    modconf.GetComponentInChildren <Text>().color = new Color(1, 0.5f, 0.1f);
                    //modconf.GetComponent<Button>().interactable = false;
                    modconf.GetComponent <Button>().onClick.RemoveAllListeners();
                    modconf.GetComponent <Button>().onClick.AddListener(() =>
                    {
                        VRCUiManagerUtils.GetVRCUiManager().ShowUi(false, true);
                        ModManager.StartCoroutine(QuickMenuUtils.PlaceUiAfterPause());
                        VRCUiManagerUtils.GetVRCUiManager().ShowScreen("UserInterface/MenuContent/Screens/ModConfig");
                    });
                }
                else
                {
                    VRCModLogger.Log("[ModConfigPage] QuickMenu/ShortcutMenu/CloseButton is null");
                }
            }
            else
            {
                VRCModLogger.Log("[ModConfigPage] UserInterface/MenuContent/Screens/Avatar is null");
            }
        }
Exemplo n.º 2
0
        public static void Setup()
        {
            try
            {
                //Create mods config page
                VRCModLogger.Log("[ModConfigPage] Setup");

                GameObject avatarscreen = GameObject.Find("UserInterface/MenuContent/Screens/Avatar");
                GameObject cameramenu   = GameObject.Find("UserInterface/MenuContent/Screens/CameraMenu");
                VRCModLogger.Log("[ModConfigPage] avatarscreen: " + avatarscreen);
                if (avatarscreen != null)
                {
                    VRCModLogger.Log("[ModConfigPage] Setting up ModConfigPage");
                    GameObject go = new GameObject("ModConfig", typeof(RectTransform), typeof(VRCUiPage));
                    go.transform.SetParent(avatarscreen.transform.parent, false);
                    go.GetComponent <VRCUiPage>().screenType  = avatarscreen.GetComponent <VRCUiPage>().screenType;
                    go.GetComponent <VRCUiPage>().displayName = "Mod Conf";
                    go.GetComponent <VRCUiPage>().AudioShow   = avatarscreen.GetComponent <VRCUiPage>().AudioShow;
                    go.GetComponent <VRCUiPage>().AudioHide   = avatarscreen.GetComponent <VRCUiPage>().AudioHide;

                    VRCModLogger.Log("[ModConfigPage] Adding ModConfigPage component");
                    go.AddComponent <ModConfigPage>();

                    //SCREEN CONTENT SIZE: 1500x1000


                    VRCModLogger.Log("[ModConfigPage] Editing QuickMenu's Settings button");

                    Transform settingsButtonTransform = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/SettingsButton");
                    settingsButtonTransform.GetComponentInChildren <Text>().text = "Mod/Game\nSettings";
                    settingsButtonTransform.GetComponent <UiTooltip>().text      = "Tune Control, Audio, Video and Mod Settings. Log Out or Quit.";

                    VRCModLogger.Log("[ModConfigPage] Editing QuickMenu's InfoBar");

                    Transform     infobarpanelTransform     = QuickMenuUtils.GetQuickMenuInstance().transform.Find("QuickMenu_NewElements/_InfoBar/Panel");
                    RectTransform infobarpanelRectTransform = infobarpanelTransform.GetComponent <RectTransform>();
                    infobarpanelRectTransform.sizeDelta        = new Vector2(infobarpanelRectTransform.sizeDelta.x, infobarpanelRectTransform.sizeDelta.y + 80);
                    infobarpanelRectTransform.anchoredPosition = new Vector2(infobarpanelRectTransform.anchoredPosition.x, infobarpanelRectTransform.anchoredPosition.y - 40);


                    VRCModLogger.Log("[ModConfigPage] Setting up SettingsMenu");

                    Transform cameraMenuTransform   = QuickMenuUtils.GetQuickMenuInstance().transform.Find("CameraMenu");
                    Transform settingsMenuTransform = Instantiate(cameraMenuTransform, QuickMenuUtils.GetQuickMenuInstance().transform);
                    settingsMenuTransform.name = "SettingsMenu";

                    Button.ButtonClickedEvent showGameConfigMenu = settingsButtonTransform.GetComponent <Button>().onClick;
                    settingsButtonTransform.GetComponent <Button>().onClick = new Button.ButtonClickedEvent();
                    settingsButtonTransform.GetComponent <Button>().onClick.AddListener(() =>
                    {
                        QuickMenuUtils.ShowQuickmenuPage("SettingsMenu");
                    });

                    VRCModLogger.Log("[ModConfigPage] Editing QuickMenu's SettingsMenu buttons");

                    int i = 0;
                    foreach (Transform child in settingsMenuTransform)
                    {
                        if (child != null)
                        {
                            if (i == 0)
                            {
                                child.name = "Game Settings";
                                child.GetComponentInChildren <Text>().text = "Game\nSettings";
                                child.GetComponent <UiTooltip>().text      = "Tune Control, Audio and Video Settings. Log Out or Quit.";
                                child.GetComponent <Button>().onClick      = showGameConfigMenu;
                            }
                            else if (i == 1)
                            {
                                child.name = "Mod Settings";
                                child.GetComponentInChildren <Text>().text = "Mod\nSettings";
                                child.GetComponent <UiTooltip>().text      = "Enable Features or Configure Installed Mods";
                                child.GetComponent <Button>().onClick      = new Button.ButtonClickedEvent();
                                child.GetComponent <Button>().onClick.AddListener(() =>
                                {
                                    VRCUiManagerUtils.GetVRCUiManager().ShowUi(false, true);
                                    ModManager.StartCoroutine(QuickMenuUtils.PlaceUiAfterPause());
                                    VRCUiManagerUtils.GetVRCUiManager().ShowScreen("UserInterface/MenuContent/Screens/ModConfig");
                                });
                            }
                            else if (child.name != "BackButton")
                            {
                                Destroy(child.gameObject);
                            }
                        }
                        i++;
                    }
                }
                else
                {
                    VRCModLogger.Log("[ModConfigPage] UserInterface/MenuContent/Screens/Avatar is null");
                }
            } catch (Exception ex)
            {
                VRCModLoader.VRCModLogger.Log("[ModConfigPage] " + ex.ToString());
            }
        }