private void CreateButton(string text, int xoffset, Action onClick)
        {
            Transform baseButtonTransform = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/CloseButton") ?? QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/SettingsButton");

            if (baseButtonTransform != null)
            {
                Transform modconf = UnityUiUtils.DuplicateButton(baseButtonTransform, text, new Vector2(0, 0));
                modconf.name = "ModConfigsButton (" + text + ")";
                modconf.GetComponentInChildren <RectTransform>().sizeDelta = new Vector2(300, 100);
                modconf.GetComponentInChildren <Text>().color = Color.white;
                //modconf.GetComponent<Button>().interactable = false;
                modconf.GetComponent <Button>().onClick.RemoveAllListeners();
                modconf.GetComponent <Button>().onClick.AddListener(() => onClick());
                modconf.GetComponent <RectTransform>().SetParent(transform, true);
                modconf.GetComponent <RectTransform>().localPosition    = new Vector3(0, 0, 0);
                modconf.GetComponent <RectTransform>().anchoredPosition = new Vector2(xoffset, -440);
                modconf.GetComponent <RectTransform>().localRotation    = Quaternion.identity;
                modconf.GetComponent <RectTransform>().localScale       = Vector3.one;
                modconf.GetComponentInChildren <Text>().fontSize        = 30;
            }
            else
            {
                VRCModLogger.Log("[ModConfigPage] QuickMenu/ShortcutMenu/SettingsButton and QuickMenu/ShortcutMenu/SettingsButton are null");
            }
        }
Example #2
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");
            }
        }
        private void CreatePref(ModPrefs.PrefDesc pref, ref float totalHeight)
        {
            GameObject textName = new GameObject("PrefName (" + pref.DisplayText + ")", typeof(RectTransform), typeof(Text));

            textName.transform.SetParent(scrollContent, false);
            textName.GetComponent <RectTransform>().sizeDelta        = new Vector2(675f, 70f);
            textName.GetComponent <RectTransform>().anchorMin        = new Vector2(0.5f, 1.0f);
            textName.GetComponent <RectTransform>().anchorMax        = new Vector2(0.5f, 1.0f);
            textName.GetComponent <RectTransform>().pivot            = new Vector2(1f, 1.0f);
            textName.GetComponent <RectTransform>().anchoredPosition = new Vector2(-75, -totalHeight);

            textName.GetComponent <Text>().font            = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/BuildNumText").GetComponent <Text>().font;
            textName.GetComponent <Text>().fontSize        = 50;
            textName.GetComponent <Text>().alignment       = TextAnchor.MiddleRight;
            textName.GetComponent <Text>().alignByGeometry = true;
            textName.GetComponent <Text>().text            = pref.DisplayText;

            if (pref.Type == ModPrefs.PrefType.BOOL)
            {
                UIToggleSwitch toggle = UnityUiUtils.CreateUIToggleSwitch(scrollContent.GetComponent <RectTransform>());
                toggle.GetComponent <RectTransform>().anchorMin        = new Vector2(0.5f, 1.0f);
                toggle.GetComponent <RectTransform>().anchorMax        = new Vector2(0.5f, 1.0f);
                toggle.GetComponent <RectTransform>().pivot            = new Vector2(0.0f, 1.0f);
                toggle.GetComponent <RectTransform>().anchoredPosition = new Vector2(75f, -totalHeight);
                toggle.GetComponent <Toggle>().isOn = pref.Value == "1";
                toggle.OnChange = (isOn) => pref.ValueEdited = isOn ? "1" : "0";
            }
            else
            {
                GameObject textValue = new GameObject("PrefValue (" + pref.DisplayText + ")", typeof(RectTransform), typeof(Text));
                textValue.transform.SetParent(scrollContent, false);
                textValue.GetComponent <RectTransform>().sizeDelta        = new Vector2(675f, 70f);
                textValue.GetComponent <RectTransform>().anchorMin        = new Vector2(0.5f, 1.0f);
                textValue.GetComponent <RectTransform>().anchorMax        = new Vector2(0.5f, 1.0f);
                textValue.GetComponent <RectTransform>().pivot            = new Vector2(0f, 1.0f);
                textValue.GetComponent <RectTransform>().anchoredPosition = new Vector2(75f, -totalHeight);

                textValue.GetComponent <Text>().font            = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/BuildNumText").GetComponent <Text>().font;
                textValue.GetComponent <Text>().fontSize        = 50;
                textValue.GetComponent <Text>().alignment       = TextAnchor.MiddleLeft;
                textValue.GetComponent <Text>().alignByGeometry = true;
                textValue.GetComponent <Text>().text            = pref.Value;
            }

            totalHeight += 70;
        }
Example #4
0
        internal static void Update()
        {
            if (enableNameplateIcons)
            {
                lock (moddedUserList)
                {
                    List <string> npl = new List <string>();
                    if (RoomManager.currentRoom == null)
                    {
                        if (!roomCleared)
                        {
                            roomCleared = true;
                            moddedUserList.Clear();
                            VRCModLogger.Log("[ModdedUsersManager] Cleared userlist");
                        }
                    }
                    else
                    {
                        if (roomCleared)
                        {
                            roomCleared = false;
                            VRCModLogger.Log("[ModdedUsersManager] Now in instance");
                        }
                        foreach (Player p in PlayerManager.GetAllPlayers())
                        {
                            APIUser pau = userProperty.GetValue(p, null) as APIUser;
                            string  pid = pau?.id;
                            if (pid != null && moddedUserList.ContainsKey(pid))
                            {
                                if (!moddedUserListFound.Contains(pid) && p.vrcPlayer != null)
                                {
                                    Transform vrctplayerSprite = UnityUiUtils.DuplicateImage(p.vrcPlayer.friendSprite.transform, new Vector2(140 * 2, 0));
                                    vrctplayerSprite.GetComponent <Image>().sprite = vrctoolsSprite;

                                    VRCModLogger.Log("[ModdedUsersManager] Added VRCTools sprite to " + pid + "'s nameplate");
                                }
                                npl.Add(pid);
                            }
                        }
                    }
                    moddedUserListFound.Clear();
                    moddedUserListFound.AddRange(npl);
                }
            }
        }
