示例#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);
        }
示例#2
0
        public IEnumerator GetInstanceCreator(ApiWorldInstance instance)
        {
            string creator = instance.ownerId;

            if (creator != null)
            {
                if (creator == APIUser.CurrentUser? .id)
                {
                    if (LocalPlayerEntry.emmNameSpoofEnabled)
                    {
                        textComponent.text = OriginalText.Replace("{instancecreator}", LocalPlayerEntry.emmSpoofedName);
                    }
                    else
                    {
                        textComponent.text = OriginalText.Replace("{instancecreator}", APIUser.CurrentUser.displayName);
                    }
                    yield break;
                }

                textComponent.text = OriginalText.Replace("{instancecreator}", "Loading...");

                yield return(new WaitForSeconds(4));

                APIUser.FetchUser(creator, new Action <APIUser>(OnIdReceived), null);
                yield break;
            }
            else
            {
                textComponent.text = OriginalText.Replace("{instancecreator}", "No Instance Creator");
            }
        }
示例#3
0
        private static IEnumerator FetchAPIUsers()
        {
            while (true)
            {
                yield return(new WaitForSeconds(1f));

                while (UsersToFetch.Count > 0)
                {
                    var id = UsersToFetch.Dequeue();
                    APIUser.FetchUser(id, new Action <APIUser>(user =>
                    {
                        CachedApiUsers.Add(user);
                        if (_reloadAvatar.Value)
                        {
                            var player = GetPlayerByUserId(id);
                            _reloadAvatarMethod.Invoke(player._vrcplayer, new object[] { true });
                        }
                    }), new Action <string>(error =>
                    {
                        MelonLogger.Error($"Could not fetch APIUser object of {id}");
                    }));
                    yield return(new WaitForSeconds(Random.Next(2, 5)));
                }
            }
        }
示例#4
0
        //string , GameObject , VRCSDK2.Validation.Performance.Stats.AvatarPerformanceStats

        public override void VRChat_OnUiManagerInit()
        {
            if (Config.CFG.Custom)
            {
                CustomList = AvatarListApi.Create(Config.CFG.CustomName + " / " + Config.DAvatars.Count, 1);
                CustomList.AList.FirstLoad(Config.DAvatars);


                CustomList.AList.avatarPedestal.field_Internal_Action_3_String_GameObject_AvatarPerformanceStats_0 = new Action <string, GameObject, VRCSDK2.Validation.Performance.Stats.AvatarPerformanceStats>((x, y, z) =>
                {
                    if (Config.DAvatars.Any(v => v.AvatarID == CustomList.AList.avatarPedestal.field_Internal_ApiAvatar_0.id))
                    {
                        FavoriteButton.Title.text = Config.CFG.RemoveFavoriteTXT;
                        CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                    }
                    else
                    {
                        FavoriteButton.Title.text = Config.CFG.AddFavoriteTXT;
                        CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                    }
                });

                //Add-Remove Favorite Button
                FavoriteButton = AviPButton.Create(Config.CFG.AddFavoriteTXT, 0f, 9.6f);
                FavoriteButton.SetAction(() =>
                {
                    var avatar = CustomList.AList.avatarPedestal.field_Internal_ApiAvatar_0;
                    if (avatar.releaseStatus != "private")
                    {
                        if (!Config.DAvatars.Any(v => v.AvatarID == avatar.id))
                        {
                            AvatarListHelper.AvatarListPassthru(avatar);
                            CustomList.AList.Refresh(Config.DAvatars.Select(x => x.AvatarID).Reverse());
                            FavoriteButton.Title.text = Config.CFG.RemoveFavoriteTXT;
                            CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                        }
                        else
                        {
                            AvatarListHelper.AvatarListPassthru(avatar);
                            CustomList.AList.Refresh(Config.DAvatars.Select(x => x.AvatarID).Reverse());
                            FavoriteButton.Title.text = Config.CFG.AddFavoriteTXT;
                            CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                        }
                    }
                });

                //Author Button
                var t = AviPButton.Create("Show Author", 320f, 9.6f);
                t.SetScale(-.1f);
                t.SetAction(() =>
                {
                    VRCUiManager.prop_VRCUiManager_0.Method_Public_Void_Boolean_0(true);
                    APIUser.FetchUser(CustomList.AList.avatarPedestal.field_Internal_ApiAvatar_0.authorId, new Action <APIUser>(x =>
                    {
                        QuickMenu.prop_QuickMenu_0.prop_APIUser_0 = x;
                        QuickMenu.prop_QuickMenu_0.Method_Public_Void_Int32_Boolean_0(4, false);
                    }), null);
                });
            }
        }
