Exemple #1
0
        private void AddUserSpecificVolume()
        {
            if (!ModPrefs.GetBool("vrcextended", "userSpecificVolume"))
            {
                return;
            }
            if (VRCEUi.UserInfoScreen == null)
            {
                ExtendedLogger.LogError("Failed to find UserInfo screen!");
                return;
            }

            // -550 - 250f, 230f - 280f
            volVoice  = new VRCEUiVolumeControl("volumeVoice", new Vector2(-620f, -230f), "Voice", 1f, VRCEUi.UserInfoScreen.transform);
            volAvatar = new VRCEUiVolumeControl("volumeAvatar", new Vector2(-290f, -230f), "Avatar", 1f, VRCEUi.UserInfoScreen.transform);
            if (!volVoice.Success || !volAvatar.Success)
            {
                ExtendedLogger.LogError("Failed to create volume sliders on UserInfo!");
                return;
            }

            // Setup volume events
            volVoice.Slider.onValueChanged.AddListener(delegate(float volume)
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }
                ExtendedUser user = ExtendedServer.Users.FirstOrDefault(a => a.APIUser.id == Patch_PageUserInfo.SelectedAPI.id);

                if (user == null)
                {
                    return;
                }
                user.VolumeVoice = volume;
            });

            /*volAvatar.Slider.onValueChanged.AddListener(delegate (float volume)
             * {
             *  if (Patch_PageUserInfo.SelectedUser == null)
             *      return;
             *  Patch_PageUserInfo.SelectedUser.VolumeAvatar = volume;
             * });*/
        }
Exemple #2
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!");
        }