Beispiel #1
0
        private void LoadUserInfoScreen()
        {
            // Refresh Button
            VRCEUiButton btnRefresh = new VRCEUiButton("refresh", new Vector2(0f, 0f), "Refresh");

            btnRefresh.OnClick += () =>
            {
                if (string.IsNullOrEmpty(PageUserInfo.userIdOfLastUserPageInfoViewed))
                {
                    return;
                }
                string id = PageUserInfo.userIdOfLastUserPageInfoViewed;

                ApiCache.Invalidate <APIUser>(id);
                APIUser.FetchUser(id, user =>
                {
                    PageUserInfo pageUserInfo = VRCEUi.UserInfoScreen.GetComponent <PageUserInfo>();

                    if (pageUserInfo != null)
                    {
                        pageUserInfo.SetupUserInfo(user);
                    }
                },
                                  error =>
                                  VRCModLogger.LogError($"Failed to fetch user of id {id}: {error}"));
            };
            VRCMenuUtilsAPI.AddUserInfoButton(btnRefresh);
        }
        public static VRCEUiButton AddUserInfoButton(string name, string text, Action clickAction)
        {
            if (!_UIInitialized)
            {
                return(null);
            }
            VRCEUiButton button = new VRCEUiButton(name, new Vector2(0f, 0f), text);

            button.OnClick += clickAction;

            OnUserInfoButtonAdd?.Invoke(button.Control);
            return(button);
        }
Beispiel #3
0
        public IEnumerator Setup()
        {
            yield return(VRCMenuUtilsAPI.WaitForInit());

            var DropPortalButton = new VRCEUiButton("Portal", Vector2.zero, "Drop Portal");

            DropPortalButton.OnClick += () =>
            {
                //VRCMenuUtilsAPI.GetPage(VRCEUi.UserInfoScreen.name).GetComponentInChildren<PageUserInfo>().user;
                APIUser usr = VRCEUi.UserInfoScreen.GetComponentInChildren <PageUserInfo>().user;
                if (usr.id == APIUser.CurrentUser.id)
                {
                    VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", "You cannot drop a portal to yourself!");
                    return;
                }
                else if (string.IsNullOrEmpty(usr.location))
                {
                    VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", usr.displayName + " has no valid location!");
                    return;
                }
                else if (usr.location.ToLower() == "private")
                {
                    VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", usr.displayName + " is in a private world!");
                    return;
                }
                else if (usr.location.ToLower() == "offline")
                {
                    VRCMenuUtilsAPI.VRCUiPopupManager.ShowAlert("Error", usr.displayName + " is offline!");
                    return;
                }
                string   id       = usr.location;
                string[] instance = id.Split(':');
                if (instance.Length == 2)
                {
                    DropPortalToWorld(instance[0], instance[1]);
                }
                else
                {
                    DropPortalToWorld(id);
                }
            };
            VRCMenuUtilsAPI.AddUserInfoButton(DropPortalButton);
        }
