Beispiel #1
0
        public override void Init(object[] parameters)
        {
            isSelf = true;
            EntryManager.localPlayerEntry = this;
            player  = Player.prop_Player_0;
            apiUser = player.prop_APIUser_0;
            userId  = apiUser.id;

            gameObject.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(new Action(() => UiManager.OpenUserInQuickMenu(player)));

            platform = PlayerUtils.GetPlatform(player).PadRight(2);
            // Join event runs after avatar instantiation event so perf calculations *should* be finished (also not sure if this will throw null refs so gonna release without a check and hope for the best)
            perf       = PerformanceRating.None;
            perfString = "<color=#" + ColorUtility.ToHtmlStringRGB(VRCUiAvatarStatsPanel.Method_Private_Static_Color_AvatarPerformanceCategory_PerformanceRating_0(AvatarPerformanceCategory.Overall, perf)) + ">" + PlayerUtils.ParsePerformanceText(perf) + "</color>";

            NetworkEvents.OnPlayerJoined += new Action <Player>((player) =>
            {
                int highestId = 0;
                foreach (int photonId in PlayerManager.prop_PlayerManager_0.field_Private_Dictionary_2_Int32_Player_0.Keys)
                {
                    if (photonId > highestId)
                    {
                        highestId = photonId;
                    }
                }

                highestPhotonIdLength = highestId.ToString().Length;
            });

            GetPlayerColor();
            OnConfigChanged();
        }
Beispiel #2
0
        public override void Init(object[] parameters)
        {
            player  = (Player)parameters[0];
            apiUser = player.prop_APIUser_0;
            userId  = apiUser.id;

            platform   = platform = PlayerUtils.GetPlatform(player).PadRight(2);
            perf       = PerformanceRating.None;
            perfString = "<color=#" + ColorUtility.ToHtmlStringRGB(VRCUiAvatarStatsPanel.Method_Private_Static_Color_AvatarPerformanceCategory_PerformanceRating_0(AvatarPerformanceCategory.Overall, perf)) + ">" + PlayerUtils.ParsePerformanceText(perf) + "</color>";

            gameObject.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(new Action(() => UiManager.OpenUserInQuickMenu(player)));

            isFriend = APIUser.IsFriendsWith(apiUser.id);
            GetPlayerColor(false);
        }
Beispiel #3
0
        public override void OnAvatarInstantiated(VRCAvatarManager manager, ApiAvatar avatar, GameObject gameObject)
        {
            apiUser = player.prop_APIUser_0;
            userId  = apiUser.id;
            if (manager.field_Private_VRCPlayer_0.prop_Player_0.prop_APIUser_0?.id != userId)
            {
                return;
            }

            perf       = manager.prop_AvatarPerformanceStats_0.field_Private_ArrayOf_PerformanceRating_0[(int)AvatarPerformanceCategory.Overall];
            perfString = "<color=#" + ColorUtility.ToHtmlStringRGB(VRCUiAvatarStatsPanel.Method_Private_Static_Color_AvatarPerformanceCategory_PerformanceRating_0(AvatarPerformanceCategory.Overall, perf)) + ">" + PlayerUtils.ParsePerformanceText(perf) + "</color>";

            if (player.prop_PlayerNet_0 != null)
            {
                UpdateEntry(player.prop_PlayerNet_0, this, true);
            }

            if (EntrySortManager.IsSortTypeInUse(EntrySortManager.SortType.AvatarPerf))
            {
                EntrySortManager.SortPlayer(playerLeftPairEntry);
            }
        }