示例#5
0
        private static void SetupUserInfo(PageUserInfo __instance)
        {
            SelectedAPI = __instance.user;
            ExtendedUser eUser = ExtendedServer.Users.FirstOrDefault(a => a.UniqueID == SelectedAPI.id);

            VRCExtended.ToggleUserInfoMore(false);
            VRCEUi.InternalUserInfoScreen.Moderator.gameObject.SetActive(false);
            if (APIUser.CurrentUser.id == __instance.user.id)
            {
                VRCExtended.UserInfoLastLogin.Text.text      = "";
                VRCExtended.UserInfoMore.Button.interactable = false;
            }
            else
            {
                APIUser.FetchUser(__instance.user.id, (APIUser user) =>
                {
                    if (string.IsNullOrEmpty(user.last_login))
                    {
                        return;
                    }
                    DateTime dt = DateTime.Parse(user.last_login);

                    if (ModPrefs.GetBool("vrcextended", "useDTFormat"))
                    {
                        VRCExtended.UserInfoLastLogin.Text.text = "Last login: "******"MM.dd.yyyy hh:mm tt");
                    }
                    else
                    {
                        VRCExtended.UserInfoLastLogin.Text.text = "Last login: "******"dd.MM.yyyy hh:mm");
                    }
                },
                                  (string error) =>
                {
                    ExtendedLogger.LogError(error);
                });
                VRCExtended.UserInfoMore.Button.interactable = true;

                if (eUser != null)
                {
                    VRCExtended.UserInfoColliderControl.Button.interactable = true;
                    VRCExtended.UserInfoColliderControl.Text.text           = (eUser.HasColliders ? "Disable colliders" : "Enable colliders");
                }
                else
                {
                    VRCExtended.UserInfoColliderControl.Button.interactable = false;
                    VRCExtended.UserInfoColliderControl.Text.text           = "Not in world!";
                }
            }
        }
示例#6
0
文件: Main.cs 项目: VRCMG/SocialColor
        private static void FetchAPIUserOnJoined(ref Player __0)
        {
            var apiUser = __0.field_Private_APIUser_0;

            if (PlayerWrappers.CachedApiUsers.Exists(x => x.id == apiUser.id))
            {
                return;
            }

            APIUser.FetchUser(apiUser.id, new Action <APIUser>(user =>
            {
                PlayerWrappers.CachedApiUsers.Add(user);
            }), new Action <string>(error =>
            {
                MelonLogger.Error($"Could not fetch APIUser object of {apiUser.displayName}-{apiUser.id}");
            }));
        }
示例#7
0
        public void RefreshAPIUser()
        {
            if (!Utils.StartRequestTimer(new Action(() => { if (refreshButtonLabel != null)
                                                            {
                                                                refreshButtonLabel.text = "Please wait between button presses";
                                                            }
                                                    }),
                                         new Action(() => { if (refreshButtonLabel != null)
                                                            {
                                                                refreshButtonLabel.text = "Pressing this button may be able to find unknown data";
                                                            }
                                                    })))
            {
                return;
            }

            if (Utils.ActiveUIEUser == null || !Utils.ActiveUIEUser.IsFullAPIUser) // Only bother to refresh if there's actually any invalid data // Still resets timer for consistent behavior on user's end
            {
                APIUser.FetchUser(VRCUtils.ActiveUserInUserInfoMenu.id, new Action <APIUser>((user) => OnUIXMenuOpen()), null);
            }
        }
示例#8
0
        protected override void ProcessText(object[] parameters = null)
        {
            if (RoomManager.field_Internal_Static_ApiWorldInstance_0 != null)
            {
                if (hasCheckedInstance)
                {
                    ChangeEntry("instancecreator", lastUserDisplayName);
                    return;
                }

                Il2CppSystem.Collections.Generic.List <ApiWorldInstance.InstanceTag> tags = RoomManager.field_Internal_Static_ApiWorldInstance_0.ParseTags(RoomManager.field_Internal_Static_ApiWorldInstance_0.idWithTags);
                foreach (ApiWorldInstance.InstanceTag tag in tags)
                {
                    if (tag.name == "private" || tag.name == "friend" || tag.name == "hidden")
                    {
                        foreach (Player player in PlayerManager.prop_PlayerManager_0.field_Private_List_1_Player_0)
                        {
                            if (player.field_Private_APIUser_0.id == tag.data)
                            {
                                ChangeEntry("instancecreator", player.field_Private_APIUser_0.displayName);
                                lastUserDisplayName = player.field_Private_APIUser_0.displayName;
                                hasCheckedInstance  = true;
                                return;
                            }
                        }

                        APIUser.FetchUser(tag.data, new Action <APIUser>(OnIdReceived), null);
                        ChangeEntry("instancecreator", "Loading...");
                        hasCheckedInstance = true;
                        return;
                    }
                }
            }
            lastUserDisplayName = "No Instance Creator";
            ChangeEntry("instancecreator", "No Instance Creator");
            hasCheckedInstance = true;
        }