Beispiel #4
0
        private void LoadSocialScreen()
        {
            // Check
            if (VRCEUi.SocialScreen == null)
            {
                return;
            }

            // Get VRChat UI elements
            Transform     currentStatus = VRCEUi.SocialScreen.transform.Find("Current Status");
            Transform     btnStatus     = currentStatus.Find("StatusButton");
            RectTransform rt_btnStatus  = btnStatus.GetComponent <RectTransform>();
            Transform     icnStatus     = currentStatus.Find("StatusIcon");
            RectTransform rt_icnStatus  = icnStatus.GetComponent <RectTransform>();
            Transform     txtStatus     = currentStatus.Find("StatusText");
            RectTransform rt_txtStatus  = txtStatus.GetComponent <RectTransform>();

            // Setup refresh button
            VRCEUiButton  btnRefresh    = new VRCEUiButton("refresh", new Vector2(rt_btnStatus.localPosition.x - 20f, rt_btnStatus.localPosition.y), "Refresh", currentStatus);
            RectTransform rt_btnRefresh = btnRefresh.Control.GetComponent <RectTransform>();

            // Fix UI positions
            rt_btnStatus.localPosition += new Vector3(210f, 0f, 0f);
            rt_icnStatus.localPosition += new Vector3(210f, 0f, 0f);
            rt_txtStatus.localPosition += new Vector3(210f, 0f, 0f);
            rt_btnRefresh.sizeDelta    -= new Vector2(5f, 10f);

            // Add click check
            btnRefresh.OnClick += () =>
            {
                UiUserList[] userLists = VRCEUi.SocialScreen.GetComponentsInChildren <UiUserList>(true);

                foreach (UiUserList userList in userLists)
                {
                    userList.ClearAll();
                    userList.Refresh();
                    userList.RefreshData();
                }
                VRCModLogger.Log("Refreshed social lists!");
            };
        }
        private static IEnumerator SetupUserInfo()
        {
            // Run UI checks
            while (VRCEUi.UserInfoScreen == null)
            {
                yield return(null);
            }

            // Get UserInfo defaults
            _userInfoDefaultButtons = new Transform[]
            {
                VRCEUi.InternalUserInfoScreen.PlaylistsButton,
                VRCEUi.InternalUserInfoScreen.FavoriteButton,
                VRCEUi.InternalUserInfoScreen.ReportButton,
                VRCEUi.InternalUserInfoScreen.OnlineVoteKickButton,
                VRCEUi.InternalUserInfoScreen.OnlineJoinButton,
                VRCEUi.InternalUserInfoScreen.OfflineJoinButton
            };
            if (_userInfoDefaultButtons.Any(a => a == null))
            {
                MVRCLogger.LogError("Failed to get UserInfo default buttons!");
                yield break;
            }
            Vector3 userInfoButtonPos = _userInfoDefaultButtons[0].GetComponent <RectTransform>().localPosition;

            // Load UserInfo UI
            MVRCLogger.Log("Loading UserInfo UI...");
            _userInfoScrollView = new VRCEUiPageScrollView("MoreScroll", new Vector2(userInfoButtonPos.x, userInfoButtonPos.y + 35f), new Vector2(200f, 75f * 5f), 75f, 3, 33f, VRCEUi.InternalUserInfoScreen.UserPanel);
            _userInfoScrollView.Control.gameObject.SetActive(false);

            _userInfoMoreButton = new VRCEUiButton("More", new Vector2(userInfoButtonPos.x, userInfoButtonPos.y + 75f), "More", VRCEUi.InternalUserInfoScreen.UserPanel);
            _userInfoMoreButton.Control.gameObject.SetActive(_userInfoScrollView.HasItems);
            _userInfoMoreButton.OnClick += () =>
                                           SetUserInfoUIState(_userInfoMoreButton.Text == "More");
            VRCEUi.UserInfoScreen.AddComponent <UserInfoActivityManager>();
            MVRCLogger.Log("UserInfo UI has been loaded!");
        }