Beispiel #4
0
        protected override void ProcessText(object[] parameters = null)
        {
            if (player == null)
            {
                Remove();                 // Sometimes ppl will desync causing the leave event to not call
            }
            if (playerNet != null)
            {
                if (Config.pingToggle.Value)
                {
                    short ping = playerNet.prop_Int16_0;
                    AddColor(GetPingColor(ping));
                    if (ping < 9999 && ping > -999)
                    {
                        AddEndColor(ping.ToString().PadRight(4) + "ms");
                    }
                    else
                    {
                        AddEndColor(((double)(ping / 1000)).ToString("N1").PadRight(5) + "s");
                    }
                    AddSpacer();
                }

                // I STG if I have to remove fps because skids start walking up to people saying poeple's fps im gonna murder someone
                if (Config.fpsToggle.Value)
                {
                    int fps = Mathf.Clamp((int)(1000f / playerNet.field_Private_Byte_0), -99, 999);

                    AddColor(GetFpsColor(fps));
                    if (playerNet.field_Private_Byte_0 == 0)
                    {
                        AddEndColor("?¿?");
                    }
                    else
                    {
                        AddEndColor(fps.ToString().PadRight(3));
                    }
                    AddSpacer();
                }
            }
            else
            {
                if (Config.pingToggle.Value)
                {
                    AddColoredText("#ff0000", "?¿?".PadRight(4));
                    AddSpacer();
                }

                // I STG if I have to remove fps because skids start walking up to people saying poeple's fps im gonna murder someone
                if (Config.fpsToggle.Value)
                {
                    AddColoredText("#ff0000", "?¿?".PadRight(3));
                    AddSpacer();
                }

                playerNet = player.GetComponent <PlayerNet>();
            }

            if (Config.platformToggle.Value)
            {
                AddText(ParsePlatform(player).PadRight(2));
                AddSpacer();
            }

            if (Config.perfToggle.Value)
            {
                PerformanceRating rating = player.field_Internal_VRCPlayer_0.prop_VRCAvatarManager_0.prop_AvatarPerformanceStats_0.field_Private_ArrayOf_PerformanceRating_0[(int)AvatarPerformanceCategory.Overall]; // Get from cache so it doesnt calculate perf all at once
                AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCUiAvatarStatsPanel.Method_Private_Static_Color_AvatarPerformanceCategory_PerformanceRating_0(AvatarPerformanceCategory.Overall, rating)), ParsePerformanceText(rating));
                AddSpacer();
            }

            if (Config.distanceToggle.Value)
            {
                if (worldAllowed)
                {
                    float distance = (player.transform.position - Player.prop_Player_0.transform.position).magnitude;
                    if (distance < 100)
                    {
                        AddText(distance.ToString("N1").PadRight(4) + "m");
                    }
                    else if (distance < 10000)
                    {
                        AddText((distance / 1000).ToString("N1").PadRight(3) + "km");
                    }
                    else if (distance < 999900)
                    {
                        AddText((distance / 1000).ToString("N0").PadRight(3) + "km");
                    }
                    else
                    {
                        AddText((distance / 9.461e+15).ToString("N2").PadRight(3) + "ly"); // If its too large for kilometers ***just convert to light years***
                    }
                }
                else
                {
                    AddText("0.0 m");
                }
                AddSpacer();
            }

            if (Config.photonIdToggle.Value)
            {
                AddText(player.field_Internal_VRCPlayer_0.field_Private_PhotonView_0.field_Private_Int32_0.ToString().PadRight(highestPhotonIdLength));
                AddSpacer();
            }

            if (Config.displayNameToggle.Value) // Why?
            {
                switch (Config.DisplayNameColorMode)
                {
                case PlayerListMod.DisplayNameColorMode.TrustAndFriends:
                    AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(player.field_Private_APIUser_0)), player.field_Private_APIUser_0.displayName);
                    break;

                case PlayerListMod.DisplayNameColorMode.None:
                    AddText(player.field_Private_APIUser_0.displayName);
                    break;

                case PlayerListMod.DisplayNameColorMode.TrustOnly:
                    // ty bono for this (https://github.com/ddakebono/)
                    spoofFriend = true;
                    AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(player.field_Private_APIUser_0)), player.field_Private_APIUser_0.displayName);
                    break;

                case PlayerListMod.DisplayNameColorMode.FriendsOnly:
                    if (APIUser.IsFriendsWith(player.field_Private_APIUser_0.id))
                    {
                        AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(player.field_Private_APIUser_0)), player.field_Private_APIUser_0.displayName);
                    }
                    else
                    {
                        AddText(player.field_Private_APIUser_0.displayName);
                    }
                    break;
                }
                AddSpacer();
            }

            if (textComponent.text.Length > 0)
            {
                if (Config.condensedText.Value)
                {
                    textComponent.text = textComponent.text.Remove(textComponent.text.Length - 1, 1);
                }
                else
                {
                    textComponent.text = textComponent.text.Remove(textComponent.text.Length - 3, 3);
                }
            }

            if (!Config.numberedList.Value)
            {
                if (Config.condensedText.Value)
                {
                    AddTextToBeginning("-");
                }
                else
                {
                    AddTextToBeginning(" - ");
                }
            }
            else
            if (Config.condensedText.Value)
            {
                AddTextToBeginning($"{gameObject.transform.GetSiblingIndex() - 1}.".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 1));     // Pad by weird amount because we cant include the header and disabled template in total number of gameobjects
            }
            else
            {
                AddTextToBeginning($"{gameObject.transform.GetSiblingIndex() - 1}. ".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 2));
            }
        }
