private void SearchForAvatars(string text) { VRCUiPopupManagerUtils.ShowPopup("AvatarFav", "Looking for avatars"); VRCModNetworkManager.SendRPC("slaynash.avatarfav.search", text.Trim(), () => { }, (error) => { VRCUiPopupManagerUtils.ShowPopup("AvatarFav", "Unable to fetch avatars:\nVRVCModNetwork returned error:\n" + error, "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup()); }); }
private void RemoveAvatar(string id) { var changed = false; if (savedFavoriteAvatars.ContainsKey(id)) { savedFavoriteAvatars.Remove(id); changed = true; } if (favoriteAvatarList.Contains(id)) { favoriteAvatarList.Remove(id); changed = true; } if (changed) { Save(); } if (useNetwork && !waitingForServer) { new Thread(() => { VRCModNetworkManager.SendRPC("slaynash.avatarfav.removeavatar", id, null, (error) => { addError = "Unable to unfavorite avatar: " + error; favButton.GetComponent <Button>().interactable = true; }); }).Start(); } }
private void AddAvatar(string id) { bool changed = true; if (!favoriteAvatarList.Contains(id)) { favoriteAvatarList.Add(id); changed = true; } if (!savedFavoriteAvatars.ContainsKey(id)) { savedFavoriteAvatars[id] = new SerializableApiAvatar() { id = id }; changed = true; } if (changed) { Save(); } if (useNetwork && !waitingForServer) { new Thread(() => { VRCModNetworkManager.SendRPC("slaynash.avatarfav.addavatar", id, null, (error) => { addError = "Unable to favorite avatar: " + error; favButton.GetComponent <Button>().interactable = true; }); }).Start(); } }
private void RemoveAvatar(string id) { new Thread(() => { VRCModNetworkManager.SendRPC("slaynash.avatarfav.removeavatar", id, null, (error) => { addError = "Unable to unfavorite avatar: " + error; favButton.GetComponent <Button>().interactable = true; }); }).Start(); }
private void RequestAvatars() { new Thread(() => VRCModNetworkManager.SendRPC("slaynash.avatarfav.getavatars", "", null, (error) => { VRCModLogger.Log("[AvatarFav] Unable to fetch avatars: Server returned " + error); if (error.Equals("SERVER_DISCONNECTED")) { waitingForServer = true; } })).Start(); }
private static IEnumerator AddAvatar(string id, string name) { bool done = false; VRCModNetworkManager.SendRPC("slaynash.avatarfav.addavatar", id, () => { VRCModLogger.Log("[VRCheatAvatarfileImporter] Avatar " + name + " successfully added"); importedAvatars++; done = true; }, (error) => { VRCModLogger.Log("[VRCheatAvatarfileImporter] Unable to add the avatar " + name + ": VRCMNW Server returned error: " + error); done = true; }); while (!done) { yield return(null); } }
public void OnUpdate() { if (!initialised) { return; } lock (actions) { foreach (Action a in actions) { try { a(); } catch (Exception e) { VRCModLogger.Log("[AvatarFav] Error while calling action from main thread: " + e); } } actions.Clear(); } try { //Update list if element is active if (favList.gameObject.activeInHierarchy) { lock (favoriteAvatarList) { if (avatarAvailables) { avatarAvailables = false; favList.ClearSpecificList(); if (newAvatarsFirst) { List <string> favReversed = favoriteAvatarList.ToList(); favReversed.Reverse(); favList.specificListIds = favReversed.ToArray(); } else { favList.specificListIds = favoriteAvatarList.ToArray(); } favList.Refresh(); freshUpdate = true; } } } if (pageAvatar.avatar != null && pageAvatar.avatar.apiAvatar != null && CurrentUserUtils.GetGetCurrentUser().GetValue(null) != null && !currentUiAvatarId.Equals(pageAvatar.avatar.apiAvatar.id) || freshUpdate) { currentUiAvatarId = pageAvatar.avatar.apiAvatar.id; bool favorited = favoriteAvatarList.Contains(currentUiAvatarId); if (favorited) { favButtonText.text = "Unfavorite"; } else { favButtonText.text = "Favorite"; } if ((!pageAvatar.avatar.apiAvatar.releaseStatus.Equals("public") && !favorited) || pageAvatar.avatar.apiAvatar.authorId == APIUser.CurrentUser.id) { favButton.gameObject.SetActive(false); avatarModel.localPosition = baseAvatarModelPosition; } else { favButton.gameObject.SetActive(true); avatarModel.localPosition = baseAvatarModelPosition + new Vector3(0, 60, 0); } } //Show returned error if exists if (addError != null) { VRCUiPopupManagerUtils.ShowPopup("Error", addError, "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup()); addError = null; } if (RoomManager.currentRoom != null && RoomManager.currentRoom.id != null && RoomManager.currentRoom.currentInstanceIdOnly != null) { if (currentRoom == null) { currentRoom = RoomManager.currentRoom; if (currentRoom.releaseStatus != "public") { VRCModLogger.Log("[AvatarFav] Current world release status isn't public. Pedestal scan disabled."); } else { VRC_AvatarPedestal[] pedestalsInWorld = GameObject.FindObjectsOfType <VRC_AvatarPedestal>(); VRCModLogger.Log("[AvatarFav] Found " + pedestalsInWorld.Length + " VRC_AvatarPedestal in current world"); string dataToSend = currentRoom.id; foreach (VRC_AvatarPedestal p in pedestalsInWorld) { if (p.blueprintId == null || p.blueprintId == "") { continue; } dataToSend += ";" + p.blueprintId; } VRCModNetworkManager.SendRPC("slaynash.avatarfav.avatarsinworld", dataToSend); } } } else { currentRoom = null; } } catch (Exception e) { VRCModLogger.Log("[AvatarFav] [ERROR] " + e.ToString()); } freshUpdate = false; }