Beispiel #6
0
        private void AddSocialRefresh()
        {
            if (VRCEUi.SocialScreen == null)
            {
                return;
            }
            Transform     currentStatus = VRCEUi.SocialScreen.transform.Find("Current Status");
            Transform     btnStatus     = currentStatus.Find("StatusButton");
            RectTransform rt_btnStatus  = btnStatus.GetComponent <RectTransform>();
            Transform     icnStatus     = currentStatus.Find("StatusIcon");
            RectTransform rt_icnStatus  = icnStatus.GetComponent <RectTransform>();
            Transform     txtStatus     = currentStatus.Find("StatusText");
            RectTransform rt_txtStatus  = txtStatus.GetComponent <RectTransform>();

            VRCEUiButton  btnRefresh    = new VRCEUiButton("Refresh", new Vector2(rt_btnStatus.localPosition.x - 20f, rt_btnStatus.localPosition.y), "Refresh", currentStatus);
            RectTransform rt_btnRefresh = btnRefresh.Control.GetComponent <RectTransform>();

            rt_btnStatus.localPosition += new Vector3(210f, 0f, 0f);
            rt_icnStatus.localPosition += new Vector3(210f, 0f, 0f);
            rt_txtStatus.localPosition += new Vector3(210f, 0f, 0f);
            rt_btnRefresh.sizeDelta    -= new Vector2(5f, 10f);

            btnRefresh.Button.onClick.AddListener(() =>
            {
                UiUserList[] userLists = VRCEUi.SocialScreen.GetComponentsInChildren <UiUserList>(true);

                foreach (UiUserList userList in userLists)
                {
                    userList.ClearAll();
                    userList.Refresh();
                    userList.FetchAndRenderElementsForCurrentPage();
                    userList.RefreshData();
                }
                ExtendedLogger.Log("Refreshed social lists!");
            });
        }
 public static void AddUserInfoButton(VRCEUiButton button) =>
 AddUserInfoButton(button.Control);
Beispiel #8
0
        public VRCEUiPageScrollView(string name, Vector2 position, Vector2 size, float spacing, int itemsPerPage, float padding = 0f, Transform parent = null)
        {
            // Create game objects
            GameObject goControl        = new GameObject(name);
            GameObject goContentControl = new GameObject("Content");

            // Get positions
            Position        = goControl.GetOrAddComponent <RectTransform>();
            ContentPosition = goContentControl.GetOrAddComponent <RectTransform>();

            // Set UI properties
            Control        = goControl.transform;
            ContentControl = goContentControl.transform;

            // Set required parts
            if (parent != null)
            {
                Control.SetParent(parent);
            }

            // Setup Control
            Control.localScale     = Vector3.one;
            Control.localRotation  = Quaternion.identity;
            Control.localPosition  = Vector3.zero;
            Position.anchorMin     = new Vector2(0.5f, 0f);
            Position.anchorMax     = new Vector2(0.5f, 0f);
            Position.pivot         = new Vector2(0.5f, 1f);
            Position.localPosition = new Vector3(position.x, position.y, 0f);
            Position.sizeDelta     = size;

            // Create buttons
            VRCEUiButton buttonUp   = new VRCEUiButton("UpButton", new Vector2(0f, -30f), "ʌ Up ʌ", goControl.transform);
            VRCEUiButton buttonDown = new VRCEUiButton("DownButton", new Vector2(0f, (30f - size.y)), "v Down v", goControl.transform);

            // Setup UpButton
            UpButtonPosition            = buttonUp.Position;
            UpButtonObject              = buttonUp.ButtonObject;
            UpButtonControl             = buttonUp.Control;
            UpButtonObject.interactable = false;
            UpButtonPosition.sizeDelta -= new Vector2(0f, Mathf.Ceil(UpButtonPosition.sizeDelta.y / 2f));
            UpButtonObject.onClick.AddListener(() =>
            {
                if (CurrentPage < 1)
                {
                    return;
                }

                SetPage(CurrentPage - 1);
            });

            // Setup DownButton
            DownButtonPosition            = buttonDown.Position;
            DownButtonObject              = buttonDown.ButtonObject;
            DownButtonControl             = buttonDown.Control;
            DownButtonObject.interactable = false;
            DownButtonPosition.sizeDelta -= new Vector2(0f, Mathf.Ceil(DownButtonPosition.sizeDelta.y / 2f));
            DownButtonObject.onClick.AddListener(() =>
            {
                if (CurrentPage >= (Pages.Count - 1))
                {
                    return;
                }

                SetPage(CurrentPage + 1);
            });

            // Setup Content
            ContentControl.SetParent(Control);
            ContentControl.localScale     = Vector3.one;
            ContentControl.localRotation  = Quaternion.identity;
            ContentControl.localPosition  = Vector3.zero;
            ContentPosition.anchorMin     = new Vector2(0.5f, 0f);
            ContentPosition.anchorMax     = new Vector2(0.5f, 0f);
            ContentPosition.pivot         = new Vector2(0.5f, 1f);
            ContentPosition.localPosition = new Vector3(0f, -60f, 0f);
            ContentPosition.sizeDelta     = new Vector2(size.x, size.y - (UpButtonPosition.sizeDelta.y + 100f));

            // Finish
            ItemsPerPage = itemsPerPage;
            Spacing      = spacing;
            Padding      = padding;
            VRCEUiScrollPage page = new VRCEUiScrollPage(itemsPerPage, spacing, padding, this);

            page.SetActive(true);
            Pages.Add(page);
            Success = true;
        }