Example #5
0
        void Awake()
        {
            scrollContent = UnityUiUtils.CreateScrollView(GetComponent <RectTransform>(), 1500, 850, 0, 875, false, true); // 1000 -> 800
            scrollContent.parent.parent.localPosition = new Vector2(0, 62);

            CreateButton("Apply", -300, () =>
            {
                ModPrefs.SaveConfigs();
                VRCUiManagerUtils.GetVRCUiManager().CloseUi(true);
                VRCUiCursorManager.SetUiActive(false);
            });
            CreateButton("Close", 300, () =>
            {
                ResetConfigs();
                VRCUiManagerUtils.GetVRCUiManager().CloseUi(true);
                VRCUiCursorManager.SetUiActive(false);
            });

            SetupConfigs();
        }
Example #6
0
        public static void Setup()
        {
            try
            {
                Transform baseTextTransform = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/BuildNumText");
                if (baseTextTransform != null)
                {
                    Transform vrcmodNetworkTransform = new GameObject("VRCModNetworkStatusText", typeof(RectTransform), typeof(Text)).transform;
                    vrcmodNetworkTransform.SetParent(baseTextTransform.parent, false);
                    vrcmodNetworkTransform.SetSiblingIndex(baseTextTransform.GetSiblingIndex() + 1);

                    networkstatusText = vrcmodNetworkTransform.GetComponent <Text>();
                    RectTransform networkstatusRT = vrcmodNetworkTransform.GetComponent <RectTransform>();

                    networkstatusRT.localScale = baseTextTransform.localScale;

                    networkstatusRT.anchorMin        = baseTextTransform.GetComponent <RectTransform>().anchorMin;
                    networkstatusRT.anchorMax        = baseTextTransform.GetComponent <RectTransform>().anchorMax;
                    networkstatusRT.anchoredPosition = baseTextTransform.GetComponent <RectTransform>().anchoredPosition;
                    networkstatusRT.sizeDelta        = new Vector2(2000, baseTextTransform.GetComponent <RectTransform>().sizeDelta.y);
                    networkstatusRT.pivot            = baseTextTransform.GetComponent <RectTransform>().pivot;

                    Vector3 newPos = baseTextTransform.localPosition;
                    newPos.x -= baseTextTransform.GetComponent <RectTransform>().sizeDelta.x * 0.5f;
                    newPos.x += 2000 * 0.5f;
                    newPos.y += -85;

                    networkstatusRT.localPosition        = newPos;
                    networkstatusText.text               = "VRCModNetworkStatus: <color=orange>Unknown</color>";
                    networkstatusText.color              = baseTextTransform.GetComponent <Text>().color;
                    networkstatusText.font               = baseTextTransform.GetComponent <Text>().font;
                    networkstatusText.fontSize           = baseTextTransform.GetComponent <Text>().fontSize;
                    networkstatusText.fontStyle          = baseTextTransform.GetComponent <Text>().fontStyle;
                    networkstatusText.horizontalOverflow = HorizontalWrapMode.Overflow;

                    Transform settingsButtonTransform = QuickMenuUtils.GetQuickMenuInstance().transform.Find("ShortcutMenu/SettingsButton");
                    vrcmnwButton = UnityUiUtils.DuplicateButton(settingsButtonTransform, "", new Vector2(-230, -930)).GetComponent <RectTransform>();
                    VRCModLogger.Log("vrcmnwButton pos: " + vrcmnwButton.position.x + ", " + vrcmnwButton.position.y + ", " + vrcmnwButton.position.z);
                    VRCModLogger.Log("networkstatusRT pos: " + networkstatusRT.position.x + ", " + networkstatusRT.position.y + ", " + networkstatusRT.position.z);
                    //vrcmnwButton.gameObject.SetActive(true);
                    //vrcmnwButton.GetComponentInChildren<Text>().text = "Mod/Game\nSettings";
                    //vrcmnwButton.GetComponent<UiTooltip>().text = "Link current VRChat account to your VRCTools account";
                    //vrcmnwButton.position = networkstatusRT.position;
                    Button vrcmnwButtonButton = vrcmnwButton.GetComponent <Button>();
                    vrcmnwButtonButton.onClick = new Button.ButtonClickedEvent();
                    vrcmnwButtonButton.onClick.AddListener(VRCModNetworkManager.LinkVRCAccount);
                    vrcmnwButton.sizeDelta = new Vector2(850, 140);

                    ExpendCollider(QuickMenuUtils.GetQuickMenuInstance().GetComponent <BoxCollider>(), new Vector2(0, -400));

                    Update();
                }
                else
                {
                    VRCModLogger.Log("[VRCMNWStatus] QuickMenu/ShortcutMenu/BuildNumText is null");
                }
            }
            catch (Exception ex)
            {
                VRCModLoader.VRCModLogger.Log("[VRCMNWStatus] " + ex);
            }
        }