示例#9
0
 public static void OpenUserInSocialMenu(string userId) => APIUser.FetchUser(userId, new Action <APIUser>(OnUserFetched), new Action <string>((thing) => UiManager.OpenErrorPopup("Something went wrong and the author could not be retreived.")));
示例#10
0
文件: IceBurn.cs 项目: VRCMG/IceBurn
        public override void VRChat_OnUiManagerInit()
        {
            //Modules.Add(new UIButtons());

            foreach (var item in Modules)
            {
                item.OnStart();
            }

            if (Config.CFG.Custom)
            {
                CustomList = AvatarListApi.Create(Config.CFG.CustomName + " / " + Config.DAvatars.Count, 1);
                CustomList.AList.FirstLoad(Config.DAvatars);


                //New Age - Delegates lol // thanks for the help khan understanding this.
                Il2CppSystem.Delegate test = (Il2CppSystem.Action <string, GameObject, VRCSDK2.Validation.Performance.Stats.AvatarPerformanceStats>) new Action <string, GameObject, VRCSDK2.Validation.Performance.Stats.AvatarPerformanceStats>((x, y, z) =>
                {
                    if (Config.DAvatars.Any(v => v.AvatarID == CustomList.AList.avatarPedestal.field_Internal_ApiAvatar_0.id))
                    {
                        FavoriteButton.Title.text = Config.CFG.RemoveFavoriteTXT;
                        CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                    }
                    else
                    {
                        FavoriteButton.Title.text = Config.CFG.AddFavoriteTXT;
                        CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                    }
                });

                //Insane how long this line is LOL;
                CustomList.AList.avatarPedestal.field_Internal_Action_3_String_GameObject_AvatarPerformanceStats_0 = Il2CppSystem.Delegate.Combine(CustomList.AList.avatarPedestal.field_Internal_Action_3_String_GameObject_AvatarPerformanceStats_0, test).Cast <Il2CppSystem.Action <string, GameObject, VRCSDK2.Validation.Performance.Stats.AvatarPerformanceStats> >();


                //Add-Remove Favorite Button
                FavoriteButton = AviPButton.Create(Config.CFG.AddFavoriteTXT, 0f, 2f);
                FavoriteButton.SetAction(() =>
                {
                    var avatar = CustomList.AList.avatarPedestal.field_Internal_ApiAvatar_0;
                    if (avatar.releaseStatus != "private")
                    {
                        if (!Config.DAvatars.Any(v => v.AvatarID == avatar.id))
                        {
                            AvatarListHelper.AvatarListPassthru(avatar);
                            CustomList.AList.Refresh(Config.DAvatars.Select(x => x.AvatarID).Reverse());
                            FavoriteButton.Title.text = Config.CFG.RemoveFavoriteTXT;
                            CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                        }
                        else
                        {
                            AvatarListHelper.AvatarListPassthru(avatar);
                            CustomList.AList.Refresh(Config.DAvatars.Select(x => x.AvatarID).Reverse());
                            FavoriteButton.Title.text = Config.CFG.AddFavoriteTXT;
                            CustomList.ListTitle.text = Config.CFG.CustomName + " / " + Config.DAvatars.Count;
                        }
                    }
                });

                DownloadButton = AviPButton.Create(Config.CFG.DownloadTXT, 1150f, 9.6f);
                DownloadButton.SetAction(() =>
                {
                    var avatar = CustomList.AList.avatarPedestal.field_Internal_ApiAvatar_0;
                    Process.Start(avatar.assetUrl);
                });

                //Author Button
                var t     = AviPButton.Create("Show Author", 0f, 9.6f);
                var scale = t.GameObj.transform.localScale;
                t.GameObj.transform.localScale = new Vector3(scale.x - 0.1f, scale.y - 0.1f, scale.z - 0.1f);
                t.SetAction(() =>
                {
                    VRCUiManager.prop_VRCUiManager_0.Method_Public_Void_Boolean_0(true);
                    APIUser.FetchUser(CustomList.AList.avatarPedestal.field_Internal_ApiAvatar_0.authorId, new Action <APIUser>(x =>
                    {
                        QuickMenu.prop_QuickMenu_0.prop_APIUser_0 = x;
                        QuickMenu.prop_QuickMenu_0.Method_Public_Void_Int32_Boolean_0(4, false);
                    }), null);
                });
            }
        }
示例#11
0
 public static void OpenUserInSocialMenu(string userId) => APIUser.FetchUser(userId, new Action <APIUser>(OnUserFetched), new Action <string>((thing) => { VRCUtils.OpenPopupV2("Error!", "Something went wrong and the author could not be retreived.", "Close", new Action(VRCUtils.ClosePopup)); }));
示例#12
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!");
        }