Beispiel #9
0
        private void AddUserInfoButtons()
        {
            if (VRCEUi.UserInfoScreen == null)
            {
                ExtendedLogger.LogError("Failed to find UserInfo screen!");
                return;
            }

            Transform btnPlaylists = VRCEUi.InternalUserInfoScreen.PlaylistsButton;
            Transform btnFavorite  = VRCEUi.InternalUserInfoScreen.FavoriteButton;
            Transform btnReport    = VRCEUi.InternalUserInfoScreen.ReportButton;

            if (btnPlaylists == null || btnFavorite == null || btnReport == null)
            {
                ExtendedLogger.LogError("Failed to get required button!");
                return;
            }
            Vector3 pos = btnPlaylists.GetComponent <RectTransform>().localPosition;

            UserInfoLastLogin = new VRCEUiText("LastLoginText", new Vector2(-470f, -130f), "", VRCEUi.UserInfoScreen.transform);
            UserInfoLastLogin.Text.fontSize -= 20;

            UserInfoMore = new VRCEUiButton("More", new Vector2(pos.x, pos.y + 75f), "More", VRCEUi.InternalUserInfoScreen.UserPanel);
            UserInfoMore.Button.onClick.AddListener(() =>
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }
                ToggleUserInfoMore(UserInfoMore.Text.text == "More");
            });

            UserInfoColliderControl = new VRCEUiButton("ColliderControl", new Vector2(pos.x, pos.y - 75f), "Not in world!", VRCEUi.InternalUserInfoScreen.UserPanel);
            UserInfoColliderControl.Control.gameObject.SetActive(false);
            UserInfoColliderControl.Button.onClick.AddListener(() =>
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }
                ExtendedUser user = ExtendedServer.Users.FirstOrDefault(a => a.APIUser.id == Patch_PageUserInfo.SelectedAPI.id);

                if (user == null)
                {
                    return;
                }
                user.HasColliders = !user.HasColliders;
                UserInfoColliderControl.Text.text = (user.HasColliders ? "Disable colliders" : "Enable colliders");
            });

            UserInfoRefresh = new VRCEUiButton("Refresh", new Vector2(pos.x, pos.y), "Refresh", VRCEUi.InternalUserInfoScreen.UserPanel);
            UserInfoRefresh.Control.gameObject.SetActive(false);
            UserInfoRefresh.Button.onClick.AddListener(() =>
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }

                ApiCache.Invalidate <APIUser>(Patch_PageUserInfo.SelectedAPI.id);
                APIUser.FetchUser(Patch_PageUserInfo.SelectedAPI.id, (APIUser user) =>
                {
                    PageUserInfo pageUserInfo = VRCEUi.UserInfoScreen.GetComponent <PageUserInfo>();
                    if (pageUserInfo != null)
                    {
                        pageUserInfo.SetupUserInfo(user);
                    }
                },
                                  (string error) =>
                {
                    ExtendedLogger.LogError(error);
                });
            });
            ExtendedLogger.Log("Setup PageUserInfo!");
        }