Beispiel #5
0
        protected override void ProcessText(object[] parameters)
        {
            // TODO: Figure out how to figure out how to know when someone blcosk u

            /*
             * List<PlayerEntry> playerEntries = PlayerListMod.playerEntries.Values.ToList();
             * // Get blocked things
             * foreach (ApiPlayerModeration moderation in ModerationManager.prop_ModerationManager_0.field_Private_List_1_ApiPlayerModeration_0)
             * {
             *  if (moderation.moderationType != ApiPlayerModeration.ModerationType.Block) continue;
             *
             *  foreach (PlayerEntry playerEntry in playerEntries)
             *  {
             *      if (playerEntry.youBlocked) continue;
             *
             *      if (playerEntry.player == null)
             *      {
             *          playerEntry.Remove();
             *          continue;
             *      }
             *
             *      if (playerEntry.userID == moderation.targetUserId)
             *      {
             *          playerEntry.youBlocked = true;
             *          MelonLoader.MelonLogger.Msg($"You have blocked {moderation.targetDisplayName}");
             *          break;
             *      }
             *  }
             * }
             */
            // Get highest photonId once per update
            int highestId = 0;

            foreach (int photonId in PlayerManager.prop_PlayerManager_0.field_Private_Dictionary_2_Int32_Player_0.Keys)
            {
                if (photonId > highestId)
                {
                    highestId = photonId;
                }
            }

            PlayerEntry.highestPhotonIdLength = highestId.ToString().Length;

            // Convert to byte as that's what's sent over network so if you spoof your ping you'll see what's actually sent over the network
            if (Config.pingToggle.Value)
            {
                short ping = (short)Photon.Pun.PhotonNetwork.field_Public_Static_LoadBalancingClient_0.prop_LoadBalancingPeer_0.RoundTripTime;
                AddColor(PlayerEntry.GetPingColor(ping));
                if (ping < 9999 && ping > -999)
                {
                    AddEndColor(ping.ToString().PadRight(4) + "ms");
                }
                else
                {
                    AddEndColor(((double)(ping / 1000)).ToString("N1").PadRight(5) + "s");
                }
                AddSpacer();
            }

            // I STG if I have to remove fps because skids start walking up to people saying poeple's fps im gonna murder someone
            if (Config.fpsToggle.Value)
            {
                int fps = Mathf.Clamp((int)(1f / Time.deltaTime), -99, 999); // Clamp between -99 and 999
                AddColoredText(PlayerEntry.GetFpsColor(fps), fps.ToString().PadRight(3));
                AddSpacer();
            }

            if (Config.platformToggle.Value)
            {
                AddText(PlayerEntry.ParsePlatform(Player.prop_Player_0).PadRight(2));
                AddSpacer();
            }

            if (Config.perfToggle.Value)
            {
                PerformanceRating rating = Player.prop_Player_0.field_Internal_VRCPlayer_0.prop_VRCAvatarManager_0.prop_AvatarPerformanceStats_0.field_Private_ArrayOf_PerformanceRating_0[(int)AvatarPerformanceCategory.Overall]; // Get from cache so it doesnt calculate perf all at once
                AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCUiAvatarStatsPanel.Method_Private_Static_Color_AvatarPerformanceCategory_PerformanceRating_0(AvatarPerformanceCategory.Overall, rating)), PlayerEntry.ParsePerformanceText(rating).PadRight(5));
                AddSpacer();
            }

            if (Config.distanceToggle.Value)
            {
                AddText("0.0 m");
                AddSpacer();
            }

            if (Config.photonIdToggle.Value)
            {
                AddText(Player.prop_Player_0.field_Internal_VRCPlayer_0.field_Private_PhotonView_0.field_Private_Int32_0.ToString().PadRight(PlayerEntry.highestPhotonIdLength));
                AddSpacer();
            }

            if (Config.displayNameToggle.Value)
            {
                switch (Config.DisplayNameColorMode)
                {
                case PlayerListMod.DisplayNameColorMode.None:
                case PlayerListMod.DisplayNameColorMode.FriendsOnly:
                    AddText(APIUser.CurrentUser.displayName);
                    break;

                case PlayerListMod.DisplayNameColorMode.TrustAndFriends:
                case PlayerListMod.DisplayNameColorMode.TrustOnly:
                    AddColoredText("#" + ColorUtility.ToHtmlStringRGB(VRCPlayer.Method_Public_Static_Color_APIUser_0(APIUser.CurrentUser)), APIUser.CurrentUser.displayName);
                    break;
                }
                AddSpacer();
            }

            if (textComponent.text.Length > 0)
            {
                if (Config.condensedText.Value)
                {
                    textComponent.text = textComponent.text.Remove(textComponent.text.Length - 1, 1);
                }
                else
                {
                    textComponent.text = textComponent.text.Remove(textComponent.text.Length - 3, 3);
                }
            }

            if (!Config.numberedList.Value)
            {
                if (Config.condensedText.Value)
                {
                    AddTextToBeginning("-");
                }
                else
                {
                    AddTextToBeginning(" - ");
                }
            }
            else
            if (Config.condensedText.Value)
            {
                AddTextToBeginning("1.".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 1));
            }
            else
            {
                AddTextToBeginning("1. ".PadRight((gameObject.transform.parent.childCount - 2).ToString().Length + 2));
            